aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata/testprogcgo
diff options
context:
space:
mode:
authorChressie Himpel <chressie@google.com>2023-05-05 14:17:38 +0000
committerChressie Himpel <chressie@google.com>2023-05-05 14:37:29 +0000
commit72c33a5ef0eea8663328375d9d339ed150310ebb (patch)
treea4272daf751239fcb9b2f1b8e1730800629f738c /src/runtime/testdata/testprogcgo
parentf379e78951a405e7e99a60fb231eeedbf976c108 (diff)
downloadgo-72c33a5ef0eea8663328375d9d339ed150310ebb.tar.xz
Revert "runtime/cgo: store M for C-created thread in pthread key"
This reverts CL 485500. Reason for revert: This breaks internal tests at Google, see b/280861579 and b/280820455. Change-Id: I426278d400f7611170918fc07c524cb059b9cc55 Reviewed-on: https://go-review.googlesource.com/c/go/+/492995 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Chressie Himpel <chressie@google.com>
Diffstat (limited to 'src/runtime/testdata/testprogcgo')
-rw-r--r--src/runtime/testdata/testprogcgo/bindm.c34
-rw-r--r--src/runtime/testdata/testprogcgo/bindm.go61
2 files changed, 0 insertions, 95 deletions
diff --git a/src/runtime/testdata/testprogcgo/bindm.c b/src/runtime/testdata/testprogcgo/bindm.c
deleted file mode 100644
index 815d8a75f2..0000000000
--- a/src/runtime/testdata/testprogcgo/bindm.c
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2023 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !plan9 && !windows
-
-#include <stdint.h>
-#include <pthread.h>
-#include <unistd.h>
-#include "_cgo_export.h"
-
-#define CTHREADS 2
-#define CHECKCALLS 100
-
-static void* checkBindMThread(void* thread) {
- int i;
- for (i = 0; i < CHECKCALLS; i++) {
- GoCheckBindM((uintptr_t)thread);
- usleep(1);
- }
- return NULL;
-}
-
-void CheckBindM() {
- int i;
- pthread_t s[CTHREADS];
-
- for (i = 0; i < CTHREADS; i++) {
- pthread_create(&s[i], NULL, checkBindMThread, &s[i]);
- }
- for (i = 0; i < CTHREADS; i++) {
- pthread_join(s[i], NULL);
- }
-}
diff --git a/src/runtime/testdata/testprogcgo/bindm.go b/src/runtime/testdata/testprogcgo/bindm.go
deleted file mode 100644
index c2003c2093..0000000000
--- a/src/runtime/testdata/testprogcgo/bindm.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2023 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !plan9 && !windows
-
-// Test that callbacks from C to Go in the same C-thread always get the same m.
-// Make sure the extra M bind to the C-thread.
-
-package main
-
-/*
-extern void CheckBindM();
-*/
-import "C"
-
-import (
- "fmt"
- "os"
- "runtime"
- "sync"
- "sync/atomic"
-)
-
-var (
- mutex = sync.Mutex{}
- cThreadToM = map[uintptr]uintptr{}
- started = atomic.Uint32{}
-)
-
-// same as CTHREADS in C, make sure all the C threads are actually started.
-const cThreadNum = 2
-
-func init() {
- register("EnsureBindM", EnsureBindM)
-}
-
-//export GoCheckBindM
-func GoCheckBindM(thread uintptr) {
- // Wait all threads start
- if started.Load() != cThreadNum {
- // Only once for each thread, since it will wait all threads start.
- started.Add(1)
- for started.Load() < cThreadNum {
- runtime.Gosched()
- }
- }
- m := runtime_getm_for_test()
- mutex.Lock()
- defer mutex.Unlock()
- if savedM, ok := cThreadToM[thread]; ok && savedM != m {
- fmt.Printf("m == %x want %x\n", m, savedM)
- os.Exit(1)
- }
- cThreadToM[thread] = m
-}
-
-func EnsureBindM() {
- C.CheckBindM()
- fmt.Println("OK")
-}