aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoren J. Rittle <ljrittle@acm.org>2003-06-24 06:34:34 +0000
committerLoren J. Rittle <ljrittle@gcc.gnu.org>2003-06-24 06:34:34 +0000
commit3d57d7bafa6c6e503c04fe234d996103b5e3e06c (patch)
tree0be11284ee79b07a95dc0f66a15c38c017d1d2a0
parentd46c570d55159311fc749bb7609e1b1ddf22a2d5 (diff)
downloadgcc-3d57d7bafa6c6e503c04fe234d996103b5e3e06c.zip
gcc-3d57d7bafa6c6e503c04fe234d996103b5e3e06c.tar.gz
gcc-3d57d7bafa6c6e503c04fe234d996103b5e3e06c.tar.bz2
* include/ext/mt_allocator.h: Portability.
From-SVN: r68406
-rw-r--r--libstdc++-v3/ChangeLog2
-rw-r--r--libstdc++-v3/include/ext/mt_allocator.h16
2 files changed, 11 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e2c9ce9..c1acd15 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -7,6 +7,8 @@
* config/abi/alpha-freebsd5/baseline_symbols.txt: New file.
* config/abi/sparc-freebsd5/baseline_symbols.txt: New file.
+ * include/ext/mt_allocator.h: Portability.
+
2003-06-23 Benjamin Kosnik <bkoz@redhat.com>
* docs/html/17_intro/libstdc++-assign.txt: Update address.
diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h
index 1e95b55..cd3b273 100644
--- a/libstdc++-v3/include/ext/mt_allocator.h
+++ b/libstdc++-v3/include/ext/mt_allocator.h
@@ -613,13 +613,15 @@ namespace __gnu_cxx
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);
+#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++)