Patchwork [fixincludes] Fix gcc.dg/pthread-init-[12].c on Solaris 8

login
register
mail settings
Submitter Rainer Orth
Date July 12, 2010, 12:09 p.m.
Message ID <ydd1vb8ucj6.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/58599/
State New
Headers show

Comments

Rainer Orth - July 12, 2010, 12:09 p.m.
Two pthread tests fail on Solaris 8:

FAIL: gcc.dg/pthread-init-1.c (test for excess errors)
FAIL: gcc.dg/pthread-init-2.c (test for excess errors)

Excess errors:
In file included from /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.dg/pthread-init-1.c:14:0:
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.dg/pthread-init-common.h:27:3: warning: missing initializer [-Wmissing-field-initializers]
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.dg/pthread-init-common.h:27:3: warning: (near initialization for 'pcond.__pthread_cond_flags.__pthread_cond_magic') [-Wmissing-field-initializers]

The problem is that the __pthread_cond_magic field isn't initialized
in PTHREAD_COND_INITIALIZER, while the equivalent field in <synch.h>
DEFAULTCV is.  Unfortunately, COND_MAGIC is used there which pollutes
the user namespace, so I'm fixing this by using the value literally.
Since Solaris 9, _COND_MAGIC is used, which lives in <sys/types.h>.

Bootstrapped without regressions on Solaris 8 to 11, both SPARC and
x86.  Ok for mainline (and the 4.4 and 4.5 branches once testing
completes there)?

Thanks.
	Rainer

2010-06-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* inclhack.def (solaris_cond_init): New fix.
	* fixincl.x: Regenerate.
	* tests/base/pthread.h [SOLARIS_COND_INIT_CHECK]: New test.
	[SOLARIS_MUTEX_INIT_2_CHECK]: Adapt.
Bruce Korb - July 12, 2010, 2:13 p.m.
This is only now being discovered?  :-O !!
OK, looks good to me......
Cheers - Bruce

On Mon, Jul 12, 2010 at 5:09 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> Two pthread tests fail on Solaris 8:
>
> FAIL: gcc.dg/pthread-init-1.c (test for excess errors)
> FAIL: gcc.dg/pthread-init-2.c (test for excess errors)
>
> Excess errors:
> In file included from /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.dg/pthread-init-1.c:14:0:
> /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.dg/pthread-init-common.h:27:3: warning: missing initializer [-Wmissing-field-initializers]
> /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.dg/pthread-init-common.h:27:3: warning: (near initialization for 'pcond.__pthread_cond_flags.__pthread_cond_magic') [-Wmissing-field-initializers]
>
> The problem is that the __pthread_cond_magic field isn't initialized
> in PTHREAD_COND_INITIALIZER,
Rainer Orth - July 12, 2010, 2:17 p.m.
Bruce Korb <bkorb@gnu.org> writes:

> This is only now being discovered?  :-O !!

Strange indeed ;-)  I've started my maintenance work at Solaris 11 and
once I got a reasonably clean slate there, started working my way
backwards until Solaris 8.  A problem like this is always easier to
analyse and fix than some code generation problem ...

> OK, looks good to me......

Thanks.
	Rainer

Patch

diff -r f9ee2257fad3 fixincludes/inclhack.def
--- a/fixincludes/inclhack.def	Fri Jul 09 12:30:44 2010 +0200
+++ b/fixincludes/inclhack.def	Fri Jul 09 12:36:12 2010 +0200
@@ -3307,6 +3307,26 @@ 
 
 
 /*
+ * Solaris 8 PTHREAD_COND_INITIALIZER lacks the __pthread_cond_magic field.
+ * COND_MAGIC is only defined in <synch.h> and pollutes the namespace, so
+ * use the value literally instead.
+ */
+fix = {
+    hackname = solaris_cond_init;
+    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
+    files = pthread.h;
+    mach = '*-*-solaris2.8';
+    c_fix = format;
+    c_fix_arg = "%1, 0x4356%2";
+    c_fix_arg = "^(#define[ \t]+PTHREAD_COND_INITIALIZER[ \t]+"
+                "\\{.*0)(\\},[ \t]*0\\}.*)$";
+    test_text =
+    '#pragma ident	"@(#)pthread.h	1.29	01/07/07 SMI"'"\n"
+    '#define	PTHREAD_COND_INITIALIZER	{{{0}, 0}, 0}	/* = DEFAULTCV */';
+};
+
+
+/*
  * Sun Solaris 10 defines several C99 math macros in terms of
  * builtins specific to the Studio compiler, in particular not
  * compatible with the GNU compiler.
diff -r f9ee2257fad3 fixincludes/tests/base/pthread.h
--- a/fixincludes/tests/base/pthread.h	Fri Jul 09 12:30:44 2010 +0200
+++ b/fixincludes/tests/base/pthread.h	Fri Jul 09 12:36:12 2010 +0200
@@ -101,6 +101,16 @@ 
 #endif  /* PTHREAD_INCOMPLETE_STRUCT_ARGUMENT_CHECK */
 
 
+#if defined( SOLARIS_COND_INIT_CHECK )
+#pragma ident	"@(#)pthread.h	1.29	01/07/07 SMI"
+#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
+#define	PTHREAD_COND_INITIALIZER	{{{0}, 0, 0x4356}, 0}	/* = DEFAULTCV */
+#else
+#define	PTHREAD_COND_INITIALIZER	{{{0}, 0, 0x4356}, {0}}	/* = DEFAULTCV */
+#endif
+#endif  /* SOLARIS_COND_INIT_CHECK */
+
+
 #if defined( SOLARIS_MUTEX_INIT_2_CHECK )
 #ident "@(#)pthread.h  1.26  98/04/12 SMI"
 #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
@@ -109,9 +119,9 @@ 
 #define PTHREAD_MUTEX_INITIALIZER	{{{0},0}, {{{0}}}, {0}}
 #endif
 #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
-#define PTHREAD_COND_INITIALIZER	{{{0}, 0}, 0}	/* DEFAULTCV */
+#define PTHREAD_COND_INITIALIZER	{{{0}, 0, 0x4356}, 0}	/* DEFAULTCV */
 #else
-#define PTHREAD_COND_INITIALIZER	{{{0}, 0}, {0}}	/* DEFAULTCV */
+#define PTHREAD_COND_INITIALIZER	{{{0}, 0, 0x4356}, {0}}	/* DEFAULTCV */
 #endif
 #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
 #define	PTHREAD_MUTEX_INITIALIZER		/* = DEFAULTMUTEX */	\