diff mbox series

[Darwin,fixincludes,committed] Fix Darwin9/10 math.h issues.

Message ID 94034027-0A17-4B34-9CD6-A8A75B63172F@sandoe.co.uk
State New
Headers show
Series [Darwin,fixincludes,committed] Fix Darwin9/10 math.h issues. | expand

Commit Message

Iain Sandoe June 21, 2019, 7:34 p.m. UTC
Darwin has had long long functions for some considerable time and these are
exposed in Darwin8 and Darwin11+ headers.  However, for some reason it was
elected to hide them behind __STRICT_ANSI__ and __STDC_VERSION__ on
Darwin9/10.  This is a problem for g++/libstdc++ that expects the functions to
be available for strict ansi (-std=c++14, for example) and without defining 
__STDC_VERSION__.  The fix here follows the pattern used in Darwin11+
headers where the functions may be explicitly hidden by defining
__DARWIN_NO_LONG_LONG.

This fixes the tr1 testsuite fails seen on Darwin9 and 10.

tested on powerpc/i686-darwin9 and x86_64-darwin10 (plus other darwin versions
and x86_64-linux-gnu).
applied to mainline
thanks
Iain

2019-06-21  Iain Sandoe  <iain@sandoe.co.uk>

	* inclhack.def: Replace the complex test using __STRICT_ANSI__ and
	__STDC_VERSION__ with a test using __DARWIN_NO_LONG_LONG.
	Ensure that the top level math.h uses <> to wrap included headers
	rather than "".
	* fixincl.x: Regenerated.
	* tests/base/architecture/ppc/math.h: Update test to include the
	__DARWIN_NO_LONG_LONG case.
diff mbox series

Patch

diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 727f7d2..861532c 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1298,12 +1298,12 @@  fix = {
 };
 
 /*
- *  For the AAB_darwin7_9_long_double_funcs fix to be useful,
- *  you have to not use "" includes.
+ *  For the AAB_darwin7_9_long_double_funcs fix (and later fixes for long long)
+ *  to be useful, the main math.h must use <> and not "" includes.
  */
 fix = {
     hackname  = darwin_9_long_double_funcs_2;
-    mach      = "*-*-darwin7.9*";
+    mach      = "*-*-darwin*";
     files     = math.h;
     select    = '#include[ \t]+\"';
     c_fix     = format;
@@ -1311,7 +1311,7 @@  fix = {
   
     c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
   
-    test_text = '#include "architecture/ppc/math.h"';
+    test_text = '#include <architecture/ppc/math.h>';
 };
 
 /*
@@ -1355,6 +1355,22 @@  fix = {
 };
 
 /*
+ * math.h hides the long long functions that are available on the system for
+ * 10.5 and 10.6 SDKs, we expect to use them in G++ without specifying a value
+ * for __STDC_VERSION__, or switching __STRICT_ANSI__ off.
+ */
+fix = {
+  hackname  = darwin_ll_funcs_avail;
+  mach      = "*-*-darwin*";
+  files     = architecture/ppc/math.h, architecture/i386/math.h;
+  select    = "#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^1]*199901L[^_]*"
+	      "__STRICT_ANSI__[^_]*__GNUC__[^\)]*";
+  sed       = "s/#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^_]*199901L[^_]*"
+	      "__STRICT_ANSI__[^_]*__GNUC__[^\\)]*\)/#if\ !\(__DARWIN_NO_LONG_LONG\)/";
+  test_text = "#if\ !(__DARWIN_NO_LONG_LONG)";
+};
+
+/*
  *  Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
  */
 fix = {
diff --git a/fixincludes/tests/base/architecture/ppc/math.h b/fixincludes/tests/base/architecture/ppc/math.h
index 4af7808..e7db705 100644
--- a/fixincludes/tests/base/architecture/ppc/math.h
+++ b/fixincludes/tests/base/architecture/ppc/math.h
@@ -12,3 +12,8 @@ 
 #if defined( BROKEN_NAN_CHECK )
 #if 1
 #endif  /* BROKEN_NAN_CHECK */
+
+
+#if defined( DARWIN_LL_FUNCS_AVAIL_CHECK )
+#if !(__DARWIN_NO_LONG_LONG)
+#endif  /* DARWIN_LL_FUNCS_AVAIL_CHECK */