Merge changes Id8a3b7dc,I00ded8f9,I02f78ad7
* changes:
Make the legacy inline headers compile standalone.
Don't redefine __ANDROID_API__.
Move <sys/_sigdefs.h> and <sys/_errdefs.h> to private.
diff --git a/libc/bionic/strerror_r.cpp b/libc/bionic/strerror_r.cpp
index d419fb1..a0a0809 100644
--- a/libc/bionic/strerror_r.cpp
+++ b/libc/bionic/strerror_r.cpp
@@ -31,7 +31,7 @@
static const Pair _sys_error_strings[] = {
#define __BIONIC_ERRDEF(x,y,z) { x, z },
-#include <sys/_errdefs.h>
+#include "private/bionic_errdefs.h"
{ 0, NULL }
};
@@ -41,7 +41,7 @@
static const Pair _sys_signal_strings[] = {
#define __BIONIC_SIGDEF(signal_number, signal_description) { signal_number, signal_description },
-#include <sys/_sigdefs.h>
+#include "private/bionic_sigdefs.h"
{ 0, NULL }
};
diff --git a/libc/bionic/sys_siglist.c b/libc/bionic/sys_siglist.c
index 3cfddbf..8e33d64 100644
--- a/libc/bionic/sys_siglist.c
+++ b/libc/bionic/sys_siglist.c
@@ -30,5 +30,5 @@
const char* const sys_siglist[NSIG] = {
#define __BIONIC_SIGDEF(signal_number, signal_description) [ signal_number ] = signal_description,
-#include <sys/_sigdefs.h>
+#include "private/bionic_sigdefs.h"
};
diff --git a/libc/bionic/sys_signame.c b/libc/bionic/sys_signame.c
index e1286f2..5158b83 100644
--- a/libc/bionic/sys_signame.c
+++ b/libc/bionic/sys_signame.c
@@ -30,5 +30,5 @@
const char* const sys_signame[NSIG] = {
#define __BIONIC_SIGDEF(signal_number, unused) [ signal_number ] = #signal_number + 3,
-#include <sys/_sigdefs.h>
+#include "private/bionic_sigdefs.h"
};
diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h
index 2d2f096..b230cef 100644
--- a/libc/include/android/api-level.h
+++ b/libc/include/android/api-level.h
@@ -33,6 +33,8 @@
* Magic version number for a current development build, which has
* not yet turned into an official release.
*/
+#ifndef __ANDROID_API__
#define __ANDROID_API__ 10000
+#endif
#endif /* ANDROID_API_LEVEL_H */
diff --git a/libc/include/android/legacy_errno_inlines.h b/libc/include/android/legacy_errno_inlines.h
index 71096fc..93cba1f 100644
--- a/libc/include/android/legacy_errno_inlines.h
+++ b/libc/include/android/legacy_errno_inlines.h
@@ -29,8 +29,11 @@
#ifndef _ANDROID_LEGACY_ERRNO_INLINES_H
#define _ANDROID_LEGACY_ERRNO_INLINES_H
+#include <errno.h>
#include <sys/cdefs.h>
+#if __ANDROID_API__ < 21
+
__BEGIN_DECLS
static __inline int __attribute__((deprecated)) __set_errno(int n) {
@@ -40,4 +43,5 @@
__END_DECLS
+#endif
#endif /* _ANDROID_LEGACY_ERRNO_INLINES_H */
diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h
index 1b6e687..bf895da 100644
--- a/libc/include/android/legacy_signal_inlines.h
+++ b/libc/include/android/legacy_signal_inlines.h
@@ -29,14 +29,18 @@
#ifndef _ANDROID_LEGACY_SIGNAL_INLINES_H_
#define _ANDROID_LEGACY_SIGNAL_INLINES_H_
+#include <errno.h>
+#include <signal.h>
#include <string.h>
#include <sys/cdefs.h>
+#if __ANDROID_API__ < 21
+
__BEGIN_DECLS
extern sighandler_t bsd_signal(int signum, sighandler_t handler);
-static __inline int sigismember(sigset_t *set, int signum) {
+static __inline int sigismember(const sigset_t *set, int signum) {
/* Signal numbers start at 1, but bit positions start at 0. */
int bit = signum - 1;
const unsigned long *local_set = (const unsigned long *)set;
@@ -95,4 +99,5 @@
__END_DECLS
+#endif
#endif /* _ANDROID_LEGACY_SIGNAL_INLINES_H_ */
diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h
index 58a2a9e..93554e5 100644
--- a/libc/include/android/legacy_stdlib_inlines.h
+++ b/libc/include/android/legacy_stdlib_inlines.h
@@ -29,8 +29,11 @@
#ifndef _ANDROID_LEGACY_STDLIB_INLINES_H_
#define _ANDROID_LEGACY_STDLIB_INLINES_H_
+#include <stdlib.h>
#include <sys/cdefs.h>
+#if __ANDROID_API__ < 21
+
__BEGIN_DECLS
static __inline float strtof(const char *nptr, char **endptr) {
@@ -61,4 +64,5 @@
__END_DECLS
+#endif
#endif /* _ANDROID_LEGACY_STDLIB_INLINES_H_ */
diff --git a/libc/include/android/legacy_sys_atomics_inlines.h b/libc/include/android/legacy_sys_atomics_inlines.h
index 85cbade..3314e35 100644
--- a/libc/include/android/legacy_sys_atomics_inlines.h
+++ b/libc/include/android/legacy_sys_atomics_inlines.h
@@ -31,6 +31,8 @@
#include <sys/cdefs.h>
+#if __ANDROID_API__ < 21
+
__BEGIN_DECLS
/* Note: atomic operations that were exported by the C library didn't
@@ -69,4 +71,5 @@
__END_DECLS
+#endif
#endif /* _ANDROID_LEGACY_SYS_ATOMICS_INLINES_H_ */
diff --git a/libc/include/android/legacy_sys_stat_inlines.h b/libc/include/android/legacy_sys_stat_inlines.h
index f6d3c0f..c08edfa 100644
--- a/libc/include/android/legacy_sys_stat_inlines.h
+++ b/libc/include/android/legacy_sys_stat_inlines.h
@@ -30,6 +30,9 @@
#define _ANDROID_LEGACY_SYS_STAT_INLINES_H_
#include <sys/cdefs.h>
+#include <sys/stat.h>
+
+#if __ANDROID_API__ < 21
__BEGIN_DECLS
@@ -39,4 +42,5 @@
__END_DECLS
+#endif
#endif /* _ANDROID_LEGACY_SYS_STAT_INLINES_H_ */
diff --git a/libc/include/android/legacy_termios_inlines.h b/libc/include/android/legacy_termios_inlines.h
index fb61f27..41ea955 100644
--- a/libc/include/android/legacy_termios_inlines.h
+++ b/libc/include/android/legacy_termios_inlines.h
@@ -34,6 +34,8 @@
#include <sys/ioctl.h>
#include <sys/types.h>
+#if __ANDROID_API__ < 21
+
__BEGIN_DECLS
static __inline int tcgetattr(int fd, struct termios *s) {
@@ -90,4 +92,5 @@
__END_DECLS
+#endif
#endif /* _ANDROID_LEGACY_TERMIOS_INLINES_H_ */
diff --git a/libc/include/errno.h b/libc/include/errno.h
index 82f4b42..2ff1369 100644
--- a/libc/include/errno.h
+++ b/libc/include/errno.h
@@ -46,10 +46,8 @@
/* a macro expanding to the errno l-value */
#define errno (*__errno())
-#if __ANDROID_API__ < 21
-#include <android/legacy_errno_inlines.h>
-#endif
-
__END_DECLS
+#include <android/legacy_errno_inlines.h>
+
#endif /* _ERRNO_H */
diff --git a/libc/include/signal.h b/libc/include/signal.h
index 763bae9..5679402 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -110,15 +110,15 @@
extern int sigaction(int, const struct sigaction*, struct sigaction*);
-extern sighandler_t signal(int, sighandler_t) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE sighandler_t signal(int, sighandler_t);
extern int siginterrupt(int, 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);
+__BIONIC_LEGACY_INLINE int sigaddset(sigset_t*, int);
+__BIONIC_LEGACY_INLINE int sigdelset(sigset_t*, int);
+__BIONIC_LEGACY_INLINE int sigemptyset(sigset_t*);
+__BIONIC_LEGACY_INLINE int sigfillset(sigset_t*);
+__BIONIC_LEGACY_INLINE int sigismember(const sigset_t*, int);
extern int sigpending(sigset_t*) __nonnull((1));
extern int sigprocmask(int, const sigset_t*, sigset_t*);
@@ -147,10 +147,8 @@
extern int sigtimedwait(const sigset_t*, siginfo_t*, const struct timespec*);
extern int sigwaitinfo(const sigset_t*, siginfo_t*);
-#if __ANDROID_API__ < 21
-#include <android/legacy_signal_inlines.h>
-#endif
-
__END_DECLS
+#include <android/legacy_signal_inlines.h>
+
#endif /* _SIGNAL_H_ */
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 88930b1..d0fb0e8 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);
-extern double atof(const char*) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE double atof(const char*);
extern double strtod(const char*, char**) __LIBC_ABI_PUBLIC__;
-extern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__ __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE float strtof(const char*, char**) __LIBC_ABI_PUBLIC__;
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;
-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);
+__BIONIC_LEGACY_INLINE int abs(int) __pure2;
+__BIONIC_LEGACY_INLINE long labs(long) __pure2;
+__BIONIC_LEGACY_INLINE long long llabs(long long) __pure2;
extern char * realpath(const char *path, char *resolved);
extern int system(const char *string);
@@ -109,9 +109,9 @@
#define RAND_MAX 0x7fffffff
-int rand(void) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE int rand(void);
int rand_r(unsigned int*);
-void srand(unsigned int) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE void srand(unsigned int);
double drand48(void);
double erand48(unsigned short[3]);
@@ -124,12 +124,12 @@
void srand48(long);
char* initstate(unsigned int, char*, size_t);
-long random(void) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE long random(void);
char* setstate(char*);
-void srandom(unsigned int) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE void srandom(unsigned int);
int getpt(void);
-int grantpt(int) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE int grantpt(int);
int posix_openpt(int);
char* ptsname(int);
int ptsname_r(int, char*, size_t);
@@ -174,10 +174,6 @@
extern size_t __ctype_get_mb_cur_max(void);
#define MB_CUR_MAX __ctype_get_mb_cur_max()
-#if __ANDROID_API__ < 21
-#include <android/legacy_stdlib_inlines.h>
-#endif
-
#if defined(__BIONIC_FORTIFY)
extern char* __realpath_real(const char*, char*) __RENAME(realpath);
@@ -201,4 +197,6 @@
__END_DECLS
+#include <android/legacy_stdlib_inlines.h>
+
#endif /* _STDLIB_H */
diff --git a/libc/include/sys/atomics.h b/libc/include/sys/atomics.h
index 38ab366..b9b2ba3 100644
--- a/libc/include/sys/atomics.h
+++ b/libc/include/sys/atomics.h
@@ -38,8 +38,6 @@
* sys/atomics.h header was removed, so we'll just add these somewhere we can be
* sure they will be included.
*/
-#if __ANDROID_API__ < 21
#include <android/legacy_sys_atomics_inlines.h>
-#endif
#endif /* _SYS_ATOMICS_H_ */
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index f51942b..2bd058e 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -443,6 +443,12 @@
/* 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_LEGACY_INLINE static __inline
+#else
+#define __BIONIC_LEGACY_INLINE extern
+#endif
+
#ifdef __clang__
#define __AVAILABILITY(...) __attribute__((availability(android,__VA_ARGS__)))
#define __INTRODUCED_IN(api_level) __AVAILABILITY(introduced=api_level)
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 86668f6..ae85f62 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -177,7 +177,7 @@
}
#endif /* defined(__BIONIC_FORTIFY) */
-extern int mkfifo(const char*, mode_t) __INTRODUCED_IN(21);
+__BIONIC_LEGACY_INLINE int mkfifo(const char*, mode_t);
extern int mkfifoat(int, const char*, mode_t);
extern int fchmodat(int, const char*, mode_t, int);
@@ -189,10 +189,8 @@
extern int utimensat(int fd, const char *path, const struct timespec times[2], int flags);
extern int futimens(int fd, const struct timespec times[2]);
-#if __ANDROID_API__ < 21
-#include <android/legacy_sys_stat_inlines.h>
-#endif
-
__END_DECLS
+#include <android/legacy_sys_stat_inlines.h>
+
#endif /* _SYS_STAT_H_ */
diff --git a/libc/include/termios.h b/libc/include/termios.h
index 683fde2..e604747 100644
--- a/libc/include/termios.h
+++ b/libc/include/termios.h
@@ -35,24 +35,22 @@
__BEGIN_DECLS
-#if __ANDROID_API__ >= 21
-speed_t cfgetispeed(const struct termios*);
-speed_t cfgetospeed(const struct termios*);
-void cfmakeraw(struct termios*);
-int cfsetispeed(struct termios*, speed_t);
-int cfsetospeed(struct termios*, speed_t);
-int cfsetspeed(struct termios*, speed_t);
-int tcdrain(int);
-int tcflow(int, int);
-int tcflush(int, int);
-int tcgetattr(int, struct termios*);
-pid_t tcgetsid(int);
-int tcsendbreak(int, int);
-int tcsetattr(int, int, const struct termios*);
-#else
-#include <android/legacy_termios_inlines.h>
-#endif
+__BIONIC_LEGACY_INLINE speed_t cfgetispeed(const struct termios*);
+__BIONIC_LEGACY_INLINE speed_t cfgetospeed(const struct termios*);
+__BIONIC_LEGACY_INLINE void cfmakeraw(struct termios*);
+__BIONIC_LEGACY_INLINE int cfsetispeed(struct termios*, speed_t);
+__BIONIC_LEGACY_INLINE int cfsetospeed(struct termios*, speed_t);
+__BIONIC_LEGACY_INLINE int cfsetspeed(struct termios*, speed_t);
+__BIONIC_LEGACY_INLINE int tcdrain(int);
+__BIONIC_LEGACY_INLINE int tcflow(int, int);
+__BIONIC_LEGACY_INLINE int tcflush(int, int);
+__BIONIC_LEGACY_INLINE int tcgetattr(int, struct termios*);
+__BIONIC_LEGACY_INLINE pid_t tcgetsid(int);
+__BIONIC_LEGACY_INLINE int tcsendbreak(int, int);
+__BIONIC_LEGACY_INLINE int tcsetattr(int, int, const struct termios*);
__END_DECLS
+#include <android/legacy_termios_inlines.h>
+
#endif /* _TERMIOS_H_ */
diff --git a/libc/include/sys/_errdefs.h b/libc/private/bionic_errdefs.h
similarity index 100%
rename from libc/include/sys/_errdefs.h
rename to libc/private/bionic_errdefs.h
diff --git a/libc/include/sys/_sigdefs.h b/libc/private/bionic_sigdefs.h
similarity index 100%
rename from libc/include/sys/_sigdefs.h
rename to libc/private/bionic_sigdefs.h