From patchwork Mon Apr 30 19:54:15 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: 155953 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 B4A52B6F9D for ; Tue, 1 May 2012 05:54:41 +1000 (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=1336420482; 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=2QvFkzY pUiGrFqRdQ0sm2tLj4Is=; b=vtIXfZ7yuZHuk7dec38f5o31zXuI9Hx00IrKSXL 61PDrzmR6Z7jj3CEmn5ni1VARPcqK5IeX8prXrzdkW8h+1DyE+yeIfMcuwZQXx4u F0AgGfjTA2XRC/U4gW4ievJNsUjYj9QGUNX81f3RfyhfocACWBmM0Ua2F5xQpJQg R0Kk= 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:X-Google-DKIM-Signature:MIME-Version:Received:Reply-To:X-Google-Appengine-App-Id:Message-ID:Date:Subject:From:To:Cc:Content-Type:X-Gm-Message-State:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=xWUpb9z6wToQbCt2esxMu6rIY7jCgh4pQ2kVLyRO/t45tPQPYSVM6HnFLhgqs4 D6CHaMUcyG+ey4lLen3BLgslRTKMUjOk1MxDs6x+6rUMUfTXEfGLPE2I4gDbfoZj K7yQFGviZNFsgUGzfPBMuUJ2j1266j/50ykHtuF5wKdlo=; Received: (qmail 9622 invoked by alias); 30 Apr 2012 19:54:34 -0000 Received: (qmail 9604 invoked by uid 22791); 30 Apr 2012 19:54:31 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vb0-f69.google.com (HELO mail-vb0-f69.google.com) (209.85.212.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Apr 2012 19:54:17 +0000 Received: by vbjk13 with SMTP id k13so5552036vbj.8 for ; Mon, 30 Apr 2012 12:54:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:reply-to:x-google-appengine-app-id:message-id:date :subject:from:to:cc:content-type:x-gm-message-state; bh=NEhFQJ2611hTdMhu12ifnSkxgvhKSV7BDRiIDqC5dQM=; b=XjizA14eSLhOgEzrtwQX4mZdB4FtiuY669ZPwsyewYNvACsXM7eoQGBTSXGf2fxEaM 4JlzBwQXuQ+tEI2gGlrToD2f5imxIwMADLnhslfR1IFynziBhvKlWR6YvDIDdmgWuZfj 0KLYythDH442MZjw5z+bW14ClJsS8eI0Yo1I96NpTNPE2HihjZTWP3WrWuVN9Qh6du2r 6U0v81C3UaYz59ysHRoMltkzB5yAL7aXzJ0x+G9YGbWPaidWkL5yJl7EAKFGXeS4h8La bRe1NiNOouXFgZ+q0/d7T2k7rvx0sE9eKNFjUsAyfv6cXl+6tkzRiilP7vrYTcJQbqRE 9lXA== MIME-Version: 1.0 Received: by 10.101.133.8 with SMTP id k8mr9340219ann.19.1335815655661; Mon, 30 Apr 2012 12:54:15 -0700 (PDT) Reply-To: asharif@chromium.org, xur@google.com, davidxl@google.com, iant@google.com, bjanakiraman@google.com, gcc-patches@gcc.gnu.org, reply@codereview-hr.appspotmail.com X-Google-Appengine-App-Id: s~codereview-hr Message-ID: <0016e6d26774a42c5204beead18a@google.com> Date: Mon, 30 Apr 2012 19:54:15 +0000 Subject: Backported r185231 from trunk. (issue 6139063) From: asharif@chromium.org To: xur@google.com, davidxl@google.com, iant@google.com Cc: bjanakiraman@google.com, gcc-patches@gcc.gnu.org, reply@codereview-hr.appspotmail.com X-Gm-Message-State: ALoCoQk+2xxOoYYF/4Q4hZuYQD0EkC0eJACPB59kYL0gxw+vsTMOMbPYOohUKtpK++m1oEHDl9Jw 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, iant2, Message: I backported the following patch: 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 http://codereview.appspot.com/6139063/ Affected files: M . M gcc/ChangeLog.google-4_6 M gcc/gthr-posix.h M gcc/gthr-single.h M gcc/gthr.h M gcc/libgcov.c M gcc/unwind-dw2-fde.c M libgcc/ChangeLog Index: . =================================================================== --- . (revision 186999) +++ . (working copy) Property changes on: . Index: libgcc/ChangeLog =================================================================== --- libgcc/ChangeLog (revision 186999) +++ 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-03-01 Release Manager * GCC 4.6.3 released. Index: gcc/unwind-dw2-fde.c =================================================================== --- gcc/unwind-dw2-fde.c (revision 186999) +++ gcc/unwind-dw2-fde.c (working copy) @@ -46,11 +46,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) { @@ -63,8 +62,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. */ Index: gcc/ChangeLog.google-4_6 =================================================================== --- gcc/ChangeLog.google-4_6 (revision 186999) +++ gcc/ChangeLog.google-4_6 (working copy) @@ -1,3 +1,22 @@ +2012-02-21 Ahmad Sharif + + Backport from mainline r185231. + 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-04-25 Rong Xu * gcc/gcc.c (ripa_lto_spec): Support -S in streaming LIPO. Index: gcc/libgcov.c =================================================================== --- gcc/libgcov.c (revision 186999) +++ gcc/libgcov.c (working copy) @@ -46,6 +46,7 @@ #include "tsystem.h" #include "coretypes.h" #include "tm.h" +#include "gthr.h" #endif /* __KERNEL__ */ #if 1 @@ -667,6 +668,26 @@ 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 @@ { 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_start_pmu_profiler (); + __gthread_mutex_unlock (&__gcov_flush_mx); } #else /* __GCOV_KERNEL__ */ @@ -1756,8 +1781,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: gcc/gthr-posix.h =================================================================== --- gcc/gthr-posix.h (revision 186999) +++ gcc/gthr-posix.h (working copy) @@ -54,6 +54,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 @@ -726,6 +727,13 @@ 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) { Index: gcc/gthr-single.h =================================================================== --- gcc/gthr-single.h (revision 186999) +++ gcc/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: gcc/gthr.h =================================================================== --- gcc/gthr.h (revision 186999) +++ gcc/gthr.h (working copy) @@ -51,11 +51,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.