Use attribute availability.
Bug: http://b/21952040
Change-Id: I3998d88bc6076d60ae5cf7efd112817f80f17971
diff --git a/libc/include/signal.h b/libc/include/signal.h
index 554e0ac..7a171b4 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -105,15 +105,15 @@
extern int sigaction(int, const struct sigaction*, struct sigaction*);
-_BIONIC_NOT_BEFORE_21(extern sighandler_t signal(int, sighandler_t);)
+extern sighandler_t signal(int, sighandler_t) __INTRODUCED_IN(21);
extern int siginterrupt(int, int);
-_BIONIC_NOT_BEFORE_21(extern int sigaddset(sigset_t*, int);)
-_BIONIC_NOT_BEFORE_21(extern int sigdelset(sigset_t*, int);)
-_BIONIC_NOT_BEFORE_21(extern int sigemptyset(sigset_t*);)
-_BIONIC_NOT_BEFORE_21(extern int sigfillset(sigset_t*);)
-_BIONIC_NOT_BEFORE_21(extern int sigismember(const sigset_t*, int);)
+extern int sigaddset(sigset_t*, int) __INTRODUCED_IN(21);
+extern int sigdelset(sigset_t*, int) __INTRODUCED_IN(21);
+extern int sigemptyset(sigset_t*) __INTRODUCED_IN(21);
+extern int sigfillset(sigset_t*) __INTRODUCED_IN(21);
+extern int sigismember(const sigset_t*, int) __INTRODUCED_IN(21);
extern int sigpending(sigset_t*) __nonnull((1));
extern int sigprocmask(int, const sigset_t*, sigset_t*);
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index efca577..d9d277a 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -76,10 +76,10 @@
extern int posix_memalign(void **memptr, size_t alignment, size_t size);
-_BIONIC_NOT_BEFORE_21(extern double atof(const char*);)
+extern double atof(const char*) __INTRODUCED_IN(21);
extern double strtod(const char*, char**) __LIBC_ABI_PUBLIC__;
-_BIONIC_NOT_BEFORE_21(extern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__;)
+extern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__ __INTRODUCED_IN(21);
extern long double strtold(const char*, char**) __LIBC_ABI_PUBLIC__;
extern long double strtold_l(const char *, char **, locale_t) __LIBC_ABI_PUBLIC__;
@@ -90,9 +90,9 @@
extern long atol(const char*) __purefunc;
extern long long atoll(const char*) __purefunc;
-_BIONIC_NOT_BEFORE_21(extern int abs(int) __pure2;)
-_BIONIC_NOT_BEFORE_21(extern long labs(long) __pure2;)
-_BIONIC_NOT_BEFORE_21(extern long long llabs(long long) __pure2;)
+extern int abs(int) __pure2 __INTRODUCED_IN(21);
+extern long labs(long) __pure2 __INTRODUCED_IN(21);
+extern long long llabs(long long) __pure2 __INTRODUCED_IN(21);
extern char * realpath(const char *path, char *resolved);
extern int system(const char *string);
@@ -109,9 +109,9 @@
#define RAND_MAX 0x7fffffff
-_BIONIC_NOT_BEFORE_21(int rand(void);)
+int rand(void) __INTRODUCED_IN(21);
int rand_r(unsigned int*);
-_BIONIC_NOT_BEFORE_21(void srand(unsigned int);)
+void srand(unsigned int) __INTRODUCED_IN(21);
double drand48(void);
double erand48(unsigned short[3]);
@@ -124,12 +124,12 @@
void srand48(long);
char* initstate(unsigned int, char*, size_t);
-_BIONIC_NOT_BEFORE_21(long random(void);)
+long random(void) __INTRODUCED_IN(21);
char* setstate(char*);
-_BIONIC_NOT_BEFORE_21(void srandom(unsigned int);)
+void srandom(unsigned int) __INTRODUCED_IN(21);
int getpt(void);
-_BIONIC_NOT_BEFORE_21(int grantpt(int);)
+int grantpt(int) __INTRODUCED_IN(21);
int posix_openpt(int);
char* ptsname(int);
int ptsname_r(int, char*, size_t);
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 8a11bc6..3ad4f42 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -572,11 +572,17 @@
/* Used to rename functions so that the compiler emits a call to 'x' rather than the function this was applied to. */
#define __RENAME(x) __asm__(#x)
-#if __ANDROID_API__ >= 21
-#define _BIONIC_NOT_BEFORE_21(x) x
+#ifdef __clang__
+#define __AVAILABILITY(...) __attribute__((availability(android,__VA_ARGS__)))
+#define __INTRODUCED_IN(api_level) __AVAILABILITY(introduced=api_level)
+#define __DEPRECATED_IN(api_level) __AVAILABILITY(deprecated=api_level)
+#define __REMOVED_IN(api_level) __AVAILABILITY(obsoleted=api_level)
#else
-#define _BIONIC_NOT_BEFORE_21(x)
-#endif /* __ANDROID_API__ >= 21 */
+#define __AVAILABILITY(...)
+#define __INTRODUCED_IN(api_level)
+#define __DEPRECATED_IN(api_level)
+#define __REMOVED_IN(api_level)
+#endif // __clang__
#if __has_builtin(__builtin_umul_overflow) || __GNUC__ >= 5
#if __LP64__
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index c22516f..65aa190 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -171,7 +171,7 @@
}
#endif /* defined(__BIONIC_FORTIFY) */
-_BIONIC_NOT_BEFORE_21(extern int mkfifo(const char*, mode_t);)
+extern int mkfifo(const char*, mode_t) __INTRODUCED_IN(21);
extern int mkfifoat(int, const char*, mode_t);
extern int fchmodat(int, const char*, mode_t, int);