summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 205cc41)
raw | patch | inline | side by side (parent: 205cc41)
author | Elliott Hughes <enh@google.com> | |
Mon, 18 Aug 2014 23:04:03 +0000 (16:04 -0700) | ||
committer | Elliott Hughes <enh@google.com> | |
Mon, 18 Aug 2014 23:04:03 +0000 (16:04 -0700) |
<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
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/bionic/clone.cpp b/libc/bionic/clone.cpp
index 0a0fdd526d26e5d0a7d47aa7b26d6cc3795eaf59..9b5c9e7ae887606b0b17bd0ea295506de0102c4e 100644 (file)
--- a/libc/bionic/clone.cpp
+++ b/libc/bionic/clone.cpp
* SUCH DAMAGE.
*/
-#define __GNU_SOURCE 1
+#define _GNU_SOURCE 1
#include <sched.h>
#include <stdlib.h>
#include <stdarg.h>
index 343c84d2b66ddbdee902c426f11e5885ad0444d7..057d1de45e3c3fc98b18f7c42971c1c06f2bd809 100644 (file)
--- a/libc/include/features.h
+++ b/libc/include/features.h
* 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 e43b6ccaa95819a17960379d14aa87ae1228f889..76249506e6f4290d4b9ec0e561a3435001ba2a94 100644 (file)
--- a/libc/include/sched.h
+++ b/libc/include/sched.h
#ifndef _SCHED_H_
#define _SCHED_H_
+#include <features.h>
#include <sys/cdefs.h>
#include <sys/time.h>
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);
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 781fc443542857faf3030e53e7269562af231202..c3e655e095f6f271185cbad087e065863b8e7c66 100644 (file)
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
#ifndef _UNISTD_H_
#define _UNISTD_H_
+#include <features.h>
#include <stddef.h>
#include <sys/cdefs.h>
#include <sys/types.h>
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 *);
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, ...);
diff --git a/libm/include/math.h b/libm/include/math.h
index 4faec333f98d48548ecb534846217e52ccb40fe3..a808d8d41f78c61f1e04f4d367be7f8c5ead7713 100644 (file)
--- a/libm/include/math.h
+++ b/libm/include/math.h
#ifndef _MATH_H_
#define _MATH_H_
+#include <features.h>
#include <sys/cdefs.h>
#include <limits.h>
#endif /* __ISO_C_VISIBLE >= 1999 */
-#if defined(_GNU_SOURCE)
+#if defined(__USE_GNU)
void sincos(double, double*, double*);
void sincosf(float, float*, float*);
void sincosl(long double, long double*, long double*);
-#endif /* _GNU_SOURCE */
+#endif /* __USE_GNU */
#pragma GCC visibility pop
__END_DECLS
diff --git a/libm/sincos.c b/libm/sincos.c
index ad755490f22ab0ee5dc689af666b53b9bf1d9ee7..a5608cfedb6b9bd4ce85b0bb723bcda2367894a9 100644 (file)
--- a/libm/sincos.c
+++ b/libm/sincos.c
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
*/
+
#define _GNU_SOURCE 1
#include <math.h>
index 0fab2c20f6a1719652b82204b496ca5cd4ffac5d..f2e30dea9f01211aeee3d56e7431bc156bb5b37f 100644 (file)
* limitations under the License.
*/
+#define _GNU_SOURCE 1
+
#include <math.h>
#include <gtest/gtest.h>