From 5a50aed32ab80022a592091af011f6f0429d269a Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Fri, 21 Jun 2019 19:18:18 +0000
Subject: [Darwin, fixincludes] Fix Darwin9/10 math.h issues.

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
and Darwin10.  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.

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.

From-SVN: r272563
---
 fixincludes/inclhack.def | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

(limited to 'fixincludes/inclhack.def')

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 = {
-- 
cgit v1.1

