diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-09-07 23:13:55 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-09-07 23:13:55 -0400 |
commit | c1a9658bd19245ff0fb52d3da567815d822fb622 (patch) | |
tree | 36af789c4a0ebc8a1af3c49eab9edb34f5dbf869 /include | |
parent | 9f65796c35bd93a1de42752ce8af901acfe4b1a4 (diff) | |
download | musl-c1a9658bd19245ff0fb52d3da567815d822fb622.tar.gz musl-c1a9658bd19245ff0fb52d3da567815d822fb622.tar.xz musl-c1a9658bd19245ff0fb52d3da567815d822fb622.zip |
default features: make musl usable without feature test macros
the old behavior of exposing nothing except plain ISO C can be obtained by defining __STRICT_ANSI__ or using a compiler option (such as -std=c99) that predefines it. the new default featureset is POSIX with XSI plus _BSD_SOURCE. any explicit feature test macros will inhibit the default. installation docs have also been updated to reflect this change.
Diffstat (limited to 'include')
47 files changed, 100 insertions, 116 deletions
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 |