From patchwork Fri Jul 2 19:49:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 57764 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 F3EAD1007D2 for ; Sat, 3 Jul 2010 05:49:56 +1000 (EST) Received: (qmail 4528 invoked by alias); 2 Jul 2010 19:49:53 -0000 Received: (qmail 4509 invoked by uid 22791); 2 Jul 2010 19:49:52 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Jul 2010 19:49:47 +0000 Received: from wpaz5.hot.corp.google.com (wpaz5.hot.corp.google.com [172.24.198.69]) by smtp-out.google.com with ESMTP id o62JniVm002687 for ; Fri, 2 Jul 2010 12:49:44 -0700 Received: from pwi3 (pwi3.prod.google.com [10.241.219.3]) by wpaz5.hot.corp.google.com with ESMTP id o62Jngx8029268 for ; Fri, 2 Jul 2010 12:49:43 -0700 Received: by pwi3 with SMTP id 3so440268pwi.21 for ; Fri, 02 Jul 2010 12:49:42 -0700 (PDT) Received: by 10.114.190.20 with SMTP id n20mr1646780waf.10.1278100182326; Fri, 02 Jul 2010 12:49:42 -0700 (PDT) Received: from coign.google.com (dhcp-172-22-126-240.mtv.corp.google.com [172.22.126.240]) by mx.google.com with ESMTPS id d35sm15215416waa.21.2010.07.02.12.49.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 02 Jul 2010 12:49:41 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org Subject: [gccgo] Initialize mutexes Date: Fri, 02 Jul 2010 12:49:39 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes 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 This patch from Vinu Rajashekhar ensures that all mutexes in libgo are initialized. Committed to gccgo branch. Ian diff -r 960b7647b1da libgo/runtime/mfinal.c --- a/libgo/runtime/mfinal.c Fri Jul 02 09:53:03 2010 -0700 +++ b/libgo/runtime/mfinal.c Fri Jul 02 12:46:46 2010 -0700 @@ -5,7 +5,7 @@ #include "runtime.h" #include "malloc.h" -Lock finlock; +Lock finlock = LOCK_INITIALIZER; // Finalizer hash table. Direct hash, linear scan, at most 3/4 full. // Table size is power of 3 so that hash can be key % max. diff -r 960b7647b1da libgo/runtime/mprof.goc --- a/libgo/runtime/mprof.goc Fri Jul 02 09:53:03 2010 -0700 +++ b/libgo/runtime/mprof.goc Fri Jul 02 12:46:46 2010 -0700 @@ -14,7 +14,7 @@ typedef struct __go_open_array Slice; // NOTE(rsc): Everything here could use cas if contention became an issue. -static Lock proflock; +static Lock proflock = LOCK_INITIALIZER; // Per-call-stack allocation information. // Lookup by hashing call stack into a linked-list hash table. diff -r 960b7647b1da libgo/runtime/runtime.h --- a/libgo/runtime/runtime.h Fri Jul 02 09:53:03 2010 -0700 +++ b/libgo/runtime/runtime.h Fri Jul 02 12:46:46 2010 -0700 @@ -111,8 +111,8 @@ * mutual exclusion locks. in the uncontended case, * as fast as spin locks (just a few user-level instructions), * but on the contention path they sleep in the kernel. - * a zeroed Lock is unlocked (no need to initialize each lock). */ +#define LOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } void initlock(Lock*); void lock(Lock*); void unlock(Lock*);