~ chicken-core (chicken-5) 3d436c5caf522c8a912e376f98fef7288d4f20f6


commit 3d436c5caf522c8a912e376f98fef7288d4f20f6
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Tue Jan 17 21:47:11 2017 +0100
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Wed Jan 18 10:35:04 2017 +1300

    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
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/Makefile.aix b/Makefile.aix
index 2d203ed1..5d0b73ef 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 d0c677ea..792fe6c8 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 b4a47d0e..6fbc2075 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 488d41b0..ba7dd4b5 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 161a31f2..7e8781b7 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 7fe7576b..154ef432 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 a0ebff49..dadfc00b 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 9f460646..fb35ac30 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 7c0bc2af..864dc424 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 f89669b1..062335b4 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 87143b75..329386df 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 e6aa4039..4c3fbb78 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 fed1a4aa..4acacee6 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"
Trap