This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

newlib stdint INTPTR_MAX etc fixincludes patch (was: Re: More stdint.h tests, fix c99-stdint-1.c bugs)


> Date: Wed, 8 Apr 2009 21:06:59 +0000 (UTC)
> From: "Joseph S. Myers" <joseph@codesourcery.com>

> The new c99-stdint-7.c 
> should fail for newlib until 
> <http://sourceware.org/ml/newlib/2009/msg00451.html>

(update at <http://sourceware.org/ml/newlib/2009/msg00464.html>)

> or a corresponding 
> fixincludes patch is applied;

Not exactly the same: by brief inspection of results and log,
apparently fixincludes isn't run when newlib is compiled in a
"combined tree" (with newlib a sibling subdir of gcc) so it
doesn't help at least in my usual setup.

I haven't actually *regtested* the following, besides the
fixincludes test, that is.  However, I thought better send it
than hoard it any longer; maybe it'll help someone.  Sorry for
including the generated files, but IIUC fewer people have
autogen installed than e.g. autotools.  It's a few days old now,
but still applies cleanly.  I'll eventually test it, but it may
take at least a few days more before I get to it.

Regarding the patch, I couldn't find anything more
newlib-specific than the actual typedef, which IMHO is good
enough.  The rest of the fix is just like the
defined(__PTRDIFF_TYPE__)-arm of the "#if" of the newlib patch.
I guess one could theoretically argue that there's no certainty
that there's a visible PTRDIFF_MAX definition, but if so, that'd
be a *different* C99-stdint.h bug to be fixincluded.

fixincludes:

	* inclhack.def (newlib_stdint_3): New fix.
	* fixincl.x: Regenerate.
	* tests/base/stdint.h: Update.

Index: fixincludes/inclhack.def
===================================================================
--- fixincludes/inclhack.def	(revision 145867)
+++ fixincludes/inclhack.def	(working copy)
@@ -2488,6 +2488,23 @@
 };
 
 
+fix = {
+    hackname  = newlib_stdint_3;
+    files     = stdint.h;
+    select    = "^typedef unsigned __PTRDIFF_TYPE__ uintptr_t;";
+    bypass   = "INTPTR_MAX";
+    c_fix     = format;
+    c_fix_arg = "%0\n"
+		"#define INTPTR_MAX PTRDIFF_MAX\n"
+		"#define INTPTR_MIN PTRDIFF_MIN\n"
+		"#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)\n";
+    test_text = "#if defined(__PTRDIFF_TYPE__)\n"
+		"typedef signed __PTRDIFF_TYPE__ intptr_t;\n"
+		"typedef unsigned __PTRDIFF_TYPE__ uintptr_t;\n"
+		"#else\n";
+};
+
+
 /*
  *  NeXT 3.2 adds const prefix to some math functions.
  *  These conflict with the built-in functions.
Index: fixincludes/tests/base/stdint.h
===================================================================
--- fixincludes/tests/base/stdint.h	(revision 145867)
+++ fixincludes/tests/base/stdint.h	(working copy)
@@ -47,3 +47,16 @@
 
 /** Macros for minimum-width integer constant expressions */
 #endif  /* NEWLIB_STDINT_2_CHECK */
+
+
+#if defined( NEWLIB_STDINT_3_CHECK )
+#if defined(__PTRDIFF_TYPE__)
+typedef signed __PTRDIFF_TYPE__ intptr_t;
+typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
+#define INTPTR_MAX PTRDIFF_MAX
+#define INTPTR_MIN PTRDIFF_MIN
+#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
+
+#else
+
+#endif  /* NEWLIB_STDINT_3_CHECK */
Index: fixincludes/fixincl.x
===================================================================
--- fixincludes/fixincl.x	(revision 145867)
+++ fixincludes/fixincl.x	(working copy)
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Tuesday March 31, 2009 at 05:01:22 PM UTC
+ * It has been AutoGen-ed  Friday April 10, 2009 at 05:40:26 AM CEST
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Tue Mar 31 17:01:22 UTC 2009
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Apr 10 05:40:26 CEST 2009
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 180 fixup descriptions.
+ * This file contains 181 fixup descriptions.
  *
  * See README for more information.
  *
@@ -4608,6 +4608,51 @@
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
+ *  Description of Newlib_Stdint_3 fix
+ */
+tSCC zNewlib_Stdint_3Name[] =
+     "newlib_stdint_3";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zNewlib_Stdint_3List[] =
+  "stdint.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+#define apzNewlib_Stdint_3Machs (const char**)NULL
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zNewlib_Stdint_3Select0[] =
+       "^typedef unsigned __PTRDIFF_TYPE__ uintptr_t;";
+
+/*
+ *  content bypass pattern - skip fix if pattern found
+ */
+tSCC zNewlib_Stdint_3Bypass0[] =
+       "INTPTR_MAX";
+
+#define    NEWLIB_STDINT_3_TEST_CT  2
+static tTestDesc aNewlib_Stdint_3Tests[] = {
+  { TT_NEGREP,   zNewlib_Stdint_3Bypass0, (regex_t*)NULL },
+  { TT_EGREP,    zNewlib_Stdint_3Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Newlib_Stdint_3
+ */
+static const char* apzNewlib_Stdint_3Patch[] = {
+    "format",
+    "%0\n\
+#define INTPTR_MAX PTRDIFF_MAX\n\
+#define INTPTR_MIN PTRDIFF_MIN\n\
+#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)\n",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
  *  Description of Next_Math_Prefix fix
  */
 tSCC zNext_Math_PrefixName[] =
@@ -7325,9 +7370,9 @@
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          225
+#define REGEX_COUNT          227
 #define MACH_LIST_SIZE_LIMIT 181
-#define FIX_COUNT            180
+#define FIX_COUNT            181
 
 /*
  *  Enumerate the fixes
@@ -7446,6 +7491,7 @@
     NETBSD_EXTRA_SEMICOLON_FIXIDX,
     NEWLIB_STDINT_1_FIXIDX,
     NEWLIB_STDINT_2_FIXIDX,
+    NEWLIB_STDINT_3_FIXIDX,
     NEXT_MATH_PREFIX_FIXIDX,
     NEXT_TEMPLATE_FIXIDX,
     NEXT_VOLITILE_FIXIDX,
@@ -8081,6 +8127,11 @@
      NEWLIB_STDINT_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aNewlib_Stdint_2Tests,   apzNewlib_Stdint_2Patch, 0 },
 
+  {  zNewlib_Stdint_3Name,    zNewlib_Stdint_3List,
+     apzNewlib_Stdint_3Machs,
+     NEWLIB_STDINT_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aNewlib_Stdint_3Tests,   apzNewlib_Stdint_3Patch, 0 },
+
   {  zNext_Math_PrefixName,    zNext_Math_PrefixList,
      apzNext_Math_PrefixMachs,
      NEXT_MATH_PREFIX_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]