From patchwork Tue Nov 29 19:27:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 128328 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 077751007F5 for ; Wed, 30 Nov 2011 06:27:52 +1100 (EST) Received: (qmail 11446 invoked by alias); 29 Nov 2011 19:27:49 -0000 Received: (qmail 11437 invoked by uid 22791); 29 Nov 2011 19:27:49 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Nov 2011 19:27:35 +0000 Received: by iahk25 with SMTP id k25so12135264iah.20 for ; Tue, 29 Nov 2011 11:27:35 -0800 (PST) Received: by 10.43.50.67 with SMTP id vd3mr53340icb.10.1322594855368; Tue, 29 Nov 2011 11:27:35 -0800 (PST) Received: by 10.43.50.67 with SMTP id vd3mr53312icb.10.1322594855125; Tue, 29 Nov 2011 11:27:35 -0800 (PST) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id jm11sm8215424ibb.1.2011.11.29.11.27.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Nov 2011 11:27:34 -0800 (PST) From: Ian Lance Taylor To: Rainer Orth Cc: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Re: Go patch committed: New lock/note implementation References: Date: Tue, 29 Nov 2011 11:27:32 -0800 In-Reply-To: (Rainer Orth's message of "Fri, 25 Nov 2011 18:10:04 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 Rainer Orth writes: > Ian Lance Taylor writes: > >> This patch updates the implementations of locks and notes used in libgo >> to use the current version from the master Go library. This now uses >> futexes when running on GNU/Linux, while still using semaphores on other >> systems. This implementation should be faster, and does not require >> explicit initialization. Bootstrapped and ran Go testsuite on >> x86_64-unknown-linux-gnu. I tested both the futex and the semaphore >> versions. Committed to mainline. > >> +static int32 >> +getproccount(void) >> +{ >> + int32 fd, rd, cnt, cpustrlen; >> + const byte *cpustr, *pos; >> + byte *bufpos; >> + byte buf[256]; >> + >> + fd = open("/proc/stat", O_RDONLY|O_CLOEXEC, 0); > > This broke bootstrap on Linux/x86_64 (CentOS 5.5), which lacks > O_CLOEXEC. Thanks for the report. Fixed in the obvious way as follows. The use of O_CLOEXEC provides extra safety but is not essential, since the program is single-threaded when the file is used. Bootstrapped on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 295f86b18961 libgo/runtime/thread-linux.c --- a/libgo/runtime/thread-linux.c Tue Nov 29 11:02:01 2011 -0800 +++ b/libgo/runtime/thread-linux.c Tue Nov 29 11:24:45 2011 -0800 @@ -62,6 +62,10 @@ *(int32*)0x1006 = 0x1006; } +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + static int32 getproccount(void) {