From patchwork Wed Dec 5 23:13:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: asharif@chromium.org X-Patchwork-Id: 204031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0F64A2C00F3 for ; Thu, 6 Dec 2012 10:13:22 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355354003; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Reply-To:Message-ID:Date:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=bO0z9Xy dOoUg3/2Wb29asFiD4Lw=; b=k+45cDldyzkUQHnqt65eD9yfk2UlbyBLST97BaX y+8nNizkvsxXI52RbXXFkaqqJTMXsvzcoGl6Tb/yIwAPJfArq4Yii5AqzbwCZDN/ OHN8fulA/3mmi+m8t2x0QYpLydxtETwpNS7pdsCxRqvwhdikRGmB9c8pymV0tcgP EUUo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Reply-To:X-Google-Appengine-App-Id:Message-ID:Date:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=l6XK/APbjFE1KCsEJZRQup11lAz/HvT26n4SNblpbKHkloziZGFH2RDaDFHThW JgiByCttBKyyI786dmpHWi/u80PGT6HPkjEAnkpY7IQydXkKGos5/IJWkAwKkfDw 8VjEbSW+UqJGoIgp8mh3pvgbW3FC5bTyGefOcSy2nQOhk=; Received: (qmail 15215 invoked by alias); 5 Dec 2012 23:13:17 -0000 Received: (qmail 15201 invoked by uid 22791); 5 Dec 2012 23:13:15 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-qa0-f69.google.com (HELO mail-qa0-f69.google.com) (209.85.216.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Dec 2012 23:13:08 +0000 Received: by mail-qa0-f69.google.com with SMTP id o19so141525qap.8 for ; Wed, 05 Dec 2012 15:13:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.58.85.106 with SMTP id g10mr6737768vez.2.1354749186964; Wed, 05 Dec 2012 15:13:06 -0800 (PST) Reply-To: asharif@chromium.org, xur@google.com, davidxl@google.com, gcc-patches@gcc.gnu.org, reply@codereview-hr.appspotmail.com X-Google-Appengine-App-Id: s~codereview-hr Message-ID: <047d7bacbc480c832a04d02320a7@google.com> Date: Wed, 05 Dec 2012 23:13:06 +0000 Subject: Backported r185231 from trunk to google/gcc-4_7. (issue 6888044) From: asharif@chromium.org To: xur@google.com, davidxl@google.com Cc: gcc-patches@gcc.gnu.org, reply@codereview-hr.appspotmail.com Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Reviewers: xur, davidxl, Message: Please take a look at this patch. Description: 2012-03-12 Richard Guenther * 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. Please review this at https://codereview.appspot.com/6888044/ Affected files: M . M gcc M gcc/ChangeLog.google-4_7 M gcc/testsuite/gcc.target/powerpc/ppc-round.c M libgcc/ChangeLog M libgcc/gthr-posix.h M libgcc/gthr-single.h M libgcc/gthr.h M libgcc/libgcov.c M libgcc/unwind-dw2-fde.c M libjava/classpath Property changes on: . Index: gcc/ChangeLog.google-4_7 =================================================================== --- gcc/ChangeLog.google-4_7 (revision 194106) +++ gcc/ChangeLog.google-4_7 (working copy) @@ -1,3 +1,23 @@ +2012-12-03 Ahmad Sharif + + Backport r185231 from trunk. + + 2012-03-12 Richard Guenther + + * 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. + 2010-12-01 Xinliang David Li Backport r194038 from trunk Property changes on: gcc/testsuite/gcc.target/powerpc/ppc-round.c ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk/gcc/testsuite/gcc.target/powerpc/ppc-round.c:r185231 Index: libgcc/gthr-posix.h =================================================================== --- libgcc/gthr-posix.h (revision 194106) +++ libgcc/gthr-posix.h (working copy) @@ -63,6 +63,7 @@ #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 @@ #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 ()) Index: libgcc/gthr.h =================================================================== --- libgcc/gthr.h (revision 194106) +++ libgcc/gthr.h (working copy) @@ -52,11 +52,12 @@ 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. Index: libgcc/gthr-single.h =================================================================== --- libgcc/gthr-single.h (revision 194106) +++ libgcc/gthr-single.h (working copy) @@ -36,6 +36,7 @@ #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)) Index: libgcc/libgcov.c =================================================================== --- libgcc/libgcov.c (revision 194106) +++ libgcc/libgcov.c (working copy) @@ -48,6 +48,7 @@ #include "tm.h" #endif /* __KERNEL__ */ #include "libgcc_tm.h" +#include "gthr.h" #if 1 #define THREAD_PREFIX __thread @@ -759,6 +760,25 @@ 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 (&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. */ @@ -766,8 +786,13 @@ void __gcov_flush (void) { + init_mx_once (); + __gthread_mutex_lock (&__gcov_flush_mx); + gcov_exit (); gcov_clear (); + + __gthread_mutex_unlock (&__gcov_flush_mx); } #else /* __GCOV_KERNEL__ */ @@ -1836,8 +1861,13 @@ 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 Index: libgcc/ChangeLog =================================================================== --- libgcc/ChangeLog (revision 194106) +++ libgcc/ChangeLog (working copy) @@ -1,3 +1,19 @@ +2012-03-12 Richard Guenther + + * 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-10-06 Mark Kettenis * config.host (*-*-openbsd*): Add t-eh-dw2-dip to tmake_file. Index: libgcc/unwind-dw2-fde.c =================================================================== --- libgcc/unwind-dw2-fde.c (revision 194106) +++ libgcc/unwind-dw2-fde.c (working copy) @@ -47,11 +47,10 @@ #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) { @@ -64,8 +63,6 @@ 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. */