From c1a9658bd19245ff0fb52d3da567815d822fb622 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 7 Sep 2012 23:13:55 -0400 Subject: 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. --- include/aio.h | 7 +------ include/assert.h | 9 ++------- include/ctype.h | 2 ++ include/dirent.h | 6 +----- include/dlfcn.h | 6 +----- include/endian.h | 4 +--- include/fcntl.h | 2 ++ include/features.h | 29 ++++++++++++++++++++++++++++- include/fnmatch.h | 2 ++ include/ftw.h | 2 ++ include/glob.h | 6 +----- include/grp.h | 2 ++ include/limits.h | 2 ++ include/locale.h | 2 ++ include/math.h | 4 +--- include/net/if.h | 2 ++ include/netdb.h | 6 +----- include/netinet/tcp.h | 2 ++ include/pwd.h | 2 ++ include/sched.h | 2 ++ include/search.h | 7 +------ include/setjmp.h | 7 +------ include/signal.h | 6 +----- include/stdio.h | 6 +----- include/stdlib.h | 13 +------------ include/string.h | 6 +----- include/sys/ipc.h | 2 ++ include/sys/mman.h | 2 ++ include/sys/resource.h | 2 ++ include/sys/sem.h | 2 ++ include/sys/sendfile.h | 1 + include/sys/shm.h | 2 ++ include/sys/stat.h | 6 +----- include/sys/statfs.h | 2 ++ include/sys/statvfs.h | 6 +----- include/sys/time.h | 6 +----- include/sys/types.h | 2 ++ include/sys/uio.h | 2 ++ include/sys/utsname.h | 2 ++ include/sys/wait.h | 2 ++ include/syslog.h | 2 ++ include/termios.h | 2 ++ include/time.h | 6 +----- include/ucontext.h | 2 ++ include/unistd.h | 13 +------------ include/wchar.h | 6 +----- include/wctype.h | 2 ++ 47 files changed, 100 insertions(+), 116 deletions(-) (limited to 'include') 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 #include #include 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 -#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 + 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 #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 #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 #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 + #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 + #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 + /* 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 #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 + #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 + /* Most limits are system-specific */ #include 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 + #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 #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 + #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 #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 + #define TCP_NODELAY 1 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #include 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 + #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 + #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 #define __NEED_size_t #include 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 #include 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 #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 #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 #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 #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 + #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 + #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 + #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 + #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 #include 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 + #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 #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 + #include 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 #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 #include 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 + #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 + #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 + 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 + #include #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 + #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 + #define __NEED_pid_t #include 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 #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 + #include #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 #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 #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 + #define __NEED_wint_t #define __NEED_wctrans_t #define __NEED_wctype_t -- cgit v1.2.1