aboutsummaryrefslogtreecommitdiff
path: root/libgcc/gthr-posix.h
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-03-12 14:23:27 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2012-03-12 14:23:27 +0000
commit33e3e24d74dd21373b4059738a04feda26312f1c (patch)
tree0b5bc7d4e9657ab185aa593ffce407fded974b61 /libgcc/gthr-posix.h
parent24219d389088db7eb34f492e89643a5246ec12a5 (diff)
downloadgcc-33e3e24d74dd21373b4059738a04feda26312f1c.zip
gcc-33e3e24d74dd21373b4059738a04feda26312f1c.tar.gz
gcc-33e3e24d74dd21373b4059738a04feda26312f1c.tar.bz2
re PR gcov-profile/49484 (gcov crash if two(or more) forks happen at the same time)
2012-03-12 Richard Guenther <rguenther@suse.de> * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification. * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define. (__gthread_mutex_init_function): New function. * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define. PR gcov/49484 * libgcov.c: Include gthr.h. (__gcov_flush_mx): New global variable. (init_mx, init_mx_once): New functions. (__gcov_flush): Protect self with a mutex. (__gcov_fork): Re-initialize mutex after forking. * unwind-dw2-fde.c: Change condition under which to use __GTHREAD_MUTEX_INIT_FUNCTION. From-SVN: r185231
Diffstat (limited to 'libgcc/gthr-posix.h')
-rw-r--r--libgcc/gthr-posix.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/libgcc/gthr-posix.h b/libgcc/gthr-posix.h
index a935e92..6c9af1a 100644
--- a/libgcc/gthr-posix.h
+++ b/libgcc/gthr-posix.h
@@ -63,6 +63,7 @@ typedef struct timespec __gthread_time_t;
#define __GTHREAD_HAS_COND 1
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
+#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
@@ -754,6 +755,14 @@ __gthread_mutex_init_function (__gthread_mutex_t *__mutex)
#endif
static inline int
+__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
+{
+ if (__gthread_active_p ())
+ return __gthrw_(pthread_mutex_init) (__mutex, NULL);
+ return 0;
+}
+
+static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())