This patch to libgo fixes misc/cgo/test in the master repository to
work with gccgo.
The package testing/internal/testdeps is now installed. It is
required by the new go test.
The function runtime.lockedOSThread is exported from the runtime
package, so that it can be called from misc/cgo/test using a
go:linkname comment.
We loop on EAGAIN when creating a new thread. This is what the gc
library does, and misc/cgo/test has a test for it.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed
to mainline.
Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 244731)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-907f6e31975443993c47fa45e09cf85d0709b7e6
+b573d4756096523d8bd4bf7b11e56383e5a2cca4
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: libgo/Makefile.am
===================================================================
--- libgo/Makefile.am (revision 244483)
+++ libgo/Makefile.am (working copy)
@@ -360,6 +360,11 @@ toolexeclibgotesting_DATA = \
testing/iotest.gox \
testing/quick.gox
+toolexeclibgotestinginternaldir = $(toolexeclibgotestingdir)/internal
+
+toolexeclibgotestinginternal_DATA = \
+ testing/internal/testdeps.gox
+
toolexeclibgotextdir = $(toolexeclibgodir)/text
toolexeclibgotext_DATA = \
Index: libgo/go/runtime/proc.go
===================================================================
--- libgo/go/runtime/proc.go (revision 244456)
+++ libgo/go/runtime/proc.go (working copy)
@@ -43,6 +43,9 @@ import (
//go:linkname runqempty runtime.runqempty
//go:linkname runqput runtime.runqput
+// Function called by misc/cgo/test.
+//go:linkname lockedOSThread runtime.lockedOSThread
+
// Functions temporarily in C that have not yet been ported.
func allocm(*p, bool, *unsafe.Pointer, *uintptr) *m
func malg(bool, bool, *unsafe.Pointer, *uintptr) *g
Index: libgo/runtime/proc.c
===================================================================
--- libgo/runtime/proc.c (revision 244456)
+++ libgo/runtime/proc.c (working copy)
@@ -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.