Patchwork Go patch committed: New lock/note implementation

login
register
mail settings
Submitter Ian Taylor
Date Nov. 29, 2011, 7:27 p.m.
Message ID <mcrfwh6wwyj.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/128328/
State New
Headers show

Comments

Ian Taylor - Nov. 29, 2011, 7:27 p.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Ian Lance Taylor <iant@google.com> 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

Patch

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)
 {