1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 //go:build linux && freebsd && openbsd
6 // +build linux,freebsd,openbsd
12 #include <sys/syscall.h>
14 static int Ctid(void) { Gosched(); return syscall(SYS_gettid); }
31 testThreadLockFunc
= testThreadLock
34 func testThreadLock(t
*testing
.T
) {
35 stop
:= make(chan int)
37 // We need the G continue running,
38 // so the M has a chance to run this G.
43 case <-time
.After(time
.Millisecond
* 100):
49 for i
:= 0; i
< 1000; i
++ {
50 if C
.int(syscall
.Gettid()) != C
.Ctid() {
51 t
.Fatalf("cgo has not locked OS thread")