Make the legacy inline headers compile standalone.
It's useful to have the legacy inlines compile by themselves, both to
make header unification easier, and to ensure that the inline versions
match the regular declarations. Notably, this wasn't true for
sigismember, which took a const sigset_t* in the regular header, and
sigset_t* in the inline version.
Bug: http://b/28178111
Change-Id: Id8a3b7dcb1bfa61eed93c9fb50d3192744f8bef5
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_ */