about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--INSTALL15
-rw-r--r--include/aio.h7
-rw-r--r--include/assert.h9
-rw-r--r--include/ctype.h2
-rw-r--r--include/dirent.h6
-rw-r--r--include/dlfcn.h6
-rw-r--r--include/endian.h4
-rw-r--r--include/fcntl.h2
-rw-r--r--include/features.h29
-rw-r--r--include/fnmatch.h2
-rw-r--r--include/ftw.h2
-rw-r--r--include/glob.h6
-rw-r--r--include/grp.h2
-rw-r--r--include/limits.h2
-rw-r--r--include/locale.h2
-rw-r--r--include/math.h4
-rw-r--r--include/net/if.h2
-rw-r--r--include/netdb.h6
-rw-r--r--include/netinet/tcp.h2
-rw-r--r--include/pwd.h2
-rw-r--r--include/sched.h2
-rw-r--r--include/search.h7
-rw-r--r--include/setjmp.h7
-rw-r--r--include/signal.h6
-rw-r--r--include/stdio.h6
-rw-r--r--include/stdlib.h13
-rw-r--r--include/string.h6
-rw-r--r--include/sys/ipc.h2
-rw-r--r--include/sys/mman.h2
-rw-r--r--include/sys/resource.h2
-rw-r--r--include/sys/sem.h2
-rw-r--r--include/sys/sendfile.h1
-rw-r--r--include/sys/shm.h2
-rw-r--r--include/sys/stat.h6
-rw-r--r--include/sys/statfs.h2
-rw-r--r--include/sys/statvfs.h6
-rw-r--r--include/sys/time.h6
-rw-r--r--include/sys/types.h2
-rw-r--r--include/sys/uio.h2
-rw-r--r--include/sys/utsname.h2
-rw-r--r--include/sys/wait.h2
-rw-r--r--include/syslog.h2
-rw-r--r--include/termios.h2
-rw-r--r--include/time.h6
-rw-r--r--include/ucontext.h2
-rw-r--r--include/unistd.h13
-rw-r--r--include/wchar.h6
-rw-r--r--include/wctype.h2
48 files changed, 102 insertions, 129 deletions
diff --git a/INSTALL b/INSTALL
index 720c94ea..5c923ee5 100644
--- a/INSTALL
+++ b/INSTALL
@@ -76,14 +76,9 @@ musl-gcc hello.c
 ./a.out
 
 To configure autoconf-based program to compile and link against musl,
-you may wish to use:
+set the CC variable to musl-gcc when running configure, as in:
 
-CC="musl-gcc -D_GNU_SOURCE" ./configure ...
-
-Correctly-written build systems should not need -D_GNU_SOURCE as part
-of $CC, but many programs do not use feature-test macros correctly and
-simply assume the compiler will automatically give them the kitchen
-sink, so the above command is an easy workaround.
+CC=musl-gcc ./configure ...
 
 You will probably also want to use --prefix when building libraries to
 ensure that they are installed under the musl prefix and not in the
@@ -140,9 +135,3 @@ dynamic linker (program interpreter) is /lib/ld-musl-$ARCH.so.1. If
 you're using static linking only, you might instead check the symbols
 and look for anything suspicious that would indicate your old glibc or
 uClibc was used.
-
-When building programs against musl, you may still want to ensure the
-appropriate feature test macros get defined, as in:
-
-CC="gcc -D_GNU_SOURCE" ./configure ...
-
diff --git a/include/aio.h b/include/aio.h
index 3e351348..d9330ebe 100644
--- a/include/aio.h
+++ b/include/aio.h
@@ -5,12 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
+#include <features.h>
 #include <signal.h>
 #include <time.h>
 
diff --git a/include/assert.h b/include/assert.h
index 30a43d68..b0dc692c 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -1,11 +1,6 @@
-#undef assert
+#include <features.h>
 
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#undef assert
 
 #ifdef NDEBUG
 #define	assert(x) (void)0
diff --git a/include/ctype.h b/include/ctype.h
index 8ceaa9f9..8f0d1687 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 int   isalnum(int);
 int   isalpha(int);
 int   isblank(int);
diff --git a/include/dirent.h b/include/dirent.h
index b6261595..726067f6 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define __NEED_ino_t
 #define __NEED_off_t
diff --git a/include/dlfcn.h b/include/dlfcn.h
index 53871ee0..46c4e185 100644
--- a/include/dlfcn.h
+++ b/include/dlfcn.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define RTLD_LAZY   1
 #define RTLD_NOW    2
diff --git a/include/endian.h b/include/endian.h
index 528cef31..1bd44451 100644
--- a/include/endian.h
+++ b/include/endian.h
@@ -1,9 +1,7 @@
 #ifndef _ENDIAN_H
 #define _ENDIAN_H
 
-#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
-#define __inline inline
-#endif
+#include <features.h>
 
 #define __LITTLE_ENDIAN 1234
 #define __BIG_ENDIAN 4321
diff --git a/include/fcntl.h b/include/fcntl.h
index 87ecf59b..4123d01d 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_off_t
 #define __NEED_pid_t
 #define __NEED_mode_t
diff --git a/include/features.h b/include/features.h
index 851afb66..a7919f37 100644
--- a/include/features.h
+++ b/include/features.h
@@ -1 +1,28 @@
-#warning "features.h is bogus"
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
+ && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
+ && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
+#define _BSD_SOURCE 1
+#define _XOPEN_SOURCE 700
+#endif
+
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
+#define __inline inline
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#elif defined(__GNUC__)
+#define _Noreturn __attribute__((__noreturn__))
+#else
+#define _Noreturn
+#endif
+
+#endif
diff --git a/include/fnmatch.h b/include/fnmatch.h
index 0731e236..72345b8b 100644
--- a/include/fnmatch.h
+++ b/include/fnmatch.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define	FNM_PATHNAME 0x1
 #define	FNM_NOESCAPE 0x2
 #define	FNM_PERIOD   0x4
diff --git a/include/ftw.h b/include/ftw.h
index e7e8fdee..f5eb9f67 100644
--- a/include/ftw.h
+++ b/include/ftw.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 /* Normally we do not nest header includes. However useless bloat
  * like ftw may be treated as a special case. Otherwise we would
  * have to deal with duplicating all the stat.h mess. */
diff --git a/include/glob.h b/include/glob.h
index c49a2dea..9fbbaa65 100644
--- a/include/glob.h
+++ b/include/glob.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define __NEED_size_t
 
diff --git a/include/grp.h b/include/grp.h
index 0a55c62b..030d7f82 100644
--- a/include/grp.h
+++ b/include/grp.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_size_t
 #define __NEED_gid_t
 
diff --git a/include/limits.h b/include/limits.h
index e354ee73..e12618af 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -1,6 +1,8 @@
 #ifndef _LIMITS_H
 #define _LIMITS_H
 
+#include <features.h>
+
 /* Most limits are system-specific */
 
 #include <bits/limits.h>
diff --git a/include/locale.h b/include/locale.h
index 9da47269..c6cc1ec7 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #undef NULL
 #ifdef __cplusplus
 #define NULL 0
diff --git a/include/math.h b/include/math.h
index f808be62..90691401 100644
--- a/include/math.h
+++ b/include/math.h
@@ -5,9 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
-#define __inline inline
-#endif
+#include <features.h>
 
 #define __NEED_float_t
 #define __NEED_double_t
diff --git a/include/net/if.h b/include/net/if.h
index e862c7c7..5813976e 100644
--- a/include/net/if.h
+++ b/include/net/if.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define IF_NAMESIZE 16
 
 struct if_nameindex
diff --git a/include/netdb.h b/include/netdb.h
index d915d9d5..ff691e0a 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 #define __NEED_size_t
diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h
index 797ce688..5049dd91 100644
--- a/include/netinet/tcp.h
+++ b/include/netinet/tcp.h
@@ -1,6 +1,8 @@
 #ifndef _NETINET_TCP_H
 #define _NETINET_TCP_H
 
+#include <features.h>
+
 #define TCP_NODELAY 1
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 #include <sys/types.h>
diff --git a/include/pwd.h b/include/pwd.h
index 37ca5208..91fe426f 100644
--- a/include/pwd.h
+++ b/include/pwd.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_size_t
 #define __NEED_uid_t
 #define __NEED_gid_t
diff --git a/include/sched.h b/include/sched.h
index e411c92b..9062772b 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_struct_timespec
 #define __NEED_pid_t
 #define __NEED_time_t
diff --git a/include/search.h b/include/search.h
index 680eee75..ebfe08a2 100644
--- a/include/search.h
+++ b/include/search.h
@@ -5,12 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
+#include <features.h>
 
 #define __NEED_size_t
 #include <bits/alltypes.h>
diff --git a/include/setjmp.h b/include/setjmp.h
index e5877b44..abc74234 100644
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -5,12 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#include <features.h>
 
 #include <bits/setjmp.h>
 
diff --git a/include/signal.h b/include/signal.h
index e0dae192..1014440d 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
diff --git a/include/stdio.h b/include/stdio.h
index 7d3130e2..9a209376 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define __NEED_FILE
 #define __NEED_va_list
diff --git a/include/stdlib.h b/include/stdlib.h
index 86cf0171..f7c59719 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -5,18 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#include <features.h>
 
 #undef NULL
 #ifdef __cplusplus
diff --git a/include/string.h b/include/string.h
index f96f71ee..5587c880 100644
--- a/include/string.h
+++ b/include/string.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #undef NULL
 #ifdef __cplusplus
diff --git a/include/sys/ipc.h b/include/sys/ipc.h
index 8e2f7172..3f896b8c 100644
--- a/include/sys/ipc.h
+++ b/include/sys/ipc.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_uid_t
 #define __NEED_gid_t
 #define __NEED_mode_t
diff --git a/include/sys/mman.h b/include/sys/mman.h
index 5cfafbed..0fa32e6a 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_mode_t
 #define __NEED_size_t
 #define __NEED_off_t
diff --git a/include/sys/resource.h b/include/sys/resource.h
index bf59d1c8..9536ba35 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_id_t
 #define __NEED_time_t
 #define __NEED_struct_timeval
diff --git a/include/sys/sem.h b/include/sys/sem.h
index add3f1c8..cc3a3e63 100644
--- a/include/sys/sem.h
+++ b/include/sys/sem.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_size_t
 #define __NEED_pid_t
 #define __NEED_time_t
diff --git a/include/sys/sendfile.h b/include/sys/sendfile.h
index 1f2b5231..e7570d8e 100644
--- a/include/sys/sendfile.h
+++ b/include/sys/sendfile.h
@@ -5,6 +5,7 @@
 extern "C" {
 #endif
 
+#include <features.h>
 #include <unistd.h>
 
 ssize_t sendfile(int, int, off_t *, size_t);
diff --git a/include/sys/shm.h b/include/sys/shm.h
index 34117cc8..ce3029f5 100644
--- a/include/sys/shm.h
+++ b/include/sys/shm.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_time_t
 #define __NEED_size_t
 #define __NEED_pid_t
diff --git a/include/sys/stat.h b/include/sys/stat.h
index e16a9682..c63c6b8b 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -4,11 +4,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define __NEED_dev_t
 #define __NEED_ino_t
diff --git a/include/sys/statfs.h b/include/sys/statfs.h
index a5a4db9c..d8128a25 100644
--- a/include/sys/statfs.h
+++ b/include/sys/statfs.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #include <sys/statvfs.h>
 
 typedef struct {
diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h
index be41c287..e0839eca 100644
--- a/include/sys/statvfs.h
+++ b/include/sys/statvfs.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define __NEED_fsblkcnt_t
 #define __NEED_fsfilcnt_t
diff --git a/include/sys/time.h b/include/sys/time.h
index bf026432..a0ed8e0f 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -4,11 +4,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #include <sys/select.h>
 
diff --git a/include/sys/types.h b/include/sys/types.h
index f5b64879..7378b60b 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_ino_t
 #define __NEED_dev_t
 #define __NEED_uid_t
diff --git a/include/sys/uio.h b/include/sys/uio.h
index 7a75a542..624ff422 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_size_t
 #define __NEED_ssize_t
 #define __NEED_struct_iovec
diff --git a/include/sys/utsname.h b/include/sys/utsname.h
index 4c36960f..6b9ea970 100644
--- a/include/sys/utsname.h
+++ b/include/sys/utsname.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 struct utsname
 {
 	char sysname[65];
diff --git a/include/sys/wait.h b/include/sys/wait.h
index 5e3012ba..8bcac8a3 100644
--- a/include/sys/wait.h
+++ b/include/sys/wait.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #include <signal.h>
 
 #define __NEED_pid_t
diff --git a/include/syslog.h b/include/syslog.h
index c0fde112..a9468d4d 100644
--- a/include/syslog.h
+++ b/include/syslog.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define LOG_EMERG   0
 #define LOG_ALERT   1
 #define LOG_CRIT    2
diff --git a/include/termios.h b/include/termios.h
index 1041759b..d73c780d 100644
--- a/include/termios.h
+++ b/include/termios.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_pid_t
 
 #include <bits/alltypes.h>
diff --git a/include/time.h b/include/time.h
index f24789e4..2f4c74f7 100644
--- a/include/time.h
+++ b/include/time.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #undef NULL
 #ifdef __cplusplus
diff --git a/include/ucontext.h b/include/ucontext.h
index 11217616..28d04ea8 100644
--- a/include/ucontext.h
+++ b/include/ucontext.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #include <signal.h>
 
 #ifdef _GNU_SOURCE
diff --git a/include/unistd.h b/include/unistd.h
index 20ba6ccb..b5206a61 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -5,18 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#include <features.h>
 
 #define STDIN_FILENO  0
 #define STDOUT_FILENO 1
diff --git a/include/wchar.h b/include/wchar.h
index b1c6b7fa..35706c7f 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -5,11 +5,7 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define __NEED_FILE
 #define __NEED_va_list
diff --git a/include/wctype.h b/include/wctype.h
index f7be2cb0..abc7d36f 100644
--- a/include/wctype.h
+++ b/include/wctype.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <features.h>
+
 #define __NEED_wint_t
 #define __NEED_wctrans_t
 #define __NEED_wctype_t