aboutsummaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-08-18 16:04:03 -0700
committerElliott Hughes <enh@google.com>2014-08-18 16:04:03 -0700
commit5f5cc45cf0e027f6ca503dc229a4890fc7164b66 (patch)
tree36bebf629f486d24d8287e7a735662b0269044a6 /libc
parent205cc41556d44b104a21bc6839b7ea44f72df9ba (diff)
downloadandroid_bionic-5f5cc45cf0e027f6ca503dc229a4890fc7164b66.tar.gz
android_bionic-5f5cc45cf0e027f6ca503dc229a4890fc7164b66.tar.bz2
android_bionic-5f5cc45cf0e027f6ca503dc229a4890fc7164b66.zip
Fix <features.h> (_BSD_SOURCE and _GNU_SOURCE).
<features.h> is supposed to take user-settable stuff like _GNU_SOURCE and _BSD_SOURCE and turn them into __USE_GNU and __USE_BSD for use in the C library headers. Instead, bionic used to unconditionally define _BSD_SOURCE and _GNU_SOURCE, and then test _GNU_SOURCE in the header files (which makes no sense whatsoever). Bug: 14659579 Change-Id: Ice4cf21a364ea2e559071dc8329e995277d5b987
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/clone.cpp2
-rw-r--r--libc/include/features.h15
-rw-r--r--libc/include/sched.h5
-rw-r--r--libc/include/unistd.h5
4 files changed, 14 insertions, 13 deletions
diff --git a/libc/bionic/clone.cpp b/libc/bionic/clone.cpp
index 0a0fdd526..9b5c9e7ae 100644
--- a/libc/bionic/clone.cpp
+++ b/libc/bionic/clone.cpp
@@ -26,7 +26,7 @@
* SUCH DAMAGE.
*/
-#define __GNU_SOURCE 1
+#define _GNU_SOURCE 1
#include <sched.h>
#include <stdlib.h>
#include <stdarg.h>
diff --git a/libc/include/features.h b/libc/include/features.h
index 343c84d2b..057d1de45 100644
--- a/libc/include/features.h
+++ b/libc/include/features.h
@@ -25,18 +25,17 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#ifndef _FEATURES_H_
#define _FEATURES_H_
-/* certain Linux-specific programs expect a <features.h> header file
- * that defines various features macros
- */
-
-/* we do include a number of BSD extensions */
-#define _BSD_SOURCE 1
+#if defined(_BSD_SOURCE)
+# define __USE_BSD 1
+#endif
-/* we do include a number of GNU extensions */
-#define _GNU_SOURCE 1
+#if defined(_GNU_SOURCE)
+# define __USE_GNU 1
+#endif
/* C95 support */
#undef __USE_ISOC95
diff --git a/libc/include/sched.h b/libc/include/sched.h
index e43b6ccaa..76249506e 100644
--- a/libc/include/sched.h
+++ b/libc/include/sched.h
@@ -28,6 +28,7 @@
#ifndef _SCHED_H_
#define _SCHED_H_
+#include <features.h>
#include <sys/cdefs.h>
#include <sys/time.h>
@@ -52,7 +53,7 @@ extern int sched_setparam(pid_t, const struct sched_param*);
extern int sched_getparam(pid_t, struct sched_param*);
extern int sched_rr_get_interval(pid_t, struct timespec*);
-#ifdef _GNU_SOURCE
+#if defined(__USE_GNU)
extern int clone(int (*)(void*), void*, int, void*, ...);
extern int unshare(int);
@@ -146,7 +147,7 @@ extern void __sched_cpufree(cpu_set_t* set);
extern int __sched_cpucount(size_t setsize, cpu_set_t* set);
-#endif /* _GNU_SOURCE */
+#endif /* __USE_GNU */
__END_DECLS
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 781fc4435..c3e655e09 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -28,6 +28,7 @@
#ifndef _UNISTD_H_
#define _UNISTD_H_
+#include <features.h>
#include <stddef.h>
#include <sys/cdefs.h>
#include <sys/types.h>
@@ -112,7 +113,7 @@ extern int chdir(const char *);
extern int fchdir(int);
extern int rmdir(const char *);
extern int pipe(int *);
-#ifdef _GNU_SOURCE
+#if defined(__USE_GNU)
extern int pipe2(int *, int);
#endif
extern int chroot(const char *);
@@ -143,7 +144,7 @@ extern ssize_t pwrite64(int, const void *, size_t, off64_t);
extern int dup(int);
extern int dup2(int, int);
-#ifdef _GNU_SOURCE
+#if defined(__USE_GNU)
extern int dup3(int, int, int);
#endif
extern int fcntl(int, int, ...);