PATCH: Fix v3 issues and bootstrap failure caused by gthr-dce.h

John David Anglin dave@hiauly1.hia.nrc.ca
Tue Jun 12 20:52:00 GMT 2001


This is for the 3.0 branch to fix a bootstrap failure compiling src/eh_alloc.cc
under hpux 10.20, and to augment the defines for v3 thread operation.  A PR
has been submitted for the bootstrap failure.  This patch is a further
update to one previously submitted to correct the bootstrap failure and
v3 issues.  This patch introduces the initializer __GTHREAD_MUTEX_INIT_DEFAULT
which is used for initializations of structs with mutex members.

Previously, only posix threads were useable with libstdc++.  The support
of GTHREADs for exceptions and STL threads in the v3 library now makes 
it possible for a much wider class of systems to make use of these
features.

This patch has gone through several weeks of testing during the development
and testing of the v3 thread fixes by Lorne Riddle and myself.  Hpux 10.X
is the only system to use gthr-dce.h.  Thus, the risk of this patch is
limited.  Part of this patch has been on the main for a month.

OK?

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

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

	* gthr-dce.h (UNUSED): Attribute unused macro.
	(__GTHREAD_MUTEX_INIT_FUNCTION and __GTHREAD_MUTEX_INIT_DEFAULT): New
	macros for mutex initialization.
	(__gthread_key_dtor): Make arguments UNUSED.
	(__gthread_key_delete): Unsupported.  Argument UNUSED.
	(__gthread_mutex_init_function): New function for mutex initialization.

--- gthr-dce.h.orig	Sat Jun  9 16:07:21 2001
+++ gthr-dce.h	Tue Jun 12 21:23:21 2001
@@ -1,6 +1,6 @@
 
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -37,12 +37,21 @@
 
 #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
+
+#define __GTHREAD_MUTEX_INIT_DEFAULT pthread_once_init
 
 #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
 
@@ -53,7 +62,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 +76,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 +420,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 +449,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 +485,6 @@
 
 #endif /* _LIBOBJC */
 
+#undef UNUSED
+
 #endif /* not __gthr_dce_h */



More information about the Gcc-patches mailing list