From a65deacedf177aae64a140eee43c699bcddf79ad Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 12 Oct 2015 19:55:05 +0200 Subject: some feature-test macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/slibc/features.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/slibc/features.h b/include/slibc/features.h index e6005f9..d223d76 100644 --- a/include/slibc/features.h +++ b/include/slibc/features.h @@ -40,7 +40,7 @@ /** * Is C99, or newer, used? */ -#if __STDC_VERSION__ >= 199901L +#if __STDC_VERSION__ >= 199901L || defined(_ISOC99_SOURCE) # define __C99__ #endif @@ -53,6 +53,55 @@ +/** + * _POSIX_SOURCE is implied if (_POSIX_C_SOURCE >= 1L). + */ +#if !defined(_POSIX_SOURCE) && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 1L) +# define _POSIX_SOURCE 1 +#endif +#if (!defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE <= 0)) && !defined(_POSIX_SOURCE) +# define _POSIX_C_SOURCE 1L +#endif + +/** + * _BSD_SOURCE || _SVID_SOURCE implies _POSIX_C_SOURCE = 2. + */ +#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) +# if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE < 1L) +# undef _POSIX_C_SOURCE +# endif +# if !defined(_POSIX_C_SOURCE) +# define _POSIX_C_SOURCE 2 +# endif +#endif + +/** + * _SVID_SOURCE implies _XOPEN_SOURCE + */ +#if defined(_SVID_SOURCE) && !defined(_XOPEN_SOURCE) +# define _XOPEN_SOURCE 1 +#endif + +/** + * _BSD_COMPATIBLE_SOURCE requires _BSD_SOURCE. + */ +#if defined(_BSD_COMPATIBLE_SOURCE) && !defined(_BSD_SOURCE) +# if !defined(_SLIBC_SUPPRESS_WARNINGS) +# warning "_BSD_COMPATIBLE_SOURCE is defined, but _BSD_SOURCE is undefined." +# endif +#endif + +/** + * _BSD_COMPATIBLE_SOURCE and _POSIX_COMPATIBLE_SOURCE + * are incompatible. + */ +#if defined(_BSD_COMPATIBLE_SOURCE) && defined(_POSIX_COMPATIBLE_SOURCE) +# if !defined(_SLIBC_SUPPRESS_WARNINGS) +# warning "You should not define both _BSD_COMPATIBLE_SOURCE and _POSIX_COMPATIBLE_SOURCE." +# endif +#endif + + /** * Feature-test macros that also change that * `_PORTABLE_SOURCE` and `_LIBRARY_HEADER` @@ -141,6 +190,18 @@ #endif +/** + * Functions that have a BSD-specification that is conficting + * with the POSIX-specification shall have this attribute. + */ +#if defined(_BSD_SOURCE) && !defined(_POSIX_COMPATIBLE_SOURCE) && !defined(_BSD_COMPATIBLE_SOURCE) +# define __bsd_posix_conflict \ + __warning("The BSD-version of this function is incompatible with the POSIX-version.") +#else +# define __bsd_posix_conflict /* ignore*/ +#endif + + /** * Format for the `format` GCC function attribute, * for `*printf` functions. -- cgit v1.2.3-70-g09d2