diff options
Diffstat (limited to 'libc')
50 files changed, 128 insertions, 149 deletions
diff --git a/libc/arch-common/bionic/crtbegin.c b/libc/arch-common/bionic/crtbegin.c index bdda1cfea..b7043dcae 100644 --- a/libc/arch-common/bionic/crtbegin.c +++ b/libc/arch-common/bionic/crtbegin.c @@ -72,7 +72,7 @@ __asm__(PRE "movq %rsp,%rdi; andq $~0xf,%rsp; callq _start_main" POST); // To ensure that the .tdata input section isn't deleted (e.g. by // --gc-sections), the .text input section (which contains _start) has a // relocation to the .tdata input section. -#if __ANDROID_API__ >= __ANDROID_API_Q__ +#if __ANDROID_API__ >= 29 #if defined(__arm__) asm(" .section .tdata,\"awT\",%progbits\n" " .p2align 5\n" diff --git a/libc/arch-common/bionic/pthread_atfork.h b/libc/arch-common/bionic/pthread_atfork.h index 742d0788b..02e383d31 100644 --- a/libc/arch-common/bionic/pthread_atfork.h +++ b/libc/arch-common/bionic/pthread_atfork.h @@ -18,7 +18,7 @@ // __register_atfork wasn't available until android-23. When using libc.a, we're // using the latest library regardless of target API level. -#if defined(_FORCE_CRT_ATFORK) || __ANDROID_API__ >= __ANDROID_API_M__ +#if defined(_FORCE_CRT_ATFORK) || __ANDROID_API__ >= 23 extern void* __dso_handle; @@ -33,4 +33,4 @@ int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(vo return __register_atfork(prepare, parent, child, &__dso_handle); } -#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */ +#endif diff --git a/libc/bionic/pthread_internal.cpp b/libc/bionic/pthread_internal.cpp index 6fddefe43..e0911581b 100644 --- a/libc/bionic/pthread_internal.cpp +++ b/libc/bionic/pthread_internal.cpp @@ -100,8 +100,8 @@ pthread_internal_t* __pthread_internal_find(pthread_t thread_id, const char* cal } } - // Historically we'd return null, but - if (android_get_application_target_sdk_version() >= __ANDROID_API_O__) { + // Historically we'd return null, but from API level 26 we catch this error. + if (android_get_application_target_sdk_version() >= 26) { if (thread == nullptr) { // This seems to be a common mistake, and it's relatively harmless because // there will never be a valid thread at address 0, whereas other invalid diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp index de62a5c01..a15e98149 100644 --- a/libc/bionic/pthread_mutex.cpp +++ b/libc/bionic/pthread_mutex.cpp @@ -799,7 +799,7 @@ static inline __always_inline bool IsMutexDestroyed(uint16_t mutex_state) { // ARM64. So make it noinline. static int __attribute__((noinline)) HandleUsingDestroyedMutex(pthread_mutex_t* mutex, const char* function_name) { - if (android_get_application_target_sdk_version() >= __ANDROID_API_P__) { + if (android_get_application_target_sdk_version() >= 28) { __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex); } return EBUSY; diff --git a/libc/bionic/semaphore.cpp b/libc/bionic/semaphore.cpp index 455e36b27..33552a90b 100644 --- a/libc/bionic/semaphore.cpp +++ b/libc/bionic/semaphore.cpp @@ -221,7 +221,7 @@ int sem_wait(sem_t* sem) { } int result = __futex_wait_ex(sem_count_ptr, shared, shared | SEMCOUNT_MINUS_ONE, false, nullptr); - if (android_get_application_target_sdk_version() >= __ANDROID_API_N__) { + if (android_get_application_target_sdk_version() >= 24) { if (result ==-EINTR) { errno = EINTR; return -1; diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h index 577fb0027..1b8af78cd 100644 --- a/libc/include/android/api-level.h +++ b/libc/include/android/api-level.h @@ -124,7 +124,7 @@ __BEGIN_DECLS */ int android_get_application_target_sdk_version() __INTRODUCED_IN(24); -#if __ANDROID_API__ < __ANDROID_API_Q__ +#if __ANDROID_API__ < 29 // android_get_device_api_level is a static inline before API level 29. #define __BIONIC_GET_DEVICE_API_LEVEL_INLINE static __inline diff --git a/libc/include/android/legacy_errno_inlines.h b/libc/include/android/legacy_errno_inlines.h index 9f116faea..fcbca1308 100644 --- a/libc/include/android/legacy_errno_inlines.h +++ b/libc/include/android/legacy_errno_inlines.h @@ -26,12 +26,11 @@ * SUCH DAMAGE. */ -#ifndef _ANDROID_LEGACY_ERRNO_INLINES_H -#define _ANDROID_LEGACY_ERRNO_INLINES_H +#pragma once #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_L__ +#if __ANDROID_API__ < 21 #include <errno.h> @@ -45,4 +44,3 @@ static __inline int __attribute__((deprecated)) __set_errno(int n) { __END_DECLS #endif -#endif /* _ANDROID_LEGACY_ERRNO_INLINES_H */ diff --git a/libc/include/android/legacy_fenv_inlines_arm.h b/libc/include/android/legacy_fenv_inlines_arm.h index 5ec558228..92caa7293 100644 --- a/libc/include/android/legacy_fenv_inlines_arm.h +++ b/libc/include/android/legacy_fenv_inlines_arm.h @@ -35,7 +35,7 @@ #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_L__ && defined(__arm__) +#if __ANDROID_API__ < 21 && defined(__arm__) #define __BIONIC_FENV_INLINE static __inline #include <bits/fenv_inlines_arm.h> diff --git a/libc/include/android/legacy_fenv_inlines_mips.h b/libc/include/android/legacy_fenv_inlines_mips.h index ccc824c6c..92589ed81 100644 --- a/libc/include/android/legacy_fenv_inlines_mips.h +++ b/libc/include/android/legacy_fenv_inlines_mips.h @@ -35,7 +35,7 @@ #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_L__ && (defined(__mips__) && !defined(__LP64__)) +#if __ANDROID_API__ < 21 && (defined(__mips__) && !defined(__LP64__)) #define __BIONIC_FENV_INLINE static __inline #include <bits/fenv_inlines_mips.h> diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h index d2c767703..90eda7dc1 100644 --- a/libc/include/android/legacy_signal_inlines.h +++ b/libc/include/android/legacy_signal_inlines.h @@ -26,12 +26,11 @@ * SUCH DAMAGE. */ -#ifndef _ANDROID_LEGACY_SIGNAL_INLINES_H_ -#define _ANDROID_LEGACY_SIGNAL_INLINES_H_ +#pragma once #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_L__ +#if __ANDROID_API__ < 21 #include <errno.h> #include <signal.h> @@ -119,6 +118,4 @@ static __inline sighandler_t signal(int s, sighandler_t f) { __END_DECLS -#endif /* __ANDROID_API__ < __ANDROID_API_L__ */ - -#endif /* _ANDROID_LEGACY_SIGNAL_INLINES_H_ */ +#endif diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h index 439b486ee..aeb1575ad 100644 --- a/libc/include/android/legacy_stdlib_inlines.h +++ b/libc/include/android/legacy_stdlib_inlines.h @@ -26,12 +26,11 @@ * SUCH DAMAGE. */ -#ifndef _ANDROID_LEGACY_STDLIB_INLINES_H_ -#define _ANDROID_LEGACY_STDLIB_INLINES_H_ +#pragma once #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_K__ +#if __ANDROID_API__ < 19 __BEGIN_DECLS @@ -45,9 +44,11 @@ static __inline long long llabs(long long __n) { __END_DECLS -#endif /* __ANDROID_API__ < __ANDROID_API_K__ */ +#endif -#if __ANDROID_API__ < __ANDROID_API_L__ + + +#if __ANDROID_API__ < 21 #include <errno.h> #include <float.h> @@ -83,9 +84,11 @@ static __inline int grantpt(int __fd __attribute((unused))) { __END_DECLS -#endif /* __ANDROID_API__ < __ANDROID_API_L__ */ +#endif + -#if __ANDROID_API__ < __ANDROID_API_O__ + +#if __ANDROID_API__ < 26 #include <stdlib.h> #include <xlocale.h> @@ -106,6 +109,4 @@ static __inline long strtol_l(const char* __s, char** __end_ptr, int __base, loc __END_DECLS -#endif /* __ANDROID_API__ < __ANDROID_API_O__ */ - -#endif /* _ANDROID_LEGACY_STDLIB_INLINES_H_ */ +#endif diff --git a/libc/include/android/legacy_strings_inlines.h b/libc/include/android/legacy_strings_inlines.h index 5d63c5a31..2cc2da272 100644 --- a/libc/include/android/legacy_strings_inlines.h +++ b/libc/include/android/legacy_strings_inlines.h @@ -26,12 +26,11 @@ * SUCH DAMAGE. */ -#ifndef _ANDROID_LEGACY_STRINGS_INLINES_H_ -#define _ANDROID_LEGACY_STRINGS_INLINES_H_ +#pragma once #include <sys/cdefs.h> -#if defined(__i386__) && __ANDROID_API__ < __ANDROID_API_J_MR2__ +#if defined(__i386__) && __ANDROID_API__ < 18 #include <strings.h> @@ -43,5 +42,3 @@ static __inline int ffs(int __n) { return __builtin_ffs(__n); } __END_DECLS #endif - -#endif diff --git a/libc/include/android/legacy_sys_mman_inlines.h b/libc/include/android/legacy_sys_mman_inlines.h index 160e6fe60..04b3e97f2 100644 --- a/libc/include/android/legacy_sys_mman_inlines.h +++ b/libc/include/android/legacy_sys_mman_inlines.h @@ -30,7 +30,7 @@ #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_L__ +#if __ANDROID_API__ < 21 #include <errno.h> #include <sys/mman.h> @@ -68,4 +68,4 @@ static __inline void* mmap64(void* __addr, size_t __size, int __prot, int __flag __END_DECLS -#endif /* __ANDROID_API__ < __ANDROID_API_L__ */ +#endif diff --git a/libc/include/android/legacy_sys_stat_inlines.h b/libc/include/android/legacy_sys_stat_inlines.h index 95216942b..d42ac01e0 100644 --- a/libc/include/android/legacy_sys_stat_inlines.h +++ b/libc/include/android/legacy_sys_stat_inlines.h @@ -26,12 +26,11 @@ * SUCH DAMAGE. */ -#ifndef _ANDROID_LEGACY_SYS_STAT_INLINES_H_ -#define _ANDROID_LEGACY_SYS_STAT_INLINES_H_ +#pragma once #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_L__ +#if __ANDROID_API__ < 21 #include <sys/stat.h> @@ -44,4 +43,3 @@ static __inline int mkfifo(const char* __path, mode_t __mode) { __END_DECLS #endif -#endif /* _ANDROID_LEGACY_SYS_STAT_INLINES_H_ */ diff --git a/libc/include/android/legacy_sys_wait_inlines.h b/libc/include/android/legacy_sys_wait_inlines.h index 4298d767b..eadc75283 100644 --- a/libc/include/android/legacy_sys_wait_inlines.h +++ b/libc/include/android/legacy_sys_wait_inlines.h @@ -26,12 +26,11 @@ * SUCH DAMAGE. */ -#ifndef _ANDROID_LEGACY_SYS_WAIT_INLINES_H_ -#define _ANDROID_LEGACY_SYS_WAIT_INLINES_H_ +#pragma once #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_J_MR2__ +#if __ANDROID_API__ < 18 #include <sys/syscall.h> #include <sys/wait.h> @@ -45,6 +44,4 @@ static __inline pid_t wait4(pid_t pid, int* status, int options, struct rusage* __END_DECLS -#endif /* __ANDROID_API__ < __ANDROID_API_J_MR2__ */ - -#endif /* _ANDROID_LEGACY_SYS_WAIT_INLINES_H_ */ +#endif diff --git a/libc/include/android/legacy_termios_inlines.h b/libc/include/android/legacy_termios_inlines.h index a63dba194..9ea588d20 100644 --- a/libc/include/android/legacy_termios_inlines.h +++ b/libc/include/android/legacy_termios_inlines.h @@ -26,12 +26,11 @@ * SUCH DAMAGE. */ -#ifndef _ANDROID_LEGACY_TERMIOS_INLINES_H_ -#define _ANDROID_LEGACY_TERMIOS_INLINES_H_ +#pragma once #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_L__ +#if __ANDROID_API__ < 21 #include <linux/termios.h> #include <sys/ioctl.h> @@ -41,5 +40,3 @@ #include <bits/termios_inlines.h> #endif - -#endif /* _ANDROID_LEGACY_TERMIOS_INLINES_H_ */ diff --git a/libc/include/android/legacy_threads_inlines.h b/libc/include/android/legacy_threads_inlines.h index e73ef37c7..c614cd01a 100644 --- a/libc/include/android/legacy_threads_inlines.h +++ b/libc/include/android/legacy_threads_inlines.h @@ -30,7 +30,7 @@ #include <sys/cdefs.h> -#if __ANDROID_API__ < __ANDROID_API_R__ +#if __ANDROID_API__ < 30 #define __BIONIC_THREADS_INLINE static __inline #include <bits/threads_inlines.h> diff --git a/libc/include/bits/fortify/fcntl.h b/libc/include/bits/fortify/fcntl.h index 3c5a0379f..70635418f 100644 --- a/libc/include/bits/fortify/fcntl.h +++ b/libc/include/bits/fortify/fcntl.h @@ -59,7 +59,7 @@ __BIONIC_FORTIFY_INLINE int open(const char* const __pass_object_size pathname, int flags) __overloadable __clang_error_if(__open_modes_useful(flags), "'open' " __open_too_few_args_error) { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __open_2(pathname, flags); #else return __open_real(pathname, flags); @@ -83,7 +83,7 @@ __BIONIC_FORTIFY_INLINE int openat(int dirfd, const char* const __pass_object_size pathname, int flags) __overloadable __clang_error_if(__open_modes_useful(flags), "'openat' " __open_too_few_args_error) { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __openat_2(dirfd, pathname, flags); #else return __openat_real(dirfd, pathname, flags); @@ -98,7 +98,7 @@ int openat(int dirfd, const char* const __pass_object_size pathname, int flags, return __openat_real(dirfd, pathname, flags, modes); } -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 /* Note that open == open64, so we reuse those bits in the open64 variants below. */ __BIONIC_ERROR_FUNCTION_VISIBILITY @@ -139,7 +139,7 @@ int openat64(int dirfd, const char* const __pass_object_size pathname, int flags "'openat64' " __open_useless_modes_warning) { return openat(dirfd, pathname, flags, modes); } -#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */ +#endif /* __ANDROID_API__ >= 21 */ #undef __open_too_many_args_error #undef __open_too_few_args_error diff --git a/libc/include/bits/fortify/poll.h b/libc/include/bits/fortify/poll.h index 30fdce409..143153c97 100644 --- a/libc/include/bits/fortify/poll.h +++ b/libc/include/bits/fortify/poll.h @@ -44,7 +44,7 @@ int poll(struct pollfd* const fds __pass_object_size, nfds_t fd_count, int timeo __overloadable __clang_error_if(__bos_unevaluated_lt(__bos(fds), sizeof(*fds) * fd_count), "in call to 'poll', fd_count is larger than the given buffer") { -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos_fds = __bos(fds); if (!__bos_fd_count_trivially_safe(bos_fds, fds, fd_count)) { @@ -54,13 +54,13 @@ int poll(struct pollfd* const fds __pass_object_size, nfds_t fd_count, int timeo return __call_bypassing_fortify(poll)(fds, fd_count, timeout); } -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 __BIONIC_FORTIFY_INLINE int ppoll(struct pollfd* const fds __pass_object_size, nfds_t fd_count, const struct timespec* timeout, const sigset_t* mask) __overloadable __clang_error_if(__bos_unevaluated_lt(__bos(fds), sizeof(*fds) * fd_count), "in call to 'ppoll', fd_count is larger than the given buffer") { -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos_fds = __bos(fds); if (!__bos_fd_count_trivially_safe(bos_fds, fds, fd_count)) { @@ -69,9 +69,9 @@ int ppoll(struct pollfd* const fds __pass_object_size, nfds_t fd_count, const st #endif return __call_bypassing_fortify(ppoll)(fds, fd_count, timeout, mask); } -#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */ +#endif /* __ANDROID_API__ >= 21 */ -#if __ANDROID_API__ >= __ANDROID_API_P__ +#if __ANDROID_API__ >= 28 __BIONIC_FORTIFY_INLINE int ppoll64(struct pollfd* const fds __pass_object_size, nfds_t fd_count, const struct timespec* timeout, const sigset64_t* mask) __overloadable @@ -86,7 +86,7 @@ int ppoll64(struct pollfd* const fds __pass_object_size, nfds_t fd_count, const #endif return __call_bypassing_fortify(ppoll64)(fds, fd_count, timeout, mask); } -#endif /* __ANDROID_API__ >= __ANDROID_API_P__ */ +#endif /* __ANDROID_API__ >= 28 */ #undef __bos_fd_count_trivially_safe diff --git a/libc/include/bits/fortify/socket.h b/libc/include/bits/fortify/socket.h index 30fe0d79c..78d4013dd 100644 --- a/libc/include/bits/fortify/socket.h +++ b/libc/include/bits/fortify/socket.h @@ -42,7 +42,7 @@ ssize_t recvfrom(int fd, void* const buf __pass_object_size0, size_t len, int fl __overloadable __clang_error_if(__bos_unevaluated_lt(__bos0(buf), len), "'recvfrom' called with size bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 24 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge(bos, len)) { @@ -57,7 +57,7 @@ ssize_t sendto(int fd, const void* const buf __pass_object_size0, size_t len, in __overloadable __clang_error_if(__bos_unevaluated_lt(__bos0(buf), len), "'sendto' called with size bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_N_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 25 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge(bos, len)) { diff --git a/libc/include/bits/fortify/stat.h b/libc/include/bits/fortify/stat.h index 43fc69c9a..e92e6ac81 100644 --- a/libc/include/bits/fortify/stat.h +++ b/libc/include/bits/fortify/stat.h @@ -41,7 +41,7 @@ mode_t umask(mode_t mode) __overloadable __enable_if(1, "") __clang_error_if(mode & ~0777, "'umask' called with invalid mode") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 18 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __umask_chk(mode); #else return __umask_real(mode); diff --git a/libc/include/bits/fortify/stdio.h b/libc/include/bits/fortify/stdio.h index fb503c333..42698dd99 100644 --- a/libc/include/bits/fortify/stdio.h +++ b/libc/include/bits/fortify/stdio.h @@ -36,7 +36,7 @@ size_t __fwrite_chk(const void*, size_t, size_t, FILE*, size_t) __INTRODUCED_IN( #if defined(__BIONIC_FORTIFY) && !defined(__BIONIC_NO_STDIO_FORTIFY) -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED /* No diag -- clang diagnoses misuses of this on its own. */ __BIONIC_FORTIFY_INLINE __printflike(3, 0) int vsnprintf(char* const __pass_object_size dest, size_t size, const char* format, va_list ap) @@ -57,7 +57,7 @@ int sprintf(char* dest, const char* format) "format string will always overflow destination buffer") __errorattr("format string will always overflow destination buffer"); -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED __BIONIC_FORTIFY_VARIADIC __printflike(2, 3) int sprintf(char* const __pass_object_size dest, const char* format, ...) __overloadable { va_list va; @@ -90,7 +90,7 @@ size_t fread(void* const __pass_object_size0 buf, size_t size, size_t count, FIL "in call to 'fread', size * count overflows") __clang_error_if(__bos_unevaluated_lt(__bos0(buf), size * count), "in call to 'fread', size * count is too large for the given buffer") { -#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 24 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_mul(bos, size, count)) { @@ -107,7 +107,7 @@ size_t fwrite(const void* const __pass_object_size0 buf, size_t size, size_t cou "in call to 'fwrite', size * count overflows") __clang_error_if(__bos_unevaluated_lt(__bos0(buf), size * count), "in call to 'fwrite', size * count is too large for the given buffer") { -#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 24 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_mul(bos, size, count)) { @@ -124,7 +124,7 @@ char* fgets(char* const __pass_object_size dest, int size, FILE* stream) __clang_error_if(size < 0, "in call to 'fgets', size should not be negative") __clang_error_if(__bos_unevaluated_lt(__bos(dest), size), "in call to 'fgets', size is larger than the destination buffer") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(dest); if (!__bos_dynamic_check_impl_and(bos, >=, (size_t)size, size >= 0)) { diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h index 7dc60f2c2..600ef147b 100644 --- a/libc/include/bits/fortify/string.h +++ b/libc/include/bits/fortify/string.h @@ -40,7 +40,7 @@ size_t __strlcat_chk(char*, const char*, size_t, size_t) __INTRODUCED_IN(17); #if defined(__BIONIC_FORTIFY) extern void* __memrchr_real(const void*, int, size_t) __RENAME(memrchr); -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED /* No diag -- clang diagnoses misuses of this on its own. */ __BIONIC_FORTIFY_INLINE void* memcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount) @@ -64,7 +64,7 @@ void* memmove(void* const dst __pass_object_size0, const void* src, size_t len) #endif #if defined(__USE_GNU) -#if __ANDROID_API__ >= __ANDROID_API_R__ +#if __ANDROID_API__ >= 30 __BIONIC_FORTIFY_INLINE void* mempcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount) __overloadable @@ -78,7 +78,7 @@ void* mempcpy(void* const dst __pass_object_size0, const void* src, size_t copy_ #endif return __builtin_mempcpy(dst, src, copy_amount); } -#endif /* __ANDROID_API__ >= __ANDROID_API_R__ */ +#endif /* __ANDROID_API__ >= 30 */ #endif /* __USE_GNU */ __BIONIC_FORTIFY_INLINE @@ -86,7 +86,7 @@ char* stpcpy(char* const dst __pass_object_size, const char* src) __overloadable __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)), "'stpcpy' called with string bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 21 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos_dst = __bos(dst); if (!__bos_trivially_gt(bos_dst, __builtin_strlen(src))) { return __builtin___stpcpy_chk(dst, src, bos_dst); @@ -100,7 +100,7 @@ char* strcpy(char* const dst __pass_object_size, const char* src) __overloadable __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)), "'strcpy' called with string bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos_dst = __bos(dst); if (!__bos_trivially_gt(bos_dst, __builtin_strlen(src))) { return __builtin___strcpy_chk(dst, src, bos_dst); @@ -114,14 +114,14 @@ char* strcat(char* const dst __pass_object_size, const char* src) __overloadable __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)), "'strcat' called with string bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __builtin___strcat_chk(dst, src, __bos(dst)); #else return __builtin_strcat(dst, src); #endif } -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED /* No diag -- clang diagnoses misuses of this on its own. */ __BIONIC_FORTIFY_INLINE char* strncat(char* const dst __pass_object_size, const char* src, size_t n) __overloadable { @@ -134,7 +134,7 @@ __BIONIC_FORTIFY_INLINE void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable /* If you're a user who wants this warning to go away: use `(&memset)(foo, bar, baz)`. */ __clang_warning_if(c && !n, "'memset' will set 0 bytes; maybe the arguments got flipped?") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(s); if (!__bos_trivially_ge(bos, n)) { return __builtin___memset_chk(s, c, n, bos); @@ -143,7 +143,7 @@ void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable return __builtin_memset(s, c, n); } -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED __BIONIC_FORTIFY_INLINE void* memchr(const void* const s __pass_object_size, int c, size_t n) __overloadable { size_t bos = __bos(s); @@ -167,7 +167,7 @@ void* __memrchr_fortify(const void* const __pass_object_size s, int c, size_t n) } #endif -#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 21 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED /* No diag -- clang diagnoses misuses of this on its own. */ __BIONIC_FORTIFY_INLINE char* stpncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n) @@ -204,7 +204,7 @@ size_t strlcpy(char* const dst __pass_object_size, const char* src, size_t size) __overloadable __clang_error_if(__bos_unevaluated_lt(__bos(dst), size), "'strlcpy' called with size bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(dst); if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) { @@ -219,7 +219,7 @@ size_t strlcat(char* const dst __pass_object_size, const char* src, size_t size) __overloadable __clang_error_if(__bos_unevaluated_lt(__bos(dst), size), "'strlcat' called with size bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(dst); if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) { @@ -231,7 +231,7 @@ size_t strlcat(char* const dst __pass_object_size, const char* src, size_t size) __BIONIC_FORTIFY_INLINE size_t strlen(const char* const s __pass_object_size0) __overloadable { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(s); if (!__bos_trivially_gt(bos, __builtin_strlen(s))) { @@ -243,7 +243,7 @@ size_t strlen(const char* const s __pass_object_size0) __overloadable { __BIONIC_FORTIFY_INLINE char* strchr(const char* const s __pass_object_size, int c) __overloadable { -#if __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 18 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(s); if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) { @@ -255,7 +255,7 @@ char* strchr(const char* const s __pass_object_size, int c) __overloadable { __BIONIC_FORTIFY_INLINE char* strrchr(const char* const s __pass_object_size, int c) __overloadable { -#if __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 18 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(s); if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) { @@ -265,7 +265,7 @@ char* strrchr(const char* const s __pass_object_size, int c) __overloadable { return __builtin_strrchr(s, c); } -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED #if defined(__cplusplus) extern "C++" { __BIONIC_FORTIFY_INLINE @@ -284,6 +284,6 @@ void* memrchr(const void* const __pass_object_size s, int c, size_t n) __overloa return __memrchr_fortify(s, c, n); } #endif -#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */ +#endif /* __ANDROID_API__ >= 23 */ #endif /* defined(__BIONIC_FORTIFY) */ diff --git a/libc/include/bits/fortify/strings.h b/libc/include/bits/fortify/strings.h index 1ebaf39e4..65fc5f17b 100644 --- a/libc/include/bits/fortify/strings.h +++ b/libc/include/bits/fortify/strings.h @@ -33,7 +33,7 @@ void __bionic_bcopy(const void *src, void* const dst __pass_object_size0, size_t __overloadable __clang_error_if(__bos_unevaluated_lt(__bos0(dst), len), "'bcopy' called with size bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(dst); if (!__bos_trivially_ge(bos, len)) { __builtin___memmove_chk(dst, src, len, bos); @@ -48,7 +48,7 @@ void __bionic_bzero(void* const b __pass_object_size0, size_t len) __overloadable __clang_error_if(__bos_unevaluated_lt(__bos0(b), len), "'bzero' called with size bigger than buffer") { -#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(b); if (!__bos_trivially_ge(bos, len)) { __builtin___memset_chk(b, 0, len, bos); diff --git a/libc/include/bits/fortify/unistd.h b/libc/include/bits/fortify/unistd.h index f1580ce3e..49a394663 100644 --- a/libc/include/bits/fortify/unistd.h +++ b/libc/include/bits/fortify/unistd.h @@ -73,7 +73,7 @@ __BIONIC_FORTIFY_INLINE char* getcwd(char* const __pass_object_size buf, size_t size) __overloadable __error_if_overflows_objectsize(size, __bos(buf), getcwd) { -#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 24 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(buf); if (!__bos_trivially_ge(bos, size)) { @@ -89,7 +89,7 @@ ssize_t pread(int fd, void* const __pass_object_size0 buf, size_t count, off_t o __overloadable __error_if_overflows_ssizet(count, pread) __error_if_overflows_objectsize(count, __bos0(buf), pread) { -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_no_overflow(bos, count)) { @@ -105,7 +105,7 @@ ssize_t pread64(int fd, void* const __pass_object_size0 buf, size_t count, off64 __overloadable __error_if_overflows_ssizet(count, pread64) __error_if_overflows_objectsize(count, __bos0(buf), pread64) { -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_no_overflow(bos, count)) { @@ -121,7 +121,7 @@ ssize_t pwrite(int fd, const void* const __pass_object_size0 buf, size_t count, __overloadable __error_if_overflows_ssizet(count, pwrite) __error_if_overflows_objectsize(count, __bos0(buf), pwrite) { -#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 24 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_no_overflow(bos, count)) { @@ -137,7 +137,7 @@ ssize_t pwrite64(int fd, const void* const __pass_object_size0 buf, size_t count __overloadable __error_if_overflows_ssizet(count, pwrite64) __error_if_overflows_objectsize(count, __bos0(buf), pwrite64) { -#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 24 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_no_overflow(bos, count)) { @@ -152,7 +152,7 @@ ssize_t read(int fd, void* const __pass_object_size0 buf, size_t count) __overloadable __error_if_overflows_ssizet(count, read) __error_if_overflows_objectsize(count, __bos0(buf), read) { -#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 21 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_no_overflow(bos, count)) { @@ -167,7 +167,7 @@ ssize_t write(int fd, const void* const __pass_object_size0 buf, size_t count) __overloadable __error_if_overflows_ssizet(count, write) __error_if_overflows_objectsize(count, __bos0(buf), write) { -#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 24 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_no_overflow(bos, count)) { @@ -182,7 +182,7 @@ ssize_t readlink(const char* path, char* const __pass_object_size buf, size_t si __overloadable __error_if_overflows_ssizet(size, readlink) __error_if_overflows_objectsize(size, __bos(buf), readlink) { -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(buf); if (!__bos_trivially_ge_no_overflow(bos, size)) { @@ -192,13 +192,13 @@ ssize_t readlink(const char* path, char* const __pass_object_size buf, size_t si return __call_bypassing_fortify(readlink)(path, buf, size); } -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 __BIONIC_FORTIFY_INLINE ssize_t readlinkat(int dirfd, const char* path, char* const __pass_object_size buf, size_t size) __overloadable __error_if_overflows_ssizet(size, readlinkat) __error_if_overflows_objectsize(size, __bos(buf), readlinkat) { -#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __ANDROID_API__ >= 23 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(buf); if (!__bos_trivially_ge_no_overflow(bos, size)) { @@ -207,7 +207,7 @@ ssize_t readlinkat(int dirfd, const char* path, char* const __pass_object_size b #endif return __call_bypassing_fortify(readlinkat)(dirfd, path, buf, size); } -#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */ +#endif /* __ANDROID_API__ >= 21 */ #undef __bos_trivially_ge_no_overflow #undef __enable_if_no_overflow_ssizet diff --git a/libc/include/bits/pthread_types.h b/libc/include/bits/pthread_types.h index a173e3c01..f35969677 100644 --- a/libc/include/bits/pthread_types.h +++ b/libc/include/bits/pthread_types.h @@ -26,8 +26,7 @@ * SUCH DAMAGE. */ -#ifndef _BITS_PTHREAD_TYPES_H_ -#define _BITS_PTHREAD_TYPES_H_ +#pragma once #include <sys/cdefs.h> #include <sys/types.h> @@ -44,7 +43,7 @@ typedef struct { #endif } pthread_attr_t; -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 typedef struct { #if defined(__LP64__) int64_t __private[4]; @@ -54,7 +53,7 @@ typedef struct { } pthread_barrier_t; #endif -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 typedef int pthread_barrierattr_t; #endif @@ -92,7 +91,7 @@ typedef struct { typedef long pthread_rwlockattr_t; -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 typedef struct { #if defined(__LP64__) int64_t __private; @@ -103,5 +102,3 @@ typedef struct { #endif typedef long pthread_t; - -#endif diff --git a/libc/include/bits/threads_inlines.h b/libc/include/bits/threads_inlines.h index 8f2beb09c..afaed64b8 100644 --- a/libc/include/bits/threads_inlines.h +++ b/libc/include/bits/threads_inlines.h @@ -103,7 +103,7 @@ __BIONIC_THREADS_INLINE int mtx_lock(mtx_t* __mtx) { return __bionic_thrd_error(pthread_mutex_lock(__mtx)); } -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 __BIONIC_THREADS_INLINE int mtx_timedlock(mtx_t* __mtx, const struct timespec* __timeout) { return __bionic_thrd_error(pthread_mutex_timedlock(__mtx, __timeout)); diff --git a/libc/include/ctype.h b/libc/include/ctype.h index e7df299ef..61fb4769a 100644 --- a/libc/include/ctype.h +++ b/libc/include/ctype.h @@ -124,7 +124,7 @@ int toupper(int __ch); */ int _toupper(int __ch) __INTRODUCED_IN(21); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 /** Like isalnum but with an ignored `locale_t`. */ int isalnum_l(int __ch, locale_t __l) __INTRODUCED_IN(21); /** Like isalpha but with an ignored `locale_t`. */ diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index c45c91ff4..23a58d64a 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -66,7 +66,7 @@ __BEGIN_DECLS /** Flag for open(). */ #define O_RSYNC O_SYNC -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 /** Flag for splice(). */ #define SPLICE_F_MOVE 1 /** Flag for splice(). */ @@ -77,7 +77,7 @@ __BEGIN_DECLS #define SPLICE_F_GIFT 8 #endif -#if __ANDROID_API__ >= __ANDROID_API_O__ +#if __ANDROID_API__ >= 26 /** Flag for sync_file_range(). */ #define SYNC_FILE_RANGE_WAIT_BEFORE 1 /** Flag for sync_file_range(). */ diff --git a/libc/include/fenv.h b/libc/include/fenv.h index 90ac80512..fd78a48d6 100644 --- a/libc/include/fenv.h +++ b/libc/include/fenv.h @@ -44,7 +44,7 @@ __BEGIN_DECLS // fenv was always available on x86. -#if __ANDROID_API__ >= __ANDROID_API_L__ || defined(__i386__) +#if __ANDROID_API__ >= 21 || defined(__i386__) int feclearexcept(int __exceptions) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9); int fegetexceptflag(fexcept_t* __flag_ptr, int __exceptions) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9); int feraiseexcept(int __exceptions) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9); diff --git a/libc/include/netinet/in.h b/libc/include/netinet/in.h index 1c9961c89..7f00a7a8a 100644 --- a/libc/include/netinet/in.h +++ b/libc/include/netinet/in.h @@ -26,8 +26,7 @@ * SUCH DAMAGE. */ -#ifndef _NETINET_IN_H_ -#define _NETINET_IN_H_ +#pragma once #include <endian.h> #include <netinet/in6.h> @@ -46,14 +45,12 @@ typedef uint16_t in_port_t; int bindresvport(int __fd, struct sockaddr_in* __sin); -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 extern const struct in6_addr in6addr_any __INTRODUCED_IN(24); extern const struct in6_addr in6addr_loopback __INTRODUCED_IN(24); #else static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; static const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; -#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */ +#endif __END_DECLS - -#endif diff --git a/libc/include/pthread.h b/libc/include/pthread.h index b549871f7..331e92ca2 100644 --- a/libc/include/pthread.h +++ b/libc/include/pthread.h @@ -54,7 +54,7 @@ enum { #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP { { ((PTHREAD_MUTEX_ERRORCHECK & 3) << 14) } } #define PTHREAD_COND_INITIALIZER { { 0 } } -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 #define PTHREAD_COND_INITIALIZER_MONOTONIC_NP { { 1 << 1 } } #endif @@ -67,7 +67,7 @@ enum { #define PTHREAD_ONCE_INIT 0 -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 #define PTHREAD_BARRIER_SERIAL_THREAD -1 #endif @@ -254,20 +254,20 @@ int pthread_rwlock_trywrlock(pthread_rwlock_t* __rwlock); int pthread_rwlock_unlock(pthread_rwlock_t* __rwlock); int pthread_rwlock_wrlock(pthread_rwlock_t* __rwlock); -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 int pthread_barrierattr_init(pthread_barrierattr_t* __attr) __INTRODUCED_IN(24); int pthread_barrierattr_destroy(pthread_barrierattr_t* __attr) __INTRODUCED_IN(24); int pthread_barrierattr_getpshared(const pthread_barrierattr_t* __attr, int* __shared) __INTRODUCED_IN(24); int pthread_barrierattr_setpshared(pthread_barrierattr_t* __attr, int __shared) __INTRODUCED_IN(24); #endif -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 int pthread_barrier_init(pthread_barrier_t* __barrier, const pthread_barrierattr_t* __attr, unsigned __count) __INTRODUCED_IN(24); int pthread_barrier_destroy(pthread_barrier_t* __barrier) __INTRODUCED_IN(24); int pthread_barrier_wait(pthread_barrier_t* __barrier) __INTRODUCED_IN(24); #endif -#if __ANDROID_API__ >= __ANDROID_API_N__ +#if __ANDROID_API__ >= 24 int pthread_spin_destroy(pthread_spinlock_t* __spinlock) __INTRODUCED_IN(24); int pthread_spin_init(pthread_spinlock_t* __spinlock, int __shared) __INTRODUCED_IN(24); int pthread_spin_lock(pthread_spinlock_t* __spinlock) __INTRODUCED_IN(24); diff --git a/libc/include/signal.h b/libc/include/signal.h index cd116569b..532e4a5e3 100644 --- a/libc/include/signal.h +++ b/libc/include/signal.h @@ -64,7 +64,7 @@ int sigaction64(int __signal, const struct sigaction64* __new_action, struct sig int siginterrupt(int __signal, int __flag); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 sighandler_t signal(int __signal, sighandler_t __handler) __INTRODUCED_IN(21); int sigaddset(sigset_t* __set, int __signal) __INTRODUCED_IN(21); int sigaddset64(sigset64_t* __set, int __signal) __INTRODUCED_IN(28); diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 6632c0170..1bf578c1d 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -46,7 +46,7 @@ #include <bits/seek_constants.h> -#if __ANDROID_API__ < __ANDROID_API_N__ +#if __ANDROID_API__ < 24 #include <bits/struct_file.h> #endif @@ -58,7 +58,7 @@ typedef off64_t fpos64_t; struct __sFILE; typedef struct __sFILE FILE; -#if __ANDROID_API__ >= __ANDROID_API_M__ +#if __ANDROID_API__ >= 23 extern FILE* stdin __INTRODUCED_IN(23); extern FILE* stdout __INTRODUCED_IN(23); extern FILE* stderr __INTRODUCED_IN(23); diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index b66e3c64e..dc7b69421 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -43,7 +43,7 @@ __BEGIN_DECLS __noreturn void abort(void); __noreturn void exit(int __status); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 __noreturn void _Exit(int __status) __INTRODUCED_IN(21); #else __noreturn void _Exit(int) __RENAME(_exit); @@ -167,7 +167,7 @@ int wctomb(char* __dst, wchar_t __wc) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD; size_t wcstombs(char* __dst, const wchar_t* __src, size_t __n); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21); #define MB_CUR_MAX __ctype_get_mb_cur_max() #else @@ -183,7 +183,7 @@ size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21); #include <bits/fortify/stdlib.h> #endif -#if __ANDROID_API__ >= __ANDROID_API_K__ +#if __ANDROID_API__ >= 19 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); @@ -191,7 +191,7 @@ long long llabs(long long __x) __attribute_const__ __INTRODUCED_IN(19); // Implemented as static inlines before 19. #endif -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 float strtof(const char* __s, char** __end_ptr) __INTRODUCED_IN(21); double atof(const char* __s) __attribute_pure__ __INTRODUCED_IN(21); int rand(void) __INTRODUCED_IN(21); @@ -207,7 +207,7 @@ long double strtold_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODU // Implemented as static inlines before 21. #endif -#if __ANDROID_API__ >= __ANDROID_API_O__ +#if __ANDROID_API__ >= 26 double strtod_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(26); float strtof_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(26); long strtol_l(const char* __s, char** __end_ptr, int, locale_t __l) __INTRODUCED_IN(26); diff --git a/libc/include/string.h b/libc/include/string.h index 25f6673a9..0cc5611aa 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -119,7 +119,7 @@ char* strsignal(int __signal); int strcoll(const char* __lhs, const char* __rhs) __attribute_pure__; size_t strxfrm(char* __dst, const char* __src, size_t __n); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 int strcoll_l(const char* __lhs, const char* __rhs, locale_t __l) __attribute_pure__ __INTRODUCED_IN(21); size_t strxfrm_l(char* __dst, const char* __src, size_t __n, locale_t __l) __INTRODUCED_IN(21); #else diff --git a/libc/include/strings.h b/libc/include/strings.h index d6ee1c832..08c2326bf 100644 --- a/libc/include/strings.h +++ b/libc/include/strings.h @@ -63,7 +63,7 @@ static __inline__ __always_inline void __bionic_bzero(void* b, size_t len) { __builtin_memset(b, 0, len); } -#if !defined(__i386__) || __ANDROID_API__ >= __ANDROID_API_J_MR2__ +#if !defined(__i386__) || __ANDROID_API__ >= 18 /** * [ffs(3)](http://man7.org/linux/man-pages/man3/ffs.3.html) finds the first set bit in `__i`. * diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h index a213a90fb..374573737 100644 --- a/libc/include/sys/epoll.h +++ b/libc/include/sys/epoll.h @@ -51,7 +51,7 @@ int epoll_create1(int __flags) __INTRODUCED_IN(21); * https://github.com/android-ndk/ndk/issues/302 * https://github.com/android-ndk/ndk/issues/394 */ -#if __ANDROID_API__ < __ANDROID_API_L__ && defined(EPOLL_CLOEXEC) +#if __ANDROID_API__ < 21 && defined(EPOLL_CLOEXEC) #undef EPOLL_CLOEXEC #endif diff --git a/libc/include/sys/inotify.h b/libc/include/sys/inotify.h index 32e16d9c1..37fbf996b 100644 --- a/libc/include/sys/inotify.h +++ b/libc/include/sys/inotify.h @@ -48,7 +48,7 @@ __BEGIN_DECLS * * https://github.com/android-ndk/ndk/issues/394 */ -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 #define IN_CLOEXEC O_CLOEXEC #define IN_NONBLOCK O_NONBLOCK #endif diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h index 3b83229d7..fe4ea7f5a 100644 --- a/libc/include/sys/mman.h +++ b/libc/include/sys/mman.h @@ -54,7 +54,7 @@ void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset); #endif -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 /** * mmap64() is a variant of mmap() that takes a 64-bit offset even on LP32. * @@ -173,7 +173,7 @@ int memfd_create(const char* __name, unsigned __flags) __INTRODUCED_IN(30); #endif -#if __ANDROID_API__ >= __ANDROID_API_M__ +#if __ANDROID_API__ >= 23 /* * Some third-party code uses the existence of POSIX_MADV_NORMAL to detect the diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h index 1ee8d2af7..79fc28d6b 100644 --- a/libc/include/sys/select.h +++ b/libc/include/sys/select.h @@ -79,7 +79,7 @@ int __FD_ISSET_chk(int, const fd_set*, size_t) __INTRODUCED_IN(21); #define __FD_SET(fd, set) (__FDS_BITS(fd_set*,set)[__FDELT(fd)] |= __FDMASK(fd)) #define __FD_ISSET(fd, set) ((__FDS_BITS(const fd_set*,set)[__FDELT(fd)] & __FDMASK(fd)) != 0) -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 /** Removes `fd` from the given set. Use <poll.h> instead. */ #define FD_CLR(fd, set) __FD_CLR_chk(fd, set, __bos(set)) diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h index e54dd65be..e2acab734 100644 --- a/libc/include/sys/socket.h +++ b/libc/include/sys/socket.h @@ -112,7 +112,7 @@ struct cmsghdr { ? (struct cmsghdr*) (msg)->msg_control : (struct cmsghdr*) NULL) #define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && (cmsg)->cmsg_len <= (unsigned long) ((mhdr)->msg_controllen - ((char*)(cmsg) - (char*)(mhdr)->msg_control))) -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 struct cmsghdr* __cmsg_nxthdr(struct msghdr* __msg, struct cmsghdr* __cmsg) __INTRODUCED_IN(21); #else /* TODO(danalbert): Move this into libandroid_support. */ @@ -127,7 +127,7 @@ static inline struct cmsghdr* __cmsg_nxthdr(struct msghdr* msg, struct cmsghdr* } return ptr; } -#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */ +#endif #define SCM_RIGHTS 0x01 #define SCM_CREDENTIALS 0x02 diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 79113b684..d8e92d92d 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -171,7 +171,7 @@ mode_t umask(mode_t __mask); #include <bits/fortify/stat.h> #endif -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 int mkfifo(const char* __path, mode_t __mode) __INTRODUCED_IN(21); #else // Implemented as a static inline before 21. diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h index 106946b0b..8c0655fe1 100644 --- a/libc/include/sys/wait.h +++ b/libc/include/sys/wait.h @@ -40,7 +40,7 @@ __BEGIN_DECLS pid_t wait(int* __status); pid_t waitpid(pid_t __pid, int* __status, int __options); -#if __ANDROID_API__ >= __ANDROID_API_J_MR2__ +#if __ANDROID_API__ >= 18 pid_t wait4(pid_t __pid, int* __status, int __options, struct rusage* __rusage) __INTRODUCED_IN(18); #else // Implemented as a static inline before 18. diff --git a/libc/include/termios.h b/libc/include/termios.h index 0fd5c9524..8eca96e3b 100644 --- a/libc/include/termios.h +++ b/libc/include/termios.h @@ -40,7 +40,7 @@ __BEGIN_DECLS -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 // This file is implemented as static inlines before API level 21. /** diff --git a/libc/include/threads.h b/libc/include/threads.h index 752761d7c..1b00b8ffd 100644 --- a/libc/include/threads.h +++ b/libc/include/threads.h @@ -78,7 +78,7 @@ enum { __BEGIN_DECLS -#if __ANDROID_API__ >= __ANDROID_API_R__ +#if __ANDROID_API__ >= 30 // This file is implemented as static inlines before API level 30. /** Uses `__flag` to ensure that `__function` is called exactly once. */ diff --git a/libc/include/time.h b/libc/include/time.h index a7a6fe53d..0db14ff9a 100644 --- a/libc/include/time.h +++ b/libc/include/time.h @@ -78,7 +78,7 @@ char* strptime(const char* __s, const char* __fmt, struct tm* __tm) __strftimeli char* strptime_l(const char* __s, const char* __fmt, struct tm* __tm, locale_t __l) __strftimelike(2) __INTRODUCED_IN(28); size_t strftime(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm) __strftimelike(3); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 size_t strftime_l(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm, locale_t __l) __strftimelike(3) __INTRODUCED_IN(21); #else // Implemented as static inline before 21. diff --git a/libc/include/unistd.h b/libc/include/unistd.h index 7c01549b5..e4afd8eb1 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -282,7 +282,7 @@ int ttyname_r(int __fd, char* __buf, size_t __buf_size); int acct(const char* __path); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 int getpagesize(void) __INTRODUCED_IN(21); #else static __inline__ int getpagesize(void) { diff --git a/libc/include/wchar.h b/libc/include/wchar.h index f33af5f9c..f0966dec4 100644 --- a/libc/include/wchar.h +++ b/libc/include/wchar.h @@ -121,7 +121,7 @@ wchar_t* wmemset(wchar_t* __dst, wchar_t __wc, size_t __n); int wprintf(const wchar_t* __fmt, ...); int wscanf(const wchar_t* __fmt, ...); -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 long long wcstoll_l(const wchar_t* __s, wchar_t** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(21); unsigned long long wcstoull_l(const wchar_t* __s, wchar_t** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(21); long double wcstold_l(const wchar_t* __s, wchar_t** __end_ptr, locale_t __l) __INTRODUCED_IN(21); diff --git a/libc/include/wctype.h b/libc/include/wctype.h index 18f5c4b8a..58510ae75 100644 --- a/libc/include/wctype.h +++ b/libc/include/wctype.h @@ -35,7 +35,7 @@ __BEGIN_DECLS -#if __ANDROID_API__ >= __ANDROID_API_L__ +#if __ANDROID_API__ >= 21 int iswalnum_l(wint_t __wc, locale_t __l) __INTRODUCED_IN(21); int iswalpha_l(wint_t __wc, locale_t __l) __INTRODUCED_IN(21); int iswblank_l(wint_t __wc, locale_t __l) __INTRODUCED_IN(21); |