Merge "Ensure same order of global group members in all NS's"
diff --git a/libc/Android.bp b/libc/Android.bp
index cdd5473..0ee353d 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -2084,6 +2084,8 @@
local_include_dirs: ["include"],
srcs: ["arch-common/bionic/crtbegin.c"],
defaults: ["crt_defaults"],
+ // When using libc.a, we're using the latest library regardless of target API level.
+ min_sdk_version: "current",
}
cc_object {
@@ -2094,6 +2096,8 @@
"crtbrand",
],
defaults: ["crt_defaults"],
+ // When using libc.a, we're using the latest library regardless of target API level.
+ min_sdk_version: "current",
}
cc_object {
@@ -2233,7 +2237,6 @@
ndk_library {
name: "libc",
- native_bridge_supported: true,
symbol_file: "libc.map.txt",
first_version: "9",
}
diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h
index 90eda7d..a673446 100644
--- a/libc/include/android/legacy_signal_inlines.h
+++ b/libc/include/android/legacy_signal_inlines.h
@@ -45,12 +45,16 @@
int __libc_current_sigrtmin() __attribute__((__weak__)) __VERSIONER_NO_GUARD;
static __inline int __ndk_legacy___libc_current_sigrtmax() {
- if (__libc_current_sigrtmax) return __libc_current_sigrtmax();
+ if (__builtin_available(android 21, *)) {
+ return __libc_current_sigrtmax();
+ }
return __SIGRTMAX; /* Should match __libc_current_sigrtmax. */
}
static __inline int __ndk_legacy___libc_current_sigrtmin() {
- if (__libc_current_sigrtmin) return __libc_current_sigrtmin();
+ if (__builtin_available(android 21, *)) {
+ return __libc_current_sigrtmin();
+ }
return __SIGRTMIN + 7; /* Should match __libc_current_sigrtmin. */
}
diff --git a/libc/include/android/versioning.h b/libc/include/android/versioning.h
index 3ea414a..2b9a027 100644
--- a/libc/include/android/versioning.h
+++ b/libc/include/android/versioning.h
@@ -33,13 +33,62 @@
#else
-#define __INTRODUCED_IN(api_level)
-#define __DEPRECATED_IN(api_level)
-#define __REMOVED_IN(api_level)
-#define __INTRODUCED_IN_32(api_level)
+// When headers are not processed by the versioner (i.e. compiled into object files),
+// the availability attributed is emitted instead. The clang compiler will make the symbol weak
+// when targeting old api_level and enforce the reference to the symbol to be guarded with
+// __builtin_available(android api_level, *).
+
+// The 'strict' flag is required for NDK clients where the use of "-Wunguarded-availability" cannot
+// be enforced. In the case, the absence of 'strict' makes it possible to call an unavailable API
+// without the __builtin_available check, which will cause a link error at runtime.
+// Android platform build system defines this macro along with -Wunguarded-availability
+#if defined(__ANDROID_UNGUARDED_AVAILABILITY__)
+#define __MAYBE_STRICT
+#else
+#define __MAYBE_STRICT ,strict
+#endif
+
+#define __INTRODUCED_IN(api_level) \
+ __attribute__((availability(android __MAYBE_STRICT,introduced=api_level)))
+#define __DEPRECATED_IN(api_level) \
+ __attribute__((availability(android __MAYBE_STRICT,deprecated=api_level)))
+#define __REMOVED_IN(api_level) \
+ __attribute__((availability(android __MAYBE_STRICT,obsoleted=api_level)))
+
+// The same availability attribute can't be annotated multiple times. Therefore, the macros are
+// defined for the configuration that it is valid for so that declarations like the below doesn't
+// cause inconsistent availability values which is an error with -Wavailability:
+//
+// void foo() __INTRODUCED_IN_32(30) __INTRODUCED_IN_64(31);
+//
+// This also takes the advantage of the fact that we never use bitness-specific macro with
+// arch-specific macro. In other words,
+//
+// void foo() __INTRODUCED_IN_ARM(30) __INTRODUCED_IN_64(31);
+//
+// hasn't been supported and won't be.
+#if !defined(__LP64__)
+#define __INTRODUCED_IN_32(api_level) \
+ __attribute__((availability(android __MAYBE_STRICT,introduced=api_level)))
#define __INTRODUCED_IN_64(api_level)
+#else
+#define __INTRODUCED_IN_32(api_level)
+#define __INTRODUCED_IN_64(api_level) \
+ __attribute__((availability(android __MAYBE_STRICT,introduced=api_level)))
+#endif
+
+#if defined(__arm__) || defined(__aarch64__)
+#define __INTRODUCED_IN_ARM(api_level) \
+ __attribute__((availability(android __MAYBE_STRICT,introduced=api_level)))
+#define __INTRODUCED_IN_X86(api_level)
+#elif defined(__i386__) || defined(__x86_64__)
+#define __INTRODUCED_IN_ARM(api_level)
+#define __INTRODUCED_IN_X86(api_level) \
+ __attribute__((availability(android __MAYBE_STRICT,introduced=api_level)))
+#else
#define __INTRODUCED_IN_ARM(api_level)
#define __INTRODUCED_IN_X86(api_level)
+#endif
#define __VERSIONER_NO_GUARD
#define __VERSIONER_FORTIFY_INLINE
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 9a31d36..91f85f9 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -216,7 +216,6 @@
ndk_library {
name: "libdl",
- native_bridge_supported: true,
symbol_file: "libdl.map.txt",
first_version: "9",
}
diff --git a/libm/Android.bp b/libm/Android.bp
index 6c8ad22..21be51b 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -516,7 +516,6 @@
ndk_library {
name: "libm",
- native_bridge_supported: true,
symbol_file: "libm.map.txt",
first_version: "9",
}
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index f465458..ffbb667 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -803,15 +803,13 @@
#endif
TEST(signal, sigset_size) {
- // The setjmp implementations for ARM, AArch64, x86, and x86_64 assume that sigset_t can fit in a
- // long. This is true because ARM and x86 have broken rt signal support, and AArch64 and x86_64
- // both have a SIGRTMAX defined as 64.
-#if defined(__arm__) || defined(__aarch64__) || defined(__i386__) || defined(__x86_64__)
+ // The setjmp implementations assume that sigset_t can fit in a
+ // long. This is true because ARM and x86 have broken rt signal support,
+ // and AArch64 and x86_64 both have a SIGRTMAX defined as 64.
#if defined(__BIONIC__)
static_assert(sizeof(sigset_t) <= sizeof(long), "sigset_t doesn't fit in a long");
#endif
static_assert(sizeof(sigset64_t)*8 >= 64, "sigset64_t too small for real-time signals");
-#endif
}
TEST(signal, sigignore_EINVAL) {