PATCH: gthr-dce.h update for v3 thread compatibility

John David Anglin dave@hiauly1.hia.nrc.ca
Sat Jun 9 21:17:00 GMT 2001


This is for the 3.0 branch.  There is a similar but slightly different
patch for the main.  It is needed for correct v3 thread operation with
DCE threads.  The essential changes are the definition of
__GTHREAD_MUTEX_INIT_FUNCTION and the correction to __gthread_key_delete.

The "UNUSED" changes are just to squelch warnings.  They have been
installed on the main for some time.

As far as I can tell, gthr-dce.h is only used with hpux 10.X.  It should
work with hpux 9.X but the configury stuff is disabled.  Posix threads
are the default on hpux 11 but the configuration changes needed to support
this aren't yet worked out.  As a result, thread support is disabled on
hpux 11.

The patch has been tested with several bootstraps and checks under hpux
10.20 with the 3.0 branch.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-06-10  John David Anglin  <dave@hiauly1.hia.nrc.ca>

        * gthr-dce.h (UNUSED): Attribute unused macro.
	(__GTHREAD_MUTEX_INIT_FUNCTION): Define macro.
	(pthread_mutex_init): Move pragma weak.
	(__gthread_key_dtor): Make arguments UNUSED.
	(__gthread_key_delete): Operation is unsupported and arguments UNUSED.
	(__gthread_mutex_init_function): New function.

--- gthr-dce.h.orig	Mon Jun  4 16:35:22 2001
+++ gthr-dce.h	Fri Jun  8 20:41:05 2001
@@ -37,12 +37,19 @@
 
 #include <pthread.h>
 
+#ifdef __cplusplus
+#define UNUSED(x) x
+#else
+#define UNUSED(x) x __attribute__((unused))
+#endif
+
 typedef pthread_key_t __gthread_key_t;
 typedef pthread_once_t __gthread_once_t;
 typedef pthread_mutex_t __gthread_mutex_t;
 
 #define __GTHREAD_ONCE_INIT pthread_once_init
-/* Howto define __GTHREAD_MUTEX_INIT? */
+
+#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
 
 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
 
@@ -53,7 +60,7 @@
 #pragma weak pthread_getspecific
 #pragma weak pthread_setspecific
 #pragma weak pthread_create
-
+#pragma weak pthread_mutex_init
 #pragma weak pthread_mutex_lock
 #pragma weak pthread_mutex_trylock
 #pragma weak pthread_mutex_unlock
@@ -67,7 +74,6 @@
 #pragma weak pthread_cond_wait
 #pragma weak pthread_exit
 #pragma weak pthread_getunique_np
-#pragma weak pthread_mutex_init
 #pragma weak pthread_mutex_destroy
 #pragma weak pthread_self
 #pragma weak pthread_yield
@@ -412,16 +418,17 @@
 }
 
 static inline int
-__gthread_key_dtor (__gthread_key_t key, void *ptr)
+__gthread_key_dtor (UNUSED (__gthread_key_t key), UNUSED (void *ptr))
 {
   /* Nothing needed. */
   return 0;
 }
 
 static inline int
-__gthread_key_delete (__gthread_key_t key)
+__gthread_key_delete (UNUSED (__gthread_key_t key))
 {
-  return pthread_key_delete (key);
+  /* Operation is not supported.  */
+  return -1;
 }
 
 static inline void *
@@ -440,6 +447,13 @@
   return pthread_setspecific (key, (void *) ptr);
 }
 
+static inline void
+__gthread_mutex_init_function (__gthread_mutex_t *mutex)
+{
+  if (__gthread_active_p ())
+    pthread_mutex_init (mutex, pthread_mutexattr_default);
+}
+
 static inline int
 __gthread_mutex_lock (__gthread_mutex_t *mutex)
 {
@@ -469,4 +483,6 @@
 
 #endif /* _LIBOBJC */
 
+#undef UNUSED
+
 #endif /* not __gthr_dce_h */



More information about the Gcc-patches mailing list