This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
PATCH (libstdc++-v3): Address non-portability comment on recent submission
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Jun 2003 01:34:39 -0500 (CDT)
- Subject: PATCH (libstdc++-v3): Address non-portability comment on recent submission
- Reply-to: rittle at labs dot mot dot com
Regarding the removed comment, this solution idiom was discussed at
the time I made a similar fix to the rope implementation. I'd rather
have this in ext code than explicit use of pthread_mutex_init. For
one, some ports need (e.g.) -pthread even when linking single-threaded
code when the mutex is initialized by the function. For two, it is an
abstraction violation. Committed under general maintainer hat "as
obvious". (For the record: only tested under check-performance rule,
which I was porting to *-*-freebsd* at the time I found it, not full
bootstrap/check.)
* include/ext/mt_allocator.h: Portability.
Index: libstdc++-v3/include/ext/mt_allocator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/mt_allocator.h,v
retrieving revision 1.1
diff -c -r1.1 mt_allocator.h
*** libstdc++-v3/include/ext/mt_allocator.h 11 Jun 2003 15:52:10 -0000 1.1
--- libstdc++-v3/include/ext/mt_allocator.h 24 Jun 2003 06:08:16 -0000
***************
*** 613,625 ****
if (!_S_bin[bin].mutex)
__throw_bad_alloc();
! /*
! * This is not only ugly - it's extremly non-portable!
! * However gthr.h does not currently provide a
! * __gthread_mutex_init() call. The correct solution to
! * this problem needs to be discussed.
! */
! pthread_mutex_init(_S_bin[bin].mutex, NULL);
#endif
for (size_t thread = 0; thread <= _S_max_threads; thread++)
--- 613,627 ----
if (!_S_bin[bin].mutex)
__throw_bad_alloc();
! #ifdef __GTHREAD_MUTEX_INIT
! {
! // Do not copy a POSIX/gthr mutex once in use.
! __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
! *_S_bin[bin].mutex = __tmp;
! }
! #else
! { __GTHREAD_MUTEX_INIT_FUNCTION (_S_bin[bin].mutex); }
! #endif
#endif
for (size_t thread = 0; thread <= _S_max_threads; thread++)