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]

[PATCH]: Fix PTHREAD_(MUTEX|COND)_INITIALIZER on solaris9


This patch fixes the PTHREAD_(MUTEX|COND)_INITIALIZER macros on
solaris9.  Yes... it changed again, fun fun fun.  In this release the
macros became multi-line with an embedded comment between the macro
name and definition on the next line.  See the added test_text and the
base/pthread.h changes for details.  Now that the pattern is updated
for solaris9 (and later) I had to ensure the patch doesn't run on
solaris10 where it's not necessary.

With this patch,  I'm getting clean results with and without -ansi on
my original testcase on solaris7, 9 and 10.

Tested via "make check", and by running fixincludes on the above three
solaris versions and checking the resulting pthread.h, as well as by
compiling the testcase which had no warnings.

Okay for all active branches?

		Thanks,
		--Kaveh


PS: With this patch all of my platforms pass my testcase, so I'll
install the test on mainline-only after this patch goes in.  The Uros
can add his test bits for glibc.



2006-09-28  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* inclhack.def (solaris_mutex_init_2): Update for Solaris9.
	Prevent it from running on solaris10 or later.
	(solaris_once_init_2): Fix comment.
	* tests/base/pthread.h: Update.

	* fixincl.x: Regenerate.

diff -rup orig/egcc-SVN20060927/fixincludes/inclhack.def egcc-SVN20060927/fixincludes/inclhack.def
--- orig/egcc-SVN20060927/fixincludes/inclhack.def	2006-09-27 21:13:11.000000000 -0400
+++ egcc-SVN20060927/fixincludes/inclhack.def	2006-09-28 23:27:15.290715149 -0400
@@ -2972,18 +2972,31 @@ fix = {
     hackname = solaris_mutex_init_2;
     select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
     files = pthread.h;
+    /*
+     * On Solaris 10, this fix is unnecessary because upad64_t is
+     * always defined correctly regardless of the definition of the
+     * __STDC__ macro.  The first "mach" pattern matches up to
+     * solaris9.  The second "mach" pattern will not match any two (or
+     * more) digit solaris version, but it will match e.g. 2.5.1.
+     */
+    mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
     c_fix = format;
     c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
                 "%0\n"
                 "#else\n"
-                "%1, {0}}%3\n"
+                "%1, {0}}%4\n"
                 "#endif";
-    c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+\\{.*)"
+    c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
+                "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
                 ",[ \t]*0\\}" "(|[ \t].*)$";
     test_text =
     '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
     "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
-    "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */";
+    "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
+    "#define	PTHREAD_MUTEX_INITIALIZER		/* = DEFAULTMUTEX */	\\\\\n"
+    "	{{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
+    "#define	PTHREAD_COND_INITIALIZER		/* = DEFAULTCV */	\\\\\n"
+    "	{{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
 };
 
 
@@ -3047,7 +3060,7 @@ fix = {
     /*
      * On Solaris 10, this fix is unnecessary because upad64_t is
      * always defined correctly regardless of the definition of the
-     * __STDC__ macro.  The first "match" pattern matches up to
+     * __STDC__ macro.  The first "mach" pattern matches up to
      * solaris9.  The second "mach" pattern will not match any two (or
      * more) digit solaris version, but it will match e.g. 2.5.1.
      */
diff -rup orig/egcc-SVN20060927/fixincludes/tests/base/pthread.h egcc-SVN20060927/fixincludes/tests/base/pthread.h
--- orig/egcc-SVN20060927/fixincludes/tests/base/pthread.h	2006-09-27 21:13:10.000000000 -0400
+++ egcc-SVN20060927/fixincludes/tests/base/pthread.h	2006-09-28 23:22:40.827561479 -0400
@@ -94,6 +94,20 @@ extern int __sigsetjmp (struct __jmp_buf
 #else
 #define PTHREAD_COND_INITIALIZER	{{{0}, 0}, {0}}	/* DEFAULTCV */
 #endif
+#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
+#define	PTHREAD_MUTEX_INITIALIZER		/* = DEFAULTMUTEX */	\
+	{{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}
+#else
+#define	PTHREAD_MUTEX_INITIALIZER		/* = DEFAULTMUTEX */	\
+	{{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, {0}}
+#endif
+#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
+#define	PTHREAD_COND_INITIALIZER		/* = DEFAULTCV */	\
+	{{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}
+#else
+#define	PTHREAD_COND_INITIALIZER		/* = DEFAULTCV */	\
+	{{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, {0}}
+#endif
 #endif  /* SOLARIS_MUTEX_INIT_2_CHECK */
 
 


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