From be22cc22e4c9416667eb6cc297456c793845c238 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Tue, 17 Jan 2017 21:47: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 Conflicts: Makefile.aix Makefile.android Makefile.bsd Makefile.cross-linux-mingw Makefile.cygwin Makefile.haiku Makefile.hurd Makefile.ios Makefile.linux Makefile.macosx Makefile.mingw Makefile.mingw-msys --- 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 2d203ed..5d0b73e 100644 --- a/Makefile.aix +++ b/Makefile.aix @@ -97,6 +97,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 d0c677e..792fe6c 100644 --- a/Makefile.android +++ b/Makefile.android @@ -91,6 +91,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 b4a47d0..6fbc207 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -97,6 +97,10 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 488d41b..ba7dd4b 100644 --- a/Makefile.cross-linux-mingw +++ b/Makefile.cross-linux-mingw @@ -114,6 +114,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 161a31f..7e8781b 100644 --- a/Makefile.cygwin +++ b/Makefile.cygwin @@ -111,6 +111,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 7fe7576..154ef43 100644 --- a/Makefile.haiku +++ b/Makefile.haiku @@ -91,6 +91,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 a0ebff4..dadfc00 100644 --- a/Makefile.hurd +++ b/Makefile.hurd @@ -92,6 +92,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 9f46064..fb35ac3 100644 --- a/Makefile.ios +++ b/Makefile.ios @@ -95,6 +95,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 7c0bc2a..864dc42 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -99,6 +99,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 f89669b..062335b 100644 --- a/Makefile.macosx +++ b/Makefile.macosx @@ -120,6 +120,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 87143b7..329386d 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -101,6 +101,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo #define C_GC_HOOKS >>$@ 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 e6aa403..4c3fbb7 100644 --- a/Makefile.mingw-msys +++ b/Makefile.mingw-msys @@ -106,6 +106,7 @@ chicken-config.h: chicken-defaults.h ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ 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 fed1a4a..4acacee 100644 --- a/chicken.h +++ b/chicken.h @@ -41,24 +41,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