diff options
author | ljrittle <ljrittle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-08 03:53:35 +0000 |
---|---|---|
committer | ljrittle <ljrittle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-08 03:53:35 +0000 |
commit | 6e77e3236833da984422d1c758e9d3188d9925c7 (patch) | |
tree | b2cbfba3edc6eab1c6b67a4c3000514516e6ca14 /libstdc++-v3/include/bits | |
parent | ff09141288889ce509849b1ce77b549f23b54831 (diff) | |
download | gcc-6e77e3236833da984422d1c758e9d3188d9925c7.tar.gz |
* config/threads-no.h: Remove file.
* config/threads-posix.h: Remove file.
* acconfig.h (_GLIBCPP_USE_THREADS): Remove.
(_GLIBCPP_SUPPORTS_WEAK): Add (required by namespace-clean gthr*.h).
(_GLIBCPP_HAVE_GTHR_DEFAULT): Likewise.
* config.h.in: Regenerate.
* acinclude.m4 (GLIBCPP_ENABLE_THREADS): Completely rework to
setup and use gthr*.h files. In particular, make gthr.h files
namespace-clean in the staging area (they don't have to be for
libgcc.a).
* aclocal.m4: Regenerate.
* configure: Regenerate.
* src/Makefile.am (build_headers): Remove bits/c++threads.h
and add bits/gthr.h bits/gthr-single.h bits/gthr-default.h.
* src/Makefile.in: Regenerate.
* include/bits/c++config: Cleanup threading configuration macros.
In particular, define __STL_GTHREADS macro which controls...
* include/bits/stl_threads.h: ...a brand new gthr.h-based
configuration here.
* config/c_io_stdio.h: Include staged gthr.h instead of local
thread configuration file. Always use __gthread_mutex_t
instead of __mutext_type (or int).
* include/bits/std_fstream.h: Likewise.
* docs/html/17_intro/howto.html: Remove placeholder comment in
case this configuration patch didn't make it. Add advice that
section only applies if configured with --enable-threads.
* docs/html/23_containers/howto.html: Reword to make clear
that _PTHREADS is no longer required for any port to be
correctly using STL with threads. Add advice that section
only applies if configured with --enable-threads.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42998 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits')
-rw-r--r-- | libstdc++-v3/include/bits/c++config | 31 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/std_fstream.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_threads.h | 91 |
3 files changed, 103 insertions, 21 deletions
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index d3d99baa926..763c917b8ef 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -62,26 +62,17 @@ // Enable concept checking code from the boost libraries. //#define _GLIBCPP_CONCEPT_CHECKS 1 -// From SGI's stl_config.h; generic settings and user hooks (_NOTHREADS). -#ifdef _REENTRANT -# define __STL_THREADS -#endif - -#if defined(_PTHREADS) && !defined(_NOTHREADS) -# define __STL_PTHREADS -#endif - -#if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS) -# define __STL_UITHREADS -#endif - -#if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \ - || defined(__STL_PTHREADS) || defined(__STL_UITHREADS) -# define __STL_THREADS -# define __STL_VOLATILE volatile -#else -# define __STL_VOLATILE -#endif +// Map gthr.h abstraction to that required for STL. Do not key off of +// __GTHREADS at this point since we haven't seen the correct symbol +// yet, instead setup so that include/bits/stl_threads.h will know to +// include gthr.h instead of any other type of thread support. Note: +// that gthr.h may well map to gthr-single.h which is a correct way to +// express no threads support in gcc. As a user, do not define +// _NOTHREADS without consideration of the consequences (e.g. it is an +// internal ABI change). +#define __STL_GTHREADS +#define __STL_THREADS +#define __STL_VOLATILE volatile // This is also a user hook, but via -f[no-]exceptions, not direct #defines. #ifdef __EXCEPTIONS diff --git a/libstdc++-v3/include/bits/std_fstream.h b/libstdc++-v3/include/bits/std_fstream.h index a06721f6cf8..a0604abbe0d 100644 --- a/libstdc++-v3/include/bits/std_fstream.h +++ b/libstdc++-v3/include/bits/std_fstream.h @@ -40,7 +40,7 @@ #include <bits/std_ostream.h> #include <bits/basic_file.h> #include <bits/std_locale.h> // For codecvt -#include <bits/c++threads.h> // For __mutext_type +#include <bits/gthr.h> namespace std { diff --git a/libstdc++-v3/include/bits/stl_threads.h b/libstdc++-v3/include/bits/stl_threads.h index e869a3fc21d..21f47225320 100644 --- a/libstdc++-v3/include/bits/stl_threads.h +++ b/libstdc++-v3/include/bits/stl_threads.h @@ -24,6 +24,15 @@ // threads standard), and Win32 threads. Uithread support by Jochen // Schlick, 1999. +// GCC extension begin +// In order to present a stable threading configuration, in all cases, +// gcc looks for it's own abstraction layer before all others. All +// modifications to this file are marked to allow easier importation of +// STL upgrades. +#if defined(__STL_GTHREADS) +#include "bits/gthr.h" +#else +// GCC extension end #if defined(__STL_SGI_THREADS) #include <mutex.h> #include <time.h> @@ -35,6 +44,9 @@ #elif defined(__STL_WIN32THREADS) #include <windows.h> #endif +// GCC extension begin +#endif +// GCC extension end namespace std { @@ -64,6 +76,22 @@ struct _Refcount_Base volatile _RC_t _M_ref_count; // Constructor +// GCC extension begin +#ifdef __STL_GTHREADS + __gthread_mutex_t _M_ref_count_lock; + _Refcount_Base(_RC_t __n) : _M_ref_count(__n) + { +#ifdef __GTHREAD_MUTEX_INIT + __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT; + _M_ref_count_lock = __tmp; +#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION) + __GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock); +#else +#error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.gnu.org. +#endif + } +#else +// GCC extension end # ifdef __STL_PTHREADS pthread_mutex_t _M_ref_count_lock; _Refcount_Base(_RC_t __n) : _M_ref_count(__n) @@ -75,7 +103,25 @@ struct _Refcount_Base # else _Refcount_Base(_RC_t __n) : _M_ref_count(__n) {} # endif +// GCC extension begin +#endif +// GCC extension end +// GCC extension begin +#ifdef __STL_GTHREADS + void _M_incr() { + __gthread_mutex_lock(&_M_ref_count_lock); + ++_M_ref_count; + __gthread_mutex_unlock(&_M_ref_count_lock); + } + _RC_t _M_decr() { + __gthread_mutex_lock(&_M_ref_count_lock); + volatile _RC_t __tmp = --_M_ref_count; + __gthread_mutex_unlock(&_M_ref_count_lock); + return __tmp; + } +#else +// GCC extension end // _M_incr and _M_decr # ifdef __STL_SGI_THREADS void _M_incr() { __add_and_fetch(&_M_ref_count, 1); } @@ -111,12 +157,24 @@ struct _Refcount_Base void _M_incr() { ++_M_ref_count; } _RC_t _M_decr() { return --_M_ref_count; } # endif +// GCC extension begin +#endif +// GCC extension end }; // Atomic swap on unsigned long // This is guaranteed to behave as though it were atomic only if all // possibly concurrent updates use _Atomic_swap. // In some cases the operation is emulated with a lock. +// GCC extension begin +#ifdef __STL_GTHREADS +// We don't provide an _Atomic_swap in this configuration. This only +// affects the use of ext/rope with threads. Someone could add this +// later, if required. You can start by cloning the __STL_PTHREADS +// path while making the obvious changes. Later it could be optimized +// to use the atomicity.h abstraction layer from libstdc++-v3. +#else +// GCC extension end # ifdef __STL_SGI_THREADS inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) { # if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) @@ -205,6 +263,9 @@ struct _Refcount_Base return __result; } # endif +// GCC extension begin +#endif +// GCC extension end // Locking class. Note that this class *does not have a constructor*. // It must be initialized either statically, with __STL_MUTEX_INITIALIZER, @@ -237,6 +298,21 @@ unsigned _STL_mutex_spin<__inst>::__last = 0; struct _STL_mutex_lock { +// GCC extension begin +#if defined(__STL_GTHREADS) + __gthread_mutex_t _M_lock; + void _M_initialize() + { +#ifdef __GTHREAD_MUTEX_INIT + // There should be no code in this path given the usage rules above. +#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION) + __GTHREAD_MUTEX_INIT_FUNCTION (&_M_lock); +#endif + } + void _M_acquire_lock() { __gthread_mutex_lock(&_M_lock); } + void _M_release_lock() { __gthread_mutex_unlock(&_M_lock); } +#else +// GCC extension end #if defined(__STL_SGI_THREADS) || defined(__STL_WIN32THREADS) // It should be relatively easy to get this to work on any modern Unix. volatile unsigned long _M_lock; @@ -330,8 +406,20 @@ struct _STL_mutex_lock void _M_acquire_lock() {} void _M_release_lock() {} #endif +// GCC extension begin +#endif +// GCC extension end }; +// GCC extension begin +#if defined(__STL_GTHREADS) +#ifdef __GTHREAD_MUTEX_INIT +#define __STL_MUTEX_INITIALIZER = { __GTHREAD_MUTEX_INIT } +#else +#define __STL_MUTEX_INITIALIZER +#endif +#else +// GCC extension end #ifdef __STL_PTHREADS // Pthreads locks must be statically initialized to something other than // the default value of zero. @@ -345,6 +433,9 @@ struct _STL_mutex_lock #else # define __STL_MUTEX_INITIALIZER #endif +// GCC extension begin +#endif +// GCC extension end // A locking class that uses _STL_mutex_lock. The constructor takes a |