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
diff --git a/libc/include/features.h b/libc/include/features.h
index 343c84d..057d1de 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
- */
+#if defined(_BSD_SOURCE)
+# define __USE_BSD 1
+#endif
-/* we do include a number of BSD extensions */
-#define _BSD_SOURCE 1
-
-/* 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