diff options
| author | Ryan Prichard <rprichard@google.com> | 2018-01-08 16:18:48 -0800 |
|---|---|---|
| committer | Ryan Prichard <rprichard@google.com> | 2018-01-08 17:46:27 -0800 |
| commit | 51a7fe8fbdda866ab5364c0b37b102be0ea337ad (patch) | |
| tree | bd765653ad9de1774d2362c15e863bdfbc26528d | |
| parent | 558a4f59237245916d93075eb60ed7d16cf55c42 (diff) | |
Mark abs/labs/llabs as 19+ rather than 21+
The libc.map.txt file already defines these three functions as having
been introduced in API 19, but these header files had declared them as
21 and up.
See https://android-review.googlesource.com/c/platform/development/+/233407
imaxabs is already declared as 19 and up.
Test: build-ndk-prebuilts.sh && ./update_platform.py &&
checkbuild.py && run_tests.py
Test: manually build app against 18 and 19
Change-Id: Iaeed48d7e6c438d816635a0433a056e557e8ebc2
| -rw-r--r-- | libc/include/android/legacy_stdlib_inlines.h | 24 | ||||
| -rw-r--r-- | libc/include/stdlib.h | 11 |
2 files changed, 24 insertions, 11 deletions
diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h index e26e5f22a..a1cc590ef 100644 --- a/libc/include/android/legacy_stdlib_inlines.h +++ b/libc/include/android/legacy_stdlib_inlines.h @@ -34,6 +34,22 @@ #include <stdlib.h> #include <sys/cdefs.h> +#if __ANDROID_API__ < __ANDROID_API_K__ + +__BEGIN_DECLS + +static __inline int abs(int __n) { return (__n < 0) ? -__n : __n; } + +static __inline long labs(long __n) { return (__n < 0L) ? -__n : __n; } + +static __inline long long llabs(long long __n) { + return (__n < 0LL) ? -__n : __n; +} + +__END_DECLS + +#endif + #if __ANDROID_API__ < __ANDROID_API_L__ __BEGIN_DECLS @@ -52,14 +68,6 @@ static __inline float strtof(const char* nptr, char** endptr) { static __inline double atof(const char *nptr) { return (strtod(nptr, NULL)); } -static __inline int abs(int __n) { return (__n < 0) ? -__n : __n; } - -static __inline long labs(long __n) { return (__n < 0L) ? -__n : __n; } - -static __inline long long llabs(long long __n) { - return (__n < 0LL) ? -__n : __n; -} - static __inline int rand(void) { return (int)lrand48(); } static __inline void srand(unsigned int __s) { srand48(__s); } diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 1ae3c6e9a..944d72ba9 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -172,12 +172,17 @@ size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21); #include <bits/fortify/stdlib.h> #endif +#if __ANDROID_API__ >= __ANDROID_API_K__ +int abs(int __x) __attribute_const__ __INTRODUCED_IN(19); +long labs(long __x) __attribute_const__ __INTRODUCED_IN(19); +long long llabs(long long __x) __attribute_const__ __INTRODUCED_IN(19); +#else +// Implemented as static inlines before 19. +#endif + #if __ANDROID_API__ >= __ANDROID_API_L__ float strtof(const char* __s, char** __end_ptr) __INTRODUCED_IN(21); double atof(const char* __s) __attribute_pure__ __INTRODUCED_IN(21); -int abs(int __x) __attribute_const__ __INTRODUCED_IN(21); -long labs(long __x) __attribute_const__ __INTRODUCED_IN(21); -long long llabs(long long __x) __attribute_const__ __INTRODUCED_IN(21); int rand(void) __INTRODUCED_IN(21); void srand(unsigned int __seed) __INTRODUCED_IN(21); long random(void) __INTRODUCED_IN(21); |
