diff mbox

AIX fixincludes for pthread.h

Message ID CAGWvnynRQ4OPvZci+ohtF=hXkQtK4Fmn0htQhD9006uzxjjX3g@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Nov. 7, 2011, 8:59 p.m. UTC
As part of the fallout from PR 50982, this patch adds some new fixes
to GCC fixincludes that corrects a syntax error in an array
initializer for PTHREAD_ONCE_INIT.  The incorrect header file still is
present in AIX 7.1; I have reported the bug to AIX as well.

        * inclhack.def (aix_once_init_[12]): New fix.
        * fixincl.x: Rebuilt.
        * tests/base/pthread.h: New tests.

Bootstrapped on powerpc-ibm-aix5.3.0.0

Okay?

Thanks, David
* inclhack.def (aix_once_init_[12]): New fix.
	* fixincl.x: Rebuilt.
	* tests/base/pthread.h: New tests.

Comments

Bruce Korb Nov. 8, 2011, 4:56 p.m. UTC | #1
On Mon, Nov 7, 2011 at 12:59 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
> Okay?

Well, okay, but I'd prefer one fix something like the following (and I confess
I've not had any test time...) because it looks simpler to me:

/*
 *  pthread.h on AIX defines PTHREAD_ONCE_INIT without enough braces.
 *  Rewrite the define as a dual define with the original name now containing
 *  the missing braces.
 */
fix = {
    hackname  = aix_once_init;
    mach      = "*-*-aix*";
    files     = "pthread.h";
    select    = "(#define[ \t]+)(PTHREAD_ONCE_INIT)( \\\\\n"
		"\\{)";

    c_fix       = format;
    c_fix_arg = "%1%2 { %2_INTERNAL }\n%1%2_INTERNAL%3";

    test_text = <<- _EOF_
	#if FUMBLE
	#define PTHREAD_ONCE_INIT \
	{ \
	       ... _PTH_FLAGS_INIT64, \
	}
	#else
	#define PTHREAD_ONCE_INIT \
	{ \
	       ... 2, \
	}
	#endif
	_EOF_;
};
David Edelsohn Nov. 8, 2011, 4:59 p.m. UTC | #2
Bruce,

I don't want to add a layer and PTHREAD_ONCE_INIT_INTERNAL.

Thanks, David
David Edelsohn Nov. 8, 2011, 6:20 p.m. UTC | #3
On Tue, Nov 8, 2011 at 11:56 AM, Bruce Korb <bkorb@gnu.org> wrote:
> On Mon, Nov 7, 2011 at 12:59 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
>> Okay?
>
> Well, okay, but I'd prefer one fix something like the following (and I confess
> I've not had any test time...) because it looks simpler to me:

Also, there are other fixincludes fixes for missing braces that
directly add the braces, not a wrapper.  They are not multi-line
macros, but there is a precedent on the style of solution.

Thanks, David
Bruce Korb Nov. 8, 2011, 6:39 p.m. UTC | #4
Hi David,

On Tue, Nov 8, 2011 at 10:20 AM, David Edelsohn <dje.gcc@gmail.com> wrote:
>>> Okay?
>>
>> Well, okay, but....
>
> Also, there are other fixincludes fixes for missing braces that
> directly add the braces, not a wrapper.  They are not multi-line
> macros, but there is a precedent on the style of solution.

Like I said, "okay, but...".  Each entry is some sort of compromise.
Each entry exacts a cost of operation.  If inserting braces with a single
fix is easy, I think that's the preferred solution.  Using two fixes to insert
a matched pair of braces just seems a bit dodgey.  Especially given that
the selection expression feels so non-specific, at least to me:
    "[ \t]0 \\\\\n\\}\n"
In the final analysis, AIX is your play area and you know the trade-offs,
so I leave it to you to decide.

Cheers - Bruce
diff mbox

Patch

Index: tests/base/pthread.h
===================================================================
--- tests/base/pthread.h	(revision 181090)
+++ tests/base/pthread.h	(working copy)
@@ -9,6 +9,20 @@ 
 
 
 
+#if defined( AIX_ONCE_INIT_1_CHECK )
+#define PTHREAD_ONCE_INIT \
+{{ \
+
+#endif  /* AIX_ONCE_INIT_1_CHECK */
+
+
+#if defined( AIX_ONCE_INIT_2_CHECK )
+	0 \
+}}
+
+#endif  /* AIX_ONCE_INIT_2_CHECK */
+
+
 #if defined( AIX_PTHREAD_CHECK )
 #define PTHREAD_MUTEX_INITIALIZER \
 {...init stuff...}
Index: fixincl.x
===================================================================
--- fixincl.x	(revision 181090)
+++ fixincl.x	(working copy)
@@ -2,11 +2,11 @@ 
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Sunday October 23, 2011 at 12:18:29 PM EST
+ * It has been AutoGen-ed  November  7, 2011 at 01:16:39 PM by AutoGen 5.10
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Oct 23 12:18:29 EST 2011
+/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Nov  7 13:16:39 EST 2011
  *
  * 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 220 fixup descriptions.
+ * This file contains 222 fixup descriptions.
  *
  * See README for more information.
  *
@@ -559,6 +559,84 @@ 
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
+ *  Description of Aix_Once_Init_1 fix
+ */
+tSCC zAix_Once_Init_1Name[] =
+     "aix_once_init_1";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zAix_Once_Init_1List[] =
+  "pthread.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzAix_Once_Init_1Machs[] = {
+        "*-*-aix*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zAix_Once_Init_1Select0[] =
+       "#define[ \t]PTHREAD_ONCE_INIT \\\\\n\
+\\{ \\\\\n";
+
+#define    AIX_ONCE_INIT_1_TEST_CT  1
+static tTestDesc aAix_Once_Init_1Tests[] = {
+  { TT_EGREP,    zAix_Once_Init_1Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Aix_Once_Init_1
+ */
+static const char* apzAix_Once_Init_1Patch[] = {
+    "format",
+    "#define PTHREAD_ONCE_INIT \\\n\
+{{ \\\n",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Aix_Once_Init_2 fix
+ */
+tSCC zAix_Once_Init_2Name[] =
+     "aix_once_init_2";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zAix_Once_Init_2List[] =
+  "pthread.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzAix_Once_Init_2Machs[] = {
+        "*-*-aix*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zAix_Once_Init_2Select0[] =
+       "[ \t]0 \\\\\n\
+\\}\n";
+
+#define    AIX_ONCE_INIT_2_TEST_CT  1
+static tTestDesc aAix_Once_Init_2Tests[] = {
+  { TT_EGREP,    zAix_Once_Init_2Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Aix_Once_Init_2
+ */
+static const char* apzAix_Once_Init_2Patch[] = {
+    "format",
+    "\t0 \\\n\
+}}\n",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
  *  Description of Aix_Pthread fix
  */
 tSCC zAix_PthreadName[] =
@@ -8956,9 +9034,9 @@ 
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          262
+#define REGEX_COUNT          264
 #define MACH_LIST_SIZE_LIMIT 181
-#define FIX_COUNT            220
+#define FIX_COUNT            222
 
 /*
  *  Enumerate the fixes
@@ -8974,6 +9052,8 @@ 
     AAB_SUN_MEMCPY_FIXIDX,
     AIX_COMPLEX_FIXIDX,
     AIX_NET_IF_ARP_FIXIDX,
+    AIX_ONCE_INIT_1_FIXIDX,
+    AIX_ONCE_INIT_2_FIXIDX,
     AIX_PTHREAD_FIXIDX,
     AIX_STDINT_1_FIXIDX,
     AIX_STDINT_2_FIXIDX,
@@ -9237,6 +9317,16 @@ 
      AIX_NET_IF_ARP_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aAix_Net_If_ArpTests,   apzAix_Net_If_ArpPatch, 0 },
 
+  {  zAix_Once_Init_1Name,    zAix_Once_Init_1List,
+     apzAix_Once_Init_1Machs,
+     AIX_ONCE_INIT_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aAix_Once_Init_1Tests,   apzAix_Once_Init_1Patch, 0 },
+
+  {  zAix_Once_Init_2Name,    zAix_Once_Init_2List,
+     apzAix_Once_Init_2Machs,
+     AIX_ONCE_INIT_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aAix_Once_Init_2Tests,   apzAix_Once_Init_2Patch, 0 },
+
   {  zAix_PthreadName,    zAix_PthreadList,
      apzAix_PthreadMachs,
      AIX_PTHREAD_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
Index: inclhack.def
===================================================================
--- inclhack.def	(revision 181090)
+++ inclhack.def	(working copy)
@@ -384,6 +384,35 @@ 
 };
 
 /*
+ *  pthread.h on AIX defines PTHREAD_ONCE_INIT without enough braces.
+ */
+fix = {
+    hackname  = aix_once_init_1;
+    mach      = "*-*-aix*";
+    files     = "pthread.h";
+    select    = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
+		"\\{ \\\\\n";
+    c_fix     = format;
+    c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
+		"{{ \\\n";
+    test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
+		"{ \\\\\n";
+};
+
+fix = {
+    hackname  = aix_once_init_2;
+    mach      = "*-*-aix*";
+    files     = "pthread.h";
+    select    = "[ \t]0 \\\\\n"
+		"\\}\n";
+    c_fix     = format;
+    c_fix_arg = "	0 \\\n"
+		"}}\n";
+    test_text = "	0 \\\\\n"
+		"}\n";
+};
+
+/*
  *  pthread.h on AIX 4.3.3 tries to define a macro without whitspace
  *  which violates a requirement of ISO C.
  */