aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/proc.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-01-20 21:18:37 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-01-20 21:18:37 +0000
commit4a5b806048bb94e2adcd34ea11ae27ca4030051f (patch)
tree93038434ff16825833e5bb4fd64a08717fe4c31f /libgo/runtime/proc.c
parenta876231c40c9e3488d91bd64aa7a12c939babe51 (diff)
downloadgcc-4a5b806048bb94e2adcd34ea11ae27ca4030051f.zip
gcc-4a5b806048bb94e2adcd34ea11ae27ca4030051f.tar.gz
gcc-4a5b806048bb94e2adcd34ea11ae27ca4030051f.tar.bz2
runtime, testing/internal/testdeps: fixes for cgo
Some fixes that permit misc/cgo/test in the master gc repository to pass using the current gccgo. Install testing/internal/testdeps.gox; it is needed by `go test`. Export runtime.lockedOSThread to enable calling via go:linkname; it is used by misc/cgo/test. Loop on EAGAIN when creating a new thread; this is what the gc code does, and misc/cgo/test tests that it works. Reviewed-on: https://go-review.googlesource.com/35479 From-SVN: r244733
Diffstat (limited to 'libgo/runtime/proc.c')
-rw-r--r--libgo/runtime/proc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
index 0ed7ebe..60d5bdb 100644
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
@@ -216,6 +217,7 @@ runtime_newosproc(M *mp)
pthread_attr_t attr;
sigset_t clear, old;
pthread_t tid;
+ int tries;
int ret;
if(pthread_attr_init(&attr) != 0)
@@ -234,11 +236,21 @@ runtime_newosproc(M *mp)
sigemptyset(&old);
pthread_sigmask(SIG_BLOCK, &clear, &old);
- ret = pthread_create(&tid, &attr, runtime_mstart, mp);
+
+ for (tries = 0; tries < 20; tries++) {
+ ret = pthread_create(&tid, &attr, runtime_mstart, mp);
+ if (ret != EAGAIN) {
+ break;
+ }
+ runtime_usleep((tries + 1) * 1000); // Milliseconds.
+ }
+
pthread_sigmask(SIG_SETMASK, &old, nil);
- if (ret != 0)
+ if (ret != 0) {
+ runtime_printf("pthread_create failed: %d\n", ret);
runtime_throw("pthread_create");
+ }
}
// First function run by a new goroutine. This replaces gogocall.