diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-05-22 21:52:08 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-05-22 21:52:08 -0400 |
commit | 419ae6d5c95629d3ebaff6f1880d52cb027ba924 (patch) | |
tree | 9e38522b2d54cdaa3c282f3effb3daac06509edc | |
parent | 7b5467cbae266d9cf91404a13c9b6b6e1d9b8204 (diff) | |
download | musl-419ae6d5c95629d3ebaff6f1880d52cb027ba924.tar.gz musl-419ae6d5c95629d3ebaff6f1880d52cb027ba924.tar.bz2 musl-419ae6d5c95629d3ebaff6f1880d52cb027ba924.tar.xz musl-419ae6d5c95629d3ebaff6f1880d52cb027ba924.zip |
support _BSD_SOURCE feature test macro
patch by Isaac Dunham. matched closely (maybe not exact) to glibc's
idea of what _BSD_SOURCE should make visible.
-rw-r--r-- | include/ctype.h | 3 | ||||
-rw-r--r-- | include/dirent.h | 2 | ||||
-rw-r--r-- | include/fcntl.h | 14 | ||||
-rw-r--r-- | include/grp.h | 2 | ||||
-rw-r--r-- | include/math.h | 10 | ||||
-rw-r--r-- | include/net/if.h | 2 | ||||
-rw-r--r-- | include/netdb.h | 4 | ||||
-rw-r--r-- | include/netinet/tcp.h | 17 | ||||
-rw-r--r-- | include/setjmp.h | 6 | ||||
-rw-r--r-- | include/signal.h | 12 | ||||
-rw-r--r-- | include/stdio.h | 11 | ||||
-rw-r--r-- | include/stdlib.h | 22 | ||||
-rw-r--r-- | include/string.h | 17 | ||||
-rw-r--r-- | include/sys/mman.h | 3 | ||||
-rw-r--r-- | include/sys/stat.h | 2 | ||||
-rw-r--r-- | include/sys/time.h | 5 | ||||
-rw-r--r-- | include/sys/types.h | 2 | ||||
-rw-r--r-- | include/sys/wait.h | 2 | ||||
-rw-r--r-- | include/syslog.h | 3 | ||||
-rw-r--r-- | include/termios.h | 2 | ||||
-rw-r--r-- | include/time.h | 6 | ||||
-rw-r--r-- | include/unistd.h | 20 |
22 files changed, 126 insertions, 41 deletions
diff --git a/include/ctype.h b/include/ctype.h index a85e907e..8ceaa9f9 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -30,7 +30,8 @@ int toupper(int); #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #define __NEED_locale_t #include <bits/alltypes.h> diff --git a/include/dirent.h b/include/dirent.h index d0a6b44e..81623562 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -36,7 +36,7 @@ int dirfd(DIR *); int alphasort(const struct dirent **, const struct dirent **); int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)); -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define DT_UNKNOWN 0 #define DT_FIFO 1 #define DT_CHR 2 diff --git a/include/fcntl.h b/include/fcntl.h index 63f1bebc..f826a5e4 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -80,12 +80,24 @@ int posix_fallocate(int, off_t, off_t); #define S_IRWXO 0007 #endif -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define FAPPEND O_APPEND #define FFSYNC O_FSYNC #define FASYNC O_ASYNC #define FNONBLOCK O_NONBLOCK #define FNDELAY O_NDELAY + +#ifndef F_OK +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_ULOCK 0 +#define F_LOCK 1 +#define F_TLOCK 2 +#define F_TEST 3 +int lockf(int, int, off_t); +#endif #endif #ifdef _LARGEFILE64_SOURCE diff --git a/include/grp.h b/include/grp.h index 51851851..0a55c62b 100644 --- a/include/grp.h +++ b/include/grp.h @@ -28,7 +28,7 @@ struct group *getgrent(void); void endgrent(void); void setgrent(void); -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) int getgrouplist(const char *, gid_t, gid_t *, int *); int setgroups(size_t, const gid_t *); int initgroups(const char *, gid_t); diff --git a/include/math.h b/include/math.h index 61738e6a..d7326483 100644 --- a/include/math.h +++ b/include/math.h @@ -330,8 +330,7 @@ double trunc(double); float truncf(float); long double truncl(long double); -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) -#define MAXFLOAT 3.40282347e+38F +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define M_E 2.7182818284590452354 /* e */ #define M_LOG2E 1.4426950408889634074 /* log_2 e */ #define M_LOG10E 0.43429448190325182765 /* log_10 e */ @@ -345,7 +344,13 @@ long double truncl(long double); #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#endif +#if defined(_XOPEN_SOURCE) +#define MAXFLOAT 3.40282347e+38F +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) extern int signgam; double j0(double); @@ -358,6 +363,7 @@ double yn(int, double); #endif #ifdef _GNU_SOURCE +#define HUGE 3.40282347e+38F double scalb(double, double); float scalbf(float, float); long double scalbl(long double, long double); diff --git a/include/net/if.h b/include/net/if.h index 00c763a4..e862c7c7 100644 --- a/include/net/if.h +++ b/include/net/if.h @@ -21,7 +21,7 @@ void if_freenameindex (struct if_nameindex *); -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #include <sys/socket.h> diff --git a/include/netdb.h b/include/netdb.h index 33b7a0ab..82c78dc8 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -5,7 +5,7 @@ extern "C" { #endif -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define __NEED_size_t #endif @@ -118,7 +118,7 @@ struct protoent *getprotoent (void); struct protoent *getprotobyname (const char *); struct protoent *getprotobynumber (int); -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) const char *hstrerror(int); struct hostent *gethostbyname (const char *); int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *); diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h index c8a1a4bc..797ce688 100644 --- a/include/netinet/tcp.h +++ b/include/netinet/tcp.h @@ -2,5 +2,22 @@ #define _NETINET_TCP_H #define TCP_NODELAY 1 +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#include <sys/types.h> +#include <sys/socket.h> +#define TCP_MAXSEG 2 +#define TCP_CORK 3 +#define TCP_KEEPIDLE 4 +#define TCP_KEEPINTVL 5 +#define TCP_KEEPCNT 6 +#define TCP_SYNCNT 7 +#define TCP_LINGER2 8 +#define TCP_DEFER_ACCEPT 9 +#define TCP_WINDOW_CLAMP 10 +#define TCP_INFO 11 +#define TCP_QUICKACK 12 +#define TCP_CONGESTION 13 +#define TCP_MD5SIG 14 +#endif #endif diff --git a/include/setjmp.h b/include/setjmp.h index b024c44e..88fb9508 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -9,7 +9,8 @@ extern "C" { #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) typedef unsigned long sigjmp_buf[(128+sizeof(jmp_buf))/sizeof(long)]; #ifdef _GNU_SOURCE #define jmp_buf sigjmp_buf @@ -19,7 +20,8 @@ void siglongjmp (sigjmp_buf, int); #endif -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) int _setjmp (jmp_buf); void _longjmp (jmp_buf, int); #endif diff --git a/include/signal.h b/include/signal.h index 38f369b1..616801b9 100644 --- a/include/signal.h +++ b/include/signal.h @@ -6,7 +6,8 @@ extern "C" { #endif #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #ifdef _GNU_SOURCE #define __siginfo siginfo @@ -204,9 +205,16 @@ void (*sigset(int, void (*)(int)))(int); #define SIGSTKSZ 8192 #endif +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +void (*bsd_signal(int, void (*)(int)))(int); +#endif + +#ifdef _BSD_SOURCE +typedef void (*sig_t)(int); +#endif + #ifdef _GNU_SOURCE typedef void (*sighandler_t)(int); -void (*bsd_signal(int, void (*)(int)))(int); int sigisemptyset(const sigset_t *); #define SA_NOMASK SA_NODEFER #define SA_ONESHOT SA_RESETHAND diff --git a/include/stdio.h b/include/stdio.h index 355f4259..e4740eb9 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -10,7 +10,8 @@ extern "C" { #define __NEED_size_t #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #define __NEED_ssize_t #define __NEED_off_t #endif @@ -120,7 +121,8 @@ char *tmpnam(char *); FILE *tmpfile(void); #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) FILE *fmemopen(void *, size_t, const char *); FILE *open_memstream(char **, size_t *); FILE *fdopen(int, const char *); @@ -146,12 +148,13 @@ char *ctermid(char *); #endif -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #define P_tmpdir "/tmp" char *tempnam(const char *, const char *); #endif -#if defined(_GNU_SOURCE) +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define L_cuserid 20 char *cuserid(char *); #undef off64_t diff --git a/include/stdlib.h b/include/stdlib.h index 11331d95..644325e6 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -78,7 +78,8 @@ size_t wcstombs (char *, const wchar_t *, size_t); #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #ifndef WEXITSTATUS #define WEXITSTATUS(s) (((s) & 0xff00) >> 8) @@ -102,20 +103,24 @@ int rand_r (unsigned *); #endif +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +char *realpath (const char *, char *); +long int random (void); +void srandom (unsigned int); +char *initstate (unsigned int, char *, size_t); +char *setstate (char *); +#endif + #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) int putenv (char *); int posix_openpt (int); int grantpt (int); int unlockpt (int); char *ptsname (int); -char *realpath (const char *, char *); char *l64a (long); long a64l (const char *); void setkey (const char *); -long int random (void); -void srandom (unsigned int); -char *initstate (unsigned int, char *, size_t); -char *setstate (char *); double drand48 (void); double erand48 (unsigned short [3]); long int lrand48 (void); @@ -127,11 +132,14 @@ unsigned short *seed48 (unsigned short [3]); void lcong48 (unsigned short [7]); #endif -#if defined(_GNU_SOURCE) +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #include <alloca.h> char *mktemp (char *); void *valloc (size_t); void *memalign(size_t, size_t); +#endif + +#ifdef _GNU_SOURCE int clearenv(void); int ptsname_r(int, char *, size_t); char *ecvt(double, int, int *, int *); diff --git a/include/string.h b/include/string.h index 8cf0ee9d..24cb1ca3 100644 --- a/include/string.h +++ b/include/string.h @@ -14,7 +14,8 @@ extern "C" { #define __NEED_size_t #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #define __NEED_locale_t #endif @@ -51,9 +52,13 @@ size_t strlen (const char *); char *strerror (int); +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +#include <strings.h> +#endif #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) char *strtok_r (char *, const char *, char **); int strerror_r (int, char *, size_t); char *stpcpy(char *, const char *); @@ -67,7 +72,8 @@ int strcoll_l (const char *, const char *, locale_t); size_t strxfrm_l (char *, const char *, size_t, locale_t); #endif -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) void *memccpy (void *, const void *, int, size_t); #endif @@ -77,9 +83,10 @@ size_t strlcpy (char *, const char *, size_t); #endif #ifdef _GNU_SOURCE +#define strdupa(x) strcpy(alloca(strlen(x)+1),x) int strverscmp (const char *, const char *); -int strcasecmp (const char *, const char *); -int strncasecmp (const char *, const char *, size_t); +int strcasecmp_l (const char *, const char *, locale_t); +int strncasecmp_l (const char *, const char *, size_t, locale_t); char *strchrnul(const char *, int); char *strcasestr(const char *, const char *); char *strsep(char **, const char *); diff --git a/include/sys/mman.h b/include/sys/mman.h index a48c2b4f..a45f11d6 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -27,6 +27,9 @@ int munlockall (void); #ifdef _GNU_SOURCE void *mremap (void *, size_t, size_t, int, ...); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) int madvise (void *, size_t, int); #endif diff --git a/include/sys/stat.h b/include/sys/stat.h index 5d50ae76..14a5424b 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -90,7 +90,7 @@ int utimensat(int, const char *, const struct timespec [2], int); int lchmod(const char *, mode_t); #endif -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define S_IREAD S_IRUSR #define S_IWRITE S_IWUSR #define S_IEXEC S_IXUSR diff --git a/include/sys/time.h b/include/sys/time.h index fa989442..144dd230 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -8,7 +8,8 @@ extern "C" { int gettimeofday (struct timeval *, void *); -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #define ITIMER_REAL 0 #define ITIMER_VIRTUAL 1 @@ -26,7 +27,7 @@ int utimes (const char *, const struct timeval [2]); #endif -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) int futimes(int, const struct timeval [2]); int lutimes(const char *, const struct timeval [2]); int settimeofday (const struct timeval *, void *); diff --git a/include/sys/types.h b/include/sys/types.h index b9b65f6a..4b1e3747 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -58,7 +58,7 @@ typedef __uint16_t u_int16_t; typedef __uint32_t u_int32_t; typedef __uint64_t u_int64_t; -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) typedef char *caddr_t; typedef unsigned char u_char; typedef unsigned short u_short, ushort; diff --git a/include/sys/wait.h b/include/sys/wait.h index e73594ae..5e3012ba 100644 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -17,7 +17,7 @@ pid_t wait (int *); int waitid (idtype_t, id_t, siginfo_t *, int); pid_t waitpid (pid_t, int *, int ); -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #include <sys/resource.h> pid_t wait3 (int *, int, struct rusage *); pid_t wait4 (pid_t, int *, int, struct rusage *); diff --git a/include/syslog.h b/include/syslog.h index e0d86c0d..278945f9 100644 --- a/include/syslog.h +++ b/include/syslog.h @@ -59,7 +59,8 @@ void openlog (const char *, int, int); int setlogmask (int); void syslog (int, const char *, ...); -#if defined(_GNU_SOURCE) +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define _PATH_LOG "/dev/log" #define __NEED_va_list #include <bits/alltypes.h> void vsyslog (int, const char *, va_list); diff --git a/include/termios.h b/include/termios.h index 76908839..1041759b 100644 --- a/include/termios.h +++ b/include/termios.h @@ -32,7 +32,7 @@ int tcflow (int, int); pid_t tcgetsid (int); -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) void cfmakeraw(struct termios *); int cfsetspeed(struct termios *, speed_t); #endif diff --git a/include/time.h b/include/time.h index 98d0111f..067b5196 100644 --- a/include/time.h +++ b/include/time.h @@ -18,7 +18,8 @@ extern "C" { #define __NEED_clock_t #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) #define __NEED_struct_timespec #define __NEED_clockid_t #define __NEED_timer_t @@ -57,7 +58,8 @@ char *ctime (const time_t *); #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) size_t strftime_l (char *, size_t, const char *, const struct tm *, locale_t); diff --git a/include/unistd.h b/include/unistd.h index b1a84d7e..01122761 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -16,6 +16,12 @@ extern "C" { #define SEEK_CUR 1 #define SEEK_END 2 +#if defined(_BSD_SOURCE) && !defined(L_SET) +#define L_SET SEEK_SET +#define L_INCR SEEK_CUR +#define L_XTND SEEK_END +#endif + #undef NULL #ifdef __cplusplus #define NULL 0 @@ -63,10 +69,13 @@ int rmdir(const char *); int truncate(const char *, off_t); int ftruncate(int, off_t); +#ifndef F_OK #define F_OK 0 #define R_OK 4 #define W_OK 2 #define X_OK 1 +#endif + int access(const char *, int); int faccessat(int, const char *, int, int); @@ -127,10 +136,12 @@ long fpathconf(int, int); long sysconf(int); size_t confstr(int, char *, size_t); +#ifndef F_ULOCK #define F_ULOCK 0 #define F_LOCK 1 #define F_TLOCK 2 #define F_TEST 3 +#endif #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) int lockf(int, int, off_t); @@ -143,10 +154,9 @@ int nice(int); void sync(void); #endif -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) int brk(void *); void *sbrk(intptr_t); -pid_t forkall(void); pid_t vfork(void); int vhangup(void); int chroot(const char *); @@ -155,6 +165,11 @@ int sethostname(const char *, size_t); int usleep(unsigned); unsigned ualarm(unsigned, unsigned); int setgroups(size_t, const gid_t []); +char *getpass(const char *); +#endif + +#ifdef _GNU_SOURCE +pid_t forkall(void); int setresuid(uid_t, uid_t, uid_t); int setresgid(gid_t, gid_t, gid_t); int getresuid(uid_t *, uid_t *, uid_t *); @@ -166,7 +181,6 @@ int getdtablesize(void); void setusershell(void); void endusershell(void); char *getusershell(void); -char *getpass(const char *); #endif #ifdef _LARGEFILE64_SOURCE |