diff options
Diffstat (limited to 'src/pkg/runtime/cgo')
-rw-r--r-- | src/pkg/runtime/cgo/Makefile | 4 | ||||
-rw-r--r-- | src/pkg/runtime/cgo/darwin_386.c | 7 | ||||
-rw-r--r-- | src/pkg/runtime/cgo/darwin_amd64.c | 7 | ||||
-rw-r--r-- | src/pkg/runtime/cgo/freebsd_386.c | 7 | ||||
-rw-r--r-- | src/pkg/runtime/cgo/freebsd_amd64.c | 7 | ||||
-rw-r--r-- | src/pkg/runtime/cgo/linux_386.c | 7 | ||||
-rw-r--r-- | src/pkg/runtime/cgo/linux_amd64.c | 7 | ||||
-rwxr-xr-x | src/pkg/runtime/cgo/windows_amd64.c | 18 |
8 files changed, 54 insertions, 10 deletions
diff --git a/src/pkg/runtime/cgo/Makefile b/src/pkg/runtime/cgo/Makefile index f26da2c51..7e752f127 100644 --- a/src/pkg/runtime/cgo/Makefile +++ b/src/pkg/runtime/cgo/Makefile @@ -10,6 +10,10 @@ ifeq ($(GOARCH),arm) ENABLED:=0 endif +ifeq ($(GOOS),plan9) +ENABLED:=0 +endif + ifeq ($(DISABLE_CGO),1) ENABLED:=0 endif diff --git a/src/pkg/runtime/cgo/darwin_386.c b/src/pkg/runtime/cgo/darwin_386.c index 13184f321..6d4e259be 100644 --- a/src/pkg/runtime/cgo/darwin_386.c +++ b/src/pkg/runtime/cgo/darwin_386.c @@ -113,11 +113,16 @@ libcgo_sys_thread_start(ThreadStart *ts) pthread_attr_t attr; pthread_t p; size_t size; + int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); ts->g->stackguard = size; - pthread_create(&p, &attr, threadentry, ts); + err = pthread_create(&p, &attr, threadentry, ts); + if (err != 0) { + fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); + abort(); + } } static void* diff --git a/src/pkg/runtime/cgo/darwin_amd64.c b/src/pkg/runtime/cgo/darwin_amd64.c index 38cd80a6f..3471044c0 100644 --- a/src/pkg/runtime/cgo/darwin_amd64.c +++ b/src/pkg/runtime/cgo/darwin_amd64.c @@ -83,11 +83,16 @@ libcgo_sys_thread_start(ThreadStart *ts) pthread_attr_t attr; pthread_t p; size_t size; + int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); ts->g->stackguard = size; - pthread_create(&p, &attr, threadentry, ts); + err = pthread_create(&p, &attr, threadentry, ts); + if (err != 0) { + fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); + abort(); + } } static void* diff --git a/src/pkg/runtime/cgo/freebsd_386.c b/src/pkg/runtime/cgo/freebsd_386.c index d08e1dee8..ae53201b4 100644 --- a/src/pkg/runtime/cgo/freebsd_386.c +++ b/src/pkg/runtime/cgo/freebsd_386.c @@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts) pthread_attr_t attr; pthread_t p; size_t size; + int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); ts->g->stackguard = size; - pthread_create(&p, &attr, threadentry, ts); + err = pthread_create(&p, &attr, threadentry, ts); + if (err != 0) { + fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); + abort(); + } } static void* diff --git a/src/pkg/runtime/cgo/freebsd_amd64.c b/src/pkg/runtime/cgo/freebsd_amd64.c index fe6ce391f..5afc1dfea 100644 --- a/src/pkg/runtime/cgo/freebsd_amd64.c +++ b/src/pkg/runtime/cgo/freebsd_amd64.c @@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts) pthread_attr_t attr; pthread_t p; size_t size; + int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); ts->g->stackguard = size; - pthread_create(&p, &attr, threadentry, ts); + err = pthread_create(&p, &attr, threadentry, ts); + if (err != 0) { + fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); + abort(); + } } static void* diff --git a/src/pkg/runtime/cgo/linux_386.c b/src/pkg/runtime/cgo/linux_386.c index 00322d4b7..e9df5ffdc 100644 --- a/src/pkg/runtime/cgo/linux_386.c +++ b/src/pkg/runtime/cgo/linux_386.c @@ -21,6 +21,7 @@ libcgo_sys_thread_start(ThreadStart *ts) pthread_attr_t attr; pthread_t p; size_t size; + int err; // Not sure why the memset is necessary here, // but without it, we get a bogus stack size @@ -30,7 +31,11 @@ libcgo_sys_thread_start(ThreadStart *ts) size = 0; pthread_attr_getstacksize(&attr, &size); ts->g->stackguard = size; - pthread_create(&p, &attr, threadentry, ts); + err = pthread_create(&p, &attr, threadentry, ts); + if (err != 0) { + fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); + abort(); + } } static void* diff --git a/src/pkg/runtime/cgo/linux_amd64.c b/src/pkg/runtime/cgo/linux_amd64.c index e77c5ddfe..d9b8b3706 100644 --- a/src/pkg/runtime/cgo/linux_amd64.c +++ b/src/pkg/runtime/cgo/linux_amd64.c @@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts) pthread_attr_t attr; pthread_t p; size_t size; + int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); ts->g->stackguard = size; - pthread_create(&p, &attr, threadentry, ts); + err = pthread_create(&p, &attr, threadentry, ts); + if (err != 0) { + fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); + abort(); + } } static void* diff --git a/src/pkg/runtime/cgo/windows_amd64.c b/src/pkg/runtime/cgo/windows_amd64.c index dafe8cd9d..fd5b397ab 100755 --- a/src/pkg/runtime/cgo/windows_amd64.c +++ b/src/pkg/runtime/cgo/windows_amd64.c @@ -37,11 +37,21 @@ threadentry(void *v) ts.g->stackbase = (uintptr)&ts; /* - * libcgo_sys_thread_start set stackguard to stack size; - * change to actual guard pointer. - */ + * libcgo_sys_thread_start set stackguard to stack size; + * change to actual guard pointer. + */ ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096; - crosscall_386(ts.fn); + /* + * Set specific keys in thread local storage. + */ + asm volatile ( + "movq %%gs:0x58, %%rax\n" // MOVQ 0x58(GS), tmp + "movq %0, 0(%%rax)\n" // MOVQ g, 0(GS) + "movq %1, 8(%%rax)\n" // MOVQ m, 8(GS) + :: "r"(ts.g), "r"(ts.m) : "%rax" + ); + + crosscall_amd64(ts.fn); return nil; } |