diff --git a/libc/include/bits/fortify/fcntl.h b/libc/include/bits/fortify/fcntl.h index 7fe60f4ee..1f6ebad71 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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __openat_2(dirfd, pathname, flags); #else return __openat_real(dirfd, pathname, flags); @@ -98,7 +98,6 @@ int openat(int dirfd, const char* const __pass_object_size pathname, int flags, return __openat_real(dirfd, pathname, flags, modes); } -#if __ANDROID_API__ >= 21 /* Note that open == open64, so we reuse those bits in the open64 variants below. */ __BIONIC_ERROR_FUNCTION_VISIBILITY @@ -139,7 +138,6 @@ 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__ >= 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 143153c97..0b5cd4bc7 100644 --- a/libc/include/bits/fortify/poll.h +++ b/libc/include/bits/fortify/poll.h @@ -54,7 +54,6 @@ 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__ >= 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 @@ -69,7 +68,6 @@ 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__ >= 21 */ #if __ANDROID_API__ >= 28 __BIONIC_FORTIFY_INLINE diff --git a/libc/include/bits/fortify/stat.h b/libc/include/bits/fortify/stat.h index 2d42a51f2..9b4ade24e 100644 --- a/libc/include/bits/fortify/stat.h +++ b/libc/include/bits/fortify/stat.h @@ -39,7 +39,7 @@ mode_t umask(mode_t mode) __overloadable __enable_if(1, "") __clang_error_if(mode & ~0777, "'umask' called with invalid mode") { -#if __ANDROID_API__ >= 18 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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 77bdbb4d8..95db0178e 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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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) @@ -58,7 +58,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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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; @@ -126,7 +126,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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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 08bce2d07..f668b9f71 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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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) @@ -82,7 +82,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__ >= 21 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __builtin___stpcpy_chk(dst, src, __bos(dst)); #else return __builtin_stpcpy(dst, src); @@ -95,7 +95,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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __builtin___strcpy_chk(dst, src, __bos(dst)); #else return __builtin_strcpy(dst, src); @@ -107,14 +107,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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __builtin___strcat_chk(dst, src, __bos(dst)); #else return __builtin_strcat(dst, src); #endif } -#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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) @@ -130,7 +130,7 @@ void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable __diagnose_as_builtin(__builtin_memset, 1, 2, 3) /* 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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __builtin___memset_chk(s, c, n, __bos0(s)); #else return __builtin_memset(s, c, n); @@ -161,7 +161,7 @@ void* __memrchr_fortify(const void* const __pass_object_size s, int c, size_t n) } #endif -#if __ANDROID_API__ >= 21 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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) @@ -200,7 +200,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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __strlcpy_chk(dst, src, size, __bos(dst)); #else return __call_bypassing_fortify(strlcpy)(dst, src, size); @@ -212,14 +212,14 @@ 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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED return __strlcat_chk(dst, src, size, __bos(dst)); #else return __call_bypassing_fortify(strlcat)(dst, src, size); #endif } -#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED __BIONIC_FORTIFY_INLINE size_t strlen(const char* const s __pass_object_size0) __overloadable { return __strlen_chk(s, __bos0(s)); @@ -228,7 +228,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__ >= 18 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(s); if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) { @@ -240,7 +240,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__ >= 18 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos(s); if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) { diff --git a/libc/include/bits/fortify/strings.h b/libc/include/bits/fortify/strings.h index 65fc5f17b..5515ef9bb 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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __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 49a394663..335d0b534 100644 --- a/libc/include/bits/fortify/unistd.h +++ b/libc/include/bits/fortify/unistd.h @@ -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__ >= 21 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED +#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED size_t bos = __bos0(buf); if (!__bos_trivially_ge_no_overflow(bos, count)) { @@ -192,7 +192,6 @@ 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__ >= 21 __BIONIC_FORTIFY_INLINE ssize_t readlinkat(int dirfd, const char* path, char* const __pass_object_size buf, size_t size) __overloadable @@ -207,7 +206,6 @@ 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__ >= 21 */ #undef __bos_trivially_ge_no_overflow #undef __enable_if_no_overflow_ssizet diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index 1ec932bd9..a8db38750 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -84,7 +84,6 @@ __BEGIN_DECLS /** Flag for open(). */ #define O_RSYNC O_SYNC -#if __ANDROID_API__ >= 21 /** Flag for splice(). */ #define SPLICE_F_MOVE 1 /** Flag for splice(). */ @@ -93,7 +92,6 @@ __BEGIN_DECLS #define SPLICE_F_MORE 4 /** Flag for splice(). */ #define SPLICE_F_GIFT 8 -#endif #if __ANDROID_API__ >= 26 /** Flag for sync_file_range(). */ diff --git a/libc/include/pthread.h b/libc/include/pthread.h index 22f949bcb..130a72f8a 100644 --- a/libc/include/pthread.h +++ b/libc/include/pthread.h @@ -58,9 +58,7 @@ enum { #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP { { ((PTHREAD_MUTEX_ERRORCHECK & 3) << 14) } } #define PTHREAD_COND_INITIALIZER { { 0 } } -#if __ANDROID_API__ >= 21 #define PTHREAD_COND_INITIALIZER_MONOTONIC_NP { { 1 << 1 } } -#endif #define PTHREAD_RWLOCK_INITIALIZER { { 0 } } diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 9de12a47f..f4b2911ac 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -136,20 +136,8 @@ int ungetc(int __ch, FILE* __fp); int vfprintf(FILE* __fp, const char* __fmt, va_list __args) __printflike(2, 0); int vprintf(const char* __fp, va_list __args) __printflike(1, 0); -#if __ANDROID_API__ >= 21 int dprintf(int __fd, const char* __fmt, ...) __printflike(2, 3) __INTRODUCED_IN(21); int vdprintf(int __fd, const char* __fmt, va_list __args) __printflike(2, 0) __INTRODUCED_IN(21); -#else -/* - * Old versions of Android called these fdprintf and vfdprintf out of fears that the glibc names - * would collide with user debug printfs. - * - * Allow users to just use dprintf and vfdprintf on any version by renaming those calls to their - * legacy equivalents if needed. - */ -int dprintf(int __fd, const char* __fmt, ...) __RENAME(fdprintf) __printflike(2, 3); -int vdprintf(int __fd, const char* __fmt, va_list __args) __RENAME(vfdprintf) __printflike(2, 0); -#endif #if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 201112L) || \ (defined(__cplusplus) && __cplusplus <= 201103L) diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 2ff808928..c185ec718 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -43,11 +43,7 @@ __BEGIN_DECLS __noreturn void abort(void) __attribute__((__nomerge__)); __noreturn void exit(int __status); -#if __ANDROID_API__ >= 21 __noreturn void _Exit(int __status) __INTRODUCED_IN(21); -#else -__noreturn void _Exit(int) __RENAME(_exit); -#endif int atexit(void (* _Nonnull __fn)(void)); diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h index 302c8c389..9e09408dd 100644 --- a/libc/include/sys/epoll.h +++ b/libc/include/sys/epoll.h @@ -40,21 +40,6 @@ __BEGIN_DECLS int epoll_create(int __size); int epoll_create1(int __flags) __INTRODUCED_IN(21); -/* - * Some third-party code uses the existence of EPOLL_CLOEXEC to detect the - * availability of epoll_create1. This is not correct, since having up-to-date - * UAPI headers says nothing about the C library, but for the time being we - * don't want to harm adoption to the unified headers. We'll undef EPOLL_CLOEXEC - * if we don't have epoll_create1 for the time being, and maybe revisit this - * later. - * - * https://github.com/android-ndk/ndk/issues/302 - * https://github.com/android-ndk/ndk/issues/394 - */ -#if __ANDROID_API__ < 21 && defined(EPOLL_CLOEXEC) -#undef EPOLL_CLOEXEC -#endif - int epoll_ctl(int __epoll_fd, int __op, int __fd, struct epoll_event* __BIONIC_COMPLICATED_NULLNESS __event); int epoll_wait(int __epoll_fd, struct epoll_event* _Nonnull __events, int __event_count, int __timeout_ms); int epoll_pwait(int __epoll_fd, struct epoll_event* _Nonnull __events, int __event_count, int __timeout_ms, const sigset_t* _Nullable __mask) __INTRODUCED_IN(21); diff --git a/libc/include/sys/inotify.h b/libc/include/sys/inotify.h index 37fbf996b..c3cdc8556 100644 --- a/libc/include/sys/inotify.h +++ b/libc/include/sys/inotify.h @@ -37,21 +37,8 @@ __BEGIN_DECLS -/* - * Some third-party code uses the existence of IN_CLOEXEC/IN_NONBLOCK to detect - * the availability of inotify_init1. This is not correct, since - * `syscall(__NR_inotify_init1, IN_CLOEXEC)` is still valid even if the C - * library doesn't have that function, but for the time being we don't want to - * harm adoption to the unified headers. We'll avoid defining IN_CLOEXEC and - * IN_NONBLOCK if we don't have inotify_init1 for the time being, and maybe - * revisit this later. - * - * https://github.com/android-ndk/ndk/issues/394 - */ -#if __ANDROID_API__ >= 21 #define IN_CLOEXEC O_CLOEXEC #define IN_NONBLOCK O_NONBLOCK -#endif int inotify_init(void); int inotify_init1(int __flags) __INTRODUCED_IN(21); diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h index 65571eb19..06914a66a 100644 --- a/libc/include/sys/select.h +++ b/libc/include/sys/select.h @@ -79,8 +79,6 @@ 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__ >= 21 - /** Removes `fd` from the given set. Use instead. */ #define FD_CLR(fd, set) __FD_CLR_chk(fd, set, __bos(set)) /** Adds `fd` to the given set. Use instead. */ @@ -88,17 +86,6 @@ int __FD_ISSET_chk(int, const fd_set*, size_t) __INTRODUCED_IN(21); /** Tests whether `fd` is in the given set. Use instead. */ #define FD_ISSET(fd, set) __FD_ISSET_chk(fd, set, __bos(set)) -#else - -/** Removes `fd` from the given set. Use instead. */ -#define FD_CLR(fd, set) __FD_CLR(fd, set) -/** Adds `fd` to the given set. Use instead. */ -#define FD_SET(fd, set) __FD_SET(fd, set) -/** Tests whether `fd` is in the given set. Use instead. */ -#define FD_ISSET(fd, set) __FD_ISSET(fd, set) - -#endif /* __ANDROID_API >= 21 */ - /** * [select(2)](http://man7.org/linux/man-pages/man2/select.2.html) waits on a * set of file descriptors. diff --git a/libc/include/unistd.h b/libc/include/unistd.h index 566caaa63..7ad94e141 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -303,13 +303,7 @@ int ttyname_r(int __fd, char* _Nonnull __buf, size_t __buf_size); int acct(const char* _Nullable __path); -#if __ANDROID_API__ >= 21 int getpagesize(void) __INTRODUCED_IN(21); -#else -static __inline__ int getpagesize(void) { - return sysconf(_SC_PAGESIZE); -} -#endif long syscall(long __number, ...);