This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

PATCH: Re: eh_globals.cc compilation errors with -threads under hpux 10.20


Here is a patch for review to correct various problems related to the
configuration and use of threads with libstdc++-v3.

A new configuration variable, THREADS_FLAGS, is introduced.  This
sets `-pthread' when using posix threads.  The effect on different
backends varies but in general they define _PTHREADS and/or _REENTRANT,
and provide the correct libraries when linking.

The v3 file threads-posix.h is changed to not define _PTHREADS.  This
allows the file to also be used with DCE threads.  Definition of either
_PTHREADS or _REENTRANT by a backend will enable _STL_THREADS.

The changes exposed problems in eh_globals.cc resulting from the eh
merge.  I made changed that enable successful compilation.  However,
these are not fully tested beyond the testing that occurs in the
V3 testsuite.  Note previously this code was not being compiled
at least on i686 linux because gthr-single.h was being included
instead of gthr-posix.h.

I have done a complete bootstrap with these changes under i686 linux
with posix threads and under hppa1.1-hp-hpux10.20 with dce threads.

Issues:

1) Sol2 on sparc and i386 uses `-pthreads'.  Is this a typo or just ...

2) Aix doesn't seem to define either _PTHREADS or _REENTRANT.  How
   does gthr.h include the right header for posix threads?

3) I imagine some further tweaking will be needed.

OK?

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

2001-05-16  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* aclocal.m4: Use threads-posix.h with DCE threads.  New variable
	THREADS_FLAGS.
	* testsuite_flags.in: Add THREADS_FLAGS to CXXFLAGS.
	* config/threads-posix.h (_PTHREAD): Don't define.
	* libsupc++/eh_globals.cc (__cxa_get_globals): Rework following eh
	merge.
	* configure: Rebuilt.

--- aclocal.m4.orig	Wed May 16 13:06:45 2001
+++ aclocal.m4	Fri May 18 12:57:49 2001
@@ -1214,14 +1214,19 @@
 
   dnl Check for thread package actually supported in libstdc++ 
   THREADH=
+  THREADS_FLAGS=
   case "$target_thread_file" in
     no | none | single)
       THREADH=threads-no.h
       ;;
+    dce)
+      THREADH=threads-posix.h
+      ;;
     posix | pthreads)
       THREADH=threads-posix.h
+      THREADS_FLAGS=-pthread
       ;;
-    decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
+    decosf1 | irix | mach | os2 | solaris | win32 | vxworks)
       AC_MSG_WARN(disabling unsupported thread package $target_thread_file)
       THREADH=threads-no.h
       ;;
@@ -1231,6 +1236,7 @@
   esac
 
   AC_LINK_FILES(config/$THREADH, include/bits/c++threads.h)
+  AC_SUBST(THREADS_FLAGS)
   if test $THREADH != threads-no.h; then
     AC_DEFINE(_GLIBCPP_USE_THREADS)
   fi
--- testsuite_flags.in.orig	Wed May 16 13:06:47 2001
+++ testsuite_flags.in	Thu May 17 17:47:37 2001
@@ -50,7 +50,7 @@
       echo ${CXX}
       ;;
     --cxxflags)
-      CXXFLAGS=" -ggdb3 -DDEBUG_ASSERT @SECTION_FLAGS@ @SECTION_LDFLAGS@"
+      CXXFLAGS=" -ggdb3 -DDEBUG_ASSERT @THREADS_FLAGS@ @SECTION_FLAGS@ @SECTION_LDFLAGS@"
       echo ${CXXFLAGS}
       ;;
     *)
--- config/threads-posix.h.orig	Fri Apr 21 16:33:29 2000
+++ config/threads-posix.h	Fri May 18 12:59:57 2001
@@ -48,9 +48,6 @@
 // Defines
 //
 
-// Currently needed for stl/bits/stl_config.h
-# define _PTHREADS
-
 // Currently libio expects this macro
 #define _IO_MTSAFE_IO
 
--- libsupc++/eh_globals.cc.orig	Wed May 16 13:07:50 2001
+++ libsupc++/eh_globals.cc	Fri May 18 10:52:12 2001
@@ -28,7 +28,9 @@
 // the GNU General Public License.
 
 
+#include <bits/c++threads.h>
 #include <exception>
+#include <cstdlib>
 #include "unwind-cxx.h"
 #include "gthr.h"
 
@@ -95,19 +97,14 @@
   g = (__cxa_eh_globals *) __gthread_getspecific (globals_key);
   if (! g)
     {
-      static __gthread_once_t once = __GTHREAD_ONCE_INIT;
-
-      // Make sure use_thread_key got initialized.  Some systems have
-      // dummy thread routines in their libc that return a success.
-      if (__gthread_once (&once, eh_threads_initialize) != 0
-	  || use_thread_key < 0)
+      // Make sure use_thread_key got initialized.
+      if (use_thread_key < 0)
 	{
 	  use_thread_key = 0;
 	  return &globals_static;
 	}
       
-      if ((g = malloc (sizeof (__cxa_eh_globals))) == 0
-	  || __gthread_setspecific (eh_context_key, (void *) g) != 0)
+      if ((g = (__cxa_eh_globals *) malloc (sizeof (__cxa_eh_globals))) == 0)
         std::terminate ();
       g->caughtExceptions = 0;
       g->uncaughtExceptions = 0;


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