]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/cgo: remove threadentry functions specialized for android
authorElias Naur <mail@eliasnaur.com>
Thu, 28 Mar 2019 12:25:21 +0000 (13:25 +0100)
committerElias Naur <mail@eliasnaur.com>
Thu, 28 Mar 2019 18:19:39 +0000 (18:19 +0000)
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 <iant@golang.org>
src/runtime/cgo/gcc_android_386.c
src/runtime/cgo/gcc_android_amd64.c
src/runtime/cgo/gcc_linux_386.c
src/runtime/cgo/gcc_linux_amd64.c

index 28f553c4463ee691a160365d7edb1e597149f0aa..d31b37e2f31d735e5ea3b1e4a978de64eea9073c 100644 (file)
@@ -7,9 +7,6 @@
 #include <signal.h>
 #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;
index 6f92d90dd4cb4e47d8f56dbc5be77e0728909a2b..a6c590a5a9d4b76f100e1972d155bcfc3c882e47 100644 (file)
@@ -7,9 +7,6 @@
 #include <signal.h>
 #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;
index 6be4569b7aea0a91bce2d94e91b169dc5e70a443..9156b056ff48302c2ac1eb5046e09dfa137f7faf 100644 (file)
@@ -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;
index 42008c319122d0a747546b1cec2a89d88471c9ba..e8994478449bc562a4ff3c1cdb8abe5cbad0ed2b 100644 (file)
@@ -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;