Add a features.h to auto enable _DEFAULT_SOURCE

Unless __STRICT_ANSI__ is defined (as it is when running the compiler in
--std=c89 or --std=c99, but not when running it without any specific
args), we can enable these by default and behave like most other
systems. I don't know why no one has done this yet despite suggesting it
multiple times and people prefer to #define _BSD_SOURCE manually
everywhere.

Remove all places in our Jamfiles and sources where it had been defined.
_DEFAULT_SOURCE is now enabled by default for all sources of Haiku, since we
let the compiler use GNU extensions (no strict C standard specified on
command line)

Use _DEFAULT_SOURCE as the define name to match current versions of
glibc. Enable it if _BSD_SOURCE is #defined in compiler flags, for
backward compatibility.

Change-Id: I6db04da5f6db437723cdfba3478f5094a69d7727
Reviewed-on: https://review.haiku-os.org/c/1633
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
Adrien Destugues
2019-07-29 20:26:46 +00:00
committed by Adrien Destugues
parent 70e55f0046
commit 4950607607
52 changed files with 92 additions and 63 deletions
+4 -1
View File
@@ -37,7 +37,10 @@
#define _ARPA_FTP_H_
#ifdef _BSD_SOURCE
#include <features.h>
#ifdef _DEFAULT_SOURCE
/* Definitions for FTP; see RFC-765. */
+4 -1
View File
@@ -38,7 +38,10 @@
#define _ARPA_TELNET_H_
#ifdef _BSD_SOURCE
#include <features.h>
#ifdef _DEFAULT_SOURCE
/*
+4 -1
View File
@@ -38,7 +38,10 @@
#define _ARPA_TFTP_H_
#ifdef _BSD_SOURCE
#include <features.h>
#ifdef _DEFAULT_SOURCE
/*
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <endian.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <config/HaikuConfig.h>
#include <support/ByteOrder.h>
+2 -1
View File
@@ -37,8 +37,9 @@
#ifndef _ERR_H_
#define _ERR_H_
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
/*
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <errno.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#define EDOOFUS EINVAL
+15
View File
@@ -0,0 +1,15 @@
/*
* Copyright 2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FEATURES_H
#define _FEATURES_H
#if defined(_BSD_SOURCE) \
|| (!defined(__STRICT_ANSI__) && !defined(_POSIX_C_SOURCE))
#define _DEFAULT_SOURCE
#endif
#endif // _FEATURES_H
+2 -1
View File
@@ -5,8 +5,9 @@
#ifndef _IFADDRS_H
#define _IFADDRS_H
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#ifdef __cplusplus
+2 -1
View File
@@ -39,8 +39,9 @@
#ifndef _LIBUTIL_H_
#define _LIBUTIL_H_
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <stdint.h>
+4 -1
View File
@@ -6,7 +6,10 @@
#define _NETINET_IN_SYSTM_H_
#ifdef _BSD_SOURCE
#include <features.h>
#ifdef _DEFAULT_SOURCE
#include <stdint.h>
+3 -2
View File
@@ -37,8 +37,9 @@
#ifndef _PATHS_H_
#define _PATHS_H_
#include <features.h>
#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#if defined(_DEFAULT_SOURCE) || defined(_GNU_SOURCE)
#include <sys/cdefs.h>
@@ -141,7 +142,7 @@ __END_DECLS
#endif /* RESCUE */
#endif /* _BSD_SOURCE || _GNU_SOURCE */
#endif /* _DEFAULT_SOURCE || _GNU_SOURCE */
#endif /* !_PATHS_H_ */
+2 -1
View File
@@ -5,8 +5,9 @@
#ifndef _BSD_PTY_H_
#define _BSD_PTY_H_
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <sys/cdefs.h>
+3 -1
View File
@@ -23,7 +23,9 @@
#ifndef _READPASSPHRASE_H_
#define _READPASSPHRASE_H_
#ifdef _BSD_SOURCE
#include <features.h>
#ifdef _DEFAULT_SOURCE
#define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */
#define RPP_ECHO_ON 0x01 /* Leave echo on. */
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <signal.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#define sigmask(sig) (1 << ((sig) - 1))
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <stdio.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#ifdef __cplusplus
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <stdlib.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#ifdef __cplusplus
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <string.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#ifdef __cplusplus
+2 -1
View File
@@ -36,8 +36,9 @@
#ifndef _STRINGLIST_H
#define _STRINGLIST_H
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <sys/cdefs.h>
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <sys/cdefs.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#define __FBSDID(x)
+2 -1
View File
@@ -6,8 +6,9 @@
#ifndef _SYS_IOCCOM_H
#define _SYS_IOCCOM_H
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
/**
+1 -1
View File
@@ -44,7 +44,7 @@
#define _SYS_LINK_ELF_H_
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <os/kernel/elf.h>
+2 -1
View File
@@ -27,8 +27,9 @@
#ifndef _MD4_H_
#define _MD4_H_
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
/* MD4 context. */
+2 -1
View File
@@ -28,8 +28,9 @@ documentation and/or software.
#ifndef _SYS_MD5_H_
#define _SYS_MD5_H_
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <stdint.h>
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <sys/param.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#ifndef _ALIGNBYTES
+3 -2
View File
@@ -33,8 +33,9 @@
#ifndef _SYS_QUEUE_H_
#define _SYS_QUEUE_H_
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <sys/cdefs.h>
@@ -619,6 +620,6 @@ void remque(void *a);
#endif /* _KERNEL */
#endif /* _BSD_SOURCE */
#endif /* _DEFAULT_SOURCE */
#endif /* !_SYS_QUEUE_H_ */
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <sys/time.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#ifdef __cplusplus
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <sys/wait.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <sys/resource.h>
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <time.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#ifdef __cplusplus
+2 -1
View File
@@ -7,9 +7,10 @@
#include_next <unistd.h>
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#define L_SET SEEK_SET
+2 -1
View File
@@ -35,8 +35,9 @@
#ifndef _VIS_H_
#define _VIS_H_
#include <features.h>
#ifdef _BSD_SOURCE
#ifdef _DEFAULT_SOURCE
#include <sys/types.h>