Merge "Nullability check for string modules."
diff --git a/libc/include/android/versioning.h b/libc/include/android/versioning.h
index efe4354..08fe45d 100644
--- a/libc/include/android/versioning.h
+++ b/libc/include/android/versioning.h
@@ -26,9 +26,6 @@
 #define __REMOVED_IN(api_level) __attribute__((annotate("obsoleted_in=" #api_level)))
 #define __INTRODUCED_IN_32(api_level) __attribute__((annotate("introduced_in_32=" #api_level)))
 #define __INTRODUCED_IN_64(api_level) __attribute__((annotate("introduced_in_64=" #api_level)))
-#define __INTRODUCED_IN_ARM(api_level) __attribute__((annotate("introduced_in_arm=" #api_level)))
-#define __INTRODUCED_IN_X86(api_level) __attribute__((annotate("introduced_in_x86=" #api_level)))
-#define __INTRODUCED_IN_X86_NO_GUARD_FOR_NDK(api_level) __attribute__((annotate("introduced_in_x86=" #api_level))) __VERSIONER_NO_GUARD
 
 #define __VERSIONER_NO_GUARD __attribute__((annotate("versioner_no_guard")))
 #define __VERSIONER_FORTIFY_INLINE __attribute__((annotate("versioner_fortify_inline")))
@@ -52,11 +49,9 @@
 #if defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__)
 #define __BIONIC_AVAILABILITY(__what) __attribute__((__availability__(android,__what)))
 #define __INTRODUCED_IN_NO_GUARD_FOR_NDK(api_level) __INTRODUCED_IN(api_level)
-#define __INTRODUCED_IN_X86_NO_GUARD_FOR_NDK(api_level) __INTRODUCED_IN_X86(api_level)
 #else
 #define __BIONIC_AVAILABILITY(__what) __attribute__((__availability__(android,strict,__what)))
 #define __INTRODUCED_IN_NO_GUARD_FOR_NDK(api_level)
-#define __INTRODUCED_IN_X86_NO_GUARD_FOR_NDK(api_level)
 #endif
 
 #define __INTRODUCED_IN(api_level) __BIONIC_AVAILABILITY(introduced=api_level)
@@ -69,12 +64,6 @@
 //
 // 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) __BIONIC_AVAILABILITY(introduced=api_level)
 #define __INTRODUCED_IN_64(api_level)
@@ -83,17 +72,6 @@
 #define __INTRODUCED_IN_64(api_level) __BIONIC_AVAILABILITY(introduced=api_level)
 #endif
 
-#if defined(__arm__) || defined(__aarch64__)
-#define __INTRODUCED_IN_ARM(api_level) __BIONIC_AVAILABILITY(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) __BIONIC_AVAILABILITY(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/libc/include/ftw.h b/libc/include/ftw.h
index c5fa4de..ee154f0 100644
--- a/libc/include/ftw.h
+++ b/libc/include/ftw.h
@@ -57,8 +57,8 @@
 __BEGIN_DECLS
 int ftw(const char* _Nonnull __dir_path, int (* _Nonnull __callback)(const char* _Nonnull, const struct stat* _Nonnull, int), int __max_fd_count) __INTRODUCED_IN(17);
 int nftw(const char* _Nonnull __dir_path, int (* _Nonnull __callback)(const char* _Nonnull, const struct stat* _Nonnull, int, struct FTW* _Nonnull), int __max_fd_count, int __flags) __INTRODUCED_IN(17);
-int ftw64(const char* _Nonnull __dir_path, int (* _Nonnull __callback)(const char* _Nonnull, const struct stat64* _Nonnull, int), int __max_fd_count) __RENAME_STAT64(ftw, 17, 21);
-int nftw64(const char* _Nonnull __dir_path, int (* _Nonnull __callback)(const char* _Nonnull, const struct stat64* _Nonnull, int, struct FTW* _Nonnull), int __max_fd_count, int __flags) __RENAME_STAT64(nftw, 17, 21);
+int ftw64(const char* _Nonnull __dir_path, int (* _Nonnull __callback)(const char* _Nonnull, const struct stat64* _Nonnull, int), int __max_fd_count) __INTRODUCED_IN(21);
+int nftw64(const char* _Nonnull __dir_path, int (* _Nonnull __callback)(const char* _Nonnull, const struct stat64* _Nonnull, int, struct FTW* _Nonnull), int __max_fd_count, int __flags) __INTRODUCED_IN(21);
 __END_DECLS
 
 #endif
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 8f4310d..4154e62 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -201,16 +201,6 @@
 #  define __RENAME_IF_FILE_OFFSET64(func)
 #endif
 
-/*
- * On all architectures, `struct stat` == `struct stat64`, but LP32 didn't gain the *64 functions
- * until API level 21.
- */
-#if defined(__LP64__) || defined(__BIONIC_LP32_USE_STAT64)
-#define __RENAME_STAT64(rewrite,rewrite_api_level,regular_api_level) __INTRODUCED_IN(regular_api_level)
-#else
-#define __RENAME_STAT64(rewrite,rewrite_api_level,regular_api_level) __RENAME(rewrite) __INTRODUCED_IN(rewrite_api_level)
-#endif
-
 /* glibc compatibility. */
 #if defined(__LP64__)
 #define __WORDSIZE 64
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 54621b7..f773ff6 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -141,13 +141,13 @@
 int mkdir(const char* _Nonnull __path, mode_t __mode);
 
 int fstat(int __fd, struct stat* _Nonnull __buf);
-int fstat64(int __fd, struct stat64* _Nonnull __buf) __RENAME_STAT64(fstat, 3, 21);
+int fstat64(int __fd, struct stat64* _Nonnull __buf) __INTRODUCED_IN(21);
 int fstatat(int __dir_fd, const char* _Nonnull __path, struct stat* _Nonnull __buf, int __flags);
-int fstatat64(int __dir_fd, const char* _Nonnull __path, struct stat64* _Nonnull __buf, int __flags) __RENAME_STAT64(fstatat, 3, 21);
+int fstatat64(int __dir_fd, const char* _Nonnull __path, struct stat64* _Nonnull __buf, int __flags) __INTRODUCED_IN(21);
 int lstat(const char* _Nonnull __path, struct stat* _Nonnull __buf);
-int lstat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf) __RENAME_STAT64(lstat, 3, 21);
+int lstat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf) __INTRODUCED_IN(21);
 int stat(const char* _Nonnull __path, struct stat* _Nonnull __buf);
-int stat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf) __RENAME_STAT64(stat, 3, 21);
+int stat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf) __INTRODUCED_IN(21);
 
 int mknod(const char* _Nonnull __path, mode_t __mode, dev_t __dev);
 mode_t umask(mode_t __mask);
diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp
index c818197..5afa00b 100644
--- a/tools/versioner/src/versioner.cpp
+++ b/tools/versioner/src/versioner.cpp
@@ -284,8 +284,8 @@
 //      If a function is declared as an inline before a certain version, the inline definition
 //      should have no version tag.
 //   3. Each availability type must only be present globally or on a per-arch basis.
-//      (e.g. __INTRODUCED_IN_ARM(9) __INTRODUCED_IN_X86(10) __DEPRECATED_IN(11) is fine,
-//      but not __INTRODUCED_IN(9) __INTRODUCED_IN_X86(10))
+//      (e.g. __INTRODUCED_IN_32(21) __INTRODUCED_IN_64(22) __DEPRECATED_IN(23) is fine,
+//      but not __INTRODUCED_IN(9) __INTRODUCED_IN_32(10))
 static bool checkSymbol(const Symbol& symbol) {
   std::string cwd = getWorkingDir() + "/";
 
diff --git a/tools/versioner/tests/preprocessor/expected/foo.h b/tools/versioner/tests/preprocessor/expected/foo.h
index d7de9a0..4f74927 100644
--- a/tools/versioner/tests/preprocessor/expected/foo.h
+++ b/tools/versioner/tests/preprocessor/expected/foo.h
@@ -54,15 +54,16 @@
 
 // __INTRODUCED_IN_64(21) should be ignored.
 
-#if (!defined(__LP64__) && __ANDROID_API__ >= 13) || (defined(__LP64__))
-int multiple_introduced_1() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_X86(13) __INTRODUCED_IN_64(21);
-#endif /* (!defined(__LP64__) && __ANDROID_API__ >= 13) || (defined(__LP64__)) */
+#if (!defined(__LP64__) && __ANDROID_API__ >= 24) || (defined(__LP64__))
+int multiple_introduced_1() __INTRODUCED_IN_32(24) __INTRODUCED_IN_64(21);
+#endif /* (!defined(__LP64__) && __ANDROID_API__ >= 24) || (defined(__LP64__)) */
 
 
+// This needs different guards for 32 vs 64.
 
-#if (!defined(__LP64__) && __ANDROID_API__ >= 13) || (defined(__LP64__) && __ANDROID_API__ >= 22)
-int multiple_introduced_2() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_X86(13) __INTRODUCED_IN_64(22);
-#endif /* (!defined(__LP64__) && __ANDROID_API__ >= 13) || (defined(__LP64__) && __ANDROID_API__ >= 22) */
+#if (!defined(__LP64__) && __ANDROID_API__ >= 24) || (defined(__LP64__) && __ANDROID_API__ >= 26)
+int multiple_introduced_2() __INTRODUCED_IN_32(24) __INTRODUCED_IN_64(26);
+#endif /* (!defined(__LP64__) && __ANDROID_API__ >= 24) || (defined(__LP64__) && __ANDROID_API__ >= 26) */
 
 
 // This produces both an LP64 and a not-LP64 check, but it doesn't need to check for all 64-bit
@@ -74,9 +75,9 @@
 
 
 
-#if (!defined(__LP64__) && __ANDROID_API__ >= 12) || (defined(__LP64__))
-int group_lp32() __INTRODUCED_IN_ARM(12) __INTRODUCED_IN_X86(12);
-#endif /* (!defined(__LP64__) && __ANDROID_API__ >= 12) || (defined(__LP64__)) */
+#if (!defined(__LP64__)) || (defined(__LP64__) && __ANDROID_API__ >= 28)
+int added_to_lp64_late() __INTRODUCED_IN_64(28);
+#endif /* (!defined(__LP64__)) || (defined(__LP64__) && __ANDROID_API__ >= 28) */
 
 
 #if defined(__cplusplus)
diff --git a/tools/versioner/tests/preprocessor/headers/foo.h b/tools/versioner/tests/preprocessor/headers/foo.h
index 7b39f29..b01d8a9 100644
--- a/tools/versioner/tests/preprocessor/headers/foo.h
+++ b/tools/versioner/tests/preprocessor/headers/foo.h
@@ -37,15 +37,16 @@
 #endif
 
 // __INTRODUCED_IN_64(21) should be ignored.
-int multiple_introduced_1() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_X86(13) __INTRODUCED_IN_64(21);
+int multiple_introduced_1() __INTRODUCED_IN_32(24) __INTRODUCED_IN_64(21);
 
-int multiple_introduced_2() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_X86(13) __INTRODUCED_IN_64(22);
+// This needs different guards for 32 vs 64.
+int multiple_introduced_2() __INTRODUCED_IN_32(24) __INTRODUCED_IN_64(26);
 
 // This produces both an LP64 and a not-LP64 check, but it doesn't need to check for all 64-bit
 // targets separately.
 int multiple_introduced_3() __INTRODUCED_IN_32(23) __INTRODUCED_IN_64(23);
 
-int group_lp32() __INTRODUCED_IN_ARM(12) __INTRODUCED_IN_X86(12);
+int added_to_lp64_late() __INTRODUCED_IN_64(28);
 
 #if defined(__cplusplus)
 }