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.
This commit is contained in:
Treehugger Robot 2016-04-15 20:59:36 +00:00 committed by Gerrit Code Review
commit 668fddb3ba
19 changed files with 76 additions and 57 deletions

View file

@ -31,7 +31,7 @@ static const char* __code_string_lookup(const Pair* strings, int code) {
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 @@ extern "C" __LIBC_HIDDEN__ const char* __strerror_lookup(int error_number) {
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 }
};

View file

@ -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"
};

View file

@ -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"
};

View file

@ -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 */

View file

@ -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 @@ static __inline int __attribute__((deprecated)) __set_errno(int n) {
__END_DECLS
#endif
#endif /* _ANDROID_LEGACY_ERRNO_INLINES_H */

View file

@ -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 @@ static __inline sighandler_t signal(int s, sighandler_t f) {
__END_DECLS
#endif
#endif /* _ANDROID_LEGACY_SIGNAL_INLINES_H_ */

View file

@ -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 @@ static __inline int grantpt(int __fd __attribute((unused))) {
__END_DECLS
#endif
#endif /* _ANDROID_LEGACY_STDLIB_INLINES_H_ */

View file

@ -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 @@ __ATOMIC_INLINE__ int __atomic_inc(volatile int *ptr) {
__END_DECLS
#endif
#endif /* _ANDROID_LEGACY_SYS_ATOMICS_INLINES_H_ */

View file

@ -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 @@ static __inline int mkfifo(const char *__p, mode_t __m) {
__END_DECLS
#endif
#endif /* _ANDROID_LEGACY_SYS_STAT_INLINES_H_ */

View file

@ -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 @@ static __inline void cfmakeraw(struct termios *s) {
__END_DECLS
#endif
#endif /* _ANDROID_LEGACY_TERMIOS_INLINES_H_ */

View file

@ -46,10 +46,8 @@ extern volatile int* __errno(void) __pure2;
/* 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 */

View file

@ -110,15 +110,15 @@ struct sigaction {
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 sigqueue(pid_t, int, const union sigval);
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_ */

View file

@ -76,10 +76,10 @@ extern unsigned long long strtoull(const char *, char **, int);
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 int atoi(const char*) __purefunc;
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 @@ void arc4random_buf(void*, size_t);
#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 @@ unsigned short* seed48(unsigned short[3]);
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 wcstombs(char *, const wchar_t *, size_t);
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 @@ char* realpath(const char* path, char* resolved) {
__END_DECLS
#include <android/legacy_stdlib_inlines.h>
#endif /* _STDLIB_H */

View file

@ -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_ */

View file

@ -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)

View file

@ -177,7 +177,7 @@ mode_t umask(mode_t mode) {
}
#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 mknodat(int, const char*, mode_t, dev_t);
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_ */

View file

@ -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_ */