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]

Re: [PATCH]: add tests for pthread initialization macros


Kaveh R. Ghazi wrote:

> Fedora Core 4 on x86_64 has issues with PTHREAD_MUTEX_INITIALIZER
> defined as "{ {0, } }" - please look at
> http://gcc.gnu.org/ml/gcc/2006-09/msg00525.html ...
> Uros.

Yes, that needs fixing too.  I think someone who has access to such a
platform and can test it should write the fix.  I.e. not me. :-) Part
of my motivation for installing the testcase is to bring to the
forefront other platforms where this kind of fix is necessary.

But I'm willing to help answer questions if you want to give it a try.
You can start by cut&pasting the existing fixes for the same macro and
changing it as needed for your glibc.


Attached patch to fixincludes fixes build warnings in gcc directory and a pack of warnings in libstdc++ build.

This patch was bootstrapped on x86_64-pc-linux-gnu. I have also checked attached patch with your proposed testcase, and it quiets two warnings.

However, looking closer into glibc-2.3.5 pthread.h, there are many more cases with wrong initializers, at least PTHREAD_RWLOCK_INITIALIZER and all PTHREAD_*_MUTEX_INITIALIZER_NP cause warnings. I'll fix these as a follow-up patch, but I suggest to include these initializers in your proposed testcase.

2006-09-28 Uros Bizjak <uros@kss-loka.si>

       * inclhack.def (pthread_mutex_init): New fix.
       * tests/base/pthread.h: Update.

* fixincl.x: Regenerate.

Uros.

Index: tests/base/pthread.h
===================================================================
--- tests/base/pthread.h	(revision 117283)
+++ tests/base/pthread.h	(working copy)
@@ -56,6 +56,13 @@
 #endif  /* ALPHA_PTHREAD_INIT_CHECK */
 
 
+#if defined( PTHREAD_MUTEX_INIT_CHECK )
+#define PTHREAD_MUTEX_INITIALIZER \
+  { { 0, 0, 0, 0, 0, 0 } }
+#define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }
+#endif  /* PTHREAD_MUTEX_INIT_CHECK */
+
+
 #if defined( PTHREAD_PAGE_SIZE_CHECK )
 extern int __page_size;
 #endif  /* PTHREAD_PAGE_SIZE_CHECK */
Index: fixincl.x
===================================================================
--- fixincl.x	(revision 117283)
+++ fixincl.x	(working copy)
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Wednesday September 27, 2006 at 08:16:42 PM EDT
+ * It has been AutoGen-ed  Thursday September 28, 2006 at 06:00:13 PM CEST
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT CVS-MERGE THIS FILE, EITHER Wed Sep 27 20:16:42 EDT 2006
+/* DO NOT CVS-MERGE THIS FILE, EITHER Thu Sep 28 18:00:13 CEST 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 199 fixup descriptions.
+ * This file contains 200 fixup descriptions.
  *
  * See README for more information.
  *
@@ -4551,6 +4551,35 @@
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
+ *  Description of Pthread_Mutex_Init fix
+ */
+tSCC zPthread_Mutex_InitName[] =
+     "pthread_mutex_init";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zPthread_Mutex_InitList[] =
+  "|pthread.h|";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzPthread_Mutex_InitMachs[] = {
+        "*-*-linux-gnu",
+        (const char*)NULL };
+#define PTHREAD_MUTEX_INIT_TEST_CT  0
+#define aPthread_Mutex_InitTests   (tTestDesc*)NULL
+
+/*
+ *  Fix Command Arguments for Pthread_Mutex_Init
+ */
+static const char* apzPthread_Mutex_InitPatch[] = { "sed",
+    "-e", "/define[ \t]*PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/,+1s/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n\
+/define[ \t]*PTHREAD_COND_INITIALIZER/s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
  *  Description of Pthread_Page_Size fix
  */
 tSCC zPthread_Page_SizeName[] =
@@ -8102,7 +8131,7 @@
  */
 #define REGEX_COUNT          242
 #define MACH_LIST_SIZE_LIMIT 261
-#define FIX_COUNT            199
+#define FIX_COUNT            200
 
 /*
  *  Enumerate the fixes
@@ -8218,6 +8247,7 @@
     OBSTACK_LVALUE_CAST_FIXIDX,
     OSF_NAMESPACE_A_FIXIDX,
     OSF_NAMESPACE_C_FIXIDX,
+    PTHREAD_MUTEX_INIT_FIXIDX,
     PTHREAD_PAGE_SIZE_FIXIDX,
     PTHREAD_INCOMPLETE_STRUCT_ARGUMENT_FIXIDX,
     READ_RET_TYPE_FIXIDX,
@@ -8860,6 +8890,11 @@
      OSF_NAMESPACE_C_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aOsf_Namespace_CTests,   apzOsf_Namespace_CPatch, 0 },
 
+  {  zPthread_Mutex_InitName,    zPthread_Mutex_InitList,
+     apzPthread_Mutex_InitMachs,
+     PTHREAD_MUTEX_INIT_TEST_CT, FD_MACH_ONLY,
+     aPthread_Mutex_InitTests,   apzPthread_Mutex_InitPatch, 0 },
+
   {  zPthread_Page_SizeName,    zPthread_Page_SizeList,
      apzPthread_Page_SizeMachs,
      PTHREAD_PAGE_SIZE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
Index: inclhack.def
===================================================================
--- inclhack.def	(revision 117283)
+++ inclhack.def	(working copy)
@@ -2507,6 +2507,26 @@
 };
 
 
+/*  glibc-2.3.5 defines PTHREAD_{MUTEX|COND}_INITIALIZER
+ *  incorrectly, so we replace them with versions that
+ *  correspond to the definition.
+ */
+fix = {
+    hackname = pthread_mutex_init;
+    files    = pthread.h;
+    mach     = *-*-linux-gnu;
+    sed      = "/define[ \t]*PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/,+1"
+               "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n"
+               "/define[ \t]*PTHREAD_COND_INITIALIZER/"
+               "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
+
+    test_text =
+    "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
+    "  { { 0, } }\n"
+    "#define PTHREAD_COND_INITIALIZER { { 0, } }";
+
+};
+
 /*
  *  Fix __page_size* declarations in pthread.h AIX 4.1.[34].
  *  The original ones fail if uninitialized externs are not common.

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