aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sharif <asharif@google.com>2012-05-01 21:22:47 +0000
committerAhmad Sharif <asharif@google.com>2012-05-01 21:22:47 +0000
commit1325d798442d46bf98707435af47b25c02735736 (patch)
treeb7acc43db8ee20d48069a1e28912eb55e1eb023e
parent8ea7a7392cc915278da347aa3d65398ba4289ad7 (diff)
Backported r185231 from trunk.
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. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/google/gcc-4_6@187026 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.google-4_619
-rw-r--r--gcc/gthr-posix.h8
-rw-r--r--gcc/gthr-single.h1
-rw-r--r--gcc/gthr.h9
-rw-r--r--gcc/libgcov.c32
-rw-r--r--gcc/unwind-dw2-fde.c5
-rw-r--r--libgcc/ChangeLog16
7 files changed, 81 insertions, 9 deletions
diff --git a/gcc/ChangeLog.google-4_6 b/gcc/ChangeLog.google-4_6
index 13fe672dd66..2d5046e8aa5 100644
--- a/gcc/ChangeLog.google-4_6
+++ b/gcc/ChangeLog.google-4_6
@@ -1,3 +1,22 @@
+2012-02-21 Ahmad Sharif <asharif@google.com>
+
+ Backport from mainline r185231.
+ 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.
+
2012-04-25 Rong Xu <xur@google.com>
* gcc/gcc.c (ripa_lto_spec): Support -S in streaming LIPO.
diff --git a/gcc/gthr-posix.h b/gcc/gthr-posix.h
index ecb06e2f4cb..6537819283a 100644
--- a/gcc/gthr-posix.h
+++ b/gcc/gthr-posix.h
@@ -54,6 +54,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
@@ -726,6 +727,13 @@ __gthread_setspecific (__gthread_key_t __key, const void *__ptr)
return __gthrw_(pthread_setspecific) (__key, __ptr);
}
+static inline void
+__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
+{
+ if (__gthread_active_p ())
+ __gthrw_(pthread_mutex_init) (__mutex, NULL);
+}
+
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
{
diff --git a/gcc/gthr-single.h b/gcc/gthr-single.h
index 357528ad1f1..4e396797785 100644
--- a/gcc/gthr-single.h
+++ b/gcc/gthr-single.h
@@ -36,6 +36,7 @@ typedef int __gthread_recursive_mutex_t;
#define __GTHREAD_ONCE_INIT 0
#define __GTHREAD_MUTEX_INIT 0
+#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
#define UNUSED __attribute__((unused))
diff --git a/gcc/gthr.h b/gcc/gthr.h
index f4dd96b9e3a..3f52cbea84f 100644
--- a/gcc/gthr.h
+++ b/gcc/gthr.h
@@ -51,11 +51,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
to initialize __gthread_mutex_t to get a fast
non-recursive mutex.
__GTHREAD_MUTEX_INIT_FUNCTION
- some systems can't initialize a mutex without a
- function call. On such systems, define this to a
- function which looks like this:
+ to initialize __gthread_mutex_t to get a fast
+ non-recursive mutex.
+ Define this to a function which looks like this:
void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
- Don't define __GTHREAD_MUTEX_INIT in this case
+ Some systems can't initialize a mutex without a
+ function call. Don't define __GTHREAD_MUTEX_INIT in this case.
__GTHREAD_RECURSIVE_MUTEX_INIT
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
as above, but for a recursive mutex.
diff --git a/gcc/libgcov.c b/gcc/libgcov.c
index 140c8b1eb96..10a7d564493 100644
--- a/gcc/libgcov.c
+++ b/gcc/libgcov.c
@@ -46,6 +46,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "tsystem.h"
#include "coretypes.h"
#include "tm.h"
+#include "gthr.h"
#endif /* __KERNEL__ */
#if 1
@@ -667,6 +668,26 @@ __gcov_init (struct gcov_info *info)
info->version = 0;
}
+#ifdef __GTHREAD_MUTEX_INIT
+ATTRIBUTE_HIDDEN __gthread_mutex_t __gcov_flush_mx = __GTHREAD_MUTEX_INIT;
+#define init_mx_once()
+#else
+__gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN;
+
+static void
+init_mx (void)
+{
+ __GTHREAD_MUTEX_INIT_FUNCTION (&__gcov_flush_mx);
+}
+static void
+init_mx_once (void)
+{
+ static __gthread_once_t once = __GTHREAD_ONCE_INIT;
+ __gthread_once (&once, init_mx);
+}
+#endif
+
+
/* Called before fork or exec - write out profile information gathered so
far and reset it to zero. This avoids duplication or loss of the
profile information gathered so far. */
@@ -676,6 +697,9 @@ __gcov_flush (void)
{
const struct gcov_info *gi_ptr;
+ init_mx_once ();
+ __gthread_mutex_lock (&__gcov_flush_mx);
+
__gcov_stop_pmu_profiler ();
gcov_exit ();
for (gi_ptr = __gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
@@ -691,6 +715,7 @@ __gcov_flush (void)
}
}
__gcov_start_pmu_profiler ();
+ __gthread_mutex_unlock (&__gcov_flush_mx);
}
#else /* __GCOV_KERNEL__ */
@@ -1756,8 +1781,13 @@ __gcov_ior_profiler (gcov_type *counters, gcov_type value)
pid_t
__gcov_fork (void)
{
+ pid_t pid;
+ extern __gthread_mutex_t __gcov_flush_mx;
__gcov_flush ();
- return fork ();
+ pid = fork ();
+ if (pid == 0)
+ __GTHREAD_MUTEX_INIT_FUNCTION (&__gcov_flush_mx);
+ return pid;
}
#endif
diff --git a/gcc/unwind-dw2-fde.c b/gcc/unwind-dw2-fde.c
index 93d427165c4..b95417d42b5 100644
--- a/gcc/unwind-dw2-fde.c
+++ b/gcc/unwind-dw2-fde.c
@@ -46,11 +46,10 @@ static struct object *seen_objects;
#ifdef __GTHREAD_MUTEX_INIT
static __gthread_mutex_t object_mutex = __GTHREAD_MUTEX_INIT;
+#define init_object_mutex_once()
#else
static __gthread_mutex_t object_mutex;
-#endif
-#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
static void
init_object_mutex (void)
{
@@ -63,8 +62,6 @@ init_object_mutex_once (void)
static __gthread_once_t once = __GTHREAD_ONCE_INIT;
__gthread_once (&once, init_object_mutex);
}
-#else
-#define init_object_mutex_once()
#endif
/* Called from crtbegin.o to register the unwind info for an object. */
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 1314669099a..196b2f8b856 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,19 @@
+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.
+
2012-03-01 Release Manager
* GCC 4.6.3 released.