Rainer Orth <r...@cebitec.uni-bielefeld.de> writes: > Ian Lance Taylor <i...@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
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) {