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_RWLOCK_INITIALIZER on solaris


The definition on PTHREAD_RWLOCK_INITIALIZER has some problems I
believe from solaris7 up to solaris9.  (I don't believe the macro
existed prior to solaris7).  This patch fixes solaris7 and should fix
solaris8.  I don't have solaris8, but the headers you provided Bruce
seem to indicate it's the same as solaris7.  The pattern for solaris9
is different, so a separate fix is necessary there.  I'm not
hardwiring any solaris versions via "mach" since these headers are
notorious for changing even within a release via patches.

Tested by running "make check" in the fixincludes dir plus running
fixincludes on solaris10 and solaris7 and verifying the appropriate
changes are made to pthread.h and that my testcase compiles as
expected in the resulting gcc compiler.

Okay on all active branches?

		Thanks,
		--Kaveh



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

	* inclhack.def (solaris_mutex_init_2): Remove test ensuring
	PTHREAD_RWLOCK_INITIALIZER is not changed.
	(solaris_rwlock_init_1): New.
	* tests/base/pthread.h: Update.

	* fixincl.x: Regenerate.

diff -rup orig/egcc-SVN20060923/fixincludes/inclhack.def egcc-SVN20060923/fixincludes/inclhack.def
--- orig/egcc-SVN20060923/fixincludes/inclhack.def	2006-09-26 11:33:58.586037960 -0400
+++ egcc-SVN20060923/fixincludes/inclhack.def	2006-09-26 11:55:53.053099850 -0400
@@ -2983,9 +2983,34 @@ fix = {
     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 */\n"
-    "#define PTHREAD_RWLOCK_INITIALIZER\t"
-             "{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
+    "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */";
+};
+
+
+/*
+ * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
+ *  fields of the pthread_rwlock_t structure, which are of type
+ *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
+ *  defined (e.g. by -ansi) it is a union. So change the initializer
+ *  to "{0}" instead.
+ */
+fix = {
+    hackname = solaris_rwlock_init_1;
+    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
+    files = pthread.h;
+    mach = '*-*-solaris*';
+    c_fix = format;
+    c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
+                "%0\n"
+                "#else\n"
+                "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
+                "#endif";
+    c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
+                "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
+
+    test_text =
+    '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
+    "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
 };
 
 
diff -rup orig/egcc-SVN20060923/fixincludes/tests/base/pthread.h egcc-SVN20060923/fixincludes/tests/base/pthread.h
--- orig/egcc-SVN20060923/fixincludes/tests/base/pthread.h	2006-09-26 11:33:58.587380300 -0400
+++ egcc-SVN20060923/fixincludes/tests/base/pthread.h	2006-09-26 11:53:02.550322827 -0400
@@ -94,10 +94,19 @@ extern int __sigsetjmp (struct __jmp_buf
 #else
 #define PTHREAD_COND_INITIALIZER	{{{0}, 0}, {0}}	/* DEFAULTCV */
 #endif
-#define PTHREAD_RWLOCK_INITIALIZER	{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}
 #endif  /* SOLARIS_MUTEX_INIT_2_CHECK */
 
 
+#if defined( SOLARIS_RWLOCK_INIT_1_CHECK )
+#ident "@(#)pthread.h  1.26  98/04/12 SMI"
+#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
+#define PTHREAD_RWLOCK_INITIALIZER	{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}
+#else
+#define PTHREAD_RWLOCK_INITIALIZER	{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}
+#endif
+#endif  /* SOLARIS_RWLOCK_INIT_1_CHECK */
+
+
 #if defined( SOLARIS_ONCE_INIT_1_CHECK )
 #pragma ident	"@(#)pthread.h	1.37	04/09/28 SMI"
 #define PTHREAD_ONCE_INIT	{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}
diff -rup orig/egcc-SVN20060923/fixincludes/fixincl.x egcc-SVN20060923/fixincludes/fixincl.x
--- orig/egcc-SVN20060923/fixincludes/fixincl.x	2006-09-26 11:33:58.599929852 -0400
+++ egcc-SVN20060923/fixincludes/fixincl.x	2006-09-26 11:56:29.000000000 -0400
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Tuesday September 26, 2006 at 10:42:37 AM EDT
+ * It has been AutoGen-ed  Tuesday September 26, 2006 at 11:56:29 AM EDT
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT CVS-MERGE THIS FILE, EITHER Tue Sep 26 10:42:37 EDT 2006
+/* DO NOT CVS-MERGE THIS FILE, EITHER Tue Sep 26 11:56:29 EDT 2006
  *
  * 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 197 fixup descriptions.
+ * This file contains 198 fixup descriptions.
  *
  * See README for more information.
  *
@@ -5498,6 +5498,48 @@ static const char* apzSolaris_Mutex_Init
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
+ *  Description of Solaris_Rwlock_Init_1 fix
+ */
+tSCC zSolaris_Rwlock_Init_1Name[] =
+     "solaris_rwlock_init_1";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zSolaris_Rwlock_Init_1List[] =
+  "|pthread.h|";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzSolaris_Rwlock_Init_1Machs[] = {
+        "*-*-solaris*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zSolaris_Rwlock_Init_1Select0[] =
+       "@\\(#\\)pthread.h[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
+
+#define    SOLARIS_RWLOCK_INIT_1_TEST_CT  1
+static tTestDesc aSolaris_Rwlock_Init_1Tests[] = {
+  { TT_EGREP,    zSolaris_Rwlock_Init_1Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Solaris_Rwlock_Init_1
+ */
+static const char* apzSolaris_Rwlock_Init_1Patch[] = {
+    "format",
+    "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n\
+%0\n\
+#else\n\
+%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n\
+#endif",
+    "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
  *  Description of Solaris_Once_Init_1 fix
  */
 tSCC zSolaris_Once_Init_1Name[] =
@@ -8015,9 +8057,9 @@ static const char* apzX11_SprintfPatch[]
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          240
+#define REGEX_COUNT          241
 #define MACH_LIST_SIZE_LIMIT 261
-#define FIX_COUNT            197
+#define FIX_COUNT            198
 
 /*
  *  Enumerate the fixes
@@ -8156,6 +8198,7 @@ typedef enum {
     SOLARIS_MATH_9_FIXIDX,
     SOLARIS_MUTEX_INIT_1_FIXIDX,
     SOLARIS_MUTEX_INIT_2_FIXIDX,
+    SOLARIS_RWLOCK_INIT_1_FIXIDX,
     SOLARIS_ONCE_INIT_1_FIXIDX,
     SOLARIS_SOCKET_FIXIDX,
     SOLARIS_STDIO_TAG_FIXIDX,
@@ -8888,6 +8931,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      SOLARIS_MUTEX_INIT_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aSolaris_Mutex_Init_2Tests,   apzSolaris_Mutex_Init_2Patch, 0 },
 
+  {  zSolaris_Rwlock_Init_1Name,    zSolaris_Rwlock_Init_1List,
+     apzSolaris_Rwlock_Init_1Machs,
+     SOLARIS_RWLOCK_INIT_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aSolaris_Rwlock_Init_1Tests,   apzSolaris_Rwlock_Init_1Patch, 0 },
+
   {  zSolaris_Once_Init_1Name,    zSolaris_Once_Init_1List,
      apzSolaris_Once_Init_1Machs,
      SOLARIS_ONCE_INIT_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,


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