Merge "Add an android_mallopt for controlling the heap tagging level."
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 1d652f7..7aeb09e 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -8,6 +8,9 @@
},
{
"name": "malloc_hooks_system_tests"
+ },
+ {
+ "name": "memunreachable_unit_test"
}
]
}
diff --git a/libc/Android.bp b/libc/Android.bp
index 67bee8b..8284174 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1811,6 +1811,7 @@
"//frameworks:__subpackages__",
"//external/perfetto:__subpackages__",
"//external/scudo:__subpackages__",
+ "//system/core/debuggerd:__subpackages__",
],
host_supported: true,
recovery_available: true,
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 21ebdbd..517d5f9 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -217,7 +217,7 @@
int nanosleep(const struct timespec*, struct timespec*) all
int clock_settime(clockid_t, const struct timespec*) all
int __clock_nanosleep:clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*) all
-int getitimer(int, const struct itimerval*) all
+int getitimer(int, struct itimerval*) all
int setitimer(int, const struct itimerval*, struct itimerval*) all
int __timer_create:timer_create(clockid_t clockid, struct sigevent* evp, __kernel_timer_t* timerid) all
int __timer_settime:timer_settime(__kernel_timer_t, int, const struct itimerspec*, struct itimerspec*) all
@@ -249,8 +249,8 @@
int __accept4:accept4(int, struct sockaddr*, socklen_t*, int) arm,arm64,mips,mips64,x86_64
int getsockname(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
int getpeername(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
-int __sendto:sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t) arm,arm64,mips,mips64,x86_64
-int recvfrom(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
+ssize_t __sendto:sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t) arm,arm64,mips,mips64,x86_64
+ssize_t recvfrom(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
int shutdown(int, int) arm,arm64,mips,mips64,x86_64
int setsockopt(int, int, int, const void*, socklen_t) arm,arm64,mips,mips64,x86_64
int getsockopt(int, int, int, void*, socklen_t*) arm,arm64,mips,mips64,x86_64
@@ -267,8 +267,8 @@
int getsockname:socketcall:6(int, struct sockaddr*, socklen_t*) x86
int getpeername:socketcall:7(int, struct sockaddr*, socklen_t*) x86
int socketpair:socketcall:8(int, int, int, int*) x86
-int __sendto:socketcall:11(int, const void*, size_t, int, const struct sockaddr*, socklen_t) x86
-int recvfrom:socketcall:12(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*) x86
+ssize_t __sendto:socketcall:11(int, const void*, size_t, int, const struct sockaddr*, socklen_t) x86
+ssize_t recvfrom:socketcall:12(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*) x86
int shutdown:socketcall:13(int, int) x86
int setsockopt:socketcall:14(int, int, int, const void*, socklen_t) x86
int getsockopt:socketcall:15(int, int, int, void*, socklen_t*) x86
@@ -340,7 +340,7 @@
int __sync_file_range2:sync_file_range2(int, unsigned int, off64_t, off64_t) arm
pid_t wait4(pid_t, int*, int, struct rusage*) all
-int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all
+int __waitid:waitid(int, pid_t, siginfo_t*, int, void*) all
# ARM-specific
int __set_tls:__ARM_NR_set_tls(void*) arm
@@ -355,8 +355,8 @@
# vdso stuff.
int __clock_getres:clock_getres(clockid_t, struct timespec*) all
-int __clock_gettime:clock_gettime(clockid_t, timespec*) all
-int __gettimeofday:gettimeofday(timeval*, timezone*) all
+int __clock_gettime:clock_gettime(clockid_t, struct timespec*) all
+int __gettimeofday:gettimeofday(struct timeval*, struct timezone*) all
# <sys/random.h>
ssize_t getrandom(void*, size_t, unsigned) all
diff --git a/libc/arch-common/bionic/crtbegin.c b/libc/arch-common/bionic/crtbegin.c
index bdda1cf..b7043dc 100644
--- a/libc/arch-common/bionic/crtbegin.c
+++ b/libc/arch-common/bionic/crtbegin.c
@@ -72,7 +72,7 @@
// 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 742d078..02e383d 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 @@
return __register_atfork(prepare, parent, child, &__dso_handle);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
diff --git a/libc/bionic/__libc_current_sigrtmin.cpp b/libc/bionic/__libc_current_sigrtmin.cpp
index d2ea75d..e6b3412 100644
--- a/libc/bionic/__libc_current_sigrtmin.cpp
+++ b/libc/bionic/__libc_current_sigrtmin.cpp
@@ -28,7 +28,7 @@
#include <signal.h>
-#include "private/sigrtmin.h"
+#include <platform/bionic/reserved_signals.h>
int __libc_current_sigrtmin() {
return __SIGRTMIN + __SIGRT_RESERVED;
diff --git a/libc/bionic/bionic_allocator.cpp b/libc/bionic/bionic_allocator.cpp
index 7fd7067..b6d6ba7 100644
--- a/libc/bionic/bionic_allocator.cpp
+++ b/libc/bionic/bionic_allocator.cpp
@@ -41,7 +41,7 @@
#include <async_safe/CHECK.h>
#include "platform/bionic/page.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
//
// BionicAllocator is a general purpose allocator designed to provide the same
diff --git a/libc/bionic/bionic_elf_tls.cpp b/libc/bionic/bionic_elf_tls.cpp
index 3fa5182..61d826c 100644
--- a/libc/bionic/bionic_elf_tls.cpp
+++ b/libc/bionic/bionic_elf_tls.cpp
@@ -36,7 +36,7 @@
#include "private/ScopedRWLock.h"
#include "private/ScopedSignalBlocker.h"
#include "private/bionic_globals.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/bionic_tls.h"
#include "pthread_internal.h"
diff --git a/libc/bionic/clone.cpp b/libc/bionic/clone.cpp
index 2a6ab41..622ca26 100644
--- a/libc/bionic/clone.cpp
+++ b/libc/bionic/clone.cpp
@@ -35,7 +35,7 @@
#include "pthread_internal.h"
#include "private/bionic_defs.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
extern "C" pid_t __bionic_clone(uint32_t flags, void* child_stack, int* parent_tid, void* tls, int* child_tid, int (*fn)(void*), void* arg);
extern "C" __noreturn void __exit(int status);
diff --git a/libc/bionic/fdsan.cpp b/libc/bionic/fdsan.cpp
index 4ebc796..d4ac71c 100644
--- a/libc/bionic/fdsan.cpp
+++ b/libc/bionic/fdsan.cpp
@@ -40,6 +40,7 @@
#include <unistd.h>
#include <async_safe/log.h>
+#include <platform/bionic/reserved_signals.h>
#include <sys/system_properties.h>
#include "private/bionic_globals.h"
@@ -168,8 +169,7 @@
ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
__BIONIC_FALLTHROUGH;
case ANDROID_FDSAN_ERROR_LEVEL_WARN_ALWAYS:
- // DEBUGGER_SIGNAL
- inline_raise(__SIGRTMIN + 3, &abort_message);
+ inline_raise(BIONIC_SIGNAL_DEBUGGER, &abort_message);
break;
case ANDROID_FDSAN_ERROR_LEVEL_FATAL:
diff --git a/libc/bionic/grp_pwd.cpp b/libc/bionic/grp_pwd.cpp
index 6f8c07e..dd8df95 100644
--- a/libc/bionic/grp_pwd.cpp
+++ b/libc/bionic/grp_pwd.cpp
@@ -44,7 +44,7 @@
#include "private/ErrnoRestorer.h"
#include "private/android_filesystem_config.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
// Generated android_ids array
#include "generated_android_ids.h"
diff --git a/libc/bionic/grp_pwd_file.h b/libc/bionic/grp_pwd_file.h
index 9004c4e..69c771b 100644
--- a/libc/bionic/grp_pwd_file.h
+++ b/libc/bionic/grp_pwd_file.h
@@ -32,7 +32,7 @@
#include <pwd.h>
#include "private/bionic_lock.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/grp_pwd.h"
class MmapFile {
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index ca94652..aafefab 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -53,7 +53,7 @@
#include "private/bionic_elf_tls.h"
#include "private/bionic_globals.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/bionic_ssp.h"
#include "private/bionic_tls.h"
#include "private/KernelArgumentBlock.h"
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index d2a5334..1ac4750 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -43,7 +43,7 @@
#include "private/bionic_call_ifunc_resolver.h"
#include "private/bionic_elf_tls.h"
#include "private/bionic_globals.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/bionic_tls.h"
#include "private/KernelArgumentBlock.h"
diff --git a/libc/bionic/locale.cpp b/libc/bionic/locale.cpp
index 8358fb0..0b7037a 100644
--- a/libc/bionic/locale.cpp
+++ b/libc/bionic/locale.cpp
@@ -35,7 +35,7 @@
#include <time.h>
#include <wchar.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#if defined(__BIONIC_BUILD_FOR_ANDROID_SUPPORT)
#define USE_TLS_SLOT 0
diff --git a/libc/bionic/mmap.cpp b/libc/bionic/mmap.cpp
index 3503319..9aad0b3 100644
--- a/libc/bionic/mmap.cpp
+++ b/libc/bionic/mmap.cpp
@@ -31,7 +31,7 @@
#include <sys/mman.h>
#include <unistd.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/ErrnoRestorer.h"
// mmap2(2) is like mmap(2), but the offset is in 4096-byte blocks, not bytes.
diff --git a/libc/bionic/mremap.cpp b/libc/bionic/mremap.cpp
index a4e5323..d7c9353 100644
--- a/libc/bionic/mremap.cpp
+++ b/libc/bionic/mremap.cpp
@@ -32,7 +32,7 @@
#include <stdint.h>
#include <unistd.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
extern "C" void* __mremap(void*, size_t, size_t, int, void*);
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index c816830..e9a5b5b 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -45,7 +45,7 @@
#include <unistd.h>
#include <wchar.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
extern "C" {
diff --git a/libc/bionic/poll.cpp b/libc/bionic/poll.cpp
index 41b2657..3290315 100644
--- a/libc/bionic/poll.cpp
+++ b/libc/bionic/poll.cpp
@@ -30,8 +30,9 @@
#include <sys/poll.h>
#include <sys/select.h>
+#include <platform/bionic/reserved_signals.h>
+
#include "private/bionic_time_conversions.h"
-#include "private/sigrtmin.h"
#include "private/SigSetConverter.h"
extern "C" int __ppoll(pollfd*, unsigned int, timespec*, const sigset64_t*, size_t);
diff --git a/libc/bionic/pthread_atfork.cpp b/libc/bionic/pthread_atfork.cpp
index fb12a3b..0dcabdf 100644
--- a/libc/bionic/pthread_atfork.cpp
+++ b/libc/bionic/pthread_atfork.cpp
@@ -30,7 +30,7 @@
#include <pthread.h>
#include <stdlib.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
struct atfork_t {
atfork_t* next;
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 03af2d9..4f7ac2b 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -42,7 +42,7 @@
#include "private/bionic_constants.h"
#include "private/bionic_defs.h"
#include "private/bionic_globals.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/bionic_ssp.h"
#include "private/bionic_systrace.h"
#include "private/bionic_tls.h"
diff --git a/libc/bionic/pthread_internal.cpp b/libc/bionic/pthread_internal.cpp
index 6fddefe..e091158 100644
--- a/libc/bionic/pthread_internal.cpp
+++ b/libc/bionic/pthread_internal.cpp
@@ -100,8 +100,8 @@
}
}
- // 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 de62a5c..a15e981 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -799,7 +799,7 @@
// 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/scandir.cpp b/libc/bionic/scandir.cpp
index 0b39049..6a7e368 100644
--- a/libc/bionic/scandir.cpp
+++ b/libc/bionic/scandir.cpp
@@ -22,7 +22,7 @@
#include <string.h>
#include <unistd.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/ScopedReaddir.h"
// A smart pointer to the scandir dirent**.
diff --git a/libc/bionic/scudo/scudo.cpp b/libc/bionic/scudo/scudo.cpp
index fb09b92..2cd36b1 100644
--- a/libc/bionic/scudo/scudo.cpp
+++ b/libc/bionic/scudo/scudo.cpp
@@ -33,7 +33,7 @@
#include <sys/param.h>
#include <sys/prctl.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "scudo.h"
diff --git a/libc/bionic/semaphore.cpp b/libc/bionic/semaphore.cpp
index 455e36b..33552a9 100644
--- a/libc/bionic/semaphore.cpp
+++ b/libc/bionic/semaphore.cpp
@@ -221,7 +221,7 @@
}
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/bionic/sigaction.cpp b/libc/bionic/sigaction.cpp
index 96e6f3c..583bf32 100644
--- a/libc/bionic/sigaction.cpp
+++ b/libc/bionic/sigaction.cpp
@@ -29,7 +29,7 @@
#include <signal.h>
#include <string.h>
-#include "private/sigrtmin.h"
+#include <platform/bionic/reserved_signals.h>
extern "C" void __restore_rt(void);
extern "C" void __restore(void);
diff --git a/libc/bionic/signal.cpp b/libc/bionic/signal.cpp
index 8246cb4..b581b5a 100644
--- a/libc/bionic/signal.cpp
+++ b/libc/bionic/signal.cpp
@@ -36,9 +36,10 @@
#include <time.h>
#include <unistd.h>
+#include <platform/bionic/reserved_signals.h>
+
#include "private/ErrnoRestorer.h"
#include "private/SigSetConverter.h"
-#include "private/sigrtmin.h"
extern "C" int __rt_sigpending(const sigset64_t*, size_t);
extern "C" int __rt_sigqueueinfo(pid_t, int, siginfo_t*);
diff --git a/libc/bionic/sigprocmask.cpp b/libc/bionic/sigprocmask.cpp
index 5f70f32..8781c9b 100644
--- a/libc/bionic/sigprocmask.cpp
+++ b/libc/bionic/sigprocmask.cpp
@@ -29,7 +29,8 @@
#include <errno.h>
#include <signal.h>
-#include "private/sigrtmin.h"
+#include <platform/bionic/reserved_signals.h>
+
#include "private/SigSetConverter.h"
extern "C" int __rt_sigprocmask(int, const sigset64_t*, sigset64_t*, size_t);
diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp
index e981a58..56822ac 100644
--- a/libc/bionic/system_property_set.cpp
+++ b/libc/bionic/system_property_set.cpp
@@ -45,7 +45,7 @@
#include <async_safe/CHECK.h>
#include "private/bionic_defs.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/ScopedFd.h"
static const char property_service_socket[] = "/dev/socket/" PROP_SERVICE_NAME;
diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h
index 577fb00..1b8af78 100644
--- a/libc/include/android/api-level.h
+++ b/libc/include/android/api-level.h
@@ -124,7 +124,7 @@
*/
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 9f116fa..fcbca13 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 @@
__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 5ec5582..92caa72 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 ccc824c..92589ed 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 d2c7677..90eda7d 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 @@
__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 439b486..aeb1575 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 @@
__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 @@
__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 @@
__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 5d63c5a..2cc2da2 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 @@
__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 160e6fe..04b3e97 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 @@
__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 9521694..d42ac01 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 @@
__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 4298d76..eadc752 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 @@
__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 a63dba1..9ea588d 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 e73ef37..c614cd0 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/android/versioning.h b/libc/include/android/versioning.h
index d60957f..1948890 100644
--- a/libc/include/android/versioning.h
+++ b/libc/include/android/versioning.h
@@ -16,6 +16,10 @@
#pragma once
+// The `annotate` attribute always pulls the annotated (inline) function into the object files, thus
+// we should only annotate headers when we are running versioner.
+#if defined(__BIONIC_VERSIONER)
+
#define __INTRODUCED_IN(api_level) __attribute__((annotate("introduced_in=" #api_level)))
#define __DEPRECATED_IN(api_level) __attribute__((annotate("deprecated_in=" #api_level)))
#define __REMOVED_IN(api_level) __attribute__((annotate("obsoleted_in=" #api_level)))
@@ -26,3 +30,20 @@
#define __INTRODUCED_IN_MIPS(api_level) __attribute__((annotate("introduced_in_mips=" #api_level)))
#define __VERSIONER_NO_GUARD __attribute__((annotate("versioner_no_guard")))
+#define __VERSIONER_FORTIFY_INLINE __attribute__((annotate("versioner_fortify_inline")))
+
+#else
+
+#define __INTRODUCED_IN(api_level)
+#define __DEPRECATED_IN(api_level)
+#define __REMOVED_IN(api_level)
+#define __INTRODUCED_IN_32(api_level)
+#define __INTRODUCED_IN_64(api_level)
+#define __INTRODUCED_IN_ARM(api_level)
+#define __INTRODUCED_IN_X86(api_level)
+#define __INTRODUCED_IN_MIPS(api_level)
+
+#define __VERSIONER_NO_GUARD
+#define __VERSIONER_FORTIFY_INLINE
+
+#endif // defined(__BIONIC_VERSIONER)
diff --git a/libc/include/bits/fortify/fcntl.h b/libc/include/bits/fortify/fcntl.h
index 3c5a037..7063541 100644
--- a/libc/include/bits/fortify/fcntl.h
+++ b/libc/include/bits/fortify/fcntl.h
@@ -59,7 +59,7 @@
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 @@
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 @@
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 @@
"'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 30fdce4..143153c 100644
--- a/libc/include/bits/fortify/poll.h
+++ b/libc/include/bits/fortify/poll.h
@@ -44,7 +44,7 @@
__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 @@
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 @@
#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 @@
#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 30fe0d7..9e7df6d 100644
--- a/libc/include/bits/fortify/socket.h
+++ b/libc/include/bits/fortify/socket.h
@@ -42,7 +42,7 @@
__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 @@
__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__ >= 26 && __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 43fc69c..e92e6ac 100644
--- a/libc/include/bits/fortify/stat.h
+++ b/libc/include/bits/fortify/stat.h
@@ -41,7 +41,7 @@
__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 fb503c3..42698dd 100644
--- a/libc/include/bits/fortify/stdio.h
+++ b/libc/include/bits/fortify/stdio.h
@@ -36,7 +36,7 @@
#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 @@
"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 @@
"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 @@
"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 @@
__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 7dc60f2..600ef14 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -40,7 +40,7 @@
#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 @@
#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 @@
#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 @@
__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 @@
__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 @@
__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 @@
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 @@
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 @@
}
#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 @@
__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 @@
__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 @@
__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 @@
__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 @@
__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 @@
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 @@
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 1ebaf39..65fc5f1 100644
--- a/libc/include/bits/fortify/strings.h
+++ b/libc/include/bits/fortify/strings.h
@@ -33,7 +33,7 @@
__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 @@
__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 f1580ce..49a3946 100644
--- a/libc/include/bits/fortify/unistd.h
+++ b/libc/include/bits/fortify/unistd.h
@@ -73,7 +73,7 @@
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 @@
__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 @@
__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 @@
__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 @@
__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 @@
__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 @@
__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 @@
__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 @@
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 @@
#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 a173e3c..f359696 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 @@
#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 @@
} 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 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 @@
#endif
typedef long pthread_t;
-
-#endif
diff --git a/libc/include/bits/threads_inlines.h b/libc/include/bits/threads_inlines.h
index 8f2beb0..afaed64 100644
--- a/libc/include/bits/threads_inlines.h
+++ b/libc/include/bits/threads_inlines.h
@@ -103,7 +103,7 @@
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 e7df299..61fb476 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -124,7 +124,7 @@
*/
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 c45c91f..23a58d6 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -66,7 +66,7 @@
/** 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 @@
#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 90ac805..fd78a48 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 1c9961c..7f00a7a 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 @@
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/paths.h b/libc/include/paths.h
index 0aa4d93..cfbc5b3 100644
--- a/libc/include/paths.h
+++ b/libc/include/paths.h
@@ -47,7 +47,7 @@
#define _PATH_CONSOLE "/dev/console"
/** Default shell search path. */
-#define _PATH_DEFPATH "/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
+#define _PATH_DEFPATH "/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
/** Path to the directory containing device files. */
#define _PATH_DEV "/dev/"
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index b549871..331e92c 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -54,7 +54,7 @@
#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 @@
#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_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/search.h b/libc/include/search.h
index 7a75404..7c4989a 100644
--- a/libc/include/search.h
+++ b/libc/include/search.h
@@ -214,6 +214,6 @@
* [twalk(3)](http://man7.org/linux/man-pages/man3/twalk.3.html) calls
* `__visitor` on every node in the tree.
*/
-void twalk(const void* __root, void (*__visitor)(const void*, VISIT, int));
+void twalk(const void* __root, void (*__visitor)(const void*, VISIT, int)) __INTRODUCED_IN(21);
__END_DECLS
diff --git a/libc/include/signal.h b/libc/include/signal.h
index cd11656..532e4a5 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -64,7 +64,7 @@
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 6632c01..1bf578c 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 @@
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 b66e3c6..dc7b694 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -43,7 +43,7 @@
__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 @@
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 @@
#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 @@
// 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 @@
// 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 25f6673..0cc5611 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -119,7 +119,7 @@
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 d6ee1c8..08c2326 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -63,7 +63,7 @@
__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/cdefs.h b/libc/include/sys/cdefs.h
index eb30690..9e214e5 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -277,7 +277,7 @@
* Because clang-FORTIFY uses overloads, we can't mark functions as `extern
* inline` without making them available externally.
*/
-# define __BIONIC_FORTIFY_INLINE static __inline__ __always_inline
+# define __BIONIC_FORTIFY_INLINE static __inline__ __always_inline __VERSIONER_FORTIFY_INLINE
/*
* We should use __BIONIC_FORTIFY_VARIADIC instead of __BIONIC_FORTIFY_INLINE
* for variadic functions because compilers cannot inline them.
diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h
index a213a90..3745737 100644
--- a/libc/include/sys/epoll.h
+++ b/libc/include/sys/epoll.h
@@ -51,7 +51,7 @@
* 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 32e16d9..37fbf99 100644
--- a/libc/include/sys/inotify.h
+++ b/libc/include/sys/inotify.h
@@ -48,7 +48,7 @@
*
* 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 3b83229..fe4ea7f 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 __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 @@
#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 1ee8d2a..79fc28d 100644
--- a/libc/include/sys/select.h
+++ b/libc/include/sys/select.h
@@ -79,7 +79,7 @@
#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 e54dd65..e2acab7 100644
--- a/libc/include/sys/socket.h
+++ b/libc/include/sys/socket.h
@@ -112,7 +112,7 @@
? (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 @@
}
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 79113b6..d8e92d9 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -171,7 +171,7 @@
#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 106946b..8c0655f 100644
--- a/libc/include/sys/wait.h
+++ b/libc/include/sys/wait.h
@@ -40,7 +40,7 @@
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 0fd5c95..8eca96e 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 752761d..1b00b8f 100644
--- a/libc/include/threads.h
+++ b/libc/include/threads.h
@@ -78,7 +78,7 @@
__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 a7a6fe5..0db14ff 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -78,7 +78,7 @@
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 7c01549..e4afd8e 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -282,7 +282,7 @@
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 f33af5f..f0966de 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -121,7 +121,7 @@
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 18f5c4b..58510ae 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);
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 01c9b0c..3ffa305 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -332,7 +332,7 @@
execvp;
execvpe; # introduced=21
exit;
- faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ faccessat;
fallocate; # introduced=21
fallocate64; # introduced=21
fchdir;
@@ -358,9 +358,9 @@
fgets;
fgetwc;
fgetws;
- fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ fgetxattr;
fileno;
- flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ flistxattr;
flock;
flockfile;
fmemopen; # introduced=23
@@ -379,13 +379,13 @@
free;
freeaddrinfo;
freelocale; # introduced=21
- fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ fremovexattr;
freopen;
fscanf;
fseek;
fseeko;
fsetpos;
- fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ fsetxattr;
fstat;
fstat64; # introduced=21
fstatat;
@@ -488,7 +488,7 @@
getutent;
getwc;
getwchar;
- getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ getxattr;
gmtime;
gmtime64; # arm x86 mips
gmtime64_r; # arm x86 mips
@@ -596,14 +596,14 @@
ldexp;
ldiv;
lfind; # introduced=21
- lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ lgetxattr;
link;
linkat; # introduced=21
listen;
- listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ listxattr;
llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
lldiv;
- llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ llistxattr;
localeconv; # introduced=21
localtime;
localtime64; # arm x86 mips
@@ -612,11 +612,11 @@
login_tty; # introduced=23
longjmp;
lrand48;
- lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ lremovexattr;
lsearch; # introduced=21
lseek;
lseek64;
- lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ lsetxattr;
lstat;
lstat64; # introduced=21
madvise;
@@ -723,7 +723,7 @@
pause;
pclose;
perror;
- personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
+ personality;
pipe;
pipe2;
poll;
@@ -850,7 +850,7 @@
rand_r; # introduced=21
random; # introduced=21
read;
- readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ readahead;
readdir;
readdir64; # introduced=21
readdir64_r; # introduced=21
@@ -870,7 +870,7 @@
regexec;
regfree;
remove;
- removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ removexattr;
remque; # introduced=21
rename;
renameat;
@@ -950,7 +950,7 @@
setuid;
setutent;
setvbuf;
- setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ setxattr;
shutdown;
sigaction;
sigaddset; # introduced=21
@@ -1068,13 +1068,13 @@
tcsendbreak; # introduced=21
tcsetattr; # introduced=21
tcsetpgrp;
- tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
- tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ tdelete;
+ tdestroy;
tee; # introduced=21
telldir; # introduced=23
tempnam;
- tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
- tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ tfind;
+ tgkill;
time;
timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
timegm64; # arm x86 mips
@@ -1103,7 +1103,7 @@
towupper_l; # introduced=21
truncate;
truncate64; # introduced=21
- tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+ tsearch;
ttyname;
ttyname_r;
twalk; # introduced=21
diff --git a/libc/malloc_debug/Config.cpp b/libc/malloc_debug/Config.cpp
index dbd3eac..11887e2 100644
--- a/libc/malloc_debug/Config.cpp
+++ b/libc/malloc_debug/Config.cpp
@@ -38,7 +38,7 @@
#include <string>
#include <vector>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include "Config.h"
#include "debug_log.h"
diff --git a/libc/malloc_debug/DebugData.h b/libc/malloc_debug/DebugData.h
index 3a36299..13bba48 100644
--- a/libc/malloc_debug/DebugData.h
+++ b/libc/malloc_debug/DebugData.h
@@ -33,7 +33,7 @@
#include <memory>
#include <vector>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include "Config.h"
#include "GuardData.h"
diff --git a/libc/malloc_debug/GuardData.h b/libc/malloc_debug/GuardData.h
index b6ec889..58e33e9 100644
--- a/libc/malloc_debug/GuardData.h
+++ b/libc/malloc_debug/GuardData.h
@@ -33,7 +33,7 @@
#include <vector>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include "OptionData.h"
diff --git a/libc/malloc_debug/MapData.h b/libc/malloc_debug/MapData.h
index 5b08b90..f2b3c1c 100644
--- a/libc/malloc_debug/MapData.h
+++ b/libc/malloc_debug/MapData.h
@@ -34,7 +34,7 @@
#include <set>
#include <string>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
struct MapEntry {
MapEntry(uintptr_t start, uintptr_t end, uintptr_t offset, const char* name, size_t name_len, int flags)
diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp
index b1e28b7..4f81ff7 100644
--- a/libc/malloc_debug/PointerData.cpp
+++ b/libc/malloc_debug/PointerData.cpp
@@ -43,7 +43,7 @@
#include <android-base/stringprintf.h>
#include <android-base/thread_annotations.h>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include "Config.h"
#include "DebugData.h"
diff --git a/libc/malloc_debug/PointerData.h b/libc/malloc_debug/PointerData.h
index 78f0ed8..37d87db 100644
--- a/libc/malloc_debug/PointerData.h
+++ b/libc/malloc_debug/PointerData.h
@@ -38,7 +38,7 @@
#include <unordered_map>
#include <vector>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include <unwindstack/LocalUnwinder.h>
#include "OptionData.h"
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
index a015882..3d37529 100644
--- a/libc/malloc_debug/RecordData.h
+++ b/libc/malloc_debug/RecordData.h
@@ -36,7 +36,7 @@
#include <mutex>
#include <string>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
class RecordEntry {
public:
diff --git a/libc/malloc_debug/debug_disable.h b/libc/malloc_debug/debug_disable.h
index f9c3149..984bc25 100644
--- a/libc/malloc_debug/debug_disable.h
+++ b/libc/malloc_debug/debug_disable.h
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
// =============================================================================
// Used to disable the debug allocation calls.
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index 70457b9..c405c7f 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -41,7 +41,7 @@
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include <private/bionic_malloc_dispatch.h>
#include "Config.h"
diff --git a/libc/private/bionic_macros.h b/libc/platform/bionic/macros.h
similarity index 100%
rename from libc/private/bionic_macros.h
rename to libc/platform/bionic/macros.h
diff --git a/libc/private/sigrtmin.h b/libc/platform/bionic/reserved_signals.h
similarity index 95%
rename from libc/private/sigrtmin.h
rename to libc/platform/bionic/reserved_signals.h
index 5de1a32..f062b1c 100644
--- a/libc/private/sigrtmin.h
+++ b/libc/platform/bionic/reserved_signals.h
@@ -32,13 +32,13 @@
#include <signal.h>
-#include "bionic_macros.h"
+#include "macros.h"
// Realtime signals reserved for internal use:
// 32 (__SIGRTMIN + 0) POSIX timers
// 33 (__SIGRTMIN + 1) libbacktrace
// 34 (__SIGRTMIN + 2) libcore
-// 35 (__SIGRTMIN + 3) debuggerd -b
+// 35 (__SIGRTMIN + 3) debuggerd
// 36 (__SIGRTMIN + 4) heapprofd native dumps
// 37 (__SIGRTMIN + 5) coverage (libprofile-extras)
// 38 (__SIGRTMIN + 6) heapprofd ART managed heap dumps
@@ -46,6 +46,8 @@
// If you change this, also change __ndk_legacy___libc_current_sigrtmin
// in <android/legacy_signal_inlines.h> to match.
+#define BIONIC_SIGNAL_DEBUGGER __SIGRTMIN + 3
+
#define __SIGRT_RESERVED 7
static inline __always_inline sigset64_t filter_reserved_signals(sigset64_t sigset, int how) {
int (*block)(sigset64_t*, int);
diff --git a/libc/private/CFIShadow.h b/libc/private/CFIShadow.h
index 84fbea5..ec87e3c 100644
--- a/libc/private/CFIShadow.h
+++ b/libc/private/CFIShadow.h
@@ -20,7 +20,7 @@
#include <stdint.h>
#include "platform/bionic/page.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
constexpr unsigned kLibraryAlignmentBits = 18;
constexpr size_t kLibraryAlignment = 1UL << kLibraryAlignmentBits;
diff --git a/libc/private/ErrnoRestorer.h b/libc/private/ErrnoRestorer.h
index 52e115a..cecf103 100644
--- a/libc/private/ErrnoRestorer.h
+++ b/libc/private/ErrnoRestorer.h
@@ -18,7 +18,7 @@
#include <errno.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
class ErrnoRestorer {
public:
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
index c8ce841..ee28d69 100644
--- a/libc/private/KernelArgumentBlock.h
+++ b/libc/private/KernelArgumentBlock.h
@@ -21,7 +21,7 @@
#include <stdint.h>
#include <sys/auxv.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
// When the kernel starts the dynamic linker, it passes a pointer to a block
// of memory containing argc, the argv array, the environment variable array,
diff --git a/libc/private/MallocXmlElem.h b/libc/private/MallocXmlElem.h
index a367972..f8c72ab 100644
--- a/libc/private/MallocXmlElem.h
+++ b/libc/private/MallocXmlElem.h
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <unistd.h>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
class MallocXmlElem {
public:
diff --git a/libc/private/ScopedFd.h b/libc/private/ScopedFd.h
index 1cec916..ea7f59e 100644
--- a/libc/private/ScopedFd.h
+++ b/libc/private/ScopedFd.h
@@ -30,7 +30,7 @@
#include <unistd.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/ErrnoRestorer.h"
class ScopedFd final {
diff --git a/libc/private/ScopedPthreadMutexLocker.h b/libc/private/ScopedPthreadMutexLocker.h
index 1c1e4a7..a87750c 100644
--- a/libc/private/ScopedPthreadMutexLocker.h
+++ b/libc/private/ScopedPthreadMutexLocker.h
@@ -18,7 +18,7 @@
#include <pthread.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
class ScopedPthreadMutexLocker {
public:
diff --git a/libc/private/ScopedRWLock.h b/libc/private/ScopedRWLock.h
index f034505..0af372b 100644
--- a/libc/private/ScopedRWLock.h
+++ b/libc/private/ScopedRWLock.h
@@ -30,7 +30,7 @@
#include <pthread.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
template <bool write> class ScopedRWLock {
public:
diff --git a/libc/private/ScopedReaddir.h b/libc/private/ScopedReaddir.h
index 9a20c09..7b07921 100644
--- a/libc/private/ScopedReaddir.h
+++ b/libc/private/ScopedReaddir.h
@@ -18,7 +18,7 @@
#include <dirent.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
class ScopedReaddir {
public:
diff --git a/libc/private/ScopedSignalBlocker.h b/libc/private/ScopedSignalBlocker.h
index 10aacb3..ce0ae64 100644
--- a/libc/private/ScopedSignalBlocker.h
+++ b/libc/private/ScopedSignalBlocker.h
@@ -18,7 +18,7 @@
#include <signal.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
class ScopedSignalBlocker {
public:
diff --git a/libc/private/WriteProtected.h b/libc/private/WriteProtected.h
index 26c239c..8f5b32d 100644
--- a/libc/private/WriteProtected.h
+++ b/libc/private/WriteProtected.h
@@ -24,7 +24,7 @@
#include <async_safe/log.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
template <typename T>
union WriteProtectedContents {
diff --git a/libc/private/bionic_lock.h b/libc/private/bionic_lock.h
index d70ba6c..8ed4939 100644
--- a/libc/private/bionic_lock.h
+++ b/libc/private/bionic_lock.h
@@ -30,7 +30,7 @@
#include <stdatomic.h>
#include "private/bionic_futex.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
// Lock is used in places like pthread_rwlock_t, which can be initialized without calling
// an initialization function. So make sure Lock can be initialized by setting its memory to 0.
diff --git a/libc/private/bionic_systrace.h b/libc/private/bionic_systrace.h
index 86d2a08..dbe1739 100644
--- a/libc/private/bionic_systrace.h
+++ b/libc/private/bionic_systrace.h
@@ -16,7 +16,7 @@
#pragma once
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
// Tracing class for bionic. To begin a trace at a specified point:
// ScopedTrace("Trace message");
diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h
index 9a80140..bb5c67b 100644
--- a/libc/private/bionic_tls.h
+++ b/libc/private/bionic_tls.h
@@ -36,7 +36,7 @@
#include <platform/bionic/tls.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "grp_pwd.h"
/** WARNING WARNING WARNING
diff --git a/libc/stdio/printf_common.h b/libc/stdio/printf_common.h
index ad4fe35..4dc5ca1 100644
--- a/libc/stdio/printf_common.h
+++ b/libc/stdio/printf_common.h
@@ -48,7 +48,7 @@
#include <unistd.h>
#include <wchar.h>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include "fvwrite.h"
#include "gdtoa.h"
diff --git a/libc/stdio/vfscanf.cpp b/libc/stdio/vfscanf.cpp
index 6fb49c9..ad20ba4 100644
--- a/libc/stdio/vfscanf.cpp
+++ b/libc/stdio/vfscanf.cpp
@@ -43,7 +43,7 @@
#include <private/bionic_ctype.h>
#include <private/bionic_fortify.h>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
#include <private/bionic_mbstate.h>
#define BUF 513 /* Maximum length of numeric string. */
diff --git a/libc/system_properties/include/system_properties/prop_area.h b/libc/system_properties/include/system_properties/prop_area.h
index 53b2745..e32a8d7 100644
--- a/libc/system_properties/include/system_properties/prop_area.h
+++ b/libc/system_properties/include/system_properties/prop_area.h
@@ -33,7 +33,7 @@
#include <string.h>
#include <sys/mman.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "prop_info.h"
diff --git a/libc/system_properties/include/system_properties/prop_info.h b/libc/system_properties/include/system_properties/prop_info.h
index 27b29c8..3ebe7c5 100644
--- a/libc/system_properties/include/system_properties/prop_info.h
+++ b/libc/system_properties/include/system_properties/prop_info.h
@@ -32,7 +32,7 @@
#include <stdint.h>
#include <sys/system_properties.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
// The C11 standard doesn't allow atomic loads from const fields,
// though C++11 does. Fudge it until standards get straightened out.
diff --git a/libm/Android.bp b/libm/Android.bp
index bf05b17..801129a 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -9,7 +9,7 @@
recovery_available: true,
static_ndk_lib: true,
- whole_static_libs: ["libarm-optimized-routines"],
+ whole_static_libs: ["libarm-optimized-routines-math"],
srcs: [
"upstream-freebsd/lib/msun/bsdsrc/b_exp.c",
diff --git a/linker/NOTICE b/linker/NOTICE
index d645695..e9ece13 100644
--- a/linker/NOTICE
+++ b/linker/NOTICE
@@ -1,202 +1,25 @@
+Copyright (C) 2007 The Android Open Source Project
+All rights reserved.
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/linker/linker.cpp b/linker/linker.cpp
index fb22a1d..8b0520a 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -209,7 +209,7 @@
};
// If you're targeting N, you don't get the greylist.
- if (g_greylist_disabled || get_application_target_sdk_version() >= __ANDROID_API_N__) {
+ if (g_greylist_disabled || get_application_target_sdk_version() >= 24) {
return false;
}
@@ -252,7 +252,7 @@
// New mapping for new apex should be added below
// Nothing to do if target sdk version is Q or above
- if (get_application_target_sdk_version() >= __ANDROID_API_Q__) {
+ if (get_application_target_sdk_version() >= 29) {
return false;
}
@@ -943,8 +943,7 @@
// Do not skip RTLD_LOCAL libraries in dlsym(RTLD_DEFAULT, ...)
// if the library is opened by application with target api level < M.
// See http://b/21565766
- if ((si->get_rtld_flags() & RTLD_GLOBAL) == 0 &&
- si->get_target_sdk_version() >= __ANDROID_API_M__) {
+ if ((si->get_rtld_flags() & RTLD_GLOBAL) == 0 && si->get_target_sdk_version() >= 23) {
continue;
}
@@ -1232,10 +1231,10 @@
#if !defined(__LP64__)
// Work around incorrect DT_NEEDED entries for old apps: http://b/21364029
int app_target_api_level = get_application_target_sdk_version();
- if (app_target_api_level < __ANDROID_API_M__) {
+ if (app_target_api_level < 23) {
const char* bname = basename(dt_needed);
if (bname != dt_needed) {
- DL_WARN_documented_change(__ANDROID_API_M__,
+ DL_WARN_documented_change(23,
"invalid-dt_needed-entries-enforced-for-api-level-23",
"library \"%s\" has invalid DT_NEEDED entry \"%s\"",
sopath, dt_needed, app_target_api_level);
@@ -1384,7 +1383,7 @@
const soinfo* needed_or_dlopened_by = task->get_needed_by();
const char* sopath = needed_or_dlopened_by == nullptr ? "(unknown)" :
needed_or_dlopened_by->get_realpath();
- DL_WARN_documented_change(__ANDROID_API_N__,
+ DL_WARN_documented_change(24,
"private-api-enforced-for-api-level-24",
"library \"%s\" (\"%s\") needed or dlopened by \"%s\" "
"is not accessible by namespace \"%s\"",
@@ -3832,9 +3831,9 @@
if (soname_ == nullptr &&
this != solist_get_somain() &&
(flags_ & FLAG_LINKER) == 0 &&
- get_application_target_sdk_version() < __ANDROID_API_M__) {
+ get_application_target_sdk_version() < 23) {
soname_ = basename(realpath_.c_str());
- DL_WARN_documented_change(__ANDROID_API_M__,
+ DL_WARN_documented_change(23,
"missing-soname-enforced-for-api-level-23",
"\"%s\" has no DT_SONAME (will use %s instead)",
get_realpath(), soname_);
@@ -3875,7 +3874,7 @@
if (has_text_relocations) {
// Fail if app is targeting M or above.
int app_target_api_level = get_application_target_sdk_version();
- if (app_target_api_level >= __ANDROID_API_M__) {
+ if (app_target_api_level >= 23) {
DL_ERR_AND_LOG("\"%s\" has text relocations (https://android.googlesource.com/platform/"
"bionic/+/master/android-changes-for-ndk-developers.md#Text-Relocations-"
"Enforced-for-API-level-23)", get_realpath());
@@ -3883,7 +3882,7 @@
}
// Make segments writable to allow text relocations to work properly. We will later call
// phdr_table_protect_segments() after all of them are applied.
- DL_WARN_documented_change(__ANDROID_API_M__,
+ DL_WARN_documented_change(23,
"Text-Relocations-Enforced-for-API-level-23",
"\"%s\" has text relocations",
get_realpath());
@@ -4203,11 +4202,13 @@
// we also need vdso to be available for all namespaces (if present)
soinfo* vdso = solist_get_vdso();
for (auto it : namespaces) {
- it.second->add_soinfo(ld_android_so);
- if (vdso != nullptr) {
- it.second->add_soinfo(vdso);
+ if (it.second != &g_default_namespace) {
+ it.second->add_soinfo(ld_android_so);
+ if (vdso != nullptr) {
+ it.second->add_soinfo(vdso);
+ }
+ // somain and ld_preloads are added to these namespaces after LD_PRELOAD libs are linked
}
- // somain and ld_preloads are added to these namespaces after LD_PRELOAD libs are linked
}
set_application_target_sdk_version(config->target_sdk_version());
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 3534287..da2d03c 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -264,12 +264,12 @@
if (header_.e_shentsize != sizeof(ElfW(Shdr))) {
// Fail if app is targeting Android O or above
- if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ if (get_application_target_sdk_version() >= 26) {
DL_ERR_AND_LOG("\"%s\" has unsupported e_shentsize: 0x%x (expected 0x%zx)",
name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr)));
return false;
}
- DL_WARN_documented_change(__ANDROID_API_O__,
+ DL_WARN_documented_change(26,
"invalid-elf-header_section-headers-enforced-for-api-level-26",
"\"%s\" has unsupported e_shentsize 0x%x (expected 0x%zx)",
name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr)));
@@ -278,12 +278,12 @@
if (header_.e_shstrndx == 0) {
// Fail if app is targeting Android O or above
- if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ if (get_application_target_sdk_version() >= 26) {
DL_ERR_AND_LOG("\"%s\" has invalid e_shstrndx", name_.c_str());
return false;
}
- DL_WARN_documented_change(__ANDROID_API_O__,
+ DL_WARN_documented_change(26,
"invalid-elf-header_section-headers-enforced-for-api-level-26",
"\"%s\" has invalid e_shstrndx", name_.c_str());
add_dlwarning(name_.c_str(), "has invalid ELF header");
@@ -392,7 +392,7 @@
}
if (pt_dynamic_offset != dynamic_shdr->sh_offset) {
- if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ if (get_application_target_sdk_version() >= 26) {
DL_ERR_AND_LOG("\"%s\" .dynamic section has invalid offset: 0x%zx, "
"expected to match PT_DYNAMIC offset: 0x%zx",
name_.c_str(),
@@ -400,7 +400,7 @@
pt_dynamic_offset);
return false;
}
- DL_WARN_documented_change(__ANDROID_API_O__,
+ DL_WARN_documented_change(26,
"invalid-elf-header_section-headers-enforced-for-api-level-26",
"\"%s\" .dynamic section has invalid offset: 0x%zx "
"(expected to match PT_DYNAMIC offset 0x%zx)",
@@ -411,7 +411,7 @@
}
if (pt_dynamic_filesz != dynamic_shdr->sh_size) {
- if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ if (get_application_target_sdk_version() >= 26) {
DL_ERR_AND_LOG("\"%s\" .dynamic section has invalid size: 0x%zx, "
"expected to match PT_DYNAMIC filesz: 0x%zx",
name_.c_str(),
@@ -419,7 +419,7 @@
pt_dynamic_filesz);
return false;
}
- DL_WARN_documented_change(__ANDROID_API_O__,
+ DL_WARN_documented_change(26,
"invalid-elf-header_section-headers-enforced-for-api-level-26",
"\"%s\" .dynamic section has invalid size: 0x%zx "
"(expected to match PT_DYNAMIC filesz 0x%zx)",
@@ -635,11 +635,11 @@
int prot = PFLAGS_TO_PROT(phdr->p_flags);
if ((prot & (PROT_EXEC | PROT_WRITE)) == (PROT_EXEC | PROT_WRITE)) {
// W + E PT_LOAD segments are not allowed in O.
- if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ if (get_application_target_sdk_version() >= 26) {
DL_ERR_AND_LOG("\"%s\": W+E load segments are not allowed", name_.c_str());
return false;
}
- DL_WARN_documented_change(__ANDROID_API_O__,
+ DL_WARN_documented_change(26,
"writable-and-executable-segments-enforced-for-api-level-26",
"\"%s\" has load segments that are both writable and executable",
name_.c_str());
diff --git a/linker/linker_soinfo.cpp b/linker/linker_soinfo.cpp
index c71945a..04aa27b 100644
--- a/linker/linker_soinfo.cpp
+++ b/linker/linker_soinfo.cpp
@@ -754,7 +754,7 @@
}
void* soinfo::to_handle() {
- if (get_application_target_sdk_version() < __ANDROID_API_N__ || !has_min_version(3)) {
+ if (get_application_target_sdk_version() < 24 || !has_min_version(3)) {
return this;
}
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index 0b4cacb..a2b5b3c 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -230,9 +230,9 @@
dlclose(handle);
}
-TEST(dlfcn, dlopen_from_nullptr_android_api_level) {
+TEST(dlfcn, dlopen_from_nullptr_android_api_level_28) {
// Regression test for http://b/123972211. Testing dlopen(nullptr) when target sdk is P
- android_set_application_target_sdk_version(__ANDROID_API_P__);
+ android_set_application_target_sdk_version(28);
ASSERT_TRUE(dlopen(nullptr, RTLD_NOW) != nullptr);
}
@@ -1229,7 +1229,7 @@
extinfo.library_namespace = ns;
// An app targeting M can open libnativehelper.so because it's on the greylist.
- android_set_application_target_sdk_version(__ANDROID_API_M__);
+ android_set_application_target_sdk_version(23);
void* handle = android_dlopen_ext("libnativehelper.so", RTLD_NOW, &extinfo);
ASSERT_TRUE(handle != nullptr) << dlerror();
@@ -1241,7 +1241,7 @@
dlclose(handle);
// An app targeting N no longer has the greylist.
- android_set_application_target_sdk_version(__ANDROID_API_N__);
+ android_set_application_target_sdk_version(24);
handle = android_dlopen_ext("libnativehelper.so", RTLD_NOW, &extinfo);
ASSERT_TRUE(handle == nullptr);
ASSERT_STREQ("dlopen failed: library \"libnativehelper.so\" not found", dlerror());
@@ -1266,7 +1266,7 @@
extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE;
extinfo.library_namespace = ns;
- android_set_application_target_sdk_version(__ANDROID_API_M__);
+ android_set_application_target_sdk_version(23);
void* handle = android_dlopen_ext("libnativehelper.so", RTLD_NOW, &extinfo);
ASSERT_TRUE(handle == nullptr);
ASSERT_STREQ("dlopen failed: library \"libnativehelper.so\" not found", dlerror());
@@ -2063,7 +2063,7 @@
}
TEST(dlext, dlopen_handle_value_app_compat) {
- android_set_application_target_sdk_version(__ANDROID_API_M__);
+ android_set_application_target_sdk_version(23);
void* handle = dlopen("libtest_dlsym_from_this.so", RTLD_NOW | RTLD_LOCAL);
ASSERT_TRUE(reinterpret_cast<uintptr_t>(handle) % sizeof(uintptr_t) == 0)
<< "dlopen should return valid pointer";
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 6b49e29..9c6b0c5 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -407,7 +407,7 @@
// TODO(73062966): We still don't have a good way to create vendor AIDs in the system or other
// non-vendor partitions, therefore we keep this check disabled.
- if (android::base::GetIntProperty("ro.product.first_api_level", 0) <= __ANDROID_API_Q__) {
+ if (android::base::GetIntProperty("ro.product.first_api_level", 0) <= 29) {
return;
}
diff --git a/tests/semaphore_test.cpp b/tests/semaphore_test.cpp
index 5a23b96..6ec8b2a 100644
--- a/tests/semaphore_test.cpp
+++ b/tests/semaphore_test.cpp
@@ -214,7 +214,7 @@
TEST(semaphore, sem_wait_no_EINTR_in_sdk_less_equal_than_23) {
#if defined(__BIONIC__)
- android_set_application_target_sdk_version(__ANDROID_API_M__);
+ android_set_application_target_sdk_version(23);
sem_t s;
ASSERT_EQ(0, sem_init(&s, 0, 0));
ScopedSignalHandler handler(SIGUSR1, sem_wait_test_signal_handler);
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index a0cda1b..75abbd2 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -853,6 +853,20 @@
ASSERT_EQ(ENOMEM, errno);
}
+// Inspired by https://github.com/landley/toybox/issues/163.
+TEST(STDIO_TEST, printf_NULL) {
+ char buf[128];
+ char* null = nullptr;
+ EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%*.*s>", 2, 2, null));
+ EXPECT_STREQ("<(n>", buf);
+ EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%*.*s>", 2, 8, null));
+ EXPECT_STREQ("<(null)>", buf);
+ EXPECT_EQ(10, snprintf(buf, sizeof(buf), "<%*.*s>", 8, 2, null));
+ EXPECT_STREQ("< (n>", buf);
+ EXPECT_EQ(10, snprintf(buf, sizeof(buf), "<%*.*s>", 8, 8, null));
+ EXPECT_STREQ("< (null)>", buf);
+}
+
TEST(STDIO_TEST, fprintf) {
TemporaryFile tf;
diff --git a/tools/versioner/src/DeclarationDatabase.cpp b/tools/versioner/src/DeclarationDatabase.cpp
index 0ba51d1..afae509 100644
--- a/tools/versioner/src/DeclarationDatabase.cpp
+++ b/tools/versioner/src/DeclarationDatabase.cpp
@@ -106,6 +106,7 @@
bool is_extern = named_decl->getFormalLinkage() == ExternalLinkage;
bool is_definition = false;
bool no_guard = false;
+ bool fortify_inline = false;
if (auto function_decl = dyn_cast<FunctionDecl>(decl)) {
is_definition = function_decl->isThisDeclarationADefinition();
@@ -147,6 +148,8 @@
llvm::StringRef annotation = attr->getAnnotation();
if (annotation == "versioner_no_guard") {
no_guard = true;
+ } else if (annotation == "versioner_fortify_inline") {
+ fortify_inline = true;
} else {
llvm::SmallVector<llvm::StringRef, 2> fragments;
annotation.split(fragments, "=");
@@ -217,7 +220,8 @@
declaration_it != symbol_it->second.declarations.end()) {
if (declaration_it->second.is_extern != is_extern ||
declaration_it->second.is_definition != is_definition ||
- declaration_it->second.no_guard != no_guard) {
+ declaration_it->second.no_guard != no_guard ||
+ declaration_it->second.fortify_inline != fortify_inline) {
errx(1, "varying declaration of '%s' at %s:%u:%u", declaration_name.c_str(),
location.filename.c_str(), location.start.line, location.start.column);
}
@@ -229,6 +233,7 @@
declaration.is_extern = is_extern;
declaration.is_definition = is_definition;
declaration.no_guard = no_guard;
+ declaration.fortify_inline = fortify_inline;
declaration.availability.insert(std::make_pair(type, availability));
symbol_it->second.declarations.insert(std::make_pair(location, declaration));
}
diff --git a/tools/versioner/src/DeclarationDatabase.h b/tools/versioner/src/DeclarationDatabase.h
index 4496ee9..9a45227 100644
--- a/tools/versioner/src/DeclarationDatabase.h
+++ b/tools/versioner/src/DeclarationDatabase.h
@@ -127,6 +127,7 @@
bool is_extern;
bool is_definition;
bool no_guard;
+ bool fortify_inline;
std::map<CompilationType, DeclarationAvailability> availability;
bool calculateAvailability(DeclarationAvailability* output) const;
@@ -143,6 +144,9 @@
if (no_guard) {
fprintf(out, "no_guard ");
}
+ if (fortify_inline) {
+ fprintf(out, "fortify_inline ");
+ }
fprintf(out, "@ %s:%u:%u", StripPrefix(location.filename, base_path).str().c_str(),
location.start.line, location.start.column);
diff --git a/tools/versioner/src/Driver.cpp b/tools/versioner/src/Driver.cpp
index 927a0f5..184c3d4 100644
--- a/tools/versioner/src/Driver.cpp
+++ b/tools/versioner/src/Driver.cpp
@@ -125,6 +125,7 @@
cmd.push_back(arch_targets[type.arch]);
cmd.push_back("-DANDROID");
+ cmd.push_back("-D__BIONIC_VERSIONER=1");
cmd.push_back("-D__ANDROID_API__="s + std::to_string(type.api_level));
cmd.push_back("-D_FORTIFY_SOURCE=2");
cmd.push_back("-D_GNU_SOURCE");
diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp
index d3c2f7c..473f1f9 100644
--- a/tools/versioner/src/versioner.cpp
+++ b/tools/versioner/src/versioner.cpp
@@ -277,7 +277,9 @@
}
// Perform a sanity check on a symbol's declarations, enforcing the following invariants:
-// 1. At most one inline definition of the function exists.
+// 1. At most one inline definition of the function exists (overloaded inline functions for
+// _FORTIFY_SOURCE do not count because they are usually introduced to intercept the original
+// functions or usually have enable_if attributes).
// 2. All of the availability declarations for a symbol are compatible.
// If a function is declared as an inline before a certain version, the inline definition
// should have no version tag.
@@ -290,7 +292,7 @@
std::unordered_map<const Declaration*, std::set<CompilationType>> inline_definitions;
for (const auto& decl_it : symbol.declarations) {
const Declaration* decl = &decl_it.second;
- if (decl->is_definition) {
+ if (decl->is_definition && !decl->fortify_inline) {
std::set<CompilationType> compilation_types = getCompilationTypes(decl);
for (const auto& inline_def_it : inline_definitions) {
auto intersection = Intersection(compilation_types, inline_def_it.second);
diff --git a/tools/versioner/tests/fortify_inline/headers/fcntl.h b/tools/versioner/tests/fortify_inline/headers/fcntl.h
new file mode 100644
index 0000000..dc81ef8
--- /dev/null
+++ b/tools/versioner/tests/fortify_inline/headers/fcntl.h
@@ -0,0 +1,29 @@
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+extern int open_real(const char* name, int flags, ...) __asm__("open");
+
+#define O_CREAT 00000100
+
+typedef unsigned int mode_t;
+
+static inline __attribute__((always_inline))
+int open(const char* name, int flags)
+ __attribute__((annotate("versioner_fortify_inline")))
+ __attribute__((overloadable))
+ __attribute__((enable_if(!(flags & O_CREAT), ""))) {
+ return open_real(name, flags);
+}
+
+static inline __attribute__((always_inline))
+int open(const char* name, int flags, mode_t mode)
+ __attribute__((annotate("versioner_fortify_inline")))
+ __attribute__((overloadable))
+ __attribute__((enable_if(flags & O_CREAT, ""))) {
+ return open_real(name, flags, mode);
+}
+
+#if defined(__cplusplus)
+}
+#endif
diff --git a/tools/versioner/tests/fortify_inline/platforms/libc.map.txt b/tools/versioner/tests/fortify_inline/platforms/libc.map.txt
new file mode 100644
index 0000000..2f09034
--- /dev/null
+++ b/tools/versioner/tests/fortify_inline/platforms/libc.map.txt
@@ -0,0 +1,4 @@
+LIBC {
+ global:
+ open;
+};
diff --git a/tools/versioner/tests/fortify_inline/run.sh b/tools/versioner/tests/fortify_inline/run.sh
new file mode 100644
index 0000000..9bfbe6d
--- /dev/null
+++ b/tools/versioner/tests/fortify_inline/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
\ No newline at end of file