From: Elias Naur Date: Thu, 28 Mar 2019 12:25:21 +0000 (+0100) Subject: runtime/cgo: remove threadentry functions specialized for android X-Git-Tag: go1.13beta1~868 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b2f19dad8bb2b942badcc1ea6f7147b11fed926e;p=gostls13.git runtime/cgo: remove threadentry functions specialized for android The specialized functions set up the g register using the pthread API instead of setg_gcc, but the inittls functions have already made sure setg_gcc works. Updates #29674 Change-Id: Ie67c068d638af8b5823978ee839f6b61b2228996 Reviewed-on: https://go-review.googlesource.com/c/go/+/169797 Reviewed-by: Ian Lance Taylor --- diff --git a/src/runtime/cgo/gcc_android_386.c b/src/runtime/cgo/gcc_android_386.c index 28f553c446..d31b37e2f3 100644 --- a/src/runtime/cgo/gcc_android_386.c +++ b/src/runtime/cgo/gcc_android_386.c @@ -7,9 +7,6 @@ #include #include "libcgo.h" -static void* threadentry(void*); -static pthread_key_t k1; - #define magic1 (0x23581321U) static void @@ -44,7 +41,6 @@ inittls(void) asm volatile("movl %%gs:0xf8, %0" : "=r"(x)); pthread_setspecific(k, 0); if (x == magic1) { - k1 = k; break; } if(ntofree >= nelem(tofree)) { @@ -68,23 +64,4 @@ inittls(void) } } - -static void* -threadentry(void *v) -{ - ThreadStart ts; - - ts = *(ThreadStart*)v; - free(v); - - if (pthread_setspecific(k1, (void*)ts.g) != 0) { - fprintf(stderr, "runtime/cgo: pthread_setspecific failed\n"); - abort(); - } - - crosscall_386(ts.fn); - return nil; -} - void (*x_cgo_inittls)(void) = inittls; -void* (*x_cgo_threadentry)(void*) = threadentry; diff --git a/src/runtime/cgo/gcc_android_amd64.c b/src/runtime/cgo/gcc_android_amd64.c index 6f92d90dd4..a6c590a5a9 100644 --- a/src/runtime/cgo/gcc_android_amd64.c +++ b/src/runtime/cgo/gcc_android_amd64.c @@ -7,9 +7,6 @@ #include #include "libcgo.h" -static void* threadentry(void*); -static pthread_key_t k1; - #define magic1 (0x23581321345589ULL) static void @@ -49,7 +46,6 @@ inittls(void) asm volatile("movq %%fs:0x1d0, %0" : "=r"(x)); pthread_setspecific(k, 0); if(x == magic1) { - k1 = k; break; } if(ntofree >= nelem(tofree)) { @@ -73,23 +69,4 @@ inittls(void) } } - -static void* -threadentry(void *v) -{ - ThreadStart ts; - - ts = *(ThreadStart*)v; - free(v); - - if (pthread_setspecific(k1, (void*)ts.g) != 0) { - fprintf(stderr, "runtime/cgo: pthread_setspecific failed\n"); - abort(); - } - - crosscall_amd64(ts.fn); - return nil; -} - void (*x_cgo_inittls)(void) = inittls; -void* (*x_cgo_threadentry)(void*) = threadentry; diff --git a/src/runtime/cgo/gcc_linux_386.c b/src/runtime/cgo/gcc_linux_386.c index 6be4569b7a..9156b056ff 100644 --- a/src/runtime/cgo/gcc_linux_386.c +++ b/src/runtime/cgo/gcc_linux_386.c @@ -11,9 +11,8 @@ static void *threadentry(void*); static void (*setg_gcc)(void*); -// These will be set in gcc_android_386.c for android-specific customization. +// This will be set in gcc_android_386.c for android-specific customization. void (*x_cgo_inittls)(void); -void* (*x_cgo_threadentry)(void*); void x_cgo_init(G *g, void (*setg)(void*)) @@ -32,7 +31,6 @@ x_cgo_init(G *g, void (*setg)(void*)) } } - void _cgo_sys_thread_start(ThreadStart *ts) { @@ -66,10 +64,6 @@ _cgo_sys_thread_start(ThreadStart *ts) static void* threadentry(void *v) { - if (x_cgo_threadentry) { - return x_cgo_threadentry(v); - } - ThreadStart ts; ts = *(ThreadStart*)v; diff --git a/src/runtime/cgo/gcc_linux_amd64.c b/src/runtime/cgo/gcc_linux_amd64.c index 42008c3191..e899447844 100644 --- a/src/runtime/cgo/gcc_linux_amd64.c +++ b/src/runtime/cgo/gcc_linux_amd64.c @@ -13,9 +13,8 @@ static void* threadentry(void*); static void (*setg_gcc)(void*); -// These will be set in gcc_android_amd64.c for android-specific customization. +// This will be set in gcc_android_amd64.c for android-specific customization. void (*x_cgo_inittls)(void); -void* (*x_cgo_threadentry)(void*); void x_cgo_init(G* g, void (*setg)(void*)) @@ -83,10 +82,6 @@ _cgo_sys_thread_start(ThreadStart *ts) static void* threadentry(void *v) { - if (x_cgo_threadentry) { - return x_cgo_threadentry(v); - } - ThreadStart ts; ts = *(ThreadStart*)v;