提交 419ae6d5 编写于 作者: R Rich Felker

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.
上级 7b5467cb
......@@ -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>
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -21,7 +21,7 @@ void if_freenameindex (struct if_nameindex *);
#ifdef _GNU_SOURCE
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#include <sys/socket.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 *);
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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 *);
......
......@@ -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 *);
......
......@@ -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
......
......@@ -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
......
......@@ -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 *);
......
......@@ -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;
......
......@@ -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 *);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册