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]: add tests for pthread initialization macros


I'd like to install a testcase for the pthread initialization macros
so we'll more easily see if (when) this breaks in the next release of
solaris.  Also some other platforms, namely aix and alpha-osf have
their own problems and may benefit from this oversight as well.  I've
added tests for "-W -Wall" and "-W -Wall -ansi" which were separate
problems on solaris.  We can add more if the other platforms have
their own issues.  Also, we can easily add more macros if they exist.

The only caveat is that these two tests assume that pthread.h exists
on your system.  I suppose anyone without that header can add a
dg-skip-if?

Okay for all active branches?

		Thanks,
		--Kaveh


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

	* gcc.dg/pthread-init-1.c, pthread-init-2.c,
	pthread-init-common.h: New.
	
diff -rup orig/egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-1.c egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-1.c
--- orig/egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-1.c	2006-09-27 12:30:07.227628248 -0400
+++ egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-1.c	2006-09-27 12:32:43.298439559 -0400
@@ -0,0 +1,11 @@
+/* Ensure we get clean warning results when using the pthread
+ * initialization macros.
+ *
+ * Origin: Kaveh Ghazi (ghazi@caip.rutgers.edu) 9/27/2006.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-W -Wall" } */
+
+#include "pthread-init-common.h"
+
diff -rup orig/egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-2.c egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-2.c
--- orig/egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-2.c	2006-09-27 12:30:09.590689554 -0400
+++ egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-2.c	2006-09-27 12:32:53.135110418 -0400
@@ -0,0 +1,11 @@
+/* Various Solaris versions have been known to have problems with the
+ * pthread initialization macros when __STDC__ is defined.
+ *
+ * Origin: Kaveh Ghazi (ghazi@caip.rutgers.edu) 9/27/2006.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-W -Wall -ansi" } */
+
+#include "pthread-init-common.h"
+
diff -rup orig/egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-common.h egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-common.h
--- orig/egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-common.h	2006-09-27 12:30:12.673161692 -0400
+++ egcc-SVN20060927/gcc/testsuite/gcc.dg/pthread-init-common.h	2006-09-27 12:33:50.002051871 -0400
@@ -0,0 +1,24 @@
+/* 
+ * Common code for the pthread-init-*.c tests.
+ *
+ * Origin: Kaveh Ghazi (ghazi@caip.rutgers.edu) 9/27/2006.
+ */
+
+#include <pthread.h>
+#define UNUSED __attribute__ ((__unused__))
+
+void foo(void)
+{
+#ifdef PTHREAD_MUTEX_INITIALIZER
+  pthread_mutex_t pmutex UNUSED = PTHREAD_MUTEX_INITIALIZER;
+#endif
+#ifdef PTHREAD_COND_INITIALIZER
+  pthread_cond_t pcond UNUSED = PTHREAD_COND_INITIALIZER;
+#endif
+#ifdef PTHREAD_RWLOCK_INITIALIZER
+  pthread_rwlock_t prwlock UNUSED = PTHREAD_RWLOCK_INITIALIZER;
+#endif
+#ifdef PTHREAD_ONCE_INIT
+  pthread_once_t ponce UNUSED = PTHREAD_ONCE_INIT;
+#endif
+}


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