Skip to content

Commit

Permalink
Clean out stdlib_support.
Browse files Browse the repository at this point in the history
We don't need two of these, and the other deserves a static_assert.

Test: ./run_tests.py
Bug: android/ndk#300
Change-Id: I76939d3bfb1a19e16fef737a0425bc173259cdd6
  • Loading branch information
DanAlbert committed Jun 30, 2017
1 parent 94af4fc commit b04b1a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
2 changes: 1 addition & 1 deletion sources/android/support/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ android_support_sources := \
src/_Exit.cpp \
src/iswblank.cpp \
src/posix_memalign.cpp \
src/stdlib_support.cpp \
src/swprintf.cpp \

# These are old sources that should be purged/rewritten/taken from bionic.
Expand All @@ -64,7 +65,6 @@ android_support_sources += \
src/musl-math/frexp.c \
src/musl-math/frexpf.c \
src/musl-math/frexpl.c \
src/stdlib_support.c \
src/wchar_support.c \
src/wcstox/floatscan.c \
src/wcstox/intscan.c \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,9 @@
* SUCH DAMAGE.
*/

// Contains an implementation of all stdlib functions missing from bionic.
//
// TODO(digit): Make these work.

#include <inttypes.h>
#include <stdlib.h>
#include <assert.h>

long double strtold(const char* nptr, char** endptr) {
//FIXME: Although in Android long double is the same as double, can we borrow stdtod?
static_assert(sizeof(double) == sizeof(long double), "double != long double");
return strtod(nptr, endptr);
}

intmax_t imaxabs(intmax_t j)
{
return (j < 0 ? -j : j);
}

imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom)
{
imaxdiv_t retval;

retval.quot = numer / denom;
retval.rem = numer % denom;
if (numer >= 0 && retval.rem < 0) {
retval.quot++;
retval.rem -= denom;
}
return (retval);
}

0 comments on commit b04b1a2

Please sign in to comment.