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
This commit is contained in:
Ian Lance Taylor 2017-01-20 21:18:37 +00:00
parent a876231c40
commit 4a5b806048
5 changed files with 60 additions and 7 deletions

View File

@ -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.

View File

@ -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 = \

View File

@ -146,6 +146,7 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
"$(DESTDIR)$(toolexeclibgoruntimedir)" \
"$(DESTDIR)$(toolexeclibgosyncdir)" \
"$(DESTDIR)$(toolexeclibgotestingdir)" \
"$(DESTDIR)$(toolexeclibgotestinginternaldir)" \
"$(DESTDIR)$(toolexeclibgotextdir)" \
"$(DESTDIR)$(toolexeclibgotexttemplatedir)" \
"$(DESTDIR)$(toolexeclibgounicodedir)"
@ -265,7 +266,8 @@ DATA = $(noinst_DATA) $(toolexeclibgo_DATA) \
$(toolexeclibgonetrpc_DATA) $(toolexeclibgoos_DATA) \
$(toolexeclibgopath_DATA) $(toolexeclibgoregexp_DATA) \
$(toolexeclibgoruntime_DATA) $(toolexeclibgosync_DATA) \
$(toolexeclibgotesting_DATA) $(toolexeclibgotext_DATA) \
$(toolexeclibgotesting_DATA) \
$(toolexeclibgotestinginternal_DATA) $(toolexeclibgotext_DATA) \
$(toolexeclibgotexttemplate_DATA) $(toolexeclibgounicode_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
@ -740,6 +742,10 @@ toolexeclibgotesting_DATA = \
testing/iotest.gox \
testing/quick.gox
toolexeclibgotestinginternaldir = $(toolexeclibgotestingdir)/internal
toolexeclibgotestinginternal_DATA = \
testing/internal/testdeps.gox
toolexeclibgotextdir = $(toolexeclibgodir)/text
toolexeclibgotext_DATA = \
text/scanner.gox \
@ -2645,6 +2651,27 @@ uninstall-toolexeclibgotestingDATA:
@list='$(toolexeclibgotesting_DATA)'; test -n "$(toolexeclibgotestingdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(toolexeclibgotestingdir)'; $(am__uninstall_files_from_dir)
install-toolexeclibgotestinginternalDATA: $(toolexeclibgotestinginternal_DATA)
@$(NORMAL_INSTALL)
@list='$(toolexeclibgotestinginternal_DATA)'; test -n "$(toolexeclibgotestinginternaldir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibgotestinginternaldir)'"; \
$(MKDIR_P) "$(DESTDIR)$(toolexeclibgotestinginternaldir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgotestinginternaldir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgotestinginternaldir)" || exit $$?; \
done
uninstall-toolexeclibgotestinginternalDATA:
@$(NORMAL_UNINSTALL)
@list='$(toolexeclibgotestinginternal_DATA)'; test -n "$(toolexeclibgotestinginternaldir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(toolexeclibgotestinginternaldir)'; $(am__uninstall_files_from_dir)
install-toolexeclibgotextDATA: $(toolexeclibgotext_DATA)
@$(NORMAL_INSTALL)
@list='$(toolexeclibgotext_DATA)'; test -n "$(toolexeclibgotextdir)" || list=; \
@ -2849,7 +2876,7 @@ all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) all-multi $(DATA) \
config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgocryptox509dir)" "$(DESTDIR)$(toolexeclibgodatabasedir)" "$(DESTDIR)$(toolexeclibgodatabasesqldir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohtmldir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoimagecolordir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgologdir)" "$(DESTDIR)$(toolexeclibgomathdir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgonethttpdir)" "$(DESTDIR)$(toolexeclibgonetrpcdir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgopathdir)" "$(DESTDIR)$(toolexeclibgoregexpdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgosyncdir)" "$(DESTDIR)$(toolexeclibgotestingdir)" "$(DESTDIR)$(toolexeclibgotextdir)" "$(DESTDIR)$(toolexeclibgotexttemplatedir)" "$(DESTDIR)$(toolexeclibgounicodedir)"; do \
for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgocryptox509dir)" "$(DESTDIR)$(toolexeclibgodatabasedir)" "$(DESTDIR)$(toolexeclibgodatabasesqldir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohtmldir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoimagecolordir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgologdir)" "$(DESTDIR)$(toolexeclibgomathdir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgonethttpdir)" "$(DESTDIR)$(toolexeclibgonetrpcdir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgopathdir)" "$(DESTDIR)$(toolexeclibgoregexpdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgosyncdir)" "$(DESTDIR)$(toolexeclibgotestingdir)" "$(DESTDIR)$(toolexeclibgotestinginternaldir)" "$(DESTDIR)$(toolexeclibgotextdir)" "$(DESTDIR)$(toolexeclibgotexttemplatedir)" "$(DESTDIR)$(toolexeclibgounicodedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
@ -2935,7 +2962,9 @@ install-exec-am: install-multi install-toolexeclibLIBRARIES \
install-toolexeclibgonetrpcDATA install-toolexeclibgoosDATA \
install-toolexeclibgopathDATA install-toolexeclibgoregexpDATA \
install-toolexeclibgoruntimeDATA install-toolexeclibgosyncDATA \
install-toolexeclibgotestingDATA install-toolexeclibgotextDATA \
install-toolexeclibgotestingDATA \
install-toolexeclibgotestinginternalDATA \
install-toolexeclibgotextDATA \
install-toolexeclibgotexttemplateDATA \
install-toolexeclibgounicodeDATA
@ -3005,6 +3034,7 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
uninstall-toolexeclibgoruntimeDATA \
uninstall-toolexeclibgosyncDATA \
uninstall-toolexeclibgotestingDATA \
uninstall-toolexeclibgotestinginternalDATA \
uninstall-toolexeclibgotextDATA \
uninstall-toolexeclibgotexttemplateDATA \
uninstall-toolexeclibgounicodeDATA
@ -3046,7 +3076,9 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
install-toolexeclibgonetrpcDATA install-toolexeclibgoosDATA \
install-toolexeclibgopathDATA install-toolexeclibgoregexpDATA \
install-toolexeclibgoruntimeDATA install-toolexeclibgosyncDATA \
install-toolexeclibgotestingDATA install-toolexeclibgotextDATA \
install-toolexeclibgotestingDATA \
install-toolexeclibgotestinginternalDATA \
install-toolexeclibgotextDATA \
install-toolexeclibgotexttemplateDATA \
install-toolexeclibgounicodeDATA installcheck installcheck-am \
installdirs installdirs-am maintainer-clean \
@ -3080,6 +3112,7 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
uninstall-toolexeclibgoruntimeDATA \
uninstall-toolexeclibgosyncDATA \
uninstall-toolexeclibgotestingDATA \
uninstall-toolexeclibgotestinginternalDATA \
uninstall-toolexeclibgotextDATA \
uninstall-toolexeclibgotexttemplateDATA \
uninstall-toolexeclibgounicodeDATA

View File

@ -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

View File

@ -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.