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

John David Anglin dave@hiauly1.hia.nrc.ca
Wed May 23 15:45:00 GMT 2001


> > Or, at least, if you do, to get the effect you desire, you need to
> > define IN_GCC which is a complete lie and libstdc++-v3 would be the
> > first library to do that...

Here how thing stand.  Thoughts?  I know there are more testsuite errors
than before under i686 linux and I don't know why.  On the otherhand,
we weren't reaaly using the posix thread stuff.

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

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

	* gthr-posix.h (__gthread_active_ptr): Add cast for C++.

--- gthr-posix.h.orig	Fri May 18 21:34:11 2001
+++ gthr-posix.h	Wed May 23 17:01:31 2001
@@ -75,7 +75,7 @@
 #pragma weak pthread_setschedparam
 #endif
 
-static void *__gthread_active_ptr = &pthread_create;
+static void *__gthread_active_ptr = (void *) &pthread_create;
 
 static inline int
 __gthread_active_p (void)
------------------------------------Cut----------------------------------------

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

	* aclocal.m4 (GLIBCPP_ENABLE_THREADS): Use threads-dce.h with DCE
	threads.
	(GLIBCPP_GTHREAD_FLAGS): New macro.
	* configure.in: Run GLIBCPP_GTHREAD_FLAGS.
	* config/dce-threads.h: New file.
	* libsupc++/Makefile.am (INCLUDES): Add source gcc/config and build
	gcc directories to list.
	(GTHREAD_FLAGS): Define.
	(ALL_CFLAGS): Add GTHREAD_FLAGS to list.
	* libsupc++/eh_alloc.cc: Include tconfig.h.
	* libsupc++/eh_globals.cc: Include tconfig.h.
	(__cxa_get_globals): Rework following eh merge.
	* libsupc++/Makefile.in: Rebuild with automake.
	* configure: Rebuild.

--- aclocal.m4.orig	Sat May 19 22:51:52 2001
+++ aclocal.m4	Wed May 23 16:36:35 2001
@@ -1218,10 +1218,13 @@
     no | none | single)
       THREADH=threads-no.h
       ;;
+    dce)
+      THREADH=threads-dce.h
+      ;;
     posix | pthreads)
       THREADH=threads-posix.h
       ;;
-    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
       ;;
@@ -1234,6 +1237,22 @@
   if test $THREADH != threads-no.h; then
     AC_DEFINE(_GLIBCPP_USE_THREADS)
   fi
+])
+
+
+dnl
+dnl Determine CFLAGS for gthread.  Note, $r is set by the top-level Makefile.
+dnl
+AC_DEFUN(GLIBCPP_GTHREAD_FLAGS, [
+  AC_CACHE_CHECK([for gthread cflags],glibcpp_cv_gthread_flags,
+  [if test -f "$r"/gcc/Makefile
+  then
+    glibcpp_cv_gthread_flags=`grep \^GTHREAD_FLAGS "$r"/gcc/Makefile | awk -F= '{ print $(2) }'`
+  else
+    AC_MSG_ERROR([not found])
+  fi])
+GTHREAD_FLAGS=$glibcpp_cv_gthread_flags
+AC_SUBST(GTHREAD_FLAGS)
 ])
 
 
--- configure.in.orig	Fri May 18 21:45:51 2001
+++ configure.in	Wed May 23 15:33:45 2001
@@ -68,6 +68,7 @@
 GLIBCPP_ENABLE_LONG_LONG([yes])
 GLIBCPP_ENABLE_CHEADERS([c_std])
 GLIBCPP_ENABLE_THREADS
+GLIBCPP_GTHREAD_FLAGS
 GLIBCPP_ENABLE_CXX_FLAGS([none])
 GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
 
--- /dev/null	Fri Jun 30 18:48:12 2000
+++ config/threads-dce.h	Wed May 23 17:15:22 2001
@@ -0,0 +1,91 @@
+// thread support (dce case)  -*- C++ -*-
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// threads-dce.h - Defines for using dce threads.
+
+// People trying to implement this should look at
+// libjava/include/posix-threads.h for more info on the interface that
+// java is using. It's one worth looking at.
+
+#ifndef _CPP_THREADS_DCE
+#define _CPP_THREADS_DCE
+
+#include <bits/c++config.h>
+
+//
+// Includes
+//
+#include <pthread.h>
+
+
+//
+// Defines
+//
+
+// Currently needed for stl/bits/stl_config.h
+# define _PTHREADS
+
+// Currently libio expects this macro
+#define _IO_MTSAFE_IO
+
+// May be needed on solaris.
+//#define PTHREAD_MUTEX_INITIALIZER {{{0},0},{{{0}}},{0}}
+
+
+//
+// Typedefs.
+//
+namespace std {
+  typedef  pthread_mutex_t	__mutext_type;
+} // std
+
+
+//
+// Condition variables.
+//
+
+
+//
+// Mutexes.
+//
+
+
+//
+// Thread creation and manipulation.
+//
+
+#endif // _CPP_THREADS_DCE
+
+
+
+
+
+
+
+
--- libsupc++/Makefile.am.orig	Fri May 18 21:47:11 2001
+++ libsupc++/Makefile.am	Wed May 23 16:54:02 2001
@@ -54,6 +54,9 @@
 WARN_CXXFLAGS = \
 	@WARN_FLAGS@ $(WERROR) -fdiagnostics-show-location=once
 
+# Thread flags to use.
+GTHREAD_FLAGS = -DIN_GCC -DIN_TARGET_LIBS @GTHREAD_FLAGS@
+
 # Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
 GLIBCPP_INCLUDE_DIR = @GLIBCPP_INCLUDE_DIR@
 C_INCLUDE_DIR = @C_INCLUDE_DIR@
@@ -64,9 +67,10 @@
 TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
 
 INCLUDES = \
-	-I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include \
-	-I$(GLIBCPP_INCLUDE_DIR) $(CSTD_INCLUDES) -I$(top_builddir)/include \
-	 $(LIBSUPCXX_INCLUDES)
+	-I$(toplevel_srcdir)/gcc  -I$(toplevel_srcdir)/gcc/config \
+	-I$(toplevel_srcdir)/include -I$(GLIBCPP_INCLUDE_DIR) \
+	$(CSTD_INCLUDES) -I$(top_builddir)/include \
+	-I$(MULTIBUILDTOP)../../../gcc $(LIBSUPCXX_INCLUDES)
 
 headers = \
 	exception new typeinfo cxxabi.h exception_defines.h 
@@ -112,6 +116,7 @@
 	$(LIBSUPCXX_CXXFLAGS) \
 	$(WARN_CXXFLAGS) \
 	$(OPTIMIZE_CXXFLAGS) \
+	$(GTHREAD_FLAGS) \
 	$(CONFIG_CXXFLAGS) 
 
 # libstdc++ libtool notes
--- libsupc++/eh_alloc.cc.orig	Fri May 18 21:47:12 2001
+++ libsupc++/eh_alloc.cc	Wed May 23 16:47:31 2001
@@ -30,6 +30,7 @@
 // This is derived from the C++ ABI for IA-64.  Where we diverge
 // for cross-architecture compatibility are noted with "@@@".
 
+#include "tconfig.h"
 #include <exception>
 #include <cstdlib>
 #include <cstring>
--- libsupc++/eh_globals.cc.orig	Fri May 18 21:47:12 2001
+++ libsupc++/eh_globals.cc	Wed May 23 14:58:53 2001
@@ -28,7 +28,9 @@
 // the GNU General Public License.
 
 
+#include "tconfig.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;



More information about the Libstdc++ mailing list