~ chicken-core (chicken-5) 56c907ce6b2c50924436e4e929b1fe5835dc2320


commit 56c907ce6b2c50924436e4e929b1fe5835dc2320
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Tue Jan 17 20:57:11 2017 +0100
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Wed Jan 18 10:14:08 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 3a2b6c0f..9ff8e01e 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 8350ca7a..1ce8ac69 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 02b51318..646ec660 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 338adfdb..9b52ec16 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 54c589dc..58fb7c80 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 3120f30f..dc54aa60 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 696fbcbd..9bb6d6f8 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 54b88b3c..0be21205 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 aa0a7711..f9dd52c2 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 6cf4f047..91634d8f 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 c249f45e..5629fde2 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 5b2aab90..eaeaaf6f 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 efb95117..5c20f63f 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"
Trap