This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [GCC PATCH]: add tests for pthread initialization macros
Bruce Korb wrote:
Hi Uros,
Looking pretty good, but still a couple of comments:
* I have some GNU C library headers that these sed commands
would not alter because the initializers are correct. Please add
a select clause (or replace the one you have) that will fire only if
there is work to do. (or, at least, there is likely to be work to do.
e.g.:
select = '0, *\}';
* When posting a patch, I think we can leave out the changes
to fixincl.x. It gets generated fairly reliably. :)
Bruce,
attached to this message please find updated version of the patch that
handles
PTHREAD_(MUTEX|RWLOCK|COND)_INITIALIZER defines. I have tighten sed
select regexp a bit and added your proposed select clause. Patch is
tested by bootstrapping gcc on x86_64 and fixes all build warnings
(there are some warnings left in libstdc++ build, these will be
addressed in a follow-up patch.
2006-09-30 Uros Bizjak <uros@kss-loka.si>
* inclhack.def (glibc_mutex_init): New fix.
* tests/base/pthread.h: Update.
* fixincl.x: Regenerate.
Uros.
Index: inclhack.def
===================================================================
--- inclhack.def (revision 117328)
+++ inclhack.def (working copy)
@@ -1288,6 +1288,38 @@
};
+/* glibc-2.3.5 defines pthread mutex initializers incorrectly,
+ * so we replace them with versions that correspond to the
+ * definition.
+ */
+fix = {
+ hackname = glibc_mutex_init;
+ files = pthread.h;
+ select = '\{ *\{ *0, *\} *\}';
+ sed = "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/,+1"
+ "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/";
+ sed = "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
+ "N;s/^[ \t]*#[ \t]*"
+ "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
+ "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n"
+ "# \\1\\n"
+ " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
+ "# else\\n"
+ "# \\1\\n"
+ " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
+ "# endif/";
+ sed = "/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_RWLOCK_INITIALIZER \\\\\n"
+ " { { 0, } }\n"
+ "#define PTHREAD_COND_INITIALIZER { { 0, } }";
+};
+
+
/*
* Fix these files to use the types we think they should for
* ptrdiff_t, size_t, and wchar_t.
Index: tests/base/pthread.h
===================================================================
--- tests/base/pthread.h (revision 117328)
+++ tests/base/pthread.h (working copy)
@@ -56,6 +56,20 @@
#endif /* ALPHA_PTHREAD_INIT_CHECK */
+#if defined( GLIBC_MUTEX_INIT_CHECK )
+#define PTHREAD_MUTEX_INITIALIZER \
+ { { 0, 0, 0, 0, 0, 0 } }
+# if __WORDSIZE == 64
+# define PTHREAD_RWLOCK_INITIALIZER \
+ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
+# else
+# define PTHREAD_RWLOCK_INITIALIZER \
+ { { 0, 0, 0, 0, 0, 0, 0, 0 } }
+# endif
+#define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }
+#endif /* GLIBC_MUTEX_INIT_CHECK */
+
+
#if defined( PTHREAD_PAGE_SIZE_CHECK )
extern int __page_size;
#endif /* PTHREAD_PAGE_SIZE_CHECK */