aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2023-03-31 19:16:12 +0000
committerCherry Mui <cherryyz@google.com>2023-03-31 19:26:35 +0000
commitbfe3c678ab70d9a033b219276636c3f4669c1dc9 (patch)
tree26b80494f04e11f926350aaf9d19eff0bc0d6fae /misc
parent99276aeb5e8b40ff9cd3cafd47ce11c58ba0130c (diff)
downloadgo-bfe3c678ab70d9a033b219276636c3f4669c1dc9.tar.gz
go-bfe3c678ab70d9a033b219276636c3f4669c1dc9.zip
Revert "runtime/cgo: store M for C-created thread in pthread key"
This reverts CL 392854. Reason for revert: caused #59294, which was derived from google internal tests. The attempted fix of #59294 caused more breakage. Change-Id: I5a061561ac2740856b7ecc09725ac28bd30f8bba Reviewed-on: https://go-review.googlesource.com/c/go/+/481060 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/test/cgo_test.go7
-rw-r--r--misc/cgo/test/cthread_unix.c24
-rw-r--r--misc/cgo/test/cthread_windows.c22
-rw-r--r--misc/cgo/test/testx.go14
4 files changed, 3 insertions, 64 deletions
diff --git a/misc/cgo/test/cgo_test.go b/misc/cgo/test/cgo_test.go
index 0c3980c12d..5b298954f5 100644
--- a/misc/cgo/test/cgo_test.go
+++ b/misc/cgo/test/cgo_test.go
@@ -104,7 +104,6 @@ func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
func TestUnsignedInt(t *testing.T) { testUnsignedInt(t) }
func TestZeroArgCallback(t *testing.T) { testZeroArgCallback(t) }
-func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
-func BenchmarkGoString(b *testing.B) { benchGoString(b) }
-func BenchmarkCGoCallback(b *testing.B) { benchCallback(b) }
-func BenchmarkCGoInCThread(b *testing.B) { benchCGoInCthread(b) }
+func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
+func BenchmarkGoString(b *testing.B) { benchGoString(b) }
+func BenchmarkCGoCallback(b *testing.B) { benchCallback(b) }
diff --git a/misc/cgo/test/cthread_unix.c b/misc/cgo/test/cthread_unix.c
index 13623254a9..247d636d06 100644
--- a/misc/cgo/test/cthread_unix.c
+++ b/misc/cgo/test/cthread_unix.c
@@ -32,27 +32,3 @@ doAdd(int max, int nthread)
for(i=0; i<nthread; i++)
pthread_join(thread_id[i], 0);
}
-
-static void*
-goDummyCallbackThread(void* p)
-{
- int i, max;
-
- max = *(int*)p;
- for(i=0; i<max; i++)
- goDummy();
- return NULL;
-}
-
-int
-callGoInCThread(int max)
-{
- pthread_t thread;
-
- if (pthread_create(&thread, NULL, goDummyCallbackThread, (void*)(&max)) != 0)
- return -1;
- if (pthread_join(thread, NULL) != 0)
- return -1;
-
- return max;
-}
diff --git a/misc/cgo/test/cthread_windows.c b/misc/cgo/test/cthread_windows.c
index 4e52209dee..3a62ddd373 100644
--- a/misc/cgo/test/cthread_windows.c
+++ b/misc/cgo/test/cthread_windows.c
@@ -35,25 +35,3 @@ doAdd(int max, int nthread)
CloseHandle((HANDLE)thread_id[i]);
}
}
-
-__stdcall
-static unsigned int
-goDummyCallbackThread(void* p)
-{
- int i, max;
-
- max = *(int*)p;
- for(i=0; i<max; i++)
- goDummy();
- return 0;
-}
-
-int
-callGoInCThread(int max)
-{
- uintptr_t thread_id;
- thread_id = _beginthreadex(0, 0, goDummyCallbackThread, &max, 0, 0);
- WaitForSingleObject((HANDLE)thread_id, INFINITE);
- CloseHandle((HANDLE)thread_id);
- return max;
-}
diff --git a/misc/cgo/test/testx.go b/misc/cgo/test/testx.go
index 0e2a51a522..6a8e97ddf3 100644
--- a/misc/cgo/test/testx.go
+++ b/misc/cgo/test/testx.go
@@ -24,7 +24,6 @@ import (
/*
// threads
extern void doAdd(int, int);
-extern int callGoInCThread(int);
// issue 1328
void IntoC(void);
@@ -147,10 +146,6 @@ func Add(x int) {
*p = 2
}
-//export goDummy
-func goDummy() {
-}
-
func testCthread(t *testing.T) {
if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && runtime.GOARCH == "arm64" {
t.Skip("the iOS exec wrapper is unable to properly handle the panic from Add")
@@ -164,15 +159,6 @@ func testCthread(t *testing.T) {
}
}
-// Benchmark measuring overhead from C to Go in a C thread.
-// Create a new C thread and invoke Go function repeatedly in the new C thread.
-func benchCGoInCthread(b *testing.B) {
- n := C.callGoInCThread(C.int(b.N))
- if int(n) != b.N {
- b.Fatal("unmatch loop times")
- }
-}
-
// issue 1328
//export BackIntoGo