From 2732296e67c46327e5239c4c57159be41808f0e7 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Tue, 17 Jan 2017 20:57:11 +0100 Subject: [PATCH] Do not use feature macros on FreeBSD. According to this post on the "freebsd-standards" mailing list, FreeBSD discourages using feature macros to enable features. It takes a very strict approach and disables all other features, including "native" standard BSD functions when you enable a specific standard. There is no way to re-enable the BSD functions (not even via _BSD_SOURCE). https://lists.freebsd.org/pipermail/freebsd-standards/2004-March/000474.html --- Makefile.aix | 1 + Makefile.android | 1 + Makefile.bsd | 4 ++++ Makefile.cross-linux-mingw | 1 + Makefile.cygwin | 1 + Makefile.haiku | 1 + Makefile.hurd | 1 + Makefile.ios | 1 + Makefile.linux | 1 + Makefile.macosx | 1 + Makefile.mingw | 1 + Makefile.mingw-msys | 1 + chicken.h | 29 +++++++++++++++++------------ 13 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Makefile.aix b/Makefile.aix index 3a2b6c0..9ff8e01 100644 --- a/Makefile.aix +++ b/Makefile.aix @@ -101,6 +101,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.android b/Makefile.android index 8350ca7..1ce8ac6 100644 --- a/Makefile.android +++ b/Makefile.android @@ -95,6 +95,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.bsd b/Makefile.bsd index 02b5131..646ec66 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -101,6 +101,10 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif +# Of the BSDs, only FreeBSD hates composable feature macros... + echo "#ifndef __FreeBSD__" >> $@ + echo "# define C_USE_STD_FEATURE_MACROS" >> $@ + echo "#endif" >> $@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw index 338adfd..9b52ec1 100644 --- a/Makefile.cross-linux-mingw +++ b/Makefile.cross-linux-mingw @@ -117,6 +117,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)rules.make diff --git a/Makefile.cygwin b/Makefile.cygwin index 54c589d..58fb7c8 100644 --- a/Makefile.cygwin +++ b/Makefile.cygwin @@ -115,6 +115,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.haiku b/Makefile.haiku index 3120f30..dc54aa6 100644 --- a/Makefile.haiku +++ b/Makefile.haiku @@ -95,6 +95,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.hurd b/Makefile.hurd index 696fbcb..9bb6d6f 100644 --- a/Makefile.hurd +++ b/Makefile.hurd @@ -96,6 +96,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.ios b/Makefile.ios index 54b88b3..0be2120 100644 --- a/Makefile.ios +++ b/Makefile.ios @@ -99,6 +99,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.linux b/Makefile.linux index aa0a771..f9dd52c 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -103,6 +103,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.macosx b/Makefile.macosx index 6cf4f04..91634d8 100644 --- a/Makefile.macosx +++ b/Makefile.macosx @@ -124,6 +124,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/Makefile.mingw b/Makefile.mingw index c249f45..5629fde 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -104,6 +104,7 @@ endif ifdef SYMBOLGC echo #define C_COLLECT_ALL_SYMBOLS >>$@ endif + echo #define C_USE_STD_FEATURE_MACROS >>$@ type chicken-defaults.h >>$@ include $(SRCDIR)rules.make diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys index 5b2aab9..eaeaaf6 100644 --- a/Makefile.mingw-msys +++ b/Makefile.mingw-msys @@ -109,6 +109,7 @@ endif ifdef SYMBOLGC echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ endif + echo "#define C_USE_STD_FEATURE_MACROS" >>$@ cat chicken-defaults.h >>$@ include $(SRCDIR)/rules.make diff --git a/chicken.h b/chicken.h index efb9511..5c20f63 100644 --- a/chicken.h +++ b/chicken.h @@ -47,24 +47,29 @@ # define __C99FEATURES__ #endif -#ifndef _XOPEN_SOURCE -# define _XOPEN_SOURCE 700 -#endif +/* Some OSes really dislike feature macros for standard levels */ +#ifdef C_USE_STD_FEATURE_MACROS -#ifndef _BSD_SOURCE -# define _BSD_SOURCE -#endif +# ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 700 +# endif -#ifndef _SVID_SOURCE -# define _SVID_SOURCE -#endif +# ifndef _BSD_SOURCE +# define _BSD_SOURCE +# endif + +# ifndef _SVID_SOURCE +# define _SVID_SOURCE +# endif /* * glibc >= 2.20 synonym for _BSD_SOURCE & _SVID_SOURCE. */ -#ifndef _DEFAULT_SOURCE -# define _DEFAULT_SOURCE -#endif +# ifndef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE +# endif + +#endif /* C_USE_STD_FEATURE_MACROS */ /* * N.B. This file MUST not rely upon "chicken-config.h" -- 2.1.4