Protect all BSD extensions with _BSD_SOURCE

* Do not define the symbols by default, as they are not in the default
libraries.
* Adjust jamfiles of all code using BSD extensions to define
_BSD_SOURCE.
* This makes Haiku slightly more compliant to standard C/POSIX.
This commit is contained in:
Adrien Destugues 2015-04-16 07:29:58 +02:00
parent e2ceb857d4
commit 091a80aeed
41 changed files with 217 additions and 7 deletions

View File

@ -36,6 +36,10 @@
#ifndef _ARPA_FTP_H_
#define _ARPA_FTP_H_
#ifdef _BSD_SOURCE
/* Definitions for FTP; see RFC-765. */
/*
@ -106,4 +110,8 @@ char *modenames[] = {"0", "Stream", "Block", "Compressed" };
#define BLK_BYTECOUNT 2 /* Bytes in this block */
#endif
#endif /* !_FTP_H_ */

View File

@ -37,6 +37,10 @@
#ifndef _ARPA_TELNET_H_
#define _ARPA_TELNET_H_
#ifdef _BSD_SOURCE
/*
* Definitions for the TELNET protocol.
*/
@ -344,4 +348,8 @@ extern char *enctype_names[];
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
#define ENCTYPE_NAME(x) enctype_names[x]
#endif
#endif /* !_TELNET_H_ */

View File

@ -37,6 +37,10 @@
#ifndef _ARPA_TFTP_H_
#define _ARPA_TFTP_H_
#ifdef _BSD_SOURCE
/*
* Trivial File Transfer Protocol (IEN-133)
*/
@ -80,4 +84,8 @@ struct tftphdr {
#define ENOUSER 7 /* no such user */
#define EOPTNEG 8 /* option negotiation failed */
#endif
#endif /* !_TFTP_H_ */

View File

@ -37,6 +37,10 @@
#ifndef _ERR_H_
#define _ERR_H_
#ifdef _BSD_SOURCE
/*
* Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two
* places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
@ -69,4 +73,8 @@ void err_set_file(void *);
void err_set_exit(void (*)(int));
__END_DECLS
#endif
#endif /* !_ERR_H_ */

View File

@ -9,6 +9,13 @@
#include_next <errno.h>
#ifdef _BSD_SOURCE
#define EDOOFUS EINVAL
#endif
#endif /* _BSD_ERRNO_H_ */

View File

@ -40,6 +40,10 @@
#ifndef _HISTEDIT_H_
#define _HISTEDIT_H_
#ifdef _BSD_SOURCE
#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
@ -225,4 +229,8 @@ int tok_str(Tokenizer *, const char *,
__END_DECLS
#endif
#endif /* _HISTEDIT_H_ */

View File

@ -6,6 +6,9 @@
#define _IFADDRS_H
#ifdef _BSD_SOURCE
#ifdef __cplusplus
extern "C" {
#endif
@ -32,4 +35,7 @@ void freeifaddrs(struct ifaddrs *ifa);
#endif
#endif
#endif

View File

@ -39,6 +39,10 @@
#ifndef _LIBUTIL_H_
#define _LIBUTIL_H_
#ifdef _BSD_SOURCE
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
@ -162,4 +166,8 @@ __END_DECLS
#define HN_GETSCALE 0x10
#define HN_AUTOSCALE 0x20
#endif
#endif /* !_LIBUTIL_H_ */

View File

@ -6,6 +6,9 @@
#define _NETINET_IN_SYSTM_H_
#ifdef _BSD_SOURCE
#include <stdint.h>
@ -14,4 +17,7 @@ typedef uint32_t n_long;
typedef uint32_t n_time;
#endif
#endif /* _NETINET_IN_SYSTM_H_ */

View File

@ -37,6 +37,10 @@
#ifndef _PATHS_H_
#define _PATHS_H_
#ifdef _BSD_SOURCE
#include <sys/cdefs.h>
/* Default search path. */
@ -136,4 +140,8 @@ __END_DECLS
#define _PATH_WALL "/rescue/wall"
#endif /* RESCUE */
#endif
#endif /* !_PATHS_H_ */

View File

@ -6,6 +6,9 @@
#define _BSD_PTY_H_
#ifdef _BSD_SOURCE
#include <sys/cdefs.h>
#include <termios.h>
@ -20,4 +23,8 @@ extern pid_t forkpty(int* master, char* name,
__END_DECLS
#endif
#endif // _BSD_PTY_H_

View File

@ -9,6 +9,9 @@
#include_next <signal.h>
#ifdef _BSD_SOURCE
#define sigmask(sig) (1 << ((sig) - 1))
@ -23,4 +26,8 @@ int sigblock(int mask);
}
#endif
#endif
#endif /* _BSD_SIGNAL_H_ */

View File

@ -9,6 +9,9 @@
#include_next <stdio.h>
#ifdef _BSD_SOURCE
#ifdef __cplusplus
extern "C" {
#endif
@ -19,4 +22,8 @@ char *fgetln(FILE *stream, size_t *_length);
}
#endif
#endif
#endif /* _BSD_STDIO_H_ */

View File

@ -9,6 +9,9 @@
#include_next <stdlib.h>
#ifdef _BSD_SOURCE
#ifdef __cplusplus
extern "C" {
#endif
@ -21,4 +24,8 @@ void setprogname(const char *programName);
}
#endif
#endif
#endif /* _BSD_STDLIB_H_ */

View File

@ -9,6 +9,9 @@
#include_next <string.h>
#ifdef _BSD_SOURCE
#ifdef __cplusplus
extern "C" {
#endif
@ -19,4 +22,8 @@ char* strsep(char** string, const char* delimiters);
}
#endif
#endif
#endif /* _BSD_STRING_H_ */

View File

@ -35,6 +35,11 @@
#ifndef _STRINGLIST_H
#define _STRINGLIST_H
#ifdef _BSD_SOURCE
#include <sys/cdefs.h>
#include <sys/types.h>
@ -54,4 +59,8 @@ void sl_free(StringList *, int);
char *sl_find(StringList *, char *);
__END_DECLS
#endif
#endif /* _STRINGLIST_H */

View File

@ -9,10 +9,17 @@
#include_next <sys/cdefs.h>
#ifdef _BSD_SOURCE
#define __FBSDID(x)
#define __unused
#define __printflike(a, b) __attribute__ ((format (__printf__, (a), (b))))
#define __printf0like(a, b)
#endif
#endif /* _BSD_SYS_CDEFS_H_ */

View File

@ -6,6 +6,10 @@
#ifndef _SYS_IOCCOM_H
#define _SYS_IOCCOM_H
#ifdef _BSD_SOURCE
/**
* @defgroup IOCTL_common sys/ioccom.h
* @brief Definitions & maros common to ioctl()
@ -77,4 +81,8 @@
/** @} */
#endif
#endif /* _SYS_IOCCOM_H */

View File

@ -26,6 +26,11 @@
#ifndef _MD4_H_
#define _MD4_H_
#ifdef _BSD_SOURCE
/* MD4 context. */
typedef struct MD4Context {
u_int32_t state[4]; /* state (ABCD) */
@ -45,4 +50,8 @@ char * MD4File(const char *, char *);
char * MD4Data(const unsigned char *, unsigned int, char *);
__END_DECLS
#endif
#endif /* _MD4_H_ */

View File

@ -28,6 +28,10 @@ documentation and/or software.
#ifndef _SYS_MD5_H_
#define _SYS_MD5_H_
#ifdef _BSD_SOURCE
#include <stdint.h>
#define MD5_BLOCK_LENGTH 64
@ -52,4 +56,9 @@ char * MD5File(const char *, char *);
char * MD5FileChunk(const char *, char *, off_t, off_t);
char * MD5Data(const unsigned char *, unsigned int, char *);
__END_DECLS
#endif
#endif /* _SYS_MD5_H_ */

View File

@ -9,6 +9,9 @@
#include_next <sys/param.h>
#ifdef _BSD_SOURCE
#ifndef _ALIGNBYTES
# define _ALIGNBYTES 7
#endif
@ -31,4 +34,8 @@
# define MAXLOGNAME 32
#endif
#endif
#endif /* _BSD_SYS_PARAM_H_ */

View File

@ -8,6 +8,10 @@
#include_next <sys/wait.h>
#ifdef _BSD_SOURCE
#include <sys/resource.h>
@ -23,4 +27,8 @@ pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
}
#endif
#endif
#endif /* _BSD_SYS_WAIT_H_ */

View File

@ -34,6 +34,10 @@
#ifndef _SYSEXITS_H_
#define _SYSEXITS_H_
#ifdef _BSD_SOURCE
/*
* SYSEXITS.H -- Exit status codes for system programs.
*
@ -113,4 +117,8 @@
#define EX__MAX 78 /* maximum listed value */
#endif
#endif /* !_SYSEXITS_H_ */

View File

@ -9,6 +9,9 @@
#include_next <time.h>
#ifdef _BSD_SOURCE
#ifdef __cplusplus
extern "C" {
#endif
@ -20,4 +23,8 @@ time_t timegm(struct tm *tm);
}
#endif
#endif
#endif /* _BSD_TIME_H_ */

View File

@ -9,6 +9,9 @@
#include_next <unistd.h>
#ifdef _BSD_SOURCE
#define L_SET SEEK_SET
#define L_INCR SEEK_CUR
#define L_XTND SEEK_END
@ -28,4 +31,8 @@ void setusershell(void);
}
#endif
#endif
#endif /* _BSD_UNISTD_H_ */

View File

@ -38,6 +38,9 @@
#define _VIS_H_
#ifdef _BSD_SOURCE
#include <sys/types.h>
@ -89,4 +92,8 @@ int strunvisx(char *, const char *, int);
int unvis(char *, int, int *, int);
__END_DECLS
#endif
#endif /* !_VIS_H_ */

View File

@ -4,7 +4,9 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UsePrivateHeaders firewire ;
UsePrivateKernelHeaders ;
DEFINES += _KERNEL=1 ;
local defines = [ FDefines _KERNEL=1 _BSD_SOURCE=1 ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;
KernelAddon firewire :
util.c

View File

@ -4,7 +4,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UsePrivateHeaders firewire ;
UsePrivateKernelHeaders ;
SubDirCcFlags [ FDefines _KERNEL=1 ] ;
SubDirCcFlags [ FDefines _KERNEL=1 _BSD_SOURCE=1 ] ;
KernelAddon fw_raw :
fw_raw.c

View File

@ -5,6 +5,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UsePrivateHeaders firewire ;
UsePrivateHeaders media ;
UsePrivateHeaders shared ;
SubDirC++Flags [ FDefines _BSD_SOURCE=1 ] ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {

View File

@ -11,6 +11,8 @@ UsePrivateSystemHeaders ;
LINKFLAGS += -Wl,--exclude-libs,ALL ;
SubDirC++Flags [ FDefines _BSD_SOURCE=1 ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) arch ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) arch x86 ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) arch x86_64 ] ;

View File

@ -2,6 +2,7 @@ SubDir HAIKU_TOP src bin fwcontrol ;
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UsePrivateHeaders firewire ;
SubDirCcFlags [ FDefines _BSD_SOURCE=1 ] ;
BinCommand fwcontrol :
eui64.c

View File

@ -9,6 +9,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
}
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
SubDirCcFlags [ FDefines _BSD_SOURCE=1 ] ;
BinCommand ftp :
cmds.c

View File

@ -10,6 +10,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UseHeaders $(SUBDIR) : true ;
SubDirCcFlags [ FDefines _BSD_SOURCE=1 ] ;
BinCommand ftpd :
ftpd.c

View File

@ -4,7 +4,8 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UseHeaders [ FDirName $(SUBDIR) ] : true ;
UseHeaders [ FDirName $(SUBDIR) libpcap ] : true ;
local defines = [ FDefines HAVE_CONFIG_H=1 _U_=\"__attribute__((unused))\" INET6=1 HAVE_SOCKADDR_STORAGE=1 ] ;
local defines = [ FDefines HAVE_CONFIG_H=1 _U_=\"__attribute__((unused))\"
INET6=1 HAVE_SOCKADDR_STORAGE=1 _BSD_SOURCE=1 ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;

View File

@ -6,7 +6,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) src libs libtelnet ] : false ;
UseBuildFeatureHeaders ncurses ;
local defines = [ FDefines USE_TERMIO=1 OLD_ENVIRON=1 ENV_HACK=1 ] ;
local defines = [ FDefines USE_TERMIO=1 OLD_ENVIRON=1 ENV_HACK=1 _BSD_SOURCE=1 ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;

View File

@ -5,7 +5,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs libtelnet ] : false ;
local defines = [ FDefines USE_TERMIO=1 ] ;
local defines = [ FDefines USE_TERMIO=1 _BSD_SOURCE=1 ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;

View File

@ -9,6 +9,8 @@ UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) headers os add-ons network_settings ]
: true ;
SubDirC++Flags [ FDefines _BSD_SOURCE=1 ] ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {
on $(architectureObject) {

View File

@ -4,6 +4,8 @@ SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
SubDirC++Flags [ FDefines _BSD_SOURCE=1 ] ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {
on $(architectureObject) {

View File

@ -5,7 +5,7 @@ SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
UseBuildFeatureHeaders ncurses ;
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
local defines = [ FDefines SCCSID=0 ] ;
local defines = [ FDefines SCCSID=0 _BSD_SOURCE=1 ] ;
SubDirCcFlags $(defines) ;
local sources =

View File

@ -3,6 +3,7 @@ SubDir HAIKU_TOP src libs libtelnet ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
SubDirCcFlags [ FDefines _BSD_SOURCE=1 ] ;
StaticLibrary libtelnet.a :
auth.c

View File

@ -4,7 +4,7 @@ SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
local defines = [ FDefines SCCSID=0 ] ;
local defines = [ FDefines SCCSID=0 _BSD_SOURCE=1 ] ;
SubDirCcFlags $(defines) ;
StaticLibrary libutil.a :