summaryrefslogtreecommitdiffstats
path: root/misc/cgo/test
diff options
context:
space:
mode:
Diffstat (limited to 'misc/cgo/test')
-rw-r--r--misc/cgo/test/backdoor.go11
-rw-r--r--misc/cgo/test/buildid_linux.go78
-rw-r--r--misc/cgo/test/callback.go1782
-rw-r--r--misc/cgo/test/callback_c.c67
-rw-r--r--misc/cgo/test/callback_c_gc.c25
-rw-r--r--misc/cgo/test/callback_c_gccgo.c21
-rw-r--r--misc/cgo/test/cgo_linux_test.go43
-rw-r--r--misc/cgo/test/cgo_stubs_android_test.go12
-rw-r--r--misc/cgo/test/cgo_test.go109
-rw-r--r--misc/cgo/test/cgo_thread_lock.go54
-rw-r--r--misc/cgo/test/cgo_unix_test.go14
-rw-r--r--misc/cgo/test/cthread_unix.c34
-rw-r--r--misc/cgo/test/cthread_windows.c37
-rw-r--r--misc/cgo/test/gcc68255.go17
-rw-r--r--misc/cgo/test/gcc68255/a.go17
-rw-r--r--misc/cgo/test/gcc68255/c.c8
-rw-r--r--misc/cgo/test/gcc68255/c.h5
-rw-r--r--misc/cgo/test/issue1435.go204
-rw-r--r--misc/cgo/test/issue18146.go129
-rw-r--r--misc/cgo/test/issue20266.go21
-rw-r--r--misc/cgo/test/issue20266/issue20266.h9
-rw-r--r--misc/cgo/test/issue20910.c19
-rw-r--r--misc/cgo/test/issue21897.go57
-rw-r--r--misc/cgo/test/issue21897b.go14
-rw-r--r--misc/cgo/test/issue23555.go13
-rw-r--r--misc/cgo/test/issue23555a/a.go12
-rw-r--r--misc/cgo/test/issue23555b/a.go12
-rw-r--r--misc/cgo/test/issue24161_darwin_test.go31
-rw-r--r--misc/cgo/test/issue24161arg/def.go17
-rw-r--r--misc/cgo/test/issue24161arg/use.go19
-rw-r--r--misc/cgo/test/issue24161e0/main.go29
-rw-r--r--misc/cgo/test/issue24161e1/main.go38
-rw-r--r--misc/cgo/test/issue24161e2/main.go40
-rw-r--r--misc/cgo/test/issue24161res/restype.go23
-rw-r--r--misc/cgo/test/issue26213/jni.h29
-rw-r--r--misc/cgo/test/issue26213/test26213.go46
-rw-r--r--misc/cgo/test/issue26430.go10
-rw-r--r--misc/cgo/test/issue26430/a.go13
-rw-r--r--misc/cgo/test/issue26430/b.go13
-rw-r--r--misc/cgo/test/issue26743.go10
-rw-r--r--misc/cgo/test/issue26743/a.go11
-rw-r--r--misc/cgo/test/issue26743/b.go9
-rw-r--r--misc/cgo/test/issue27054/egl.h8
-rw-r--r--misc/cgo/test/issue27054/test27054.go21
-rw-r--r--misc/cgo/test/issue27340.go12
-rw-r--r--misc/cgo/test/issue27340/a.go42
-rw-r--r--misc/cgo/test/issue29563.go13
-rw-r--r--misc/cgo/test/issue29563/weak.go13
-rw-r--r--misc/cgo/test/issue29563/weak1.c11
-rw-r--r--misc/cgo/test/issue29563/weak2.c11
-rw-r--r--misc/cgo/test/issue30527.go14
-rw-r--r--misc/cgo/test/issue30527/a.go19
-rw-r--r--misc/cgo/test/issue30527/b.go11
-rw-r--r--misc/cgo/test/issue31891.c13
-rw-r--r--misc/cgo/test/issue4029.c30
-rw-r--r--misc/cgo/test/issue4029.go80
-rw-r--r--misc/cgo/test/issue4029w.go13
-rw-r--r--misc/cgo/test/issue41761.go20
-rw-r--r--misc/cgo/test/issue41761a/a.go14
-rw-r--r--misc/cgo/test/issue42018.go14
-rw-r--r--misc/cgo/test/issue42018_windows.go46
-rw-r--r--misc/cgo/test/issue42495.go15
-rw-r--r--misc/cgo/test/issue4273.c10
-rw-r--r--misc/cgo/test/issue4273b.c11
-rw-r--r--misc/cgo/test/issue4339.c18
-rw-r--r--misc/cgo/test/issue4339.h9
-rw-r--r--misc/cgo/test/issue43639.go9
-rw-r--r--misc/cgo/test/issue43639/a.go8
-rw-r--r--misc/cgo/test/issue52611.go13
-rw-r--r--misc/cgo/test/issue52611a/a.go16
-rw-r--r--misc/cgo/test/issue52611a/b.go11
-rw-r--r--misc/cgo/test/issue52611b/a.go11
-rw-r--r--misc/cgo/test/issue52611b/b.go16
-rw-r--r--misc/cgo/test/issue5548_c.c24
-rw-r--r--misc/cgo/test/issue5740a.c9
-rw-r--r--misc/cgo/test/issue5740b.c9
-rw-r--r--misc/cgo/test/issue6833_c.c10
-rw-r--r--misc/cgo/test/issue6907export_c.c11
-rw-r--r--misc/cgo/test/issue6997_linux.c28
-rw-r--r--misc/cgo/test/issue6997_linux.go45
-rw-r--r--misc/cgo/test/issue7234_test.go21
-rw-r--r--misc/cgo/test/issue8148.c11
-rw-r--r--misc/cgo/test/issue8148.go24
-rw-r--r--misc/cgo/test/issue8331.h7
-rw-r--r--misc/cgo/test/issue8517.go14
-rw-r--r--misc/cgo/test/issue8517_windows.c24
-rw-r--r--misc/cgo/test/issue8517_windows.go45
-rw-r--r--misc/cgo/test/issue8694.go41
-rw-r--r--misc/cgo/test/issue8756.go17
-rw-r--r--misc/cgo/test/issue8756/issue8756.go11
-rw-r--r--misc/cgo/test/issue8811.c8
-rw-r--r--misc/cgo/test/issue8828.go16
-rw-r--r--misc/cgo/test/issue8828/issue8828.c7
-rw-r--r--misc/cgo/test/issue8828/trivial.go8
-rw-r--r--misc/cgo/test/issue9026.go9
-rw-r--r--misc/cgo/test/issue9026/issue9026.go36
-rw-r--r--misc/cgo/test/issue9400/asm_386.s27
-rw-r--r--misc/cgo/test/issue9400/asm_amd64x.s27
-rw-r--r--misc/cgo/test/issue9400/asm_arm.s39
-rw-r--r--misc/cgo/test/issue9400/asm_arm64.s39
-rw-r--r--misc/cgo/test/issue9400/asm_loong64.s28
-rw-r--r--misc/cgo/test/issue9400/asm_mips64x.s33
-rw-r--r--misc/cgo/test/issue9400/asm_mipsx.s31
-rw-r--r--misc/cgo/test/issue9400/asm_ppc64x.s32
-rw-r--r--misc/cgo/test/issue9400/asm_riscv64.s31
-rw-r--r--misc/cgo/test/issue9400/asm_s390x.s26
-rw-r--r--misc/cgo/test/issue9400/gccgo.go26
-rw-r--r--misc/cgo/test/issue9400/stubs.go11
-rw-r--r--misc/cgo/test/issue9400_linux.go67
-rw-r--r--misc/cgo/test/issue9510.go24
-rw-r--r--misc/cgo/test/issue9510a/a.go15
-rw-r--r--misc/cgo/test/issue9510b/b.go15
-rw-r--r--misc/cgo/test/setgid2_linux.go35
-rw-r--r--misc/cgo/test/setgid_linux.go49
-rw-r--r--misc/cgo/test/sigaltstack.go79
-rw-r--r--misc/cgo/test/sigprocmask.c51
-rw-r--r--misc/cgo/test/sigprocmask.go41
-rw-r--r--misc/cgo/test/test.go2303
-rw-r--r--misc/cgo/test/test26213.go15
-rw-r--r--misc/cgo/test/test_unix.go12
-rw-r--r--misc/cgo/test/test_windows.go9
-rw-r--r--misc/cgo/test/testx.c24
-rw-r--r--misc/cgo/test/testx.go583
-rw-r--r--misc/cgo/test/typeparam.go17
124 files changed, 7838 insertions, 0 deletions
diff --git a/misc/cgo/test/backdoor.go b/misc/cgo/test/backdoor.go
new file mode 100644
index 0000000..6fb33d6
--- /dev/null
+++ b/misc/cgo/test/backdoor.go
@@ -0,0 +1,11 @@
+// Copyright 2014 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.
+
+package cgotest
+
+import _ "unsafe"
+
+//go:linkname lockedOSThread runtime.lockedOSThread
+//extern runtime_lockedOSThread
+func lockedOSThread() bool
diff --git a/misc/cgo/test/buildid_linux.go b/misc/cgo/test/buildid_linux.go
new file mode 100644
index 0000000..84d3edb
--- /dev/null
+++ b/misc/cgo/test/buildid_linux.go
@@ -0,0 +1,78 @@
+// Copyright 2014 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.
+
+package cgotest
+
+// Test that we have no more than one build ID. In the past we used
+// to generate a separate build ID for each package using cgo, and the
+// linker concatenated them all. We don't want that--we only want
+// one.
+
+import (
+ "bytes"
+ "debug/elf"
+ "os"
+ "testing"
+)
+
+func testBuildID(t *testing.T) {
+ f, err := elf.Open("/proc/self/exe")
+ if err != nil {
+ if os.IsNotExist(err) {
+ t.Skip("no /proc/self/exe")
+ }
+ t.Fatal("opening /proc/self/exe: ", err)
+ }
+ defer f.Close()
+
+ c := 0
+sections:
+ for i, s := range f.Sections {
+ if s.Type != elf.SHT_NOTE {
+ continue
+ }
+
+ d, err := s.Data()
+ if err != nil {
+ t.Logf("reading data of note section %d: %v", i, err)
+ continue
+ }
+
+ for len(d) > 0 {
+
+ // ELF standards differ as to the sizes in
+ // note sections. Both the GNU linker and
+ // gold always generate 32-bit sizes, so that
+ // is what we assume here.
+
+ if len(d) < 12 {
+ t.Logf("note section %d too short (%d < 12)", i, len(d))
+ continue sections
+ }
+
+ namesz := f.ByteOrder.Uint32(d)
+ descsz := f.ByteOrder.Uint32(d[4:])
+ typ := f.ByteOrder.Uint32(d[8:])
+
+ an := (namesz + 3) &^ 3
+ ad := (descsz + 3) &^ 3
+
+ if int(12+an+ad) > len(d) {
+ t.Logf("note section %d too short for header (%d < 12 + align(%d,4) + align(%d,4))", i, len(d), namesz, descsz)
+ continue sections
+ }
+
+ // 3 == NT_GNU_BUILD_ID
+ if typ == 3 && namesz == 4 && bytes.Equal(d[12:16], []byte("GNU\000")) {
+ c++
+ }
+
+ d = d[12+an+ad:]
+ }
+ }
+
+ if c > 1 {
+ t.Errorf("found %d build ID notes", c)
+ }
+}
diff --git a/misc/cgo/test/callback.go b/misc/cgo/test/callback.go
new file mode 100644
index 0000000..08dd9b3
--- /dev/null
+++ b/misc/cgo/test/callback.go
@@ -0,0 +1,1782 @@
+// Copyright 2011 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.
+
+package cgotest
+
+/*
+void callback(void *f);
+void callGoFoo(void);
+void callGoStackCheck(void);
+void callPanic(void);
+int callGoReturnVal(void);
+int returnAfterGrow(void);
+int returnAfterGrowFromGo(void);
+void callGoWithString(void);
+*/
+import "C"
+
+import (
+ "path"
+ "runtime"
+ "strings"
+ "sync"
+ "testing"
+ "unsafe"
+)
+
+// Pass a func value from nestedCall to goCallback using an integer token.
+var callbackMutex sync.Mutex
+var callbackToken int
+var callbackFuncs = make(map[int]func())
+
+// nestedCall calls into C, back into Go, and finally to f.
+func nestedCall(f func()) {
+ // callback(x) calls goCallback(x)
+ callbackMutex.Lock()
+ callbackToken++
+ i := callbackToken
+ callbackFuncs[i] = f
+ callbackMutex.Unlock()
+
+ // Pass the address of i because the C function was written to
+ // take a pointer. We could pass an int if we felt like
+ // rewriting the C code.
+ C.callback(unsafe.Pointer(&i))
+
+ callbackMutex.Lock()
+ delete(callbackFuncs, i)
+ callbackMutex.Unlock()
+}
+
+//export goCallback
+func goCallback(p unsafe.Pointer) {
+ i := *(*int)(p)
+
+ callbackMutex.Lock()
+ f := callbackFuncs[i]
+ callbackMutex.Unlock()
+
+ if f == nil {
+ panic("missing callback function")
+ }
+ f()
+}
+
+func testCallback(t *testing.T) {
+ var x = false
+ nestedCall(func() { x = true })
+ if !x {
+ t.Fatal("nestedCall did not call func")
+ }
+}
+
+func testCallbackGC(t *testing.T) {
+ nestedCall(runtime.GC)
+}
+
+func testCallbackPanic(t *testing.T) {
+ // Make sure panic during callback unwinds properly.
+ if lockedOSThread() {
+ t.Fatal("locked OS thread on entry to TestCallbackPanic")
+ }
+ defer func() {
+ s := recover()
+ if s == nil {
+ t.Fatal("did not panic")
+ }
+ if s.(string) != "callback panic" {
+ t.Fatal("wrong panic:", s)
+ }
+ if lockedOSThread() {
+ t.Fatal("locked OS thread on exit from TestCallbackPanic")
+ }
+ }()
+ nestedCall(func() { panic("callback panic") })
+ panic("nestedCall returned")
+}
+
+func testCallbackPanicLoop(t *testing.T) {
+ // Make sure we don't blow out m->g0 stack.
+ for i := 0; i < 100000; i++ {
+ testCallbackPanic(t)
+ }
+}
+
+func testCallbackPanicLocked(t *testing.T) {
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ if !lockedOSThread() {
+ t.Fatal("runtime.LockOSThread didn't")
+ }
+ defer func() {
+ s := recover()
+ if s == nil {
+ t.Fatal("did not panic")
+ }
+ if s.(string) != "callback panic" {
+ t.Fatal("wrong panic:", s)
+ }
+ if !lockedOSThread() {
+ t.Fatal("lost lock on OS thread after panic")
+ }
+ }()
+ nestedCall(func() { panic("callback panic") })
+ panic("nestedCall returned")
+}
+
+// Callback with zero arguments used to make the stack misaligned,
+// which broke the garbage collector and other things.
+func testZeroArgCallback(t *testing.T) {
+ defer func() {
+ s := recover()
+ if s != nil {
+ t.Fatal("panic during callback:", s)
+ }
+ }()
+ C.callGoFoo()
+}
+
+//export goFoo
+func goFoo() {
+ x := 1
+ for i := 0; i < 10000; i++ {
+ // variadic call mallocs + writes to
+ variadic(x, x, x)
+ if x != 1 {
+ panic("bad x")
+ }
+ }
+}
+
+func variadic(x ...interface{}) {}
+
+func testBlocking(t *testing.T) {
+ c := make(chan int)
+ go func() {
+ for i := 0; i < 10; i++ {
+ c <- <-c
+ }
+ }()
+ nestedCall(func() {
+ for i := 0; i < 10; i++ {
+ c <- i
+ if j := <-c; j != i {
+ t.Errorf("out of sync %d != %d", j, i)
+ }
+ }
+ })
+}
+
+// Test that the stack can be unwound through a call out and call back
+// into Go.
+func testCallbackCallers(t *testing.T) {
+ if runtime.Compiler != "gc" {
+ // The exact function names are not going to be the same.
+ t.Skip("skipping for non-gc toolchain")
+ }
+ pc := make([]uintptr, 100)
+ n := 0
+ name := []string{
+ "runtime.cgocallbackg1",
+ "runtime.cgocallbackg",
+ "runtime.cgocallback",
+ "runtime.systemstack_switch",
+ "runtime.cgocall",
+ "test._Cfunc_callback",
+ "test.nestedCall.func1",
+ "test.nestedCall",
+ "test.testCallbackCallers",
+ "test.TestCallbackCallers",
+ "testing.tRunner",
+ "runtime.goexit",
+ }
+ nestedCall(func() {
+ n = runtime.Callers(4, pc)
+ })
+ if n != len(name) {
+ t.Errorf("expected %d frames, got %d", len(name), n)
+ }
+ for i := 0; i < n; i++ {
+ f := runtime.FuncForPC(pc[i] - 1) // TODO: use runtime.CallersFrames
+ if f == nil {
+ t.Fatalf("expected non-nil Func for pc %d", pc[i])
+ }
+ fname := f.Name()
+ // Remove the prepended pathname from automatically
+ // generated cgo function names.
+ if strings.HasPrefix(fname, "_") {
+ fname = path.Base(f.Name()[1:])
+ }
+ // In module mode, this package has a fully-qualified import path.
+ // Remove it if present.
+ fname = strings.TrimPrefix(fname, "misc/cgo/")
+
+ namei := ""
+ if i < len(name) {
+ namei = name[i]
+ }
+ if fname != namei {
+ t.Errorf("stk[%d] = %q, want %q", i, fname, namei)
+ }
+ }
+}
+
+func testPanicFromC(t *testing.T) {
+ defer func() {
+ r := recover()
+ if r == nil {
+ t.Fatal("did not panic")
+ }
+ if r.(string) != "panic from C" {
+ t.Fatal("wrong panic:", r)
+ }
+ }()
+ C.callPanic()
+}
+
+// Test that C code can return a value if it calls a Go function that
+// causes a stack copy.
+func testReturnAfterGrow(t *testing.T) {
+ // Use a new goroutine so that we get a small stack.
+ c := make(chan int)
+ go func() {
+ c <- int(C.returnAfterGrow())
+ }()
+ if got, want := <-c, 123456; got != want {
+ t.Errorf("got %d want %d", got, want)
+ }
+}
+
+// Test that we can return a value from Go->C->Go if the Go code
+// causes a stack copy.
+func testReturnAfterGrowFromGo(t *testing.T) {
+ // Use a new goroutine so that we get a small stack.
+ c := make(chan int)
+ go func() {
+ c <- int(C.returnAfterGrowFromGo())
+ }()
+ if got, want := <-c, 129*128/2; got != want {
+ t.Errorf("got %d want %d", got, want)
+ }
+}
+
+//export goReturnVal
+func goReturnVal() (r C.int) {
+ // Force a stack copy.
+ var f func(int) int
+ f = func(i int) int {
+ var buf [256]byte
+ use(buf[:])
+ if i == 0 {
+ return 0
+ }
+ return i + f(i-1)
+ }
+ r = C.int(f(128))
+ return
+}
+
+// Test that C can pass in a Go string from a string constant.
+func testCallGoWithString(t *testing.T) {
+ C.callGoWithString()
+ want := "string passed from C to Go"
+ if stringFromGo != want {
+ t.Errorf("string passed through C is %s, want %s", stringFromGo, want)
+ }
+}
+
+var stringFromGo string
+
+//export goWithString
+func goWithString(s string) {
+ stringFromGo = s
+}
+
+func testCallbackStack(t *testing.T) {
+ // Make cgo call and callback with different amount of stack available.
+ // We do not do any explicit checks, just ensure that it does not crash.
+ for _, f := range splitTests {
+ f()
+ }
+}
+
+//export goStackCheck
+func goStackCheck() {
+ // use some stack memory to trigger split stack check
+ var buf [256]byte
+ use(buf[:])
+}
+
+var Used byte
+
+func use(buf []byte) {
+ for _, c := range buf {
+ Used += c
+ }
+}
+
+var splitTests = []func(){
+ // Edit .+1,/^}/-1|seq 4 4 5000 | sed 's/.*/ stack&,/' | fmt
+ stack4, stack8, stack12, stack16, stack20, stack24, stack28,
+ stack32, stack36, stack40, stack44, stack48, stack52, stack56,
+ stack60, stack64, stack68, stack72, stack76, stack80, stack84,
+ stack88, stack92, stack96, stack100, stack104, stack108, stack112,
+ stack116, stack120, stack124, stack128, stack132, stack136,
+ stack140, stack144, stack148, stack152, stack156, stack160,
+ stack164, stack168, stack172, stack176, stack180, stack184,
+ stack188, stack192, stack196, stack200, stack204, stack208,
+ stack212, stack216, stack220, stack224, stack228, stack232,
+ stack236, stack240, stack244, stack248, stack252, stack256,
+ stack260, stack264, stack268, stack272, stack276, stack280,
+ stack284, stack288, stack292, stack296, stack300, stack304,
+ stack308, stack312, stack316, stack320, stack324, stack328,
+ stack332, stack336, stack340, stack344, stack348, stack352,
+ stack356, stack360, stack364, stack368, stack372, stack376,
+ stack380, stack384, stack388, stack392, stack396, stack400,
+ stack404, stack408, stack412, stack416, stack420, stack424,
+ stack428, stack432, stack436, stack440, stack444, stack448,
+ stack452, stack456, stack460, stack464, stack468, stack472,
+ stack476, stack480, stack484, stack488, stack492, stack496,
+ stack500, stack504, stack508, stack512, stack516, stack520,
+ stack524, stack528, stack532, stack536, stack540, stack544,
+ stack548, stack552, stack556, stack560, stack564, stack568,
+ stack572, stack576, stack580, stack584, stack588, stack592,
+ stack596, stack600, stack604, stack608, stack612, stack616,
+ stack620, stack624, stack628, stack632, stack636, stack640,
+ stack644, stack648, stack652, stack656, stack660, stack664,
+ stack668, stack672, stack676, stack680, stack684, stack688,
+ stack692, stack696, stack700, stack704, stack708, stack712,
+ stack716, stack720, stack724, stack728, stack732, stack736,
+ stack740, stack744, stack748, stack752, stack756, stack760,
+ stack764, stack768, stack772, stack776, stack780, stack784,
+ stack788, stack792, stack796, stack800, stack804, stack808,
+ stack812, stack816, stack820, stack824, stack828, stack832,
+ stack836, stack840, stack844, stack848, stack852, stack856,
+ stack860, stack864, stack868, stack872, stack876, stack880,
+ stack884, stack888, stack892, stack896, stack900, stack904,
+ stack908, stack912, stack916, stack920, stack924, stack928,
+ stack932, stack936, stack940, stack944, stack948, stack952,
+ stack956, stack960, stack964, stack968, stack972, stack976,
+ stack980, stack984, stack988, stack992, stack996, stack1000,
+ stack1004, stack1008, stack1012, stack1016, stack1020, stack1024,
+ stack1028, stack1032, stack1036, stack1040, stack1044, stack1048,
+ stack1052, stack1056, stack1060, stack1064, stack1068, stack1072,
+ stack1076, stack1080, stack1084, stack1088, stack1092, stack1096,
+ stack1100, stack1104, stack1108, stack1112, stack1116, stack1120,
+ stack1124, stack1128, stack1132, stack1136, stack1140, stack1144,
+ stack1148, stack1152, stack1156, stack1160, stack1164, stack1168,
+ stack1172, stack1176, stack1180, stack1184, stack1188, stack1192,
+ stack1196, stack1200, stack1204, stack1208, stack1212, stack1216,
+ stack1220, stack1224, stack1228, stack1232, stack1236, stack1240,
+ stack1244, stack1248, stack1252, stack1256, stack1260, stack1264,
+ stack1268, stack1272, stack1276, stack1280, stack1284, stack1288,
+ stack1292, stack1296, stack1300, stack1304, stack1308, stack1312,
+ stack1316, stack1320, stack1324, stack1328, stack1332, stack1336,
+ stack1340, stack1344, stack1348, stack1352, stack1356, stack1360,
+ stack1364, stack1368, stack1372, stack1376, stack1380, stack1384,
+ stack1388, stack1392, stack1396, stack1400, stack1404, stack1408,
+ stack1412, stack1416, stack1420, stack1424, stack1428, stack1432,
+ stack1436, stack1440, stack1444, stack1448, stack1452, stack1456,
+ stack1460, stack1464, stack1468, stack1472, stack1476, stack1480,
+ stack1484, stack1488, stack1492, stack1496, stack1500, stack1504,
+ stack1508, stack1512, stack1516, stack1520, stack1524, stack1528,
+ stack1532, stack1536, stack1540, stack1544, stack1548, stack1552,
+ stack1556, stack1560, stack1564, stack1568, stack1572, stack1576,
+ stack1580, stack1584, stack1588, stack1592, stack1596, stack1600,
+ stack1604, stack1608, stack1612, stack1616, stack1620, stack1624,
+ stack1628, stack1632, stack1636, stack1640, stack1644, stack1648,
+ stack1652, stack1656, stack1660, stack1664, stack1668, stack1672,
+ stack1676, stack1680, stack1684, stack1688, stack1692, stack1696,
+ stack1700, stack1704, stack1708, stack1712, stack1716, stack1720,
+ stack1724, stack1728, stack1732, stack1736, stack1740, stack1744,
+ stack1748, stack1752, stack1756, stack1760, stack1764, stack1768,
+ stack1772, stack1776, stack1780, stack1784, stack1788, stack1792,
+ stack1796, stack1800, stack1804, stack1808, stack1812, stack1816,
+ stack1820, stack1824, stack1828, stack1832, stack1836, stack1840,
+ stack1844, stack1848, stack1852, stack1856, stack1860, stack1864,
+ stack1868, stack1872, stack1876, stack1880, stack1884, stack1888,
+ stack1892, stack1896, stack1900, stack1904, stack1908, stack1912,
+ stack1916, stack1920, stack1924, stack1928, stack1932, stack1936,
+ stack1940, stack1944, stack1948, stack1952, stack1956, stack1960,
+ stack1964, stack1968, stack1972, stack1976, stack1980, stack1984,
+ stack1988, stack1992, stack1996, stack2000, stack2004, stack2008,
+ stack2012, stack2016, stack2020, stack2024, stack2028, stack2032,
+ stack2036, stack2040, stack2044, stack2048, stack2052, stack2056,
+ stack2060, stack2064, stack2068, stack2072, stack2076, stack2080,
+ stack2084, stack2088, stack2092, stack2096, stack2100, stack2104,
+ stack2108, stack2112, stack2116, stack2120, stack2124, stack2128,
+ stack2132, stack2136, stack2140, stack2144, stack2148, stack2152,
+ stack2156, stack2160, stack2164, stack2168, stack2172, stack2176,
+ stack2180, stack2184, stack2188, stack2192, stack2196, stack2200,
+ stack2204, stack2208, stack2212, stack2216, stack2220, stack2224,
+ stack2228, stack2232, stack2236, stack2240, stack2244, stack2248,
+ stack2252, stack2256, stack2260, stack2264, stack2268, stack2272,
+ stack2276, stack2280, stack2284, stack2288, stack2292, stack2296,
+ stack2300, stack2304, stack2308, stack2312, stack2316, stack2320,
+ stack2324, stack2328, stack2332, stack2336, stack2340, stack2344,
+ stack2348, stack2352, stack2356, stack2360, stack2364, stack2368,
+ stack2372, stack2376, stack2380, stack2384, stack2388, stack2392,
+ stack2396, stack2400, stack2404, stack2408, stack2412, stack2416,
+ stack2420, stack2424, stack2428, stack2432, stack2436, stack2440,
+ stack2444, stack2448, stack2452, stack2456, stack2460, stack2464,
+ stack2468, stack2472, stack2476, stack2480, stack2484, stack2488,
+ stack2492, stack2496, stack2500, stack2504, stack2508, stack2512,
+ stack2516, stack2520, stack2524, stack2528, stack2532, stack2536,
+ stack2540, stack2544, stack2548, stack2552, stack2556, stack2560,
+ stack2564, stack2568, stack2572, stack2576, stack2580, stack2584,
+ stack2588, stack2592, stack2596, stack2600, stack2604, stack2608,
+ stack2612, stack2616, stack2620, stack2624, stack2628, stack2632,
+ stack2636, stack2640, stack2644, stack2648, stack2652, stack2656,
+ stack2660, stack2664, stack2668, stack2672, stack2676, stack2680,
+ stack2684, stack2688, stack2692, stack2696, stack2700, stack2704,
+ stack2708, stack2712, stack2716, stack2720, stack2724, stack2728,
+ stack2732, stack2736, stack2740, stack2744, stack2748, stack2752,
+ stack2756, stack2760, stack2764, stack2768, stack2772, stack2776,
+ stack2780, stack2784, stack2788, stack2792, stack2796, stack2800,
+ stack2804, stack2808, stack2812, stack2816, stack2820, stack2824,
+ stack2828, stack2832, stack2836, stack2840, stack2844, stack2848,
+ stack2852, stack2856, stack2860, stack2864, stack2868, stack2872,
+ stack2876, stack2880, stack2884, stack2888, stack2892, stack2896,
+ stack2900, stack2904, stack2908, stack2912, stack2916, stack2920,
+ stack2924, stack2928, stack2932, stack2936, stack2940, stack2944,
+ stack2948, stack2952, stack2956, stack2960, stack2964, stack2968,
+ stack2972, stack2976, stack2980, stack2984, stack2988, stack2992,
+ stack2996, stack3000, stack3004, stack3008, stack3012, stack3016,
+ stack3020, stack3024, stack3028, stack3032, stack3036, stack3040,
+ stack3044, stack3048, stack3052, stack3056, stack3060, stack3064,
+ stack3068, stack3072, stack3076, stack3080, stack3084, stack3088,
+ stack3092, stack3096, stack3100, stack3104, stack3108, stack3112,
+ stack3116, stack3120, stack3124, stack3128, stack3132, stack3136,
+ stack3140, stack3144, stack3148, stack3152, stack3156, stack3160,
+ stack3164, stack3168, stack3172, stack3176, stack3180, stack3184,
+ stack3188, stack3192, stack3196, stack3200, stack3204, stack3208,
+ stack3212, stack3216, stack3220, stack3224, stack3228, stack3232,
+ stack3236, stack3240, stack3244, stack3248, stack3252, stack3256,
+ stack3260, stack3264, stack3268, stack3272, stack3276, stack3280,
+ stack3284, stack3288, stack3292, stack3296, stack3300, stack3304,
+ stack3308, stack3312, stack3316, stack3320, stack3324, stack3328,
+ stack3332, stack3336, stack3340, stack3344, stack3348, stack3352,
+ stack3356, stack3360, stack3364, stack3368, stack3372, stack3376,
+ stack3380, stack3384, stack3388, stack3392, stack3396, stack3400,
+ stack3404, stack3408, stack3412, stack3416, stack3420, stack3424,
+ stack3428, stack3432, stack3436, stack3440, stack3444, stack3448,
+ stack3452, stack3456, stack3460, stack3464, stack3468, stack3472,
+ stack3476, stack3480, stack3484, stack3488, stack3492, stack3496,
+ stack3500, stack3504, stack3508, stack3512, stack3516, stack3520,
+ stack3524, stack3528, stack3532, stack3536, stack3540, stack3544,
+ stack3548, stack3552, stack3556, stack3560, stack3564, stack3568,
+ stack3572, stack3576, stack3580, stack3584, stack3588, stack3592,
+ stack3596, stack3600, stack3604, stack3608, stack3612, stack3616,
+ stack3620, stack3624, stack3628, stack3632, stack3636, stack3640,
+ stack3644, stack3648, stack3652, stack3656, stack3660, stack3664,
+ stack3668, stack3672, stack3676, stack3680, stack3684, stack3688,
+ stack3692, stack3696, stack3700, stack3704, stack3708, stack3712,
+ stack3716, stack3720, stack3724, stack3728, stack3732, stack3736,
+ stack3740, stack3744, stack3748, stack3752, stack3756, stack3760,
+ stack3764, stack3768, stack3772, stack3776, stack3780, stack3784,
+ stack3788, stack3792, stack3796, stack3800, stack3804, stack3808,
+ stack3812, stack3816, stack3820, stack3824, stack3828, stack3832,
+ stack3836, stack3840, stack3844, stack3848, stack3852, stack3856,
+ stack3860, stack3864, stack3868, stack3872, stack3876, stack3880,
+ stack3884, stack3888, stack3892, stack3896, stack3900, stack3904,
+ stack3908, stack3912, stack3916, stack3920, stack3924, stack3928,
+ stack3932, stack3936, stack3940, stack3944, stack3948, stack3952,
+ stack3956, stack3960, stack3964, stack3968, stack3972, stack3976,
+ stack3980, stack3984, stack3988, stack3992, stack3996, stack4000,
+ stack4004, stack4008, stack4012, stack4016, stack4020, stack4024,
+ stack4028, stack4032, stack4036, stack4040, stack4044, stack4048,
+ stack4052, stack4056, stack4060, stack4064, stack4068, stack4072,
+ stack4076, stack4080, stack4084, stack4088, stack4092, stack4096,
+ stack4100, stack4104, stack4108, stack4112, stack4116, stack4120,
+ stack4124, stack4128, stack4132, stack4136, stack4140, stack4144,
+ stack4148, stack4152, stack4156, stack4160, stack4164, stack4168,
+ stack4172, stack4176, stack4180, stack4184, stack4188, stack4192,
+ stack4196, stack4200, stack4204, stack4208, stack4212, stack4216,
+ stack4220, stack4224, stack4228, stack4232, stack4236, stack4240,
+ stack4244, stack4248, stack4252, stack4256, stack4260, stack4264,
+ stack4268, stack4272, stack4276, stack4280, stack4284, stack4288,
+ stack4292, stack4296, stack4300, stack4304, stack4308, stack4312,
+ stack4316, stack4320, stack4324, stack4328, stack4332, stack4336,
+ stack4340, stack4344, stack4348, stack4352, stack4356, stack4360,
+ stack4364, stack4368, stack4372, stack4376, stack4380, stack4384,
+ stack4388, stack4392, stack4396, stack4400, stack4404, stack4408,
+ stack4412, stack4416, stack4420, stack4424, stack4428, stack4432,
+ stack4436, stack4440, stack4444, stack4448, stack4452, stack4456,
+ stack4460, stack4464, stack4468, stack4472, stack4476, stack4480,
+ stack4484, stack4488, stack4492, stack4496, stack4500, stack4504,
+ stack4508, stack4512, stack4516, stack4520, stack4524, stack4528,
+ stack4532, stack4536, stack4540, stack4544, stack4548, stack4552,
+ stack4556, stack4560, stack4564, stack4568, stack4572, stack4576,
+ stack4580, stack4584, stack4588, stack4592, stack4596, stack4600,
+ stack4604, stack4608, stack4612, stack4616, stack4620, stack4624,
+ stack4628, stack4632, stack4636, stack4640, stack4644, stack4648,
+ stack4652, stack4656, stack4660, stack4664, stack4668, stack4672,
+ stack4676, stack4680, stack4684, stack4688, stack4692, stack4696,
+ stack4700, stack4704, stack4708, stack4712, stack4716, stack4720,
+ stack4724, stack4728, stack4732, stack4736, stack4740, stack4744,
+ stack4748, stack4752, stack4756, stack4760, stack4764, stack4768,
+ stack4772, stack4776, stack4780, stack4784, stack4788, stack4792,
+ stack4796, stack4800, stack4804, stack4808, stack4812, stack4816,
+ stack4820, stack4824, stack4828, stack4832, stack4836, stack4840,
+ stack4844, stack4848, stack4852, stack4856, stack4860, stack4864,
+ stack4868, stack4872, stack4876, stack4880, stack4884, stack4888,
+ stack4892, stack4896, stack4900, stack4904, stack4908, stack4912,
+ stack4916, stack4920, stack4924, stack4928, stack4932, stack4936,
+ stack4940, stack4944, stack4948, stack4952, stack4956, stack4960,
+ stack4964, stack4968, stack4972, stack4976, stack4980, stack4984,
+ stack4988, stack4992, stack4996, stack5000,
+}
+
+// Edit .+1,$ | seq 4 4 5000 | sed 's/.*/func stack&() { var buf [&]byte; use(buf[:]); C.callGoStackCheck() }/'
+func stack4() { var buf [4]byte; use(buf[:]); C.callGoStackCheck() }
+func stack8() { var buf [8]byte; use(buf[:]); C.callGoStackCheck() }
+func stack12() { var buf [12]byte; use(buf[:]); C.callGoStackCheck() }
+func stack16() { var buf [16]byte; use(buf[:]); C.callGoStackCheck() }
+func stack20() { var buf [20]byte; use(buf[:]); C.callGoStackCheck() }
+func stack24() { var buf [24]byte; use(buf[:]); C.callGoStackCheck() }
+func stack28() { var buf [28]byte; use(buf[:]); C.callGoStackCheck() }
+func stack32() { var buf [32]byte; use(buf[:]); C.callGoStackCheck() }
+func stack36() { var buf [36]byte; use(buf[:]); C.callGoStackCheck() }
+func stack40() { var buf [40]byte; use(buf[:]); C.callGoStackCheck() }
+func stack44() { var buf [44]byte; use(buf[:]); C.callGoStackCheck() }
+func stack48() { var buf [48]byte; use(buf[:]); C.callGoStackCheck() }
+func stack52() { var buf [52]byte; use(buf[:]); C.callGoStackCheck() }
+func stack56() { var buf [56]byte; use(buf[:]); C.callGoStackCheck() }
+func stack60() { var buf [60]byte; use(buf[:]); C.callGoStackCheck() }
+func stack64() { var buf [64]byte; use(buf[:]); C.callGoStackCheck() }
+func stack68() { var buf [68]byte; use(buf[:]); C.callGoStackCheck() }
+func stack72() { var buf [72]byte; use(buf[:]); C.callGoStackCheck() }
+func stack76() { var buf [76]byte; use(buf[:]); C.callGoStackCheck() }
+func stack80() { var buf [80]byte; use(buf[:]); C.callGoStackCheck() }
+func stack84() { var buf [84]byte; use(buf[:]); C.callGoStackCheck() }
+func stack88() { var buf [88]byte; use(buf[:]); C.callGoStackCheck() }
+func stack92() { var buf [92]byte; use(buf[:]); C.callGoStackCheck() }
+func stack96() { var buf [96]byte; use(buf[:]); C.callGoStackCheck() }
+func stack100() { var buf [100]byte; use(buf[:]); C.callGoStackCheck() }
+func stack104() { var buf [104]byte; use(buf[:]); C.callGoStackCheck() }
+func stack108() { var buf [108]byte; use(buf[:]); C.callGoStackCheck() }
+func stack112() { var buf [112]byte; use(buf[:]); C.callGoStackCheck() }
+func stack116() { var buf [116]byte; use(buf[:]); C.callGoStackCheck() }
+func stack120() { var buf [120]byte; use(buf[:]); C.callGoStackCheck() }
+func stack124() { var buf [124]byte; use(buf[:]); C.callGoStackCheck() }
+func stack128() { var buf [128]byte; use(buf[:]); C.callGoStackCheck() }
+func stack132() { var buf [132]byte; use(buf[:]); C.callGoStackCheck() }
+func stack136() { var buf [136]byte; use(buf[:]); C.callGoStackCheck() }
+func stack140() { var buf [140]byte; use(buf[:]); C.callGoStackCheck() }
+func stack144() { var buf [144]byte; use(buf[:]); C.callGoStackCheck() }
+func stack148() { var buf [148]byte; use(buf[:]); C.callGoStackCheck() }
+func stack152() { var buf [152]byte; use(buf[:]); C.callGoStackCheck() }
+func stack156() { var buf [156]byte; use(buf[:]); C.callGoStackCheck() }
+func stack160() { var buf [160]byte; use(buf[:]); C.callGoStackCheck() }
+func stack164() { var buf [164]byte; use(buf[:]); C.callGoStackCheck() }
+func stack168() { var buf [168]byte; use(buf[:]); C.callGoStackCheck() }
+func stack172() { var buf [172]byte; use(buf[:]); C.callGoStackCheck() }
+func stack176() { var buf [176]byte; use(buf[:]); C.callGoStackCheck() }
+func stack180() { var buf [180]byte; use(buf[:]); C.callGoStackCheck() }
+func stack184() { var buf [184]byte; use(buf[:]); C.callGoStackCheck() }
+func stack188() { var buf [188]byte; use(buf[:]); C.callGoStackCheck() }
+func stack192() { var buf [192]byte; use(buf[:]); C.callGoStackCheck() }
+func stack196() { var buf [196]byte; use(buf[:]); C.callGoStackCheck() }
+func stack200() { var buf [200]byte; use(buf[:]); C.callGoStackCheck() }
+func stack204() { var buf [204]byte; use(buf[:]); C.callGoStackCheck() }
+func stack208() { var buf [208]byte; use(buf[:]); C.callGoStackCheck() }
+func stack212() { var buf [212]byte; use(buf[:]); C.callGoStackCheck() }
+func stack216() { var buf [216]byte; use(buf[:]); C.callGoStackCheck() }
+func stack220() { var buf [220]byte; use(buf[:]); C.callGoStackCheck() }
+func stack224() { var buf [224]byte; use(buf[:]); C.callGoStackCheck() }
+func stack228() { var buf [228]byte; use(buf[:]); C.callGoStackCheck() }
+func stack232() { var buf [232]byte; use(buf[:]); C.callGoStackCheck() }
+func stack236() { var buf [236]byte; use(buf[:]); C.callGoStackCheck() }
+func stack240() { var buf [240]byte; use(buf[:]); C.callGoStackCheck() }
+func stack244() { var buf [244]byte; use(buf[:]); C.callGoStackCheck() }
+func stack248() { var buf [248]byte; use(buf[:]); C.callGoStackCheck() }
+func stack252() { var buf [252]byte; use(buf[:]); C.callGoStackCheck() }
+func stack256() { var buf [256]byte; use(buf[:]); C.callGoStackCheck() }
+func stack260() { var buf [260]byte; use(buf[:]); C.callGoStackCheck() }
+func stack264() { var buf [264]byte; use(buf[:]); C.callGoStackCheck() }
+func stack268() { var buf [268]byte; use(buf[:]); C.callGoStackCheck() }
+func stack272() { var buf [272]byte; use(buf[:]); C.callGoStackCheck() }
+func stack276() { var buf [276]byte; use(buf[:]); C.callGoStackCheck() }
+func stack280() { var buf [280]byte; use(buf[:]); C.callGoStackCheck() }
+func stack284() { var buf [284]byte; use(buf[:]); C.callGoStackCheck() }
+func stack288() { var buf [288]byte; use(buf[:]); C.callGoStackCheck() }
+func stack292() { var buf [292]byte; use(buf[:]); C.callGoStackCheck() }
+func stack296() { var buf [296]byte; use(buf[:]); C.callGoStackCheck() }
+func stack300() { var buf [300]byte; use(buf[:]); C.callGoStackCheck() }
+func stack304() { var buf [304]byte; use(buf[:]); C.callGoStackCheck() }
+func stack308() { var buf [308]byte; use(buf[:]); C.callGoStackCheck() }
+func stack312() { var buf [312]byte; use(buf[:]); C.callGoStackCheck() }
+func stack316() { var buf [316]byte; use(buf[:]); C.callGoStackCheck() }
+func stack320() { var buf [320]byte; use(buf[:]); C.callGoStackCheck() }
+func stack324() { var buf [324]byte; use(buf[:]); C.callGoStackCheck() }
+func stack328() { var buf [328]byte; use(buf[:]); C.callGoStackCheck() }
+func stack332() { var buf [332]byte; use(buf[:]); C.callGoStackCheck() }
+func stack336() { var buf [336]byte; use(buf[:]); C.callGoStackCheck() }
+func stack340() { var buf [340]byte; use(buf[:]); C.callGoStackCheck() }
+func stack344() { var buf [344]byte; use(buf[:]); C.callGoStackCheck() }
+func stack348() { var buf [348]byte; use(buf[:]); C.callGoStackCheck() }
+func stack352() { var buf [352]byte; use(buf[:]); C.callGoStackCheck() }
+func stack356() { var buf [356]byte; use(buf[:]); C.callGoStackCheck() }
+func stack360() { var buf [360]byte; use(buf[:]); C.callGoStackCheck() }
+func stack364() { var buf [364]byte; use(buf[:]); C.callGoStackCheck() }
+func stack368() { var buf [368]byte; use(buf[:]); C.callGoStackCheck() }
+func stack372() { var buf [372]byte; use(buf[:]); C.callGoStackCheck() }
+func stack376() { var buf [376]byte; use(buf[:]); C.callGoStackCheck() }
+func stack380() { var buf [380]byte; use(buf[:]); C.callGoStackCheck() }
+func stack384() { var buf [384]byte; use(buf[:]); C.callGoStackCheck() }
+func stack388() { var buf [388]byte; use(buf[:]); C.callGoStackCheck() }
+func stack392() { var buf [392]byte; use(buf[:]); C.callGoStackCheck() }
+func stack396() { var buf [396]byte; use(buf[:]); C.callGoStackCheck() }
+func stack400() { var buf [400]byte; use(buf[:]); C.callGoStackCheck() }
+func stack404() { var buf [404]byte; use(buf[:]); C.callGoStackCheck() }
+func stack408() { var buf [408]byte; use(buf[:]); C.callGoStackCheck() }
+func stack412() { var buf [412]byte; use(buf[:]); C.callGoStackCheck() }
+func stack416() { var buf [416]byte; use(buf[:]); C.callGoStackCheck() }
+func stack420() { var buf [420]byte; use(buf[:]); C.callGoStackCheck() }
+func stack424() { var buf [424]byte; use(buf[:]); C.callGoStackCheck() }
+func stack428() { var buf [428]byte; use(buf[:]); C.callGoStackCheck() }
+func stack432() { var buf [432]byte; use(buf[:]); C.callGoStackCheck() }
+func stack436() { var buf [436]byte; use(buf[:]); C.callGoStackCheck() }
+func stack440() { var buf [440]byte; use(buf[:]); C.callGoStackCheck() }
+func stack444() { var buf [444]byte; use(buf[:]); C.callGoStackCheck() }
+func stack448() { var buf [448]byte; use(buf[:]); C.callGoStackCheck() }
+func stack452() { var buf [452]byte; use(buf[:]); C.callGoStackCheck() }
+func stack456() { var buf [456]byte; use(buf[:]); C.callGoStackCheck() }
+func stack460() { var buf [460]byte; use(buf[:]); C.callGoStackCheck() }
+func stack464() { var buf [464]byte; use(buf[:]); C.callGoStackCheck() }
+func stack468() { var buf [468]byte; use(buf[:]); C.callGoStackCheck() }
+func stack472() { var buf [472]byte; use(buf[:]); C.callGoStackCheck() }
+func stack476() { var buf [476]byte; use(buf[:]); C.callGoStackCheck() }
+func stack480() { var buf [480]byte; use(buf[:]); C.callGoStackCheck() }
+func stack484() { var buf [484]byte; use(buf[:]); C.callGoStackCheck() }
+func stack488() { var buf [488]byte; use(buf[:]); C.callGoStackCheck() }
+func stack492() { var buf [492]byte; use(buf[:]); C.callGoStackCheck() }
+func stack496() { var buf [496]byte; use(buf[:]); C.callGoStackCheck() }
+func stack500() { var buf [500]byte; use(buf[:]); C.callGoStackCheck() }
+func stack504() { var buf [504]byte; use(buf[:]); C.callGoStackCheck() }
+func stack508() { var buf [508]byte; use(buf[:]); C.callGoStackCheck() }
+func stack512() { var buf [512]byte; use(buf[:]); C.callGoStackCheck() }
+func stack516() { var buf [516]byte; use(buf[:]); C.callGoStackCheck() }
+func stack520() { var buf [520]byte; use(buf[:]); C.callGoStackCheck() }
+func stack524() { var buf [524]byte; use(buf[:]); C.callGoStackCheck() }
+func stack528() { var buf [528]byte; use(buf[:]); C.callGoStackCheck() }
+func stack532() { var buf [532]byte; use(buf[:]); C.callGoStackCheck() }
+func stack536() { var buf [536]byte; use(buf[:]); C.callGoStackCheck() }
+func stack540() { var buf [540]byte; use(buf[:]); C.callGoStackCheck() }
+func stack544() { var buf [544]byte; use(buf[:]); C.callGoStackCheck() }
+func stack548() { var buf [548]byte; use(buf[:]); C.callGoStackCheck() }
+func stack552() { var buf [552]byte; use(buf[:]); C.callGoStackCheck() }
+func stack556() { var buf [556]byte; use(buf[:]); C.callGoStackCheck() }
+func stack560() { var buf [560]byte; use(buf[:]); C.callGoStackCheck() }
+func stack564() { var buf [564]byte; use(buf[:]); C.callGoStackCheck() }
+func stack568() { var buf [568]byte; use(buf[:]); C.callGoStackCheck() }
+func stack572() { var buf [572]byte; use(buf[:]); C.callGoStackCheck() }
+func stack576() { var buf [576]byte; use(buf[:]); C.callGoStackCheck() }
+func stack580() { var buf [580]byte; use(buf[:]); C.callGoStackCheck() }
+func stack584() { var buf [584]byte; use(buf[:]); C.callGoStackCheck() }
+func stack588() { var buf [588]byte; use(buf[:]); C.callGoStackCheck() }
+func stack592() { var buf [592]byte; use(buf[:]); C.callGoStackCheck() }
+func stack596() { var buf [596]byte; use(buf[:]); C.callGoStackCheck() }
+func stack600() { var buf [600]byte; use(buf[:]); C.callGoStackCheck() }
+func stack604() { var buf [604]byte; use(buf[:]); C.callGoStackCheck() }
+func stack608() { var buf [608]byte; use(buf[:]); C.callGoStackCheck() }
+func stack612() { var buf [612]byte; use(buf[:]); C.callGoStackCheck() }
+func stack616() { var buf [616]byte; use(buf[:]); C.callGoStackCheck() }
+func stack620() { var buf [620]byte; use(buf[:]); C.callGoStackCheck() }
+func stack624() { var buf [624]byte; use(buf[:]); C.callGoStackCheck() }
+func stack628() { var buf [628]byte; use(buf[:]); C.callGoStackCheck() }
+func stack632() { var buf [632]byte; use(buf[:]); C.callGoStackCheck() }
+func stack636() { var buf [636]byte; use(buf[:]); C.callGoStackCheck() }
+func stack640() { var buf [640]byte; use(buf[:]); C.callGoStackCheck() }
+func stack644() { var buf [644]byte; use(buf[:]); C.callGoStackCheck() }
+func stack648() { var buf [648]byte; use(buf[:]); C.callGoStackCheck() }
+func stack652() { var buf [652]byte; use(buf[:]); C.callGoStackCheck() }
+func stack656() { var buf [656]byte; use(buf[:]); C.callGoStackCheck() }
+func stack660() { var buf [660]byte; use(buf[:]); C.callGoStackCheck() }
+func stack664() { var buf [664]byte; use(buf[:]); C.callGoStackCheck() }
+func stack668() { var buf [668]byte; use(buf[:]); C.callGoStackCheck() }
+func stack672() { var buf [672]byte; use(buf[:]); C.callGoStackCheck() }
+func stack676() { var buf [676]byte; use(buf[:]); C.callGoStackCheck() }
+func stack680() { var buf [680]byte; use(buf[:]); C.callGoStackCheck() }
+func stack684() { var buf [684]byte; use(buf[:]); C.callGoStackCheck() }
+func stack688() { var buf [688]byte; use(buf[:]); C.callGoStackCheck() }
+func stack692() { var buf [692]byte; use(buf[:]); C.callGoStackCheck() }
+func stack696() { var buf [696]byte; use(buf[:]); C.callGoStackCheck() }
+func stack700() { var buf [700]byte; use(buf[:]); C.callGoStackCheck() }
+func stack704() { var buf [704]byte; use(buf[:]); C.callGoStackCheck() }
+func stack708() { var buf [708]byte; use(buf[:]); C.callGoStackCheck() }
+func stack712() { var buf [712]byte; use(buf[:]); C.callGoStackCheck() }
+func stack716() { var buf [716]byte; use(buf[:]); C.callGoStackCheck() }
+func stack720() { var buf [720]byte; use(buf[:]); C.callGoStackCheck() }
+func stack724() { var buf [724]byte; use(buf[:]); C.callGoStackCheck() }
+func stack728() { var buf [728]byte; use(buf[:]); C.callGoStackCheck() }
+func stack732() { var buf [732]byte; use(buf[:]); C.callGoStackCheck() }
+func stack736() { var buf [736]byte; use(buf[:]); C.callGoStackCheck() }
+func stack740() { var buf [740]byte; use(buf[:]); C.callGoStackCheck() }
+func stack744() { var buf [744]byte; use(buf[:]); C.callGoStackCheck() }
+func stack748() { var buf [748]byte; use(buf[:]); C.callGoStackCheck() }
+func stack752() { var buf [752]byte; use(buf[:]); C.callGoStackCheck() }
+func stack756() { var buf [756]byte; use(buf[:]); C.callGoStackCheck() }
+func stack760() { var buf [760]byte; use(buf[:]); C.callGoStackCheck() }
+func stack764() { var buf [764]byte; use(buf[:]); C.callGoStackCheck() }
+func stack768() { var buf [768]byte; use(buf[:]); C.callGoStackCheck() }
+func stack772() { var buf [772]byte; use(buf[:]); C.callGoStackCheck() }
+func stack776() { var buf [776]byte; use(buf[:]); C.callGoStackCheck() }
+func stack780() { var buf [780]byte; use(buf[:]); C.callGoStackCheck() }
+func stack784() { var buf [784]byte; use(buf[:]); C.callGoStackCheck() }
+func stack788() { var buf [788]byte; use(buf[:]); C.callGoStackCheck() }
+func stack792() { var buf [792]byte; use(buf[:]); C.callGoStackCheck() }
+func stack796() { var buf [796]byte; use(buf[:]); C.callGoStackCheck() }
+func stack800() { var buf [800]byte; use(buf[:]); C.callGoStackCheck() }
+func stack804() { var buf [804]byte; use(buf[:]); C.callGoStackCheck() }
+func stack808() { var buf [808]byte; use(buf[:]); C.callGoStackCheck() }
+func stack812() { var buf [812]byte; use(buf[:]); C.callGoStackCheck() }
+func stack816() { var buf [816]byte; use(buf[:]); C.callGoStackCheck() }
+func stack820() { var buf [820]byte; use(buf[:]); C.callGoStackCheck() }
+func stack824() { var buf [824]byte; use(buf[:]); C.callGoStackCheck() }
+func stack828() { var buf [828]byte; use(buf[:]); C.callGoStackCheck() }
+func stack832() { var buf [832]byte; use(buf[:]); C.callGoStackCheck() }
+func stack836() { var buf [836]byte; use(buf[:]); C.callGoStackCheck() }
+func stack840() { var buf [840]byte; use(buf[:]); C.callGoStackCheck() }
+func stack844() { var buf [844]byte; use(buf[:]); C.callGoStackCheck() }
+func stack848() { var buf [848]byte; use(buf[:]); C.callGoStackCheck() }
+func stack852() { var buf [852]byte; use(buf[:]); C.callGoStackCheck() }
+func stack856() { var buf [856]byte; use(buf[:]); C.callGoStackCheck() }
+func stack860() { var buf [860]byte; use(buf[:]); C.callGoStackCheck() }
+func stack864() { var buf [864]byte; use(buf[:]); C.callGoStackCheck() }
+func stack868() { var buf [868]byte; use(buf[:]); C.callGoStackCheck() }
+func stack872() { var buf [872]byte; use(buf[:]); C.callGoStackCheck() }
+func stack876() { var buf [876]byte; use(buf[:]); C.callGoStackCheck() }
+func stack880() { var buf [880]byte; use(buf[:]); C.callGoStackCheck() }
+func stack884() { var buf [884]byte; use(buf[:]); C.callGoStackCheck() }
+func stack888() { var buf [888]byte; use(buf[:]); C.callGoStackCheck() }
+func stack892() { var buf [892]byte; use(buf[:]); C.callGoStackCheck() }
+func stack896() { var buf [896]byte; use(buf[:]); C.callGoStackCheck() }
+func stack900() { var buf [900]byte; use(buf[:]); C.callGoStackCheck() }
+func stack904() { var buf [904]byte; use(buf[:]); C.callGoStackCheck() }
+func stack908() { var buf [908]byte; use(buf[:]); C.callGoStackCheck() }
+func stack912() { var buf [912]byte; use(buf[:]); C.callGoStackCheck() }
+func stack916() { var buf [916]byte; use(buf[:]); C.callGoStackCheck() }
+func stack920() { var buf [920]byte; use(buf[:]); C.callGoStackCheck() }
+func stack924() { var buf [924]byte; use(buf[:]); C.callGoStackCheck() }
+func stack928() { var buf [928]byte; use(buf[:]); C.callGoStackCheck() }
+func stack932() { var buf [932]byte; use(buf[:]); C.callGoStackCheck() }
+func stack936() { var buf [936]byte; use(buf[:]); C.callGoStackCheck() }
+func stack940() { var buf [940]byte; use(buf[:]); C.callGoStackCheck() }
+func stack944() { var buf [944]byte; use(buf[:]); C.callGoStackCheck() }
+func stack948() { var buf [948]byte; use(buf[:]); C.callGoStackCheck() }
+func stack952() { var buf [952]byte; use(buf[:]); C.callGoStackCheck() }
+func stack956() { var buf [956]byte; use(buf[:]); C.callGoStackCheck() }
+func stack960() { var buf [960]byte; use(buf[:]); C.callGoStackCheck() }
+func stack964() { var buf [964]byte; use(buf[:]); C.callGoStackCheck() }
+func stack968() { var buf [968]byte; use(buf[:]); C.callGoStackCheck() }
+func stack972() { var buf [972]byte; use(buf[:]); C.callGoStackCheck() }
+func stack976() { var buf [976]byte; use(buf[:]); C.callGoStackCheck() }
+func stack980() { var buf [980]byte; use(buf[:]); C.callGoStackCheck() }
+func stack984() { var buf [984]byte; use(buf[:]); C.callGoStackCheck() }
+func stack988() { var buf [988]byte; use(buf[:]); C.callGoStackCheck() }
+func stack992() { var buf [992]byte; use(buf[:]); C.callGoStackCheck() }
+func stack996() { var buf [996]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1000() { var buf [1000]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1004() { var buf [1004]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1008() { var buf [1008]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1012() { var buf [1012]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1016() { var buf [1016]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1020() { var buf [1020]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1024() { var buf [1024]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1028() { var buf [1028]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1032() { var buf [1032]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1036() { var buf [1036]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1040() { var buf [1040]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1044() { var buf [1044]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1048() { var buf [1048]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1052() { var buf [1052]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1056() { var buf [1056]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1060() { var buf [1060]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1064() { var buf [1064]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1068() { var buf [1068]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1072() { var buf [1072]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1076() { var buf [1076]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1080() { var buf [1080]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1084() { var buf [1084]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1088() { var buf [1088]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1092() { var buf [1092]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1096() { var buf [1096]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1100() { var buf [1100]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1104() { var buf [1104]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1108() { var buf [1108]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1112() { var buf [1112]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1116() { var buf [1116]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1120() { var buf [1120]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1124() { var buf [1124]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1128() { var buf [1128]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1132() { var buf [1132]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1136() { var buf [1136]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1140() { var buf [1140]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1144() { var buf [1144]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1148() { var buf [1148]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1152() { var buf [1152]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1156() { var buf [1156]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1160() { var buf [1160]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1164() { var buf [1164]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1168() { var buf [1168]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1172() { var buf [1172]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1176() { var buf [1176]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1180() { var buf [1180]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1184() { var buf [1184]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1188() { var buf [1188]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1192() { var buf [1192]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1196() { var buf [1196]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1200() { var buf [1200]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1204() { var buf [1204]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1208() { var buf [1208]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1212() { var buf [1212]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1216() { var buf [1216]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1220() { var buf [1220]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1224() { var buf [1224]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1228() { var buf [1228]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1232() { var buf [1232]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1236() { var buf [1236]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1240() { var buf [1240]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1244() { var buf [1244]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1248() { var buf [1248]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1252() { var buf [1252]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1256() { var buf [1256]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1260() { var buf [1260]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1264() { var buf [1264]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1268() { var buf [1268]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1272() { var buf [1272]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1276() { var buf [1276]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1280() { var buf [1280]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1284() { var buf [1284]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1288() { var buf [1288]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1292() { var buf [1292]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1296() { var buf [1296]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1300() { var buf [1300]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1304() { var buf [1304]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1308() { var buf [1308]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1312() { var buf [1312]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1316() { var buf [1316]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1320() { var buf [1320]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1324() { var buf [1324]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1328() { var buf [1328]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1332() { var buf [1332]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1336() { var buf [1336]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1340() { var buf [1340]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1344() { var buf [1344]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1348() { var buf [1348]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1352() { var buf [1352]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1356() { var buf [1356]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1360() { var buf [1360]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1364() { var buf [1364]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1368() { var buf [1368]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1372() { var buf [1372]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1376() { var buf [1376]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1380() { var buf [1380]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1384() { var buf [1384]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1388() { var buf [1388]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1392() { var buf [1392]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1396() { var buf [1396]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1400() { var buf [1400]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1404() { var buf [1404]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1408() { var buf [1408]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1412() { var buf [1412]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1416() { var buf [1416]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1420() { var buf [1420]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1424() { var buf [1424]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1428() { var buf [1428]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1432() { var buf [1432]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1436() { var buf [1436]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1440() { var buf [1440]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1444() { var buf [1444]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1448() { var buf [1448]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1452() { var buf [1452]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1456() { var buf [1456]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1460() { var buf [1460]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1464() { var buf [1464]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1468() { var buf [1468]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1472() { var buf [1472]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1476() { var buf [1476]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1480() { var buf [1480]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1484() { var buf [1484]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1488() { var buf [1488]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1492() { var buf [1492]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1496() { var buf [1496]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1500() { var buf [1500]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1504() { var buf [1504]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1508() { var buf [1508]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1512() { var buf [1512]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1516() { var buf [1516]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1520() { var buf [1520]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1524() { var buf [1524]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1528() { var buf [1528]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1532() { var buf [1532]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1536() { var buf [1536]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1540() { var buf [1540]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1544() { var buf [1544]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1548() { var buf [1548]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1552() { var buf [1552]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1556() { var buf [1556]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1560() { var buf [1560]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1564() { var buf [1564]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1568() { var buf [1568]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1572() { var buf [1572]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1576() { var buf [1576]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1580() { var buf [1580]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1584() { var buf [1584]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1588() { var buf [1588]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1592() { var buf [1592]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1596() { var buf [1596]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1600() { var buf [1600]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1604() { var buf [1604]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1608() { var buf [1608]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1612() { var buf [1612]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1616() { var buf [1616]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1620() { var buf [1620]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1624() { var buf [1624]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1628() { var buf [1628]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1632() { var buf [1632]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1636() { var buf [1636]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1640() { var buf [1640]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1644() { var buf [1644]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1648() { var buf [1648]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1652() { var buf [1652]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1656() { var buf [1656]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1660() { var buf [1660]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1664() { var buf [1664]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1668() { var buf [1668]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1672() { var buf [1672]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1676() { var buf [1676]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1680() { var buf [1680]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1684() { var buf [1684]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1688() { var buf [1688]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1692() { var buf [1692]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1696() { var buf [1696]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1700() { var buf [1700]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1704() { var buf [1704]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1708() { var buf [1708]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1712() { var buf [1712]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1716() { var buf [1716]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1720() { var buf [1720]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1724() { var buf [1724]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1728() { var buf [1728]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1732() { var buf [1732]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1736() { var buf [1736]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1740() { var buf [1740]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1744() { var buf [1744]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1748() { var buf [1748]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1752() { var buf [1752]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1756() { var buf [1756]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1760() { var buf [1760]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1764() { var buf [1764]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1768() { var buf [1768]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1772() { var buf [1772]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1776() { var buf [1776]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1780() { var buf [1780]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1784() { var buf [1784]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1788() { var buf [1788]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1792() { var buf [1792]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1796() { var buf [1796]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1800() { var buf [1800]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1804() { var buf [1804]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1808() { var buf [1808]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1812() { var buf [1812]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1816() { var buf [1816]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1820() { var buf [1820]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1824() { var buf [1824]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1828() { var buf [1828]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1832() { var buf [1832]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1836() { var buf [1836]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1840() { var buf [1840]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1844() { var buf [1844]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1848() { var buf [1848]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1852() { var buf [1852]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1856() { var buf [1856]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1860() { var buf [1860]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1864() { var buf [1864]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1868() { var buf [1868]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1872() { var buf [1872]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1876() { var buf [1876]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1880() { var buf [1880]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1884() { var buf [1884]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1888() { var buf [1888]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1892() { var buf [1892]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1896() { var buf [1896]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1900() { var buf [1900]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1904() { var buf [1904]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1908() { var buf [1908]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1912() { var buf [1912]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1916() { var buf [1916]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1920() { var buf [1920]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1924() { var buf [1924]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1928() { var buf [1928]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1932() { var buf [1932]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1936() { var buf [1936]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1940() { var buf [1940]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1944() { var buf [1944]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1948() { var buf [1948]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1952() { var buf [1952]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1956() { var buf [1956]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1960() { var buf [1960]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1964() { var buf [1964]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1968() { var buf [1968]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1972() { var buf [1972]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1976() { var buf [1976]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1980() { var buf [1980]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1984() { var buf [1984]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1988() { var buf [1988]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1992() { var buf [1992]byte; use(buf[:]); C.callGoStackCheck() }
+func stack1996() { var buf [1996]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2000() { var buf [2000]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2004() { var buf [2004]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2008() { var buf [2008]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2012() { var buf [2012]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2016() { var buf [2016]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2020() { var buf [2020]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2024() { var buf [2024]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2028() { var buf [2028]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2032() { var buf [2032]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2036() { var buf [2036]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2040() { var buf [2040]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2044() { var buf [2044]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2048() { var buf [2048]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2052() { var buf [2052]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2056() { var buf [2056]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2060() { var buf [2060]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2064() { var buf [2064]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2068() { var buf [2068]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2072() { var buf [2072]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2076() { var buf [2076]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2080() { var buf [2080]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2084() { var buf [2084]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2088() { var buf [2088]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2092() { var buf [2092]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2096() { var buf [2096]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2100() { var buf [2100]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2104() { var buf [2104]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2108() { var buf [2108]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2112() { var buf [2112]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2116() { var buf [2116]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2120() { var buf [2120]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2124() { var buf [2124]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2128() { var buf [2128]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2132() { var buf [2132]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2136() { var buf [2136]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2140() { var buf [2140]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2144() { var buf [2144]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2148() { var buf [2148]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2152() { var buf [2152]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2156() { var buf [2156]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2160() { var buf [2160]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2164() { var buf [2164]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2168() { var buf [2168]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2172() { var buf [2172]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2176() { var buf [2176]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2180() { var buf [2180]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2184() { var buf [2184]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2188() { var buf [2188]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2192() { var buf [2192]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2196() { var buf [2196]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2200() { var buf [2200]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2204() { var buf [2204]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2208() { var buf [2208]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2212() { var buf [2212]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2216() { var buf [2216]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2220() { var buf [2220]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2224() { var buf [2224]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2228() { var buf [2228]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2232() { var buf [2232]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2236() { var buf [2236]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2240() { var buf [2240]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2244() { var buf [2244]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2248() { var buf [2248]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2252() { var buf [2252]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2256() { var buf [2256]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2260() { var buf [2260]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2264() { var buf [2264]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2268() { var buf [2268]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2272() { var buf [2272]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2276() { var buf [2276]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2280() { var buf [2280]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2284() { var buf [2284]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2288() { var buf [2288]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2292() { var buf [2292]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2296() { var buf [2296]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2300() { var buf [2300]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2304() { var buf [2304]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2308() { var buf [2308]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2312() { var buf [2312]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2316() { var buf [2316]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2320() { var buf [2320]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2324() { var buf [2324]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2328() { var buf [2328]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2332() { var buf [2332]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2336() { var buf [2336]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2340() { var buf [2340]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2344() { var buf [2344]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2348() { var buf [2348]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2352() { var buf [2352]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2356() { var buf [2356]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2360() { var buf [2360]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2364() { var buf [2364]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2368() { var buf [2368]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2372() { var buf [2372]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2376() { var buf [2376]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2380() { var buf [2380]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2384() { var buf [2384]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2388() { var buf [2388]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2392() { var buf [2392]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2396() { var buf [2396]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2400() { var buf [2400]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2404() { var buf [2404]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2408() { var buf [2408]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2412() { var buf [2412]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2416() { var buf [2416]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2420() { var buf [2420]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2424() { var buf [2424]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2428() { var buf [2428]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2432() { var buf [2432]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2436() { var buf [2436]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2440() { var buf [2440]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2444() { var buf [2444]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2448() { var buf [2448]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2452() { var buf [2452]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2456() { var buf [2456]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2460() { var buf [2460]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2464() { var buf [2464]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2468() { var buf [2468]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2472() { var buf [2472]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2476() { var buf [2476]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2480() { var buf [2480]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2484() { var buf [2484]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2488() { var buf [2488]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2492() { var buf [2492]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2496() { var buf [2496]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2500() { var buf [2500]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2504() { var buf [2504]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2508() { var buf [2508]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2512() { var buf [2512]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2516() { var buf [2516]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2520() { var buf [2520]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2524() { var buf [2524]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2528() { var buf [2528]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2532() { var buf [2532]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2536() { var buf [2536]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2540() { var buf [2540]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2544() { var buf [2544]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2548() { var buf [2548]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2552() { var buf [2552]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2556() { var buf [2556]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2560() { var buf [2560]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2564() { var buf [2564]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2568() { var buf [2568]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2572() { var buf [2572]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2576() { var buf [2576]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2580() { var buf [2580]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2584() { var buf [2584]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2588() { var buf [2588]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2592() { var buf [2592]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2596() { var buf [2596]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2600() { var buf [2600]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2604() { var buf [2604]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2608() { var buf [2608]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2612() { var buf [2612]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2616() { var buf [2616]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2620() { var buf [2620]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2624() { var buf [2624]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2628() { var buf [2628]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2632() { var buf [2632]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2636() { var buf [2636]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2640() { var buf [2640]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2644() { var buf [2644]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2648() { var buf [2648]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2652() { var buf [2652]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2656() { var buf [2656]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2660() { var buf [2660]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2664() { var buf [2664]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2668() { var buf [2668]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2672() { var buf [2672]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2676() { var buf [2676]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2680() { var buf [2680]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2684() { var buf [2684]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2688() { var buf [2688]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2692() { var buf [2692]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2696() { var buf [2696]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2700() { var buf [2700]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2704() { var buf [2704]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2708() { var buf [2708]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2712() { var buf [2712]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2716() { var buf [2716]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2720() { var buf [2720]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2724() { var buf [2724]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2728() { var buf [2728]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2732() { var buf [2732]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2736() { var buf [2736]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2740() { var buf [2740]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2744() { var buf [2744]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2748() { var buf [2748]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2752() { var buf [2752]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2756() { var buf [2756]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2760() { var buf [2760]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2764() { var buf [2764]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2768() { var buf [2768]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2772() { var buf [2772]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2776() { var buf [2776]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2780() { var buf [2780]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2784() { var buf [2784]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2788() { var buf [2788]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2792() { var buf [2792]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2796() { var buf [2796]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2800() { var buf [2800]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2804() { var buf [2804]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2808() { var buf [2808]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2812() { var buf [2812]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2816() { var buf [2816]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2820() { var buf [2820]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2824() { var buf [2824]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2828() { var buf [2828]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2832() { var buf [2832]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2836() { var buf [2836]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2840() { var buf [2840]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2844() { var buf [2844]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2848() { var buf [2848]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2852() { var buf [2852]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2856() { var buf [2856]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2860() { var buf [2860]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2864() { var buf [2864]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2868() { var buf [2868]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2872() { var buf [2872]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2876() { var buf [2876]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2880() { var buf [2880]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2884() { var buf [2884]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2888() { var buf [2888]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2892() { var buf [2892]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2896() { var buf [2896]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2900() { var buf [2900]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2904() { var buf [2904]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2908() { var buf [2908]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2912() { var buf [2912]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2916() { var buf [2916]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2920() { var buf [2920]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2924() { var buf [2924]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2928() { var buf [2928]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2932() { var buf [2932]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2936() { var buf [2936]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2940() { var buf [2940]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2944() { var buf [2944]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2948() { var buf [2948]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2952() { var buf [2952]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2956() { var buf [2956]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2960() { var buf [2960]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2964() { var buf [2964]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2968() { var buf [2968]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2972() { var buf [2972]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2976() { var buf [2976]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2980() { var buf [2980]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2984() { var buf [2984]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2988() { var buf [2988]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2992() { var buf [2992]byte; use(buf[:]); C.callGoStackCheck() }
+func stack2996() { var buf [2996]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3000() { var buf [3000]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3004() { var buf [3004]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3008() { var buf [3008]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3012() { var buf [3012]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3016() { var buf [3016]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3020() { var buf [3020]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3024() { var buf [3024]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3028() { var buf [3028]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3032() { var buf [3032]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3036() { var buf [3036]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3040() { var buf [3040]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3044() { var buf [3044]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3048() { var buf [3048]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3052() { var buf [3052]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3056() { var buf [3056]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3060() { var buf [3060]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3064() { var buf [3064]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3068() { var buf [3068]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3072() { var buf [3072]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3076() { var buf [3076]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3080() { var buf [3080]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3084() { var buf [3084]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3088() { var buf [3088]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3092() { var buf [3092]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3096() { var buf [3096]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3100() { var buf [3100]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3104() { var buf [3104]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3108() { var buf [3108]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3112() { var buf [3112]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3116() { var buf [3116]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3120() { var buf [3120]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3124() { var buf [3124]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3128() { var buf [3128]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3132() { var buf [3132]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3136() { var buf [3136]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3140() { var buf [3140]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3144() { var buf [3144]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3148() { var buf [3148]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3152() { var buf [3152]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3156() { var buf [3156]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3160() { var buf [3160]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3164() { var buf [3164]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3168() { var buf [3168]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3172() { var buf [3172]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3176() { var buf [3176]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3180() { var buf [3180]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3184() { var buf [3184]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3188() { var buf [3188]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3192() { var buf [3192]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3196() { var buf [3196]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3200() { var buf [3200]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3204() { var buf [3204]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3208() { var buf [3208]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3212() { var buf [3212]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3216() { var buf [3216]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3220() { var buf [3220]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3224() { var buf [3224]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3228() { var buf [3228]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3232() { var buf [3232]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3236() { var buf [3236]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3240() { var buf [3240]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3244() { var buf [3244]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3248() { var buf [3248]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3252() { var buf [3252]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3256() { var buf [3256]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3260() { var buf [3260]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3264() { var buf [3264]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3268() { var buf [3268]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3272() { var buf [3272]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3276() { var buf [3276]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3280() { var buf [3280]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3284() { var buf [3284]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3288() { var buf [3288]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3292() { var buf [3292]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3296() { var buf [3296]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3300() { var buf [3300]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3304() { var buf [3304]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3308() { var buf [3308]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3312() { var buf [3312]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3316() { var buf [3316]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3320() { var buf [3320]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3324() { var buf [3324]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3328() { var buf [3328]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3332() { var buf [3332]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3336() { var buf [3336]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3340() { var buf [3340]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3344() { var buf [3344]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3348() { var buf [3348]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3352() { var buf [3352]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3356() { var buf [3356]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3360() { var buf [3360]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3364() { var buf [3364]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3368() { var buf [3368]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3372() { var buf [3372]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3376() { var buf [3376]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3380() { var buf [3380]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3384() { var buf [3384]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3388() { var buf [3388]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3392() { var buf [3392]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3396() { var buf [3396]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3400() { var buf [3400]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3404() { var buf [3404]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3408() { var buf [3408]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3412() { var buf [3412]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3416() { var buf [3416]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3420() { var buf [3420]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3424() { var buf [3424]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3428() { var buf [3428]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3432() { var buf [3432]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3436() { var buf [3436]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3440() { var buf [3440]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3444() { var buf [3444]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3448() { var buf [3448]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3452() { var buf [3452]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3456() { var buf [3456]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3460() { var buf [3460]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3464() { var buf [3464]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3468() { var buf [3468]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3472() { var buf [3472]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3476() { var buf [3476]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3480() { var buf [3480]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3484() { var buf [3484]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3488() { var buf [3488]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3492() { var buf [3492]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3496() { var buf [3496]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3500() { var buf [3500]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3504() { var buf [3504]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3508() { var buf [3508]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3512() { var buf [3512]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3516() { var buf [3516]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3520() { var buf [3520]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3524() { var buf [3524]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3528() { var buf [3528]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3532() { var buf [3532]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3536() { var buf [3536]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3540() { var buf [3540]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3544() { var buf [3544]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3548() { var buf [3548]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3552() { var buf [3552]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3556() { var buf [3556]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3560() { var buf [3560]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3564() { var buf [3564]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3568() { var buf [3568]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3572() { var buf [3572]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3576() { var buf [3576]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3580() { var buf [3580]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3584() { var buf [3584]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3588() { var buf [3588]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3592() { var buf [3592]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3596() { var buf [3596]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3600() { var buf [3600]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3604() { var buf [3604]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3608() { var buf [3608]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3612() { var buf [3612]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3616() { var buf [3616]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3620() { var buf [3620]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3624() { var buf [3624]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3628() { var buf [3628]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3632() { var buf [3632]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3636() { var buf [3636]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3640() { var buf [3640]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3644() { var buf [3644]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3648() { var buf [3648]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3652() { var buf [3652]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3656() { var buf [3656]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3660() { var buf [3660]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3664() { var buf [3664]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3668() { var buf [3668]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3672() { var buf [3672]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3676() { var buf [3676]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3680() { var buf [3680]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3684() { var buf [3684]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3688() { var buf [3688]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3692() { var buf [3692]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3696() { var buf [3696]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3700() { var buf [3700]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3704() { var buf [3704]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3708() { var buf [3708]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3712() { var buf [3712]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3716() { var buf [3716]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3720() { var buf [3720]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3724() { var buf [3724]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3728() { var buf [3728]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3732() { var buf [3732]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3736() { var buf [3736]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3740() { var buf [3740]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3744() { var buf [3744]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3748() { var buf [3748]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3752() { var buf [3752]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3756() { var buf [3756]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3760() { var buf [3760]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3764() { var buf [3764]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3768() { var buf [3768]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3772() { var buf [3772]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3776() { var buf [3776]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3780() { var buf [3780]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3784() { var buf [3784]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3788() { var buf [3788]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3792() { var buf [3792]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3796() { var buf [3796]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3800() { var buf [3800]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3804() { var buf [3804]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3808() { var buf [3808]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3812() { var buf [3812]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3816() { var buf [3816]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3820() { var buf [3820]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3824() { var buf [3824]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3828() { var buf [3828]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3832() { var buf [3832]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3836() { var buf [3836]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3840() { var buf [3840]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3844() { var buf [3844]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3848() { var buf [3848]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3852() { var buf [3852]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3856() { var buf [3856]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3860() { var buf [3860]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3864() { var buf [3864]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3868() { var buf [3868]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3872() { var buf [3872]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3876() { var buf [3876]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3880() { var buf [3880]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3884() { var buf [3884]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3888() { var buf [3888]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3892() { var buf [3892]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3896() { var buf [3896]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3900() { var buf [3900]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3904() { var buf [3904]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3908() { var buf [3908]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3912() { var buf [3912]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3916() { var buf [3916]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3920() { var buf [3920]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3924() { var buf [3924]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3928() { var buf [3928]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3932() { var buf [3932]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3936() { var buf [3936]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3940() { var buf [3940]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3944() { var buf [3944]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3948() { var buf [3948]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3952() { var buf [3952]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3956() { var buf [3956]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3960() { var buf [3960]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3964() { var buf [3964]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3968() { var buf [3968]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3972() { var buf [3972]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3976() { var buf [3976]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3980() { var buf [3980]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3984() { var buf [3984]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3988() { var buf [3988]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3992() { var buf [3992]byte; use(buf[:]); C.callGoStackCheck() }
+func stack3996() { var buf [3996]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4000() { var buf [4000]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4004() { var buf [4004]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4008() { var buf [4008]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4012() { var buf [4012]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4016() { var buf [4016]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4020() { var buf [4020]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4024() { var buf [4024]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4028() { var buf [4028]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4032() { var buf [4032]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4036() { var buf [4036]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4040() { var buf [4040]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4044() { var buf [4044]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4048() { var buf [4048]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4052() { var buf [4052]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4056() { var buf [4056]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4060() { var buf [4060]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4064() { var buf [4064]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4068() { var buf [4068]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4072() { var buf [4072]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4076() { var buf [4076]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4080() { var buf [4080]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4084() { var buf [4084]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4088() { var buf [4088]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4092() { var buf [4092]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4096() { var buf [4096]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4100() { var buf [4100]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4104() { var buf [4104]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4108() { var buf [4108]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4112() { var buf [4112]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4116() { var buf [4116]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4120() { var buf [4120]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4124() { var buf [4124]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4128() { var buf [4128]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4132() { var buf [4132]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4136() { var buf [4136]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4140() { var buf [4140]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4144() { var buf [4144]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4148() { var buf [4148]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4152() { var buf [4152]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4156() { var buf [4156]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4160() { var buf [4160]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4164() { var buf [4164]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4168() { var buf [4168]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4172() { var buf [4172]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4176() { var buf [4176]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4180() { var buf [4180]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4184() { var buf [4184]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4188() { var buf [4188]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4192() { var buf [4192]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4196() { var buf [4196]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4200() { var buf [4200]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4204() { var buf [4204]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4208() { var buf [4208]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4212() { var buf [4212]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4216() { var buf [4216]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4220() { var buf [4220]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4224() { var buf [4224]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4228() { var buf [4228]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4232() { var buf [4232]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4236() { var buf [4236]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4240() { var buf [4240]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4244() { var buf [4244]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4248() { var buf [4248]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4252() { var buf [4252]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4256() { var buf [4256]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4260() { var buf [4260]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4264() { var buf [4264]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4268() { var buf [4268]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4272() { var buf [4272]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4276() { var buf [4276]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4280() { var buf [4280]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4284() { var buf [4284]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4288() { var buf [4288]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4292() { var buf [4292]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4296() { var buf [4296]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4300() { var buf [4300]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4304() { var buf [4304]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4308() { var buf [4308]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4312() { var buf [4312]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4316() { var buf [4316]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4320() { var buf [4320]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4324() { var buf [4324]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4328() { var buf [4328]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4332() { var buf [4332]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4336() { var buf [4336]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4340() { var buf [4340]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4344() { var buf [4344]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4348() { var buf [4348]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4352() { var buf [4352]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4356() { var buf [4356]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4360() { var buf [4360]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4364() { var buf [4364]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4368() { var buf [4368]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4372() { var buf [4372]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4376() { var buf [4376]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4380() { var buf [4380]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4384() { var buf [4384]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4388() { var buf [4388]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4392() { var buf [4392]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4396() { var buf [4396]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4400() { var buf [4400]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4404() { var buf [4404]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4408() { var buf [4408]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4412() { var buf [4412]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4416() { var buf [4416]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4420() { var buf [4420]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4424() { var buf [4424]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4428() { var buf [4428]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4432() { var buf [4432]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4436() { var buf [4436]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4440() { var buf [4440]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4444() { var buf [4444]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4448() { var buf [4448]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4452() { var buf [4452]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4456() { var buf [4456]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4460() { var buf [4460]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4464() { var buf [4464]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4468() { var buf [4468]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4472() { var buf [4472]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4476() { var buf [4476]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4480() { var buf [4480]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4484() { var buf [4484]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4488() { var buf [4488]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4492() { var buf [4492]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4496() { var buf [4496]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4500() { var buf [4500]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4504() { var buf [4504]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4508() { var buf [4508]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4512() { var buf [4512]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4516() { var buf [4516]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4520() { var buf [4520]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4524() { var buf [4524]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4528() { var buf [4528]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4532() { var buf [4532]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4536() { var buf [4536]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4540() { var buf [4540]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4544() { var buf [4544]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4548() { var buf [4548]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4552() { var buf [4552]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4556() { var buf [4556]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4560() { var buf [4560]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4564() { var buf [4564]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4568() { var buf [4568]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4572() { var buf [4572]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4576() { var buf [4576]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4580() { var buf [4580]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4584() { var buf [4584]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4588() { var buf [4588]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4592() { var buf [4592]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4596() { var buf [4596]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4600() { var buf [4600]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4604() { var buf [4604]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4608() { var buf [4608]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4612() { var buf [4612]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4616() { var buf [4616]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4620() { var buf [4620]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4624() { var buf [4624]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4628() { var buf [4628]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4632() { var buf [4632]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4636() { var buf [4636]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4640() { var buf [4640]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4644() { var buf [4644]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4648() { var buf [4648]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4652() { var buf [4652]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4656() { var buf [4656]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4660() { var buf [4660]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4664() { var buf [4664]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4668() { var buf [4668]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4672() { var buf [4672]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4676() { var buf [4676]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4680() { var buf [4680]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4684() { var buf [4684]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4688() { var buf [4688]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4692() { var buf [4692]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4696() { var buf [4696]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4700() { var buf [4700]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4704() { var buf [4704]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4708() { var buf [4708]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4712() { var buf [4712]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4716() { var buf [4716]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4720() { var buf [4720]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4724() { var buf [4724]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4728() { var buf [4728]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4732() { var buf [4732]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4736() { var buf [4736]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4740() { var buf [4740]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4744() { var buf [4744]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4748() { var buf [4748]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4752() { var buf [4752]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4756() { var buf [4756]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4760() { var buf [4760]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4764() { var buf [4764]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4768() { var buf [4768]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4772() { var buf [4772]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4776() { var buf [4776]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4780() { var buf [4780]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4784() { var buf [4784]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4788() { var buf [4788]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4792() { var buf [4792]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4796() { var buf [4796]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4800() { var buf [4800]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4804() { var buf [4804]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4808() { var buf [4808]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4812() { var buf [4812]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4816() { var buf [4816]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4820() { var buf [4820]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4824() { var buf [4824]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4828() { var buf [4828]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4832() { var buf [4832]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4836() { var buf [4836]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4840() { var buf [4840]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4844() { var buf [4844]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4848() { var buf [4848]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4852() { var buf [4852]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4856() { var buf [4856]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4860() { var buf [4860]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4864() { var buf [4864]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4868() { var buf [4868]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4872() { var buf [4872]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4876() { var buf [4876]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4880() { var buf [4880]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4884() { var buf [4884]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4888() { var buf [4888]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4892() { var buf [4892]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4896() { var buf [4896]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4900() { var buf [4900]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4904() { var buf [4904]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4908() { var buf [4908]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4912() { var buf [4912]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4916() { var buf [4916]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4920() { var buf [4920]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4924() { var buf [4924]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4928() { var buf [4928]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4932() { var buf [4932]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4936() { var buf [4936]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4940() { var buf [4940]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4944() { var buf [4944]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4948() { var buf [4948]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4952() { var buf [4952]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4956() { var buf [4956]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4960() { var buf [4960]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4964() { var buf [4964]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4968() { var buf [4968]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4972() { var buf [4972]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4976() { var buf [4976]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4980() { var buf [4980]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4984() { var buf [4984]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4988() { var buf [4988]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4992() { var buf [4992]byte; use(buf[:]); C.callGoStackCheck() }
+func stack4996() { var buf [4996]byte; use(buf[:]); C.callGoStackCheck() }
+func stack5000() { var buf [5000]byte; use(buf[:]); C.callGoStackCheck() }
diff --git a/misc/cgo/test/callback_c.c b/misc/cgo/test/callback_c.c
new file mode 100644
index 0000000..8ecf70f
--- /dev/null
+++ b/misc/cgo/test/callback_c.c
@@ -0,0 +1,67 @@
+// Copyright 2011 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.
+
+#include <string.h>
+
+#include "_cgo_export.h"
+
+void
+callback(void *f)
+{
+ // use some stack space
+ volatile char data[64*1024];
+
+ data[0] = 0;
+ goCallback(f);
+ data[sizeof(data)-1] = 0;
+}
+
+void
+callGoFoo(void)
+{
+ extern void goFoo(void);
+ goFoo();
+}
+
+void
+IntoC(void)
+{
+ BackIntoGo();
+}
+
+void
+Issue1560InC(void)
+{
+ Issue1560FromC();
+}
+
+void
+callGoStackCheck(void)
+{
+ extern void goStackCheck(void);
+ goStackCheck();
+}
+
+int
+returnAfterGrow(void)
+{
+ extern int goReturnVal(void);
+ goReturnVal();
+ return 123456;
+}
+
+int
+returnAfterGrowFromGo(void)
+{
+ extern int goReturnVal(void);
+ return goReturnVal();
+}
+
+void
+callGoWithString(void)
+{
+ extern void goWithString(GoString);
+ const char *str = "string passed from C to Go";
+ goWithString((GoString){str, strlen(str)});
+}
diff --git a/misc/cgo/test/callback_c_gc.c b/misc/cgo/test/callback_c_gc.c
new file mode 100644
index 0000000..eb720eb
--- /dev/null
+++ b/misc/cgo/test/callback_c_gc.c
@@ -0,0 +1,25 @@
+// Copyright 2013 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.
+
+// +build gc
+
+#include "_cgo_export.h"
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Test calling panic from C. This is what SWIG does. */
+
+extern void crosscall2(void (*fn)(void *, int), void *, int);
+extern void _cgo_panic(void *, int);
+extern void _cgo_allocate(void *, int);
+
+void
+callPanic(void)
+{
+ struct { const char *p; } a;
+ a.p = "panic from C";
+ crosscall2(_cgo_panic, &a, sizeof a);
+ *(int*)1 = 1;
+}
diff --git a/misc/cgo/test/callback_c_gccgo.c b/misc/cgo/test/callback_c_gccgo.c
new file mode 100644
index 0000000..4eaa818
--- /dev/null
+++ b/misc/cgo/test/callback_c_gccgo.c
@@ -0,0 +1,21 @@
+// Copyright 2013 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.
+
+// +build gccgo
+
+#include "_cgo_export.h"
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Test calling panic from C. This is what SWIG does. */
+
+extern void _cgo_panic(const char *);
+extern void *_cgo_allocate(size_t);
+
+void
+callPanic(void)
+{
+ _cgo_panic("panic from C");
+}
diff --git a/misc/cgo/test/cgo_linux_test.go b/misc/cgo/test/cgo_linux_test.go
new file mode 100644
index 0000000..3a1cf98
--- /dev/null
+++ b/misc/cgo/test/cgo_linux_test.go
@@ -0,0 +1,43 @@
+// Copyright 2012 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.
+
+package cgotest
+
+import (
+ "os"
+ "runtime"
+ "testing"
+)
+
+func TestSetgid(t *testing.T) {
+ if runtime.GOOS == "android" {
+ t.Skip("unsupported on Android")
+ }
+ if _, err := os.Stat("/etc/alpine-release"); err == nil {
+ t.Skip("setgid is broken with musl libc - go.dev/issue/39857")
+ }
+ testSetgid(t)
+}
+
+func TestSetgidStress(t *testing.T) {
+ if runtime.GOOS == "android" {
+ t.Skip("unsupported on Android")
+ }
+ if _, err := os.Stat("/etc/alpine-release"); err == nil {
+ t.Skip("setgid is broken with musl libc - go.dev/issue/39857")
+ }
+ testSetgidStress(t)
+}
+
+func Test1435(t *testing.T) { test1435(t) }
+func Test6997(t *testing.T) { test6997(t) }
+
+func Test9400(t *testing.T) {
+ if _, err := os.Stat("/etc/alpine-release"); err == nil {
+ t.Skip("setgid is broken with musl libc - go.dev/issue/39857")
+ }
+ test9400(t)
+}
+
+func TestBuildID(t *testing.T) { testBuildID(t) }
diff --git a/misc/cgo/test/cgo_stubs_android_test.go b/misc/cgo/test/cgo_stubs_android_test.go
new file mode 100644
index 0000000..a1c2482
--- /dev/null
+++ b/misc/cgo/test/cgo_stubs_android_test.go
@@ -0,0 +1,12 @@
+// Copyright 2012 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.
+
+package cgotest
+
+import "testing"
+
+// Stubs for tests that fails to build on Android
+func test6997(t *testing.T) {}
+func test8694(t *testing.T) {}
+func testSigaltstack(t *testing.T) {}
diff --git a/misc/cgo/test/cgo_test.go b/misc/cgo/test/cgo_test.go
new file mode 100644
index 0000000..5b29895
--- /dev/null
+++ b/misc/cgo/test/cgo_test.go
@@ -0,0 +1,109 @@
+// Copyright 2011 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.
+
+package cgotest
+
+import "testing"
+
+// The actual test functions are in non-_test.go files
+// so that they can use cgo (import "C").
+// These wrappers are here for gotest to find.
+
+func Test1328(t *testing.T) { test1328(t) }
+func Test1560(t *testing.T) { test1560(t) }
+func Test1635(t *testing.T) { test1635(t) }
+func Test3250(t *testing.T) { test3250(t) }
+func Test3729(t *testing.T) { test3729(t) }
+func Test3775(t *testing.T) { test3775(t) }
+func Test4029(t *testing.T) { test4029(t) }
+func Test4339(t *testing.T) { test4339(t) }
+func Test5227(t *testing.T) { test5227(t) }
+func Test5242(t *testing.T) { test5242(t) }
+func Test5337(t *testing.T) { test5337(t) }
+func Test5548(t *testing.T) { test5548(t) }
+func Test5603(t *testing.T) { test5603(t) }
+func Test5986(t *testing.T) { test5986(t) }
+func Test6390(t *testing.T) { test6390(t) }
+func Test6833(t *testing.T) { test6833(t) }
+func Test6907(t *testing.T) { test6907(t) }
+func Test6907Go(t *testing.T) { test6907Go(t) }
+func Test7560(t *testing.T) { test7560(t) }
+func Test7665(t *testing.T) { test7665(t) }
+func Test7978(t *testing.T) { test7978(t) }
+func Test8092(t *testing.T) { test8092(t) }
+func Test8517(t *testing.T) { test8517(t) }
+func Test8694(t *testing.T) { test8694(t) }
+func Test8756(t *testing.T) { test8756(t) }
+func Test8811(t *testing.T) { test8811(t) }
+func Test9026(t *testing.T) { test9026(t) }
+func Test9510(t *testing.T) { test9510(t) }
+func Test9557(t *testing.T) { test9557(t) }
+func Test10303(t *testing.T) { test10303(t, 10) }
+func Test11925(t *testing.T) { test11925(t) }
+func Test12030(t *testing.T) { test12030(t) }
+func Test14838(t *testing.T) { test14838(t) }
+func Test17065(t *testing.T) { test17065(t) }
+func Test17537(t *testing.T) { test17537(t) }
+func Test18126(t *testing.T) { test18126(t) }
+func Test18720(t *testing.T) { test18720(t) }
+func Test20129(t *testing.T) { test20129(t) }
+func Test20266(t *testing.T) { test20266(t) }
+func Test20369(t *testing.T) { test20369(t) }
+func Test20910(t *testing.T) { test20910(t) }
+func Test21708(t *testing.T) { test21708(t) }
+func Test21809(t *testing.T) { test21809(t) }
+func Test21897(t *testing.T) { test21897(t) }
+func Test22906(t *testing.T) { test22906(t) }
+func Test23356(t *testing.T) { test23356(t) }
+func Test24206(t *testing.T) { test24206(t) }
+func Test25143(t *testing.T) { test25143(t) }
+func Test26066(t *testing.T) { test26066(t) }
+func Test26213(t *testing.T) { test26213(t) }
+func Test27660(t *testing.T) { test27660(t) }
+func Test28896(t *testing.T) { test28896(t) }
+func Test30065(t *testing.T) { test30065(t) }
+func Test32579(t *testing.T) { test32579(t) }
+func Test31891(t *testing.T) { test31891(t) }
+func Test42018(t *testing.T) { test42018(t) }
+func Test45451(t *testing.T) { test45451(t) }
+func Test49633(t *testing.T) { test49633(t) }
+func TestAlign(t *testing.T) { testAlign(t) }
+func TestAtol(t *testing.T) { testAtol(t) }
+func TestBlocking(t *testing.T) { testBlocking(t) }
+func TestBoolAlign(t *testing.T) { testBoolAlign(t) }
+func TestCallGoWithString(t *testing.T) { testCallGoWithString(t) }
+func TestCallback(t *testing.T) { testCallback(t) }
+func TestCallbackCallers(t *testing.T) { testCallbackCallers(t) }
+func TestCallbackGC(t *testing.T) { testCallbackGC(t) }
+func TestCallbackPanic(t *testing.T) { testCallbackPanic(t) }
+func TestCallbackPanicLocked(t *testing.T) { testCallbackPanicLocked(t) }
+func TestCallbackPanicLoop(t *testing.T) { testCallbackPanicLoop(t) }
+func TestCallbackStack(t *testing.T) { testCallbackStack(t) }
+func TestCflags(t *testing.T) { testCflags(t) }
+func TestCheckConst(t *testing.T) { testCheckConst(t) }
+func TestConst(t *testing.T) { testConst(t) }
+func TestCthread(t *testing.T) { testCthread(t) }
+func TestEnum(t *testing.T) { testEnum(t) }
+func TestNamedEnum(t *testing.T) { testNamedEnum(t) }
+func TestCastToEnum(t *testing.T) { testCastToEnum(t) }
+func TestErrno(t *testing.T) { testErrno(t) }
+func TestFpVar(t *testing.T) { testFpVar(t) }
+func TestGCC68255(t *testing.T) { testGCC68255(t) }
+func TestHandle(t *testing.T) { testHandle(t) }
+func TestHelpers(t *testing.T) { testHelpers(t) }
+func TestLibgcc(t *testing.T) { testLibgcc(t) }
+func TestMultipleAssign(t *testing.T) { testMultipleAssign(t) }
+func TestNaming(t *testing.T) { testNaming(t) }
+func TestPanicFromC(t *testing.T) { testPanicFromC(t) }
+func TestPrintf(t *testing.T) { testPrintf(t) }
+func TestReturnAfterGrow(t *testing.T) { testReturnAfterGrow(t) }
+func TestReturnAfterGrowFromGo(t *testing.T) { testReturnAfterGrowFromGo(t) }
+func TestSetEnv(t *testing.T) { testSetEnv(t) }
+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) }
diff --git a/misc/cgo/test/cgo_thread_lock.go b/misc/cgo/test/cgo_thread_lock.go
new file mode 100644
index 0000000..3b9ac84
--- /dev/null
+++ b/misc/cgo/test/cgo_thread_lock.go
@@ -0,0 +1,54 @@
+// Copyright 2016 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 linux && freebsd && openbsd
+// +build linux,freebsd,openbsd
+
+package cgotest
+
+/*
+#include <unistd.h>
+#include <sys/syscall.h>
+void Gosched(void);
+static int Ctid(void) { Gosched(); return syscall(SYS_gettid); }
+*/
+import "C"
+
+import (
+ "runtime"
+ "syscall"
+ "testing"
+ "time"
+)
+
+//export Gosched
+func Gosched() {
+ runtime.Gosched()
+}
+
+func init() {
+ testThreadLockFunc = testThreadLock
+}
+
+func testThreadLock(t *testing.T) {
+ stop := make(chan int)
+ go func() {
+ // We need the G continue running,
+ // so the M has a chance to run this G.
+ for {
+ select {
+ case <-stop:
+ return
+ case <-time.After(time.Millisecond * 100):
+ }
+ }
+ }()
+ defer close(stop)
+
+ for i := 0; i < 1000; i++ {
+ if C.int(syscall.Gettid()) != C.Ctid() {
+ t.Fatalf("cgo has not locked OS thread")
+ }
+ }
+}
diff --git a/misc/cgo/test/cgo_unix_test.go b/misc/cgo/test/cgo_unix_test.go
new file mode 100644
index 0000000..a324503
--- /dev/null
+++ b/misc/cgo/test/cgo_unix_test.go
@@ -0,0 +1,14 @@
+// Copyright 2015 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 !windows
+// +build !windows
+
+package cgotest
+
+import "testing"
+
+func TestSigaltstack(t *testing.T) { testSigaltstack(t) }
+func TestSigprocmask(t *testing.T) { testSigprocmask(t) }
+func Test18146(t *testing.T) { test18146(t) }
diff --git a/misc/cgo/test/cthread_unix.c b/misc/cgo/test/cthread_unix.c
new file mode 100644
index 0000000..247d636
--- /dev/null
+++ b/misc/cgo/test/cthread_unix.c
@@ -0,0 +1,34 @@
+// Copyright 2013 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.
+
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
+
+#include <pthread.h>
+#include "_cgo_export.h"
+
+static void*
+addThread(void *p)
+{
+ int i, max;
+
+ max = *(int*)p;
+ for(i=0; i<max; i++)
+ Add(i);
+ return 0;
+}
+
+void
+doAdd(int max, int nthread)
+{
+ enum { MaxThread = 20 };
+ int i;
+ pthread_t thread_id[MaxThread];
+
+ if(nthread > MaxThread)
+ nthread = MaxThread;
+ for(i=0; i<nthread; i++)
+ pthread_create(&thread_id[i], 0, addThread, &max);
+ for(i=0; i<nthread; i++)
+ pthread_join(thread_id[i], 0);
+}
diff --git a/misc/cgo/test/cthread_windows.c b/misc/cgo/test/cthread_windows.c
new file mode 100644
index 0000000..3a62ddd
--- /dev/null
+++ b/misc/cgo/test/cthread_windows.c
@@ -0,0 +1,37 @@
+// Copyright 2013 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.
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <process.h>
+#include "_cgo_export.h"
+
+__stdcall
+static unsigned int
+addThread(void *p)
+{
+ int i, max;
+
+ max = *(int*)p;
+ for(i=0; i<max; i++)
+ Add(i);
+ return 0;
+}
+
+void
+doAdd(int max, int nthread)
+{
+ enum { MaxThread = 20 };
+ int i;
+ uintptr_t thread_id[MaxThread];
+
+ if(nthread > MaxThread)
+ nthread = MaxThread;
+ for(i=0; i<nthread; i++)
+ thread_id[i] = _beginthreadex(0, 0, addThread, &max, 0, 0);
+ for(i=0; i<nthread; i++) {
+ WaitForSingleObject((HANDLE)thread_id[i], INFINITE);
+ CloseHandle((HANDLE)thread_id[i]);
+ }
+}
diff --git a/misc/cgo/test/gcc68255.go b/misc/cgo/test/gcc68255.go
new file mode 100644
index 0000000..7b25e02
--- /dev/null
+++ b/misc/cgo/test/gcc68255.go
@@ -0,0 +1,17 @@
+// Copyright 2015 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.
+
+package cgotest
+
+import (
+ "testing"
+
+ "misc/cgo/test/gcc68255"
+)
+
+func testGCC68255(t *testing.T) {
+ if !gcc68255.F() {
+ t.Error("C global variable was not initialized")
+ }
+}
diff --git a/misc/cgo/test/gcc68255/a.go b/misc/cgo/test/gcc68255/a.go
new file mode 100644
index 0000000..e106dee
--- /dev/null
+++ b/misc/cgo/test/gcc68255/a.go
@@ -0,0 +1,17 @@
+// Copyright 2015 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.
+
+// Test that it's OK to have C code that does nothing other than
+// initialize a global variable. This used to fail with gccgo.
+
+package gcc68255
+
+/*
+#include "c.h"
+*/
+import "C"
+
+func F() bool {
+ return C.v != nil
+}
diff --git a/misc/cgo/test/gcc68255/c.c b/misc/cgo/test/gcc68255/c.c
new file mode 100644
index 0000000..a4fe193
--- /dev/null
+++ b/misc/cgo/test/gcc68255/c.c
@@ -0,0 +1,8 @@
+// Copyright 2015 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.
+
+static void f(void) {
+}
+
+void (*v)(void) = f;
diff --git a/misc/cgo/test/gcc68255/c.h b/misc/cgo/test/gcc68255/c.h
new file mode 100644
index 0000000..05ecd81
--- /dev/null
+++ b/misc/cgo/test/gcc68255/c.h
@@ -0,0 +1,5 @@
+// Copyright 2015 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.
+
+extern void (*v)(void);
diff --git a/misc/cgo/test/issue1435.go b/misc/cgo/test/issue1435.go
new file mode 100644
index 0000000..3fb721a
--- /dev/null
+++ b/misc/cgo/test/issue1435.go
@@ -0,0 +1,204 @@
+// Copyright 2019 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 linux && cgo
+// +build linux,cgo
+
+package cgotest
+
+import (
+ "fmt"
+ "os"
+ "runtime"
+ "sort"
+ "strings"
+ "syscall"
+ "testing"
+)
+
+// #include <stdio.h>
+// #include <stdlib.h>
+// #include <pthread.h>
+// #include <unistd.h>
+// #include <sys/types.h>
+//
+// pthread_t *t = NULL;
+// pthread_mutex_t mu;
+// int nts = 0;
+// int all_done = 0;
+//
+// static void *aFn(void *vargp) {
+// int done = 0;
+// while (!done) {
+// usleep(100);
+// pthread_mutex_lock(&mu);
+// done = all_done;
+// pthread_mutex_unlock(&mu);
+// }
+// return NULL;
+// }
+//
+// void trial(int argc) {
+// int i;
+// nts = argc;
+// t = calloc(nts, sizeof(pthread_t));
+// pthread_mutex_init(&mu, NULL);
+// for (i = 0; i < nts; i++) {
+// pthread_create(&t[i], NULL, aFn, NULL);
+// }
+// }
+//
+// void cleanup(void) {
+// int i;
+// pthread_mutex_lock(&mu);
+// all_done = 1;
+// pthread_mutex_unlock(&mu);
+// for (i = 0; i < nts; i++) {
+// pthread_join(t[i], NULL);
+// }
+// pthread_mutex_destroy(&mu);
+// free(t);
+// }
+import "C"
+
+// compareStatus is used to confirm the contents of the thread
+// specific status files match expectations.
+func compareStatus(filter, expect string) error {
+ expected := filter + expect
+ pid := syscall.Getpid()
+ fs, err := os.ReadDir(fmt.Sprintf("/proc/%d/task", pid))
+ if err != nil {
+ return fmt.Errorf("unable to find %d tasks: %v", pid, err)
+ }
+ expectedProc := fmt.Sprintf("Pid:\t%d", pid)
+ foundAThread := false
+ for _, f := range fs {
+ tf := fmt.Sprintf("/proc/%s/status", f.Name())
+ d, err := os.ReadFile(tf)
+ if err != nil {
+ // There are a surprising number of ways this
+ // can error out on linux. We've seen all of
+ // the following, so treat any error here as
+ // equivalent to the "process is gone":
+ // os.IsNotExist(err),
+ // "... : no such process",
+ // "... : bad file descriptor.
+ continue
+ }
+ lines := strings.Split(string(d), "\n")
+ for _, line := range lines {
+ // Different kernel vintages pad differently.
+ line = strings.TrimSpace(line)
+ if strings.HasPrefix(line, "Pid:\t") {
+ // On loaded systems, it is possible
+ // for a TID to be reused really
+ // quickly. As such, we need to
+ // validate that the thread status
+ // info we just read is a task of the
+ // same process PID as we are
+ // currently running, and not a
+ // recently terminated thread
+ // resurfaced in a different process.
+ if line != expectedProc {
+ break
+ }
+ // Fall through in the unlikely case
+ // that filter at some point is
+ // "Pid:\t".
+ }
+ if strings.HasPrefix(line, filter) {
+ if line == expected {
+ foundAThread = true
+ break
+ }
+ if filter == "Groups:" && strings.HasPrefix(line, "Groups:\t") {
+ // https://github.com/golang/go/issues/46145
+ // Containers don't reliably output this line in sorted order so manually sort and compare that.
+ a := strings.Split(line[8:], " ")
+ sort.Strings(a)
+ got := strings.Join(a, " ")
+ if got == expected[8:] {
+ foundAThread = true
+ break
+ }
+
+ }
+ return fmt.Errorf("%q got:%q want:%q (bad) [pid=%d file:'%s' %v]\n", tf, line, expected, pid, string(d), expectedProc)
+ }
+ }
+ }
+ if !foundAThread {
+ return fmt.Errorf("found no thread /proc/<TID>/status files for process %q", expectedProc)
+ }
+ return nil
+}
+
+// test1435 test 9 glibc implemented setuid/gid syscall functions are
+// mapped. This test is a slightly more expansive test than that of
+// src/syscall/syscall_linux_test.go:TestSetuidEtc() insofar as it
+// launches concurrent threads from C code via CGo and validates that
+// they are subject to the system calls being tested. For the actual
+// Go functionality being tested here, the syscall_linux_test version
+// is considered authoritative, but non-trivial improvements to that
+// should be mirrored here.
+func test1435(t *testing.T) {
+ if syscall.Getuid() != 0 {
+ t.Skip("skipping root only test")
+ }
+ if runtime.GOOS == "linux" {
+ if _, err := os.Stat("/etc/alpine-release"); err == nil {
+ t.Skip("skipping failing test on alpine - go.dev/issue/19938")
+ }
+ }
+
+ // Launch some threads in C.
+ const cts = 5
+ C.trial(cts)
+ defer C.cleanup()
+
+ vs := []struct {
+ call string
+ fn func() error
+ filter, expect string
+ }{
+ {call: "Setegid(1)", fn: func() error { return syscall.Setegid(1) }, filter: "Gid:", expect: "\t0\t1\t0\t1"},
+ {call: "Setegid(0)", fn: func() error { return syscall.Setegid(0) }, filter: "Gid:", expect: "\t0\t0\t0\t0"},
+
+ {call: "Seteuid(1)", fn: func() error { return syscall.Seteuid(1) }, filter: "Uid:", expect: "\t0\t1\t0\t1"},
+ {call: "Setuid(0)", fn: func() error { return syscall.Setuid(0) }, filter: "Uid:", expect: "\t0\t0\t0\t0"},
+
+ {call: "Setgid(1)", fn: func() error { return syscall.Setgid(1) }, filter: "Gid:", expect: "\t1\t1\t1\t1"},
+ {call: "Setgid(0)", fn: func() error { return syscall.Setgid(0) }, filter: "Gid:", expect: "\t0\t0\t0\t0"},
+
+ {call: "Setgroups([]int{0,1,2,3})", fn: func() error { return syscall.Setgroups([]int{0, 1, 2, 3}) }, filter: "Groups:", expect: "\t0 1 2 3"},
+ {call: "Setgroups(nil)", fn: func() error { return syscall.Setgroups(nil) }, filter: "Groups:", expect: ""},
+ {call: "Setgroups([]int{0})", fn: func() error { return syscall.Setgroups([]int{0}) }, filter: "Groups:", expect: "\t0"},
+
+ {call: "Setregid(101,0)", fn: func() error { return syscall.Setregid(101, 0) }, filter: "Gid:", expect: "\t101\t0\t0\t0"},
+ {call: "Setregid(0,102)", fn: func() error { return syscall.Setregid(0, 102) }, filter: "Gid:", expect: "\t0\t102\t102\t102"},
+ {call: "Setregid(0,0)", fn: func() error { return syscall.Setregid(0, 0) }, filter: "Gid:", expect: "\t0\t0\t0\t0"},
+
+ {call: "Setreuid(1,0)", fn: func() error { return syscall.Setreuid(1, 0) }, filter: "Uid:", expect: "\t1\t0\t0\t0"},
+ {call: "Setreuid(0,2)", fn: func() error { return syscall.Setreuid(0, 2) }, filter: "Uid:", expect: "\t0\t2\t2\t2"},
+ {call: "Setreuid(0,0)", fn: func() error { return syscall.Setreuid(0, 0) }, filter: "Uid:", expect: "\t0\t0\t0\t0"},
+
+ {call: "Setresgid(101,0,102)", fn: func() error { return syscall.Setresgid(101, 0, 102) }, filter: "Gid:", expect: "\t101\t0\t102\t0"},
+ {call: "Setresgid(0,102,101)", fn: func() error { return syscall.Setresgid(0, 102, 101) }, filter: "Gid:", expect: "\t0\t102\t101\t102"},
+ {call: "Setresgid(0,0,0)", fn: func() error { return syscall.Setresgid(0, 0, 0) }, filter: "Gid:", expect: "\t0\t0\t0\t0"},
+
+ {call: "Setresuid(1,0,2)", fn: func() error { return syscall.Setresuid(1, 0, 2) }, filter: "Uid:", expect: "\t1\t0\t2\t0"},
+ {call: "Setresuid(0,2,1)", fn: func() error { return syscall.Setresuid(0, 2, 1) }, filter: "Uid:", expect: "\t0\t2\t1\t2"},
+ {call: "Setresuid(0,0,0)", fn: func() error { return syscall.Setresuid(0, 0, 0) }, filter: "Uid:", expect: "\t0\t0\t0\t0"},
+ }
+
+ for i, v := range vs {
+ if err := v.fn(); err != nil {
+ t.Errorf("[%d] %q failed: %v", i, v.call, err)
+ continue
+ }
+ if err := compareStatus(v.filter, v.expect); err != nil {
+ t.Errorf("[%d] %q comparison: %v", i, v.call, err)
+ }
+ }
+}
diff --git a/misc/cgo/test/issue18146.go b/misc/cgo/test/issue18146.go
new file mode 100644
index 0000000..e50f9ae
--- /dev/null
+++ b/misc/cgo/test/issue18146.go
@@ -0,0 +1,129 @@
+// Copyright 2016 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 !windows
+// +build !windows
+
+// Issue 18146: pthread_create failure during syscall.Exec.
+
+package cgotest
+
+import (
+ "bytes"
+ "crypto/md5"
+ "os"
+ "os/exec"
+ "runtime"
+ "syscall"
+ "testing"
+ "time"
+)
+
+func test18146(t *testing.T) {
+ if testing.Short() {
+ t.Skip("skipping in short mode")
+ }
+
+ if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
+ t.Skipf("skipping flaky test on %s; see golang.org/issue/18202", runtime.GOOS)
+ }
+
+ if runtime.GOARCH == "mips" || runtime.GOARCH == "mips64" {
+ t.Skipf("skipping on %s", runtime.GOARCH)
+ }
+
+ attempts := 1000
+ threads := 4
+
+ // Restrict the number of attempts based on RLIMIT_NPROC.
+ // Tediously, RLIMIT_NPROC was left out of the syscall package,
+ // probably because it is not in POSIX.1, so we define it here.
+ // It is not defined on Solaris.
+ var nproc int
+ setNproc := true
+ switch runtime.GOOS {
+ default:
+ setNproc = false
+ case "aix":
+ nproc = 9
+ case "linux":
+ nproc = 6
+ case "darwin", "dragonfly", "freebsd", "netbsd", "openbsd":
+ nproc = 7
+ }
+ if setNproc {
+ var rlim syscall.Rlimit
+ if syscall.Getrlimit(nproc, &rlim) == nil {
+ max := int(rlim.Cur) / (threads + 5)
+ if attempts > max {
+ t.Logf("lowering attempts from %d to %d for RLIMIT_NPROC", attempts, max)
+ attempts = max
+ }
+ }
+ }
+
+ if os.Getenv("test18146") == "exec" {
+ runtime.GOMAXPROCS(1)
+ for n := threads; n > 0; n-- {
+ go func() {
+ for {
+ _ = md5.Sum([]byte("Hello, ï €!"))
+ }
+ }()
+ }
+ runtime.GOMAXPROCS(threads)
+ argv := append(os.Args, "-test.run=NoSuchTestExists")
+ if err := syscall.Exec(os.Args[0], argv, os.Environ()); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ var cmds []*exec.Cmd
+ defer func() {
+ for _, cmd := range cmds {
+ cmd.Process.Kill()
+ }
+ }()
+
+ args := append(append([]string(nil), os.Args[1:]...), "-test.run=Test18146")
+ for n := attempts; n > 0; n-- {
+ cmd := exec.Command(os.Args[0], args...)
+ cmd.Env = append(os.Environ(), "test18146=exec")
+ buf := bytes.NewBuffer(nil)
+ cmd.Stdout = buf
+ cmd.Stderr = buf
+ if err := cmd.Start(); err != nil {
+ // We are starting so many processes that on
+ // some systems (problem seen on Darwin,
+ // Dragonfly, OpenBSD) the fork call will fail
+ // with EAGAIN.
+ if pe, ok := err.(*os.PathError); ok {
+ err = pe.Err
+ }
+ if se, ok := err.(syscall.Errno); ok && (se == syscall.EAGAIN || se == syscall.EMFILE) {
+ time.Sleep(time.Millisecond)
+ continue
+ }
+
+ t.Error(err)
+ return
+ }
+ cmds = append(cmds, cmd)
+ }
+
+ failures := 0
+ for _, cmd := range cmds {
+ err := cmd.Wait()
+ if err == nil {
+ continue
+ }
+
+ t.Errorf("syscall.Exec failed: %v\n%s", err, cmd.Stdout)
+ failures++
+ }
+
+ if failures > 0 {
+ t.Logf("Failed %v of %v attempts.", failures, len(cmds))
+ }
+}
diff --git a/misc/cgo/test/issue20266.go b/misc/cgo/test/issue20266.go
new file mode 100644
index 0000000..9f95086
--- /dev/null
+++ b/misc/cgo/test/issue20266.go
@@ -0,0 +1,21 @@
+// Copyright 2017 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.
+
+// Issue 20266: use -I with a relative path.
+
+package cgotest
+
+/*
+#cgo CFLAGS: -I issue20266 -Iissue20266 -Ddef20266
+#include "issue20266.h"
+*/
+import "C"
+
+import "testing"
+
+func test20266(t *testing.T) {
+ if got, want := C.issue20266, 20266; got != want {
+ t.Errorf("got %d, want %d", got, want)
+ }
+}
diff --git a/misc/cgo/test/issue20266/issue20266.h b/misc/cgo/test/issue20266/issue20266.h
new file mode 100644
index 0000000..8d3258e
--- /dev/null
+++ b/misc/cgo/test/issue20266/issue20266.h
@@ -0,0 +1,9 @@
+// Copyright 2017 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.
+
+#define issue20266 20266
+
+#ifndef def20266
+#error "expected def20266 to be defined"
+#endif
diff --git a/misc/cgo/test/issue20910.c b/misc/cgo/test/issue20910.c
new file mode 100644
index 0000000..e8d623f
--- /dev/null
+++ b/misc/cgo/test/issue20910.c
@@ -0,0 +1,19 @@
+// Copyright 2017 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.
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include "_cgo_export.h"
+
+/* Test calling a Go function with multiple return values. */
+
+void
+callMulti(void)
+{
+ struct multi_return result = multi();
+ assert(strcmp(result.r0, "multi") == 0);
+ assert(result.r1 == 0);
+ free(result.r0);
+}
diff --git a/misc/cgo/test/issue21897.go b/misc/cgo/test/issue21897.go
new file mode 100644
index 0000000..8f39252
--- /dev/null
+++ b/misc/cgo/test/issue21897.go
@@ -0,0 +1,57 @@
+// Copyright 2017 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 darwin && cgo && !internal
+// +build darwin,cgo,!internal
+
+package cgotest
+
+/*
+#cgo LDFLAGS: -framework CoreFoundation
+#include <CoreFoundation/CoreFoundation.h>
+*/
+import "C"
+import (
+ "runtime/debug"
+ "testing"
+ "unsafe"
+)
+
+func test21897(t *testing.T) {
+ // Please write barrier, kick in soon.
+ defer debug.SetGCPercent(debug.SetGCPercent(1))
+
+ for i := 0; i < 10000; i++ {
+ testCFNumberRef()
+ testCFDateRef()
+ testCFBooleanRef()
+ // Allocate some memory, so eventually the write barrier is enabled
+ // and it will see writes of bad pointers in the test* functions below.
+ byteSliceSink = make([]byte, 1024)
+ }
+}
+
+var byteSliceSink []byte
+
+func testCFNumberRef() {
+ var v int64 = 0
+ xCFNumberRef = C.CFNumberCreate(C.kCFAllocatorSystemDefault, C.kCFNumberSInt64Type, unsafe.Pointer(&v))
+ //fmt.Printf("CFNumberRef: %x\n", uintptr(unsafe.Pointer(xCFNumberRef)))
+}
+
+var xCFNumberRef C.CFNumberRef
+
+func testCFDateRef() {
+ xCFDateRef = C.CFDateCreate(C.kCFAllocatorSystemDefault, 0) // 0 value is 1 Jan 2001 00:00:00 GMT
+ //fmt.Printf("CFDateRef: %x\n", uintptr(unsafe.Pointer(xCFDateRef)))
+}
+
+var xCFDateRef C.CFDateRef
+
+func testCFBooleanRef() {
+ xCFBooleanRef = C.kCFBooleanFalse
+ //fmt.Printf("CFBooleanRef: %x\n", uintptr(unsafe.Pointer(xCFBooleanRef)))
+}
+
+var xCFBooleanRef C.CFBooleanRef
diff --git a/misc/cgo/test/issue21897b.go b/misc/cgo/test/issue21897b.go
new file mode 100644
index 0000000..50aece3
--- /dev/null
+++ b/misc/cgo/test/issue21897b.go
@@ -0,0 +1,14 @@
+// Copyright 2017 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 !darwin || !cgo || internal
+// +build !darwin !cgo internal
+
+package cgotest
+
+import "testing"
+
+func test21897(t *testing.T) {
+ t.Skip("test runs only on darwin+cgo")
+}
diff --git a/misc/cgo/test/issue23555.go b/misc/cgo/test/issue23555.go
new file mode 100644
index 0000000..e84c23c
--- /dev/null
+++ b/misc/cgo/test/issue23555.go
@@ -0,0 +1,13 @@
+// Copyright 2018 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.
+
+// Test that we can have two identical cgo packages in a single binary.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+import (
+ _ "misc/cgo/test/issue23555a"
+ _ "misc/cgo/test/issue23555b"
+)
diff --git a/misc/cgo/test/issue23555a/a.go b/misc/cgo/test/issue23555a/a.go
new file mode 100644
index 0000000..cb6626b
--- /dev/null
+++ b/misc/cgo/test/issue23555a/a.go
@@ -0,0 +1,12 @@
+// Copyright 2018 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.
+
+package issue23555
+
+// #include <stdlib.h>
+import "C"
+
+func X() {
+ C.free(C.malloc(10))
+}
diff --git a/misc/cgo/test/issue23555b/a.go b/misc/cgo/test/issue23555b/a.go
new file mode 100644
index 0000000..cb6626b
--- /dev/null
+++ b/misc/cgo/test/issue23555b/a.go
@@ -0,0 +1,12 @@
+// Copyright 2018 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.
+
+package issue23555
+
+// #include <stdlib.h>
+import "C"
+
+func X() {
+ C.free(C.malloc(10))
+}
diff --git a/misc/cgo/test/issue24161_darwin_test.go b/misc/cgo/test/issue24161_darwin_test.go
new file mode 100644
index 0000000..7bb2af6
--- /dev/null
+++ b/misc/cgo/test/issue24161_darwin_test.go
@@ -0,0 +1,31 @@
+// Copyright 2018 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.
+
+package cgotest
+
+import (
+ "testing"
+
+ "misc/cgo/test/issue24161arg"
+ "misc/cgo/test/issue24161e0"
+ "misc/cgo/test/issue24161e1"
+ "misc/cgo/test/issue24161e2"
+ "misc/cgo/test/issue24161res"
+)
+
+func Test24161Arg(t *testing.T) {
+ issue24161arg.Test(t)
+}
+func Test24161Res(t *testing.T) {
+ issue24161res.Test(t)
+}
+func Test24161Example0(t *testing.T) {
+ issue24161e0.Test(t)
+}
+func Test24161Example1(t *testing.T) {
+ issue24161e1.Test(t)
+}
+func Test24161Example2(t *testing.T) {
+ issue24161e2.Test(t)
+}
diff --git a/misc/cgo/test/issue24161arg/def.go b/misc/cgo/test/issue24161arg/def.go
new file mode 100644
index 0000000..d33479a
--- /dev/null
+++ b/misc/cgo/test/issue24161arg/def.go
@@ -0,0 +1,17 @@
+// Copyright 2018 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.
+
+// +build darwin
+
+package issue24161arg
+
+/*
+#cgo LDFLAGS: -framework CoreFoundation
+#include <CoreFoundation/CoreFoundation.h>
+*/
+import "C"
+
+func test24161array() C.CFArrayRef {
+ return C.CFArrayCreate(0, nil, 0, nil)
+}
diff --git a/misc/cgo/test/issue24161arg/use.go b/misc/cgo/test/issue24161arg/use.go
new file mode 100644
index 0000000..3e74944
--- /dev/null
+++ b/misc/cgo/test/issue24161arg/use.go
@@ -0,0 +1,19 @@
+// Copyright 2018 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.
+
+// +build darwin
+
+package issue24161arg
+
+/*
+#cgo LDFLAGS: -framework CoreFoundation
+#include <CoreFoundation/CoreFoundation.h>
+*/
+import "C"
+import "testing"
+
+func Test(t *testing.T) {
+ a := test24161array()
+ C.CFArrayCreateCopy(0, a)
+}
diff --git a/misc/cgo/test/issue24161e0/main.go b/misc/cgo/test/issue24161e0/main.go
new file mode 100644
index 0000000..efe5345
--- /dev/null
+++ b/misc/cgo/test/issue24161e0/main.go
@@ -0,0 +1,29 @@
+// Copyright 2018 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.
+
+// +build darwin
+
+package issue24161e0
+
+/*
+#cgo CFLAGS: -x objective-c
+#cgo LDFLAGS: -framework CoreFoundation -framework Security
+#include <TargetConditionals.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <Security/Security.h>
+#if TARGET_OS_IPHONE == 0 && __MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+ typedef CFStringRef SecKeyAlgorithm;
+ static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
+ #define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
+ static SecKeyAlgorithm foo(void){return NULL;}
+#endif
+*/
+import "C"
+import "testing"
+
+func f1() {
+ C.SecKeyCreateSignature(0, C.kSecKeyAlgorithmECDSASignatureDigestX962SHA1, 0, nil)
+}
+
+func Test(t *testing.T) {}
diff --git a/misc/cgo/test/issue24161e1/main.go b/misc/cgo/test/issue24161e1/main.go
new file mode 100644
index 0000000..82bf172
--- /dev/null
+++ b/misc/cgo/test/issue24161e1/main.go
@@ -0,0 +1,38 @@
+// Copyright 2018 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.
+
+// +build darwin
+
+package issue24161e1
+
+/*
+#cgo CFLAGS: -x objective-c
+#cgo LDFLAGS: -framework CoreFoundation -framework Security
+#include <TargetConditionals.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <Security/Security.h>
+#if TARGET_OS_IPHONE == 0 && __MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+ typedef CFStringRef SecKeyAlgorithm;
+ static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
+ #define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
+ static SecKeyAlgorithm foo(void){return NULL;}
+#endif
+*/
+import "C"
+import (
+ "fmt"
+ "testing"
+)
+
+func f1() {
+ C.SecKeyCreateSignature(0, C.kSecKeyAlgorithmECDSASignatureDigestX962SHA1, 0, nil)
+}
+
+func f2(e C.CFErrorRef) {
+ if desc := C.CFErrorCopyDescription(e); desc != 0 {
+ fmt.Println(desc)
+ }
+}
+
+func Test(t *testing.T) {}
diff --git a/misc/cgo/test/issue24161e2/main.go b/misc/cgo/test/issue24161e2/main.go
new file mode 100644
index 0000000..82d2ec1
--- /dev/null
+++ b/misc/cgo/test/issue24161e2/main.go
@@ -0,0 +1,40 @@
+// Copyright 2018 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.
+
+// +build darwin
+
+package issue24161e2
+
+/*
+#cgo CFLAGS: -x objective-c
+#cgo LDFLAGS: -framework CoreFoundation -framework Security
+#include <TargetConditionals.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <Security/Security.h>
+#if TARGET_OS_IPHONE == 0 && __MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+ typedef CFStringRef SecKeyAlgorithm;
+ static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
+ #define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
+ static SecKeyAlgorithm foo(void){return NULL;}
+#endif
+*/
+import "C"
+import (
+ "fmt"
+ "testing"
+)
+
+var _ C.CFStringRef
+
+func f1() {
+ C.SecKeyCreateSignature(0, C.kSecKeyAlgorithmECDSASignatureDigestX962SHA1, 0, nil)
+}
+
+func f2(e C.CFErrorRef) {
+ if desc := C.CFErrorCopyDescription(e); desc != 0 {
+ fmt.Println(desc)
+ }
+}
+
+func Test(t *testing.T) {}
diff --git a/misc/cgo/test/issue24161res/restype.go b/misc/cgo/test/issue24161res/restype.go
new file mode 100644
index 0000000..e5719f2
--- /dev/null
+++ b/misc/cgo/test/issue24161res/restype.go
@@ -0,0 +1,23 @@
+// Copyright 2018 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.
+
+// +build darwin
+
+package issue24161res
+
+/*
+#cgo LDFLAGS: -framework CoreFoundation
+#include <CoreFoundation/CoreFoundation.h>
+*/
+import "C"
+import (
+ "reflect"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ if k := reflect.TypeOf(C.CFArrayCreate(0, nil, 0, nil)).Kind(); k != reflect.Uintptr {
+ t.Fatalf("bad kind %s\n", k)
+ }
+}
diff --git a/misc/cgo/test/issue26213/jni.h b/misc/cgo/test/issue26213/jni.h
new file mode 100644
index 0000000..0c76979
--- /dev/null
+++ b/misc/cgo/test/issue26213/jni.h
@@ -0,0 +1,29 @@
+// Copyright 2018 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.
+
+// It's going to be hard to include a whole real JVM to test this.
+// So we'll simulate a really easy JVM using just the parts we need.
+
+// This is the relevant part of jni.h.
+
+// On Android NDK16, jobject is defined like this in C and C++
+typedef void* jobject;
+
+typedef jobject jclass;
+typedef jobject jthrowable;
+typedef jobject jstring;
+typedef jobject jarray;
+typedef jarray jbooleanArray;
+typedef jarray jbyteArray;
+typedef jarray jcharArray;
+typedef jarray jshortArray;
+typedef jarray jintArray;
+typedef jarray jlongArray;
+typedef jarray jfloatArray;
+typedef jarray jdoubleArray;
+typedef jarray jobjectArray;
+
+typedef jobject jweak;
+
+// Note: jvalue is already a non-pointer type due to it being a C union.
diff --git a/misc/cgo/test/issue26213/test26213.go b/misc/cgo/test/issue26213/test26213.go
new file mode 100644
index 0000000..5d1f637
--- /dev/null
+++ b/misc/cgo/test/issue26213/test26213.go
@@ -0,0 +1,46 @@
+// Copyright 2018 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.
+
+package issue26213
+
+/*
+#include "jni.h"
+*/
+import "C"
+import (
+ "testing"
+)
+
+func Test26213(t *testing.T) {
+ var x1 C.jobject = 0 // Note: 0, not nil. That makes sure we use uintptr for these types.
+ _ = x1
+ var x2 C.jclass = 0
+ _ = x2
+ var x3 C.jthrowable = 0
+ _ = x3
+ var x4 C.jstring = 0
+ _ = x4
+ var x5 C.jarray = 0
+ _ = x5
+ var x6 C.jbooleanArray = 0
+ _ = x6
+ var x7 C.jbyteArray = 0
+ _ = x7
+ var x8 C.jcharArray = 0
+ _ = x8
+ var x9 C.jshortArray = 0
+ _ = x9
+ var x10 C.jintArray = 0
+ _ = x10
+ var x11 C.jlongArray = 0
+ _ = x11
+ var x12 C.jfloatArray = 0
+ _ = x12
+ var x13 C.jdoubleArray = 0
+ _ = x13
+ var x14 C.jobjectArray = 0
+ _ = x14
+ var x15 C.jweak = 0
+ _ = x15
+}
diff --git a/misc/cgo/test/issue26430.go b/misc/cgo/test/issue26430.go
new file mode 100644
index 0000000..b551939
--- /dev/null
+++ b/misc/cgo/test/issue26430.go
@@ -0,0 +1,10 @@
+// Copyright 2018 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.
+
+// Issue 26430: incomplete typedef leads to inconsistent typedefs error.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+import _ "misc/cgo/test/issue26430"
diff --git a/misc/cgo/test/issue26430/a.go b/misc/cgo/test/issue26430/a.go
new file mode 100644
index 0000000..fbaa46b
--- /dev/null
+++ b/misc/cgo/test/issue26430/a.go
@@ -0,0 +1,13 @@
+// Copyright 2018 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.
+
+package a
+
+// typedef struct S ST;
+// static ST* F() { return 0; }
+import "C"
+
+func F1() {
+ C.F()
+}
diff --git a/misc/cgo/test/issue26430/b.go b/misc/cgo/test/issue26430/b.go
new file mode 100644
index 0000000..a7c527c
--- /dev/null
+++ b/misc/cgo/test/issue26430/b.go
@@ -0,0 +1,13 @@
+// Copyright 2018 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.
+
+package a
+
+// typedef struct S ST;
+// struct S { int f; };
+import "C"
+
+func F2(p *C.ST) {
+ p.f = 1
+}
diff --git a/misc/cgo/test/issue26743.go b/misc/cgo/test/issue26743.go
new file mode 100644
index 0000000..716f2e4
--- /dev/null
+++ b/misc/cgo/test/issue26743.go
@@ -0,0 +1,10 @@
+// Copyright 2018 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.
+
+// Issue 26743: typedef of uint leads to inconsistent typedefs error.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+import _ "misc/cgo/test/issue26743"
diff --git a/misc/cgo/test/issue26743/a.go b/misc/cgo/test/issue26743/a.go
new file mode 100644
index 0000000..a3df179
--- /dev/null
+++ b/misc/cgo/test/issue26743/a.go
@@ -0,0 +1,11 @@
+// Copyright 2018 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.
+
+package issue26743
+
+// typedef unsigned int uint;
+// int C1(uint x) { return x; }
+import "C"
+
+var V1 = C.C1(0)
diff --git a/misc/cgo/test/issue26743/b.go b/misc/cgo/test/issue26743/b.go
new file mode 100644
index 0000000..c5f1ae4
--- /dev/null
+++ b/misc/cgo/test/issue26743/b.go
@@ -0,0 +1,9 @@
+// Copyright 2018 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.
+
+package issue26743
+
+import "C"
+
+var V2 C.uint
diff --git a/misc/cgo/test/issue27054/egl.h b/misc/cgo/test/issue27054/egl.h
new file mode 100644
index 0000000..3079627
--- /dev/null
+++ b/misc/cgo/test/issue27054/egl.h
@@ -0,0 +1,8 @@
+// Copyright 2018 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.
+
+// This is the relevant part of EGL/egl.h.
+
+typedef void *EGLDisplay;
+typedef void *EGLConfig;
diff --git a/misc/cgo/test/issue27054/test27054.go b/misc/cgo/test/issue27054/test27054.go
new file mode 100644
index 0000000..01bf43a
--- /dev/null
+++ b/misc/cgo/test/issue27054/test27054.go
@@ -0,0 +1,21 @@
+// Copyright 2018 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.
+
+package issue27054
+
+/*
+#include "egl.h"
+*/
+import "C"
+import (
+ "testing"
+)
+
+func Test27054(t *testing.T) {
+ var (
+ // Note: 0, not nil. That makes sure we use uintptr for these types.
+ _ C.EGLDisplay = 0
+ _ C.EGLConfig = 0
+ )
+}
diff --git a/misc/cgo/test/issue27340.go b/misc/cgo/test/issue27340.go
new file mode 100644
index 0000000..2c51088
--- /dev/null
+++ b/misc/cgo/test/issue27340.go
@@ -0,0 +1,12 @@
+// Copyright 2018 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.
+
+// Failed to resolve typedefs consistently.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+import "misc/cgo/test/issue27340"
+
+var issue27340Var = issue27340.Issue27340GoFunc
diff --git a/misc/cgo/test/issue27340/a.go b/misc/cgo/test/issue27340/a.go
new file mode 100644
index 0000000..f5b120c
--- /dev/null
+++ b/misc/cgo/test/issue27340/a.go
@@ -0,0 +1,42 @@
+// Copyright 2018 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.
+
+// Failed to resolve typedefs consistently.
+// No runtime test; just make sure it compiles.
+// In separate directory to isolate #pragma GCC diagnostic.
+
+package issue27340
+
+// We use the #pragma to avoid a compiler warning about incompatible
+// pointer types, because we generate code passing a struct ptr rather
+// than using the typedef. This warning is expected and does not break
+// a normal build.
+// We can only disable -Wincompatible-pointer-types starting with GCC 5.
+
+// #if __GNU_MAJOR__ >= 5
+//
+// #pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+//
+// typedef struct {
+// int a;
+// } issue27340Struct, *issue27340Ptr;
+//
+// static void issue27340CFunc(issue27340Ptr p) {}
+//
+// #else /* _GNU_MAJOR_ < 5 */
+//
+// typedef struct {
+// int a;
+// } issue27340Struct;
+//
+// static issue27340Struct* issue27340Ptr(issue27340Struct* p) { return p; }
+//
+// static void issue27340CFunc(issue27340Struct *p) {}
+// #endif /* _GNU_MAJOR_ < 5 */
+import "C"
+
+func Issue27340GoFunc() {
+ var s C.issue27340Struct
+ C.issue27340CFunc(C.issue27340Ptr(&s))
+}
diff --git a/misc/cgo/test/issue29563.go b/misc/cgo/test/issue29563.go
new file mode 100644
index 0000000..9f29da4
--- /dev/null
+++ b/misc/cgo/test/issue29563.go
@@ -0,0 +1,13 @@
+// Copyright 2019 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 !windows
+// +build !windows
+
+// Issue 29563: internal linker fails on duplicate weak symbols.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+import _ "misc/cgo/test/issue29563"
diff --git a/misc/cgo/test/issue29563/weak.go b/misc/cgo/test/issue29563/weak.go
new file mode 100644
index 0000000..21cf635
--- /dev/null
+++ b/misc/cgo/test/issue29563/weak.go
@@ -0,0 +1,13 @@
+// Copyright 2019 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.
+
+package issue29563
+
+//int foo1();
+//int foo2();
+import "C"
+
+func Bar() int {
+ return int(C.foo1()) + int(C.foo2())
+}
diff --git a/misc/cgo/test/issue29563/weak1.c b/misc/cgo/test/issue29563/weak1.c
new file mode 100644
index 0000000..86a2273
--- /dev/null
+++ b/misc/cgo/test/issue29563/weak1.c
@@ -0,0 +1,11 @@
+// Copyright 2019 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.
+
+extern int weaksym __attribute__((__weak__));
+int weaksym = 42;
+
+int foo1()
+{
+ return weaksym;
+}
diff --git a/misc/cgo/test/issue29563/weak2.c b/misc/cgo/test/issue29563/weak2.c
new file mode 100644
index 0000000..e01eae8
--- /dev/null
+++ b/misc/cgo/test/issue29563/weak2.c
@@ -0,0 +1,11 @@
+// Copyright 2019 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.
+
+extern int weaksym __attribute__((__weak__));
+int weaksym = 42;
+
+int foo2()
+{
+ return weaksym;
+}
diff --git a/misc/cgo/test/issue30527.go b/misc/cgo/test/issue30527.go
new file mode 100644
index 0000000..e0e18be
--- /dev/null
+++ b/misc/cgo/test/issue30527.go
@@ -0,0 +1,14 @@
+// Copyright 2019 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.
+
+// Issue 30527: function call rewriting casts untyped
+// constants to int because of ":=" usage.
+
+package cgotest
+
+import "misc/cgo/test/issue30527"
+
+func issue30527G() {
+ issue30527.G(nil)
+}
diff --git a/misc/cgo/test/issue30527/a.go b/misc/cgo/test/issue30527/a.go
new file mode 100644
index 0000000..eb50147
--- /dev/null
+++ b/misc/cgo/test/issue30527/a.go
@@ -0,0 +1,19 @@
+// Copyright 2019 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.
+
+package issue30527
+
+import "math"
+
+/*
+#include <inttypes.h>
+
+static void issue30527F(char **p, uint64_t mod, uint32_t unused) {}
+*/
+import "C"
+
+func G(p **C.char) {
+ C.issue30527F(p, math.MaxUint64, 1)
+ C.issue30527F(p, 1<<64-1, Z)
+}
diff --git a/misc/cgo/test/issue30527/b.go b/misc/cgo/test/issue30527/b.go
new file mode 100644
index 0000000..87e8255
--- /dev/null
+++ b/misc/cgo/test/issue30527/b.go
@@ -0,0 +1,11 @@
+// Copyright 2019 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.
+
+package issue30527
+
+const (
+ X = 1 << iota
+ Y
+ Z
+)
diff --git a/misc/cgo/test/issue31891.c b/misc/cgo/test/issue31891.c
new file mode 100644
index 0000000..67a0dda
--- /dev/null
+++ b/misc/cgo/test/issue31891.c
@@ -0,0 +1,13 @@
+// Copyright 2019 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.
+
+#include "_cgo_export.h"
+
+void callIssue31891() {
+ Issue31891A a;
+ useIssue31891A(&a);
+
+ Issue31891B b;
+ useIssue31891B(&b);
+}
diff --git a/misc/cgo/test/issue4029.c b/misc/cgo/test/issue4029.c
new file mode 100644
index 0000000..e79c5a7
--- /dev/null
+++ b/misc/cgo/test/issue4029.c
@@ -0,0 +1,30 @@
+// Copyright 2015 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.
+
+// +build !windows,!static
+// +build !darwin !internal_pie,!arm64
+
+#include <stdint.h>
+#include <dlfcn.h>
+
+// Write our own versions of dlopen/dlsym/dlclose so that we represent
+// the opaque handle as a Go uintptr rather than a Go pointer to avoid
+// garbage collector confusion. See issue 23663.
+
+uintptr_t dlopen4029(char* name, int flags) {
+ return (uintptr_t)(dlopen(name, flags));
+}
+
+uintptr_t dlsym4029(uintptr_t handle, char* name) {
+ return (uintptr_t)(dlsym((void*)(handle), name));
+}
+
+int dlclose4029(uintptr_t handle) {
+ return dlclose((void*)(handle));
+}
+
+void call4029(void *arg) {
+ void (*fn)(void) = arg;
+ fn();
+}
diff --git a/misc/cgo/test/issue4029.go b/misc/cgo/test/issue4029.go
new file mode 100644
index 0000000..90ca08c
--- /dev/null
+++ b/misc/cgo/test/issue4029.go
@@ -0,0 +1,80 @@
+// Copyright 2012 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 !windows && !static && (!darwin || (!internal_pie && !arm64))
+// +build !windows
+// +build !static
+// +build !darwin !internal_pie,!arm64
+
+// Excluded in darwin internal linking PIE mode, as dynamic export is not
+// supported.
+// Excluded in internal linking mode on darwin/arm64, as it is always PIE.
+
+package cgotest
+
+/*
+#include <stdint.h>
+#include <dlfcn.h>
+#cgo linux LDFLAGS: -ldl
+
+extern uintptr_t dlopen4029(char*, int);
+extern uintptr_t dlsym4029(uintptr_t, char*);
+extern int dlclose4029(uintptr_t);
+
+extern void call4029(uintptr_t arg);
+*/
+import "C"
+
+import (
+ "testing"
+)
+
+var callbacks int
+
+//export IMPIsOpaque
+func IMPIsOpaque() {
+ callbacks++
+}
+
+//export IMPInitWithFrame
+func IMPInitWithFrame() {
+ callbacks++
+}
+
+//export IMPDrawRect
+func IMPDrawRect() {
+ callbacks++
+}
+
+//export IMPWindowResize
+func IMPWindowResize() {
+ callbacks++
+}
+
+func test4029(t *testing.T) {
+ loadThySelf(t, "IMPWindowResize")
+ loadThySelf(t, "IMPDrawRect")
+ loadThySelf(t, "IMPInitWithFrame")
+ loadThySelf(t, "IMPIsOpaque")
+ if callbacks != 4 {
+ t.Errorf("got %d callbacks, expected 4", callbacks)
+ }
+}
+
+func loadThySelf(t *testing.T, symbol string) {
+ this_process := C.dlopen4029(nil, C.RTLD_NOW)
+ if this_process == 0 {
+ t.Error("dlopen:", C.GoString(C.dlerror()))
+ return
+ }
+ defer C.dlclose4029(this_process)
+
+ symbol_address := C.dlsym4029(this_process, C.CString(symbol))
+ if symbol_address == 0 {
+ t.Error("dlsym:", C.GoString(C.dlerror()))
+ return
+ }
+ t.Log(symbol, symbol_address)
+ C.call4029(symbol_address)
+}
diff --git a/misc/cgo/test/issue4029w.go b/misc/cgo/test/issue4029w.go
new file mode 100644
index 0000000..c2f5948
--- /dev/null
+++ b/misc/cgo/test/issue4029w.go
@@ -0,0 +1,13 @@
+// Copyright 2012 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 windows || static || (darwin && internal_pie) || (darwin && arm64)
+// +build windows static darwin,internal_pie darwin,arm64
+
+package cgotest
+
+import "testing"
+
+func test4029(t *testing.T) {
+}
diff --git a/misc/cgo/test/issue41761.go b/misc/cgo/test/issue41761.go
new file mode 100644
index 0000000..ed45b46
--- /dev/null
+++ b/misc/cgo/test/issue41761.go
@@ -0,0 +1,20 @@
+// Copyright 2020 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.
+
+package cgotest
+
+/*
+ typedef struct S41761 S41761;
+*/
+import "C"
+
+import (
+ "misc/cgo/test/issue41761a"
+ "testing"
+)
+
+func test41761(t *testing.T) {
+ var x issue41761a.T
+ _ = (*C.struct_S41761)(x.X)
+}
diff --git a/misc/cgo/test/issue41761a/a.go b/misc/cgo/test/issue41761a/a.go
new file mode 100644
index 0000000..1c52782
--- /dev/null
+++ b/misc/cgo/test/issue41761a/a.go
@@ -0,0 +1,14 @@
+// Copyright 2020 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.
+
+package issue41761a
+
+/*
+ typedef struct S41761 S41761;
+*/
+import "C"
+
+type T struct {
+ X *C.S41761
+}
diff --git a/misc/cgo/test/issue42018.go b/misc/cgo/test/issue42018.go
new file mode 100644
index 0000000..fab686a
--- /dev/null
+++ b/misc/cgo/test/issue42018.go
@@ -0,0 +1,14 @@
+// Copyright 2021 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 !windows
+// +build !windows
+
+package cgotest
+
+import "testing"
+
+func test42018(t *testing.T) {
+ t.Skip("skipping Windows-only test")
+}
diff --git a/misc/cgo/test/issue42018_windows.go b/misc/cgo/test/issue42018_windows.go
new file mode 100644
index 0000000..8f4570a
--- /dev/null
+++ b/misc/cgo/test/issue42018_windows.go
@@ -0,0 +1,46 @@
+// Copyright 2021 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.
+
+package cgotest
+
+/*
+typedef void *HANDLE;
+
+struct HWND__{int unused;}; typedef struct HWND__ *HWND;
+*/
+import "C"
+
+import (
+ "testing"
+ "unsafe"
+)
+
+func test42018(t *testing.T) {
+ // Test that Windows handles are marked go:notinheap, by growing the
+ // stack and checking for pointer adjustments. Trick from
+ // test/fixedbugs/issue40954.go.
+ var i int
+ handle := C.HANDLE(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
+ recurseHANDLE(100, handle, uintptr(unsafe.Pointer(&i)))
+ hwnd := C.HWND(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
+ recurseHWND(400, hwnd, uintptr(unsafe.Pointer(&i)))
+}
+
+func recurseHANDLE(n int, p C.HANDLE, v uintptr) {
+ if n > 0 {
+ recurseHANDLE(n-1, p, v)
+ }
+ if uintptr(unsafe.Pointer(p)) != v {
+ panic("adjusted notinheap pointer")
+ }
+}
+
+func recurseHWND(n int, p C.HWND, v uintptr) {
+ if n > 0 {
+ recurseHWND(n-1, p, v)
+ }
+ if uintptr(unsafe.Pointer(p)) != v {
+ panic("adjusted notinheap pointer")
+ }
+}
diff --git a/misc/cgo/test/issue42495.go b/misc/cgo/test/issue42495.go
new file mode 100644
index 0000000..509a67d
--- /dev/null
+++ b/misc/cgo/test/issue42495.go
@@ -0,0 +1,15 @@
+// Copyright 2020 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.
+
+package cgotest
+
+// typedef struct { } T42495A;
+// typedef struct { int x[0]; } T42495B;
+import "C"
+
+//export Issue42495A
+func Issue42495A(C.T42495A) {}
+
+//export Issue42495B
+func Issue42495B(C.T42495B) {}
diff --git a/misc/cgo/test/issue4273.c b/misc/cgo/test/issue4273.c
new file mode 100644
index 0000000..cac9876
--- /dev/null
+++ b/misc/cgo/test/issue4273.c
@@ -0,0 +1,10 @@
+// Copyright 2012 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.
+
+#ifdef __ELF__
+__attribute__((weak))
+__attribute__((visibility("hidden")))
+void _compilerrt_abort_impl(const char *file, int line, const char *func) {
+}
+#endif
diff --git a/misc/cgo/test/issue4273b.c b/misc/cgo/test/issue4273b.c
new file mode 100644
index 0000000..71e3f0d
--- /dev/null
+++ b/misc/cgo/test/issue4273b.c
@@ -0,0 +1,11 @@
+// Copyright 2012 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.
+
+#ifdef __ELF__
+extern void _compilerrt_abort_impl(const char *file, int line, const char *func);
+
+void __my_abort(const char *file, int line, const char *func) {
+ _compilerrt_abort_impl(file, line, func);
+}
+#endif
diff --git a/misc/cgo/test/issue4339.c b/misc/cgo/test/issue4339.c
new file mode 100644
index 0000000..15d0004
--- /dev/null
+++ b/misc/cgo/test/issue4339.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include "issue4339.h"
+
+static void
+impl(void)
+{
+ //printf("impl\n");
+}
+
+Issue4339 exported4339 = {"bar", impl};
+
+void
+handle4339(Issue4339 *x)
+{
+ //printf("handle\n");
+ x->bar();
+ //printf("done\n");
+}
diff --git a/misc/cgo/test/issue4339.h b/misc/cgo/test/issue4339.h
new file mode 100644
index 0000000..20f6ceb
--- /dev/null
+++ b/misc/cgo/test/issue4339.h
@@ -0,0 +1,9 @@
+typedef struct Issue4339 Issue4339;
+
+struct Issue4339 {
+ char *name;
+ void (*bar)(void);
+};
+
+extern Issue4339 exported4339;
+void handle4339(Issue4339*);
diff --git a/misc/cgo/test/issue43639.go b/misc/cgo/test/issue43639.go
new file mode 100644
index 0000000..41e1471
--- /dev/null
+++ b/misc/cgo/test/issue43639.go
@@ -0,0 +1,9 @@
+// Copyright 2021 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.
+
+package cgotest
+
+// Issue 43639: No runtime test needed, make sure package misc/cgo/test/issue43639 compiles well.
+
+import _ "misc/cgo/test/issue43639"
diff --git a/misc/cgo/test/issue43639/a.go b/misc/cgo/test/issue43639/a.go
new file mode 100644
index 0000000..fe37d5e
--- /dev/null
+++ b/misc/cgo/test/issue43639/a.go
@@ -0,0 +1,8 @@
+// Copyright 2021 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.
+
+package issue43639
+
+// #cgo CFLAGS: -W -Wall -Werror
+import "C"
diff --git a/misc/cgo/test/issue52611.go b/misc/cgo/test/issue52611.go
new file mode 100644
index 0000000..2b59d52
--- /dev/null
+++ b/misc/cgo/test/issue52611.go
@@ -0,0 +1,13 @@
+// Copyright 2022 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.
+
+// Issue 52611: inconsistent compiler behaviour when compiling a C.struct.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+import (
+ _ "misc/cgo/test/issue52611a"
+ _ "misc/cgo/test/issue52611b"
+)
diff --git a/misc/cgo/test/issue52611a/a.go b/misc/cgo/test/issue52611a/a.go
new file mode 100644
index 0000000..0764688
--- /dev/null
+++ b/misc/cgo/test/issue52611a/a.go
@@ -0,0 +1,16 @@
+// Copyright 2022 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.
+
+package issue52611a
+
+/*
+typedef struct Foo {
+ int X;
+} Foo;
+*/
+import "C"
+
+func GetX1(foo *C.struct_Foo) int32 {
+ return int32(foo.X)
+}
diff --git a/misc/cgo/test/issue52611a/b.go b/misc/cgo/test/issue52611a/b.go
new file mode 100644
index 0000000..74a50c5
--- /dev/null
+++ b/misc/cgo/test/issue52611a/b.go
@@ -0,0 +1,11 @@
+// Copyright 2022 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.
+
+package issue52611a
+
+import "C"
+
+func GetX2(foo *C.struct_Foo) int32 {
+ return int32(foo.X)
+}
diff --git a/misc/cgo/test/issue52611b/a.go b/misc/cgo/test/issue52611b/a.go
new file mode 100644
index 0000000..730b52f
--- /dev/null
+++ b/misc/cgo/test/issue52611b/a.go
@@ -0,0 +1,11 @@
+// Copyright 2022 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.
+
+package issue52611b
+
+import "C"
+
+func GetX1(bar *C.struct_Bar) int32 {
+ return int32(bar.X)
+}
diff --git a/misc/cgo/test/issue52611b/b.go b/misc/cgo/test/issue52611b/b.go
new file mode 100644
index 0000000..d304175
--- /dev/null
+++ b/misc/cgo/test/issue52611b/b.go
@@ -0,0 +1,16 @@
+// Copyright 2022 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.
+
+package issue52611b
+
+/*
+typedef struct Bar {
+ int X;
+} Bar;
+*/
+import "C"
+
+func GetX2(bar *C.struct_Bar) int32 {
+ return int32(bar.X)
+}
diff --git a/misc/cgo/test/issue5548_c.c b/misc/cgo/test/issue5548_c.c
new file mode 100644
index 0000000..8411526
--- /dev/null
+++ b/misc/cgo/test/issue5548_c.c
@@ -0,0 +1,24 @@
+// Copyright 2013 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.
+
+#include "_cgo_export.h"
+
+static void clobber_stack() {
+ volatile char a[1024];
+ int i;
+ for(i = 0; i < sizeof a; i++)
+ a[i] = 0xff;
+}
+
+static int call_go() {
+ GoString s;
+ s.p = "test";
+ s.n = 4;
+ return issue5548FromC(s, 42);
+}
+
+int issue5548_in_c() {
+ clobber_stack();
+ return call_go();
+}
diff --git a/misc/cgo/test/issue5740a.c b/misc/cgo/test/issue5740a.c
new file mode 100644
index 0000000..a6a7d0c
--- /dev/null
+++ b/misc/cgo/test/issue5740a.c
@@ -0,0 +1,9 @@
+// Copyright 2013 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.
+
+static int volatile val = 2;
+
+int test5740a() {
+ return val;
+}
diff --git a/misc/cgo/test/issue5740b.c b/misc/cgo/test/issue5740b.c
new file mode 100644
index 0000000..c2ff5fb
--- /dev/null
+++ b/misc/cgo/test/issue5740b.c
@@ -0,0 +1,9 @@
+// Copyright 2013 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.
+
+static int volatile val = 3;
+
+int test5740b() {
+ return val;
+}
diff --git a/misc/cgo/test/issue6833_c.c b/misc/cgo/test/issue6833_c.c
new file mode 100644
index 0000000..c94c2c6
--- /dev/null
+++ b/misc/cgo/test/issue6833_c.c
@@ -0,0 +1,10 @@
+// Copyright 2013 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.
+
+#include "_cgo_export.h"
+
+unsigned long long
+issue6833Func(unsigned int aui, unsigned long long aull) {
+ return GoIssue6833Func(aui, aull);
+}
diff --git a/misc/cgo/test/issue6907export_c.c b/misc/cgo/test/issue6907export_c.c
new file mode 100644
index 0000000..9b1a4fc
--- /dev/null
+++ b/misc/cgo/test/issue6907export_c.c
@@ -0,0 +1,11 @@
+// Copyright 2017 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.
+
+#include <string.h>
+
+#include "_cgo_export.h"
+
+int CheckIssue6907C(_GoString_ s) {
+ return CheckIssue6907Go(s);
+}
diff --git a/misc/cgo/test/issue6997_linux.c b/misc/cgo/test/issue6997_linux.c
new file mode 100644
index 0000000..de803d2
--- /dev/null
+++ b/misc/cgo/test/issue6997_linux.c
@@ -0,0 +1,28 @@
+// Copyright 2014 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.
+
+// +build !android
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static pthread_t thread;
+
+static void* threadfunc(void* dummy) {
+ while(1) {
+ sleep(1);
+ }
+}
+
+int StartThread() {
+ return pthread_create(&thread, NULL, &threadfunc, NULL);
+}
+
+int CancelThread() {
+ void *r;
+ pthread_cancel(thread);
+ pthread_join(thread, &r);
+ return (r == PTHREAD_CANCELED);
+}
diff --git a/misc/cgo/test/issue6997_linux.go b/misc/cgo/test/issue6997_linux.go
new file mode 100644
index 0000000..4acc8c1
--- /dev/null
+++ b/misc/cgo/test/issue6997_linux.go
@@ -0,0 +1,45 @@
+// Copyright 2014 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 !android
+// +build !android
+
+// Test that pthread_cancel works as expected
+// (NPTL uses SIGRTMIN to implement thread cancellation)
+// See https://golang.org/issue/6997
+package cgotest
+
+/*
+#cgo CFLAGS: -pthread
+#cgo LDFLAGS: -pthread
+extern int StartThread();
+extern int CancelThread();
+*/
+import "C"
+
+import (
+ "testing"
+ "time"
+)
+
+func test6997(t *testing.T) {
+ r := C.StartThread()
+ if r != 0 {
+ t.Error("pthread_create failed")
+ }
+ c := make(chan C.int)
+ go func() {
+ time.Sleep(500 * time.Millisecond)
+ c <- C.CancelThread()
+ }()
+
+ select {
+ case r = <-c:
+ if r == 0 {
+ t.Error("pthread finished but wasn't canceled??")
+ }
+ case <-time.After(30 * time.Second):
+ t.Error("hung in pthread_cancel/pthread_join")
+ }
+}
diff --git a/misc/cgo/test/issue7234_test.go b/misc/cgo/test/issue7234_test.go
new file mode 100644
index 0000000..c191a1a
--- /dev/null
+++ b/misc/cgo/test/issue7234_test.go
@@ -0,0 +1,21 @@
+// Copyright 2014 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.
+
+package cgotest
+
+import "testing"
+
+// This test actually doesn't have anything to do with cgo. It is a
+// test of https://golang.org/issue/7234, a compiler/linker bug in
+// handling string constants when using -linkmode=external. The test
+// is in this directory because we routinely test -linkmode=external
+// here.
+
+var v7234 = [...]string{"runtime/cgo"}
+
+func Test7234(t *testing.T) {
+ if v7234[0] != "runtime/cgo" {
+ t.Errorf("bad string constant %q", v7234[0])
+ }
+}
diff --git a/misc/cgo/test/issue8148.c b/misc/cgo/test/issue8148.c
new file mode 100644
index 0000000..927b434
--- /dev/null
+++ b/misc/cgo/test/issue8148.c
@@ -0,0 +1,11 @@
+// Copyright 2014 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.
+
+#include "_cgo_export.h"
+
+int get8148(void) {
+ T t;
+ t.i = 42;
+ return issue8148Callback(&t);
+}
diff --git a/misc/cgo/test/issue8148.go b/misc/cgo/test/issue8148.go
new file mode 100644
index 0000000..aee9003
--- /dev/null
+++ b/misc/cgo/test/issue8148.go
@@ -0,0 +1,24 @@
+// Copyright 2014 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.
+
+// Issue 8148. A typedef of an unnamed struct didn't work when used
+// with an exported Go function. No runtime test; just make sure it
+// compiles.
+
+package cgotest
+
+/*
+typedef struct { int i; } T;
+int get8148(void);
+*/
+import "C"
+
+//export issue8148Callback
+func issue8148Callback(t *C.T) C.int {
+ return t.i
+}
+
+func Issue8148() int {
+ return int(C.get8148())
+}
diff --git a/misc/cgo/test/issue8331.h b/misc/cgo/test/issue8331.h
new file mode 100644
index 0000000..8065be0
--- /dev/null
+++ b/misc/cgo/test/issue8331.h
@@ -0,0 +1,7 @@
+// Copyright 2014 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.
+
+typedef struct {
+ int i;
+} issue8331;
diff --git a/misc/cgo/test/issue8517.go b/misc/cgo/test/issue8517.go
new file mode 100644
index 0000000..7316ab0
--- /dev/null
+++ b/misc/cgo/test/issue8517.go
@@ -0,0 +1,14 @@
+// Copyright 2014 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 !windows
+// +build !windows
+
+package cgotest
+
+import "testing"
+
+func test8517(t *testing.T) {
+ t.Skip("skipping windows only test")
+}
diff --git a/misc/cgo/test/issue8517_windows.c b/misc/cgo/test/issue8517_windows.c
new file mode 100644
index 0000000..a0b94c1
--- /dev/null
+++ b/misc/cgo/test/issue8517_windows.c
@@ -0,0 +1,24 @@
+// Copyright 2014 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.
+
+#include "windows.h"
+
+extern void testHandleLeaksCallback();
+
+DWORD WINAPI testHandleLeaksFunc(LPVOID lpThreadParameter)
+{
+ int i;
+ for(i = 0; i < 100; i++) {
+ testHandleLeaksCallback();
+ }
+ return 0;
+}
+
+void testHandleLeaks()
+{
+ HANDLE h;
+ h = CreateThread(NULL, 0, &testHandleLeaksFunc, 0, 0, NULL);
+ WaitForSingleObject(h, INFINITE);
+ CloseHandle(h);
+}
diff --git a/misc/cgo/test/issue8517_windows.go b/misc/cgo/test/issue8517_windows.go
new file mode 100644
index 0000000..3782631
--- /dev/null
+++ b/misc/cgo/test/issue8517_windows.go
@@ -0,0 +1,45 @@
+// Copyright 2014 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.
+
+package cgotest
+
+//void testHandleLeaks();
+import "C"
+
+import (
+ "syscall"
+ "testing"
+ "unsafe"
+)
+
+var issue8517counter int
+
+var (
+ kernel32 = syscall.MustLoadDLL("kernel32.dll")
+ getProcessHandleCount = kernel32.MustFindProc("GetProcessHandleCount")
+)
+
+func processHandleCount(t *testing.T) int {
+ const current_process = ^uintptr(0)
+ var c uint32
+ r, _, err := getProcessHandleCount.Call(current_process, uintptr(unsafe.Pointer(&c)))
+ if r == 0 {
+ t.Fatal(err)
+ }
+ return int(c)
+}
+
+func test8517(t *testing.T) {
+ c1 := processHandleCount(t)
+ C.testHandleLeaks()
+ c2 := processHandleCount(t)
+ if c1+issue8517counter <= c2 {
+ t.Fatalf("too many handles leaked: issue8517counter=%v c1=%v c2=%v", issue8517counter, c1, c2)
+ }
+}
+
+//export testHandleLeaksCallback
+func testHandleLeaksCallback() {
+ issue8517counter++
+}
diff --git a/misc/cgo/test/issue8694.go b/misc/cgo/test/issue8694.go
new file mode 100644
index 0000000..19071ce
--- /dev/null
+++ b/misc/cgo/test/issue8694.go
@@ -0,0 +1,41 @@
+// Copyright 2014 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 !android
+// +build !android
+
+package cgotest
+
+/*
+#include <complex.h>
+
+complex float complexFloatSquared(complex float a) { return a*a; }
+complex double complexDoubleSquared(complex double a) { return a*a; }
+*/
+import "C"
+
+import (
+ "runtime"
+ "testing"
+)
+
+func test8694(t *testing.T) {
+ if runtime.GOARCH == "arm" {
+ t.Skip("test8694 is disabled on ARM because 5l cannot handle thumb library.")
+ }
+ // Really just testing that this compiles, but check answer anyway.
+ x := C.complexfloat(2 + 3i)
+ x2 := x * x
+ cx2 := C.complexFloatSquared(x)
+ if cx2 != x2 {
+ t.Errorf("C.complexFloatSquared(%v) = %v, want %v", x, cx2, x2)
+ }
+
+ y := C.complexdouble(2 + 3i)
+ y2 := y * y
+ cy2 := C.complexDoubleSquared(y)
+ if cy2 != y2 {
+ t.Errorf("C.complexDoubleSquared(%v) = %v, want %v", y, cy2, y2)
+ }
+}
diff --git a/misc/cgo/test/issue8756.go b/misc/cgo/test/issue8756.go
new file mode 100644
index 0000000..08099dc
--- /dev/null
+++ b/misc/cgo/test/issue8756.go
@@ -0,0 +1,17 @@
+package cgotest
+
+/*
+#cgo LDFLAGS: -lm
+#include <math.h>
+*/
+import "C"
+import (
+ "testing"
+
+ "misc/cgo/test/issue8756"
+)
+
+func test8756(t *testing.T) {
+ issue8756.Pow()
+ C.pow(1, 2)
+}
diff --git a/misc/cgo/test/issue8756/issue8756.go b/misc/cgo/test/issue8756/issue8756.go
new file mode 100644
index 0000000..5f6b777
--- /dev/null
+++ b/misc/cgo/test/issue8756/issue8756.go
@@ -0,0 +1,11 @@
+package issue8756
+
+/*
+#cgo LDFLAGS: -lm
+#include <math.h>
+*/
+import "C"
+
+func Pow() {
+ C.pow(1, 2)
+}
diff --git a/misc/cgo/test/issue8811.c b/misc/cgo/test/issue8811.c
new file mode 100644
index 0000000..41b3c7c
--- /dev/null
+++ b/misc/cgo/test/issue8811.c
@@ -0,0 +1,8 @@
+// Copyright 2014 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.
+
+int issue8811Initialized = 0;
+
+void issue8811Init() {
+}
diff --git a/misc/cgo/test/issue8828.go b/misc/cgo/test/issue8828.go
new file mode 100644
index 0000000..3b5765d
--- /dev/null
+++ b/misc/cgo/test/issue8828.go
@@ -0,0 +1,16 @@
+// compile
+
+// Copyright 2014 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.
+
+// Issue 8828: compiling a file with -compiler=gccgo fails if a .c file
+// has the same name as compiled directory.
+
+package cgotest
+
+import "misc/cgo/test/issue8828"
+
+func p() {
+ issue8828.Bar()
+}
diff --git a/misc/cgo/test/issue8828/issue8828.c b/misc/cgo/test/issue8828/issue8828.c
new file mode 100644
index 0000000..27ec23a
--- /dev/null
+++ b/misc/cgo/test/issue8828/issue8828.c
@@ -0,0 +1,7 @@
+// Copyright 2014 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.
+
+void foo()
+{
+}
diff --git a/misc/cgo/test/issue8828/trivial.go b/misc/cgo/test/issue8828/trivial.go
new file mode 100644
index 0000000..e7b9a4e
--- /dev/null
+++ b/misc/cgo/test/issue8828/trivial.go
@@ -0,0 +1,8 @@
+package issue8828
+
+//void foo();
+import "C"
+
+func Bar() {
+ C.foo()
+}
diff --git a/misc/cgo/test/issue9026.go b/misc/cgo/test/issue9026.go
new file mode 100644
index 0000000..a30196c
--- /dev/null
+++ b/misc/cgo/test/issue9026.go
@@ -0,0 +1,9 @@
+package cgotest
+
+import (
+ "testing"
+
+ "misc/cgo/test/issue9026"
+)
+
+func test9026(t *testing.T) { issue9026.Test(t) }
diff --git a/misc/cgo/test/issue9026/issue9026.go b/misc/cgo/test/issue9026/issue9026.go
new file mode 100644
index 0000000..ff269ca
--- /dev/null
+++ b/misc/cgo/test/issue9026/issue9026.go
@@ -0,0 +1,36 @@
+package issue9026
+
+// This file appears in its own package since the assertion tests the
+// per-package counter used to create fresh identifiers.
+
+/*
+typedef struct { int i; } git_merge_file_input;
+
+typedef struct { int j; } git_merge_file_options;
+
+void git_merge_file(
+ git_merge_file_input *in,
+ git_merge_file_options *opts) {}
+*/
+import "C"
+import (
+ "fmt"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ var in C.git_merge_file_input
+ var opts *C.git_merge_file_options
+ C.git_merge_file(&in, opts)
+
+ // Test that the generated type names are deterministic.
+ // (Previously this would fail about 10% of the time.)
+ //
+ // Brittle: the assertion may fail spuriously when the algorithm
+ // changes, but should remain stable otherwise.
+ got := fmt.Sprintf("%T %T", in, opts)
+ want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___1"
+ if got != want {
+ t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
+ }
+}
diff --git a/misc/cgo/test/issue9400/asm_386.s b/misc/cgo/test/issue9400/asm_386.s
new file mode 100644
index 0000000..96b8b60
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_386.s
@@ -0,0 +1,27 @@
+// Copyright 2014 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.
+
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT,$0-0
+ MOVL $·Baton(SB), BX
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADDL $(1024 * 8), SP
+
+ // Ask signaller to setgid
+ MOVL $1, (BX)
+
+ // Wait for setgid completion
+loop:
+ PAUSE
+ MOVL (BX), AX
+ CMPL AX, $0
+ JNE loop
+
+ // Restore stack
+ SUBL $(1024 * 8), SP
+ RET
diff --git a/misc/cgo/test/issue9400/asm_amd64x.s b/misc/cgo/test/issue9400/asm_amd64x.s
new file mode 100644
index 0000000..99509bc
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_amd64x.s
@@ -0,0 +1,27 @@
+// Copyright 2014 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.
+
+// +build amd64 amd64p32
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT,$0-0
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADDQ $(1024 * 8), SP
+
+ // Ask signaller to setgid
+ MOVL $1, ·Baton(SB)
+
+ // Wait for setgid completion
+loop:
+ PAUSE
+ MOVL ·Baton(SB), AX
+ CMPL AX, $0
+ JNE loop
+
+ // Restore stack
+ SUBQ $(1024 * 8), SP
+ RET
diff --git a/misc/cgo/test/issue9400/asm_arm.s b/misc/cgo/test/issue9400/asm_arm.s
new file mode 100644
index 0000000..cc92856
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_arm.s
@@ -0,0 +1,39 @@
+// Copyright 2014 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.
+
+// +build gc
+
+#include "textflag.h"
+
+TEXT cas<>(SB),NOSPLIT,$0
+ MOVW $0xffff0fc0, R15 // R15 is PC
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
+ // Save link register
+ MOVW R14, R4
+
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADD $(1024 * 8), R13
+
+ // Ask signaller to setgid
+ MOVW $·Baton(SB), R2
+storeloop:
+ MOVW 0(R2), R0
+ MOVW $1, R1
+ BL cas<>(SB)
+ BCC storeloop
+
+ // Wait for setgid completion
+loop:
+ MOVW $0, R0
+ MOVW $0, R1
+ BL cas<>(SB)
+ BCC loop
+
+ // Restore stack
+ SUB $(1024 * 8), R13
+
+ MOVW R4, R14
+ RET
diff --git a/misc/cgo/test/issue9400/asm_arm64.s b/misc/cgo/test/issue9400/asm_arm64.s
new file mode 100644
index 0000000..2565793
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_arm64.s
@@ -0,0 +1,39 @@
+// Copyright 2014 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.
+
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
+ // Save link register
+ MOVD R30, R9
+
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADD $(1024 * 8), RSP
+
+ // Ask signaller to setgid
+ MOVD $·Baton(SB), R0
+ MOVD $1, R1
+storeloop:
+ LDAXRW (R0), R2
+ STLXRW R1, (R0), R3
+ CBNZ R3, storeloop
+
+ // Wait for setgid completion
+ MOVW $0, R1
+ MOVW $0, R2
+loop:
+ LDAXRW (R0), R3
+ CMPW R1, R3
+ BNE loop
+ STLXRW R2, (R0), R3
+ CBNZ R3, loop
+
+ // Restore stack
+ SUB $(1024 * 8), RSP
+
+ MOVD R9, R30
+ RET
diff --git a/misc/cgo/test/issue9400/asm_loong64.s b/misc/cgo/test/issue9400/asm_loong64.s
new file mode 100644
index 0000000..c242fc6
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_loong64.s
@@ -0,0 +1,28 @@
+// Copyright 2022 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.
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADDV $(1024*8), R3
+
+ // Ask signaller to setgid
+ MOVW $1, R12
+ DBAR
+ MOVW R12, ·Baton(SB)
+ DBAR
+
+ // Wait for setgid completion
+loop:
+ DBAR
+ MOVW ·Baton(SB), R12
+ OR R13, R13, R13 // hint that we're in a spin loop
+ BNE R12, loop
+ DBAR
+
+ // Restore stack
+ ADDV $(-1024*8), R3
+ RET
diff --git a/misc/cgo/test/issue9400/asm_mips64x.s b/misc/cgo/test/issue9400/asm_mips64x.s
new file mode 100644
index 0000000..693231d
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_mips64x.s
@@ -0,0 +1,33 @@
+// Copyright 2016 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.
+
+// +build mips64 mips64le
+// +build gc
+
+#include "textflag.h"
+
+#define SYNC WORD $0xf
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADDV $(1024*8), R29
+
+ // Ask signaller to setgid
+ MOVW $1, R1
+ SYNC
+ MOVW R1, ·Baton(SB)
+ SYNC
+
+ // Wait for setgid completion
+loop:
+ SYNC
+ MOVW ·Baton(SB), R1
+ OR R2, R2, R2 // hint that we're in a spin loop
+ BNE R1, loop
+ SYNC
+
+ // Restore stack
+ ADDV $(-1024*8), R29
+ RET
diff --git a/misc/cgo/test/issue9400/asm_mipsx.s b/misc/cgo/test/issue9400/asm_mipsx.s
new file mode 100644
index 0000000..63261bb
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_mipsx.s
@@ -0,0 +1,31 @@
+// Copyright 2016 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.
+
+// +build mips mipsle
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADDU $(1024*8), R29
+
+ // Ask signaller to setgid
+ MOVW $1, R1
+ SYNC
+ MOVW R1, ·Baton(SB)
+ SYNC
+
+ // Wait for setgid completion
+loop:
+ SYNC
+ MOVW ·Baton(SB), R1
+ OR R2, R2, R2 // hint that we're in a spin loop
+ BNE R1, loop
+ SYNC
+
+ // Restore stack
+ ADDU $(-1024*8), R29
+ RET
diff --git a/misc/cgo/test/issue9400/asm_ppc64x.s b/misc/cgo/test/issue9400/asm_ppc64x.s
new file mode 100644
index 0000000..b5613fb
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_ppc64x.s
@@ -0,0 +1,32 @@
+// Copyright 2014 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.
+
+// +build ppc64 ppc64le
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADD $(1024 * 8), R1
+
+ // Ask signaller to setgid
+ MOVW $1, R3
+ SYNC
+ MOVW R3, ·Baton(SB)
+
+ // Wait for setgid completion
+loop:
+ SYNC
+ MOVW ·Baton(SB), R3
+ CMP R3, $0
+ // Hint that we're in a spin loop
+ OR R1, R1, R1
+ BNE loop
+ ISYNC
+
+ // Restore stack
+ SUB $(1024 * 8), R1
+ RET
diff --git a/misc/cgo/test/issue9400/asm_riscv64.s b/misc/cgo/test/issue9400/asm_riscv64.s
new file mode 100644
index 0000000..244dada
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_riscv64.s
@@ -0,0 +1,31 @@
+// Copyright 2020 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.
+
+// +build riscv64
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADD $(1024*8), X2
+
+ // Ask signaller to setgid
+ MOV $1, X5
+ FENCE
+ MOVW X5, ·Baton(SB)
+ FENCE
+
+ // Wait for setgid completion
+loop:
+ FENCE
+ MOVW ·Baton(SB), X5
+ OR X6, X6, X6 // hint that we're in a spin loop
+ BNE ZERO, X5, loop
+ FENCE
+
+ // Restore stack
+ ADD $(-1024*8), X2
+ RET
diff --git a/misc/cgo/test/issue9400/asm_s390x.s b/misc/cgo/test/issue9400/asm_s390x.s
new file mode 100644
index 0000000..4856492
--- /dev/null
+++ b/misc/cgo/test/issue9400/asm_s390x.s
@@ -0,0 +1,26 @@
+// Copyright 2016 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.
+
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·RewindAndSetgid(SB),NOSPLIT,$0-0
+ // Rewind stack pointer so anything that happens on the stack
+ // will clobber the test pattern created by the caller
+ ADD $(1024 * 8), R15
+
+ // Ask signaller to setgid
+ MOVD $·Baton(SB), R5
+ MOVW $1, 0(R5)
+
+ // Wait for setgid completion
+loop:
+ SYNC
+ MOVW ·Baton(SB), R3
+ CMPBNE R3, $0, loop
+
+ // Restore stack
+ SUB $(1024 * 8), R15
+ RET
diff --git a/misc/cgo/test/issue9400/gccgo.go b/misc/cgo/test/issue9400/gccgo.go
new file mode 100644
index 0000000..a9b62b0
--- /dev/null
+++ b/misc/cgo/test/issue9400/gccgo.go
@@ -0,0 +1,26 @@
+// Copyright 2014 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.
+
+// +build gccgo
+
+package issue9400
+
+import (
+ "runtime"
+ "sync/atomic"
+)
+
+// The test for the gc compiler resets the stack pointer so that the
+// stack gets modified. We don't have a way to do that for gccgo
+// without writing more assembly code, which we haven't bothered to
+// do. So this is not much of a test.
+
+var Baton int32
+
+func RewindAndSetgid() {
+ atomic.StoreInt32(&Baton, 1)
+ for atomic.LoadInt32(&Baton) != 0 {
+ runtime.Gosched()
+ }
+}
diff --git a/misc/cgo/test/issue9400/stubs.go b/misc/cgo/test/issue9400/stubs.go
new file mode 100644
index 0000000..e431c5a
--- /dev/null
+++ b/misc/cgo/test/issue9400/stubs.go
@@ -0,0 +1,11 @@
+// Copyright 2014 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.
+
+// +build gc
+
+package issue9400
+
+var Baton int32
+
+func RewindAndSetgid()
diff --git a/misc/cgo/test/issue9400_linux.go b/misc/cgo/test/issue9400_linux.go
new file mode 100644
index 0000000..38fa9dd
--- /dev/null
+++ b/misc/cgo/test/issue9400_linux.go
@@ -0,0 +1,67 @@
+// Copyright 2014 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.
+
+// Test that SIGSETXID runs on signal stack, since it's likely to
+// overflow if it runs on the Go stack.
+
+package cgotest
+
+/*
+#include <sys/types.h>
+#include <unistd.h>
+*/
+import "C"
+
+import (
+ "runtime"
+ "runtime/debug"
+ "sync/atomic"
+ "testing"
+
+ "misc/cgo/test/issue9400"
+)
+
+func test9400(t *testing.T) {
+ // We synchronize through a shared variable, so we need two procs
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2))
+
+ // Start signaller
+ atomic.StoreInt32(&issue9400.Baton, 0)
+ go func() {
+ // Wait for RewindAndSetgid
+ for atomic.LoadInt32(&issue9400.Baton) == 0 {
+ runtime.Gosched()
+ }
+ // Broadcast SIGSETXID
+ runtime.LockOSThread()
+ C.setgid(0)
+ // Indicate that signalling is done
+ atomic.StoreInt32(&issue9400.Baton, 0)
+ }()
+
+ // Grow the stack and put down a test pattern
+ const pattern = 0x123456789abcdef
+ var big [1024]uint64 // len must match assembly
+ for i := range big {
+ big[i] = pattern
+ }
+
+ // Disable GC for the duration of the test.
+ // This avoids a potential GC deadlock when spinning in uninterruptable ASM below #49695.
+ defer debug.SetGCPercent(debug.SetGCPercent(-1))
+ // SetGCPercent waits until the mark phase is over, but the runtime
+ // also preempts at the start of the sweep phase, so make sure that's
+ // done too. See #49695.
+ runtime.GC()
+
+ // Temporarily rewind the stack and trigger SIGSETXID
+ issue9400.RewindAndSetgid()
+
+ // Check test pattern
+ for i := range big {
+ if big[i] != pattern {
+ t.Fatalf("entry %d of test pattern is wrong; %#x != %#x", i, big[i], uint64(pattern))
+ }
+ }
+}
diff --git a/misc/cgo/test/issue9510.go b/misc/cgo/test/issue9510.go
new file mode 100644
index 0000000..325b0cf
--- /dev/null
+++ b/misc/cgo/test/issue9510.go
@@ -0,0 +1,24 @@
+// Copyright 2015 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.
+
+// Test that we can link together two different cgo packages that both
+// use the same libgcc function.
+
+package cgotest
+
+import (
+ "runtime"
+ "testing"
+
+ "misc/cgo/test/issue9510a"
+ "misc/cgo/test/issue9510b"
+)
+
+func test9510(t *testing.T) {
+ if runtime.GOARCH == "arm" {
+ t.Skip("skipping because libgcc may be a Thumb library")
+ }
+ issue9510a.F(1, 1)
+ issue9510b.F(1, 1)
+}
diff --git a/misc/cgo/test/issue9510a/a.go b/misc/cgo/test/issue9510a/a.go
new file mode 100644
index 0000000..1a5224b
--- /dev/null
+++ b/misc/cgo/test/issue9510a/a.go
@@ -0,0 +1,15 @@
+package issue9510a
+
+/*
+static double csquare(double a, double b) {
+ __complex__ double d;
+ __real__ d = a;
+ __imag__ d = b;
+ return __real__ (d * d);
+}
+*/
+import "C"
+
+func F(a, b float64) float64 {
+ return float64(C.csquare(C.double(a), C.double(b)))
+}
diff --git a/misc/cgo/test/issue9510b/b.go b/misc/cgo/test/issue9510b/b.go
new file mode 100644
index 0000000..5016b39
--- /dev/null
+++ b/misc/cgo/test/issue9510b/b.go
@@ -0,0 +1,15 @@
+package issue9510b
+
+/*
+static double csquare(double a, double b) {
+ __complex__ double d;
+ __real__ d = a;
+ __imag__ d = b;
+ return __real__ (d * d);
+}
+*/
+import "C"
+
+func F(a, b float64) float64 {
+ return float64(C.csquare(C.double(a), C.double(b)))
+}
diff --git a/misc/cgo/test/setgid2_linux.go b/misc/cgo/test/setgid2_linux.go
new file mode 100644
index 0000000..438f5ae
--- /dev/null
+++ b/misc/cgo/test/setgid2_linux.go
@@ -0,0 +1,35 @@
+// Copyright 2022 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.
+
+// Stress test setgid and thread creation. A thread
+// can get a SIGSETXID signal early on at thread
+// initialization, causing crash. See issue 53374.
+
+package cgotest
+
+/*
+#include <sys/types.h>
+#include <unistd.h>
+*/
+import "C"
+
+import (
+ "runtime"
+ "testing"
+)
+
+func testSetgidStress(t *testing.T) {
+ const N = 50
+ ch := make(chan int, N)
+ for i := 0; i < N; i++ {
+ go func() {
+ C.setgid(0)
+ ch <- 1
+ runtime.LockOSThread() // so every goroutine uses a new thread
+ }()
+ }
+ for i := 0; i < N; i++ {
+ <-ch
+ }
+}
diff --git a/misc/cgo/test/setgid_linux.go b/misc/cgo/test/setgid_linux.go
new file mode 100644
index 0000000..7c64946
--- /dev/null
+++ b/misc/cgo/test/setgid_linux.go
@@ -0,0 +1,49 @@
+// Copyright 2012 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.
+
+// Test that setgid does not hang on Linux.
+// See https://golang.org/issue/3871 for details.
+
+package cgotest
+
+/*
+#include <sys/types.h>
+#include <unistd.h>
+*/
+import "C"
+
+import (
+ "os"
+ "os/signal"
+ "syscall"
+ "testing"
+ "time"
+)
+
+func runTestSetgid() bool {
+ c := make(chan bool)
+ go func() {
+ C.setgid(0)
+ c <- true
+ }()
+ select {
+ case <-c:
+ return true
+ case <-time.After(5 * time.Second):
+ return false
+ }
+
+}
+
+func testSetgid(t *testing.T) {
+ if !runTestSetgid() {
+ t.Error("setgid hung")
+ }
+
+ // Now try it again after using signal.Notify.
+ signal.Notify(make(chan os.Signal, 1), syscall.SIGINT)
+ if !runTestSetgid() {
+ t.Error("setgid hung after signal.Notify")
+ }
+}
diff --git a/misc/cgo/test/sigaltstack.go b/misc/cgo/test/sigaltstack.go
new file mode 100644
index 0000000..6b37189
--- /dev/null
+++ b/misc/cgo/test/sigaltstack.go
@@ -0,0 +1,79 @@
+// Copyright 2015 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 !windows && !android
+// +build !windows,!android
+
+// Test that the Go runtime still works if C code changes the signal stack.
+
+package cgotest
+
+/*
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _AIX
+// On AIX, SIGSTKSZ is too small to handle Go sighandler.
+#define CSIGSTKSZ 0x4000
+#else
+#define CSIGSTKSZ SIGSTKSZ
+#endif
+
+static stack_t oss;
+static char signalStack[CSIGSTKSZ];
+
+static void changeSignalStack(void) {
+ stack_t ss;
+ memset(&ss, 0, sizeof ss);
+ ss.ss_sp = signalStack;
+ ss.ss_flags = 0;
+ ss.ss_size = CSIGSTKSZ;
+ if (sigaltstack(&ss, &oss) < 0) {
+ perror("sigaltstack");
+ abort();
+ }
+}
+
+static void restoreSignalStack(void) {
+#if (defined(__x86_64__) || defined(__i386__)) && defined(__APPLE__)
+ // The Darwin C library enforces a minimum that the kernel does not.
+ // This is OK since we allocated this much space in mpreinit,
+ // it was just removed from the buffer by stackalloc.
+ oss.ss_size = MINSIGSTKSZ;
+#endif
+ if (sigaltstack(&oss, NULL) < 0) {
+ perror("sigaltstack restore");
+ abort();
+ }
+}
+
+static int zero(void) {
+ return 0;
+}
+*/
+import "C"
+
+import (
+ "runtime"
+ "testing"
+)
+
+func testSigaltstack(t *testing.T) {
+ switch {
+ case runtime.GOOS == "solaris", runtime.GOOS == "illumos", runtime.GOOS == "ios" && runtime.GOARCH == "arm64":
+ t.Skipf("switching signal stack not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+ }
+
+ C.changeSignalStack()
+ defer C.restoreSignalStack()
+ defer func() {
+ if recover() == nil {
+ t.Error("did not see expected panic")
+ }
+ }()
+ v := 1 / int(C.zero())
+ t.Errorf("unexpected success of division by zero == %d", v)
+}
diff --git a/misc/cgo/test/sigprocmask.c b/misc/cgo/test/sigprocmask.c
new file mode 100644
index 0000000..e77ba5b
--- /dev/null
+++ b/misc/cgo/test/sigprocmask.c
@@ -0,0 +1,51 @@
+// Copyright 2015 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.
+
+// +build !windows
+
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+extern void IntoGoAndBack();
+
+int CheckBlocked() {
+ sigset_t mask;
+ sigprocmask(SIG_BLOCK, NULL, &mask);
+ return sigismember(&mask, SIGIO);
+}
+
+static void* sigthreadfunc(void* unused) {
+ sigset_t mask;
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGIO);
+ sigprocmask(SIG_BLOCK, &mask, NULL);
+ IntoGoAndBack();
+ return NULL;
+}
+
+int RunSigThread() {
+ int tries;
+ pthread_t thread;
+ int r;
+ struct timespec ts;
+
+ for (tries = 0; tries < 20; tries++) {
+ r = pthread_create(&thread, NULL, &sigthreadfunc, NULL);
+ if (r == 0) {
+ return pthread_join(thread, NULL);
+ }
+ if (r != EAGAIN) {
+ return r;
+ }
+ ts.tv_sec = 0;
+ ts.tv_nsec = (tries + 1) * 1000 * 1000; // Milliseconds.
+ nanosleep(&ts, NULL);
+ }
+ return EAGAIN;
+}
diff --git a/misc/cgo/test/sigprocmask.go b/misc/cgo/test/sigprocmask.go
new file mode 100644
index 0000000..983734c
--- /dev/null
+++ b/misc/cgo/test/sigprocmask.go
@@ -0,0 +1,41 @@
+// Copyright 2015 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 !windows
+// +build !windows
+
+package cgotest
+
+/*
+#cgo CFLAGS: -pthread
+#cgo LDFLAGS: -pthread
+extern int RunSigThread();
+extern int CheckBlocked();
+*/
+import "C"
+import (
+ "os"
+ "os/signal"
+ "syscall"
+ "testing"
+)
+
+var blocked bool
+
+//export IntoGoAndBack
+func IntoGoAndBack() {
+ // Verify that SIGIO stays blocked on the C thread
+ // even when unblocked for signal.Notify().
+ signal.Notify(make(chan os.Signal), syscall.SIGIO)
+ blocked = C.CheckBlocked() != 0
+}
+
+func testSigprocmask(t *testing.T) {
+ if r := C.RunSigThread(); r != 0 {
+ t.Errorf("pthread_create/pthread_join failed: %d", r)
+ }
+ if !blocked {
+ t.Error("Go runtime unblocked SIGIO")
+ }
+}
diff --git a/misc/cgo/test/test.go b/misc/cgo/test/test.go
new file mode 100644
index 0000000..9d9b14e
--- /dev/null
+++ b/misc/cgo/test/test.go
@@ -0,0 +1,2303 @@
+// Copyright 2010 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.
+
+// Test cases for cgo.
+// Both the import "C" prologue and the main file are sorted by issue number.
+// This file contains C definitions (not just declarations)
+// and so it must NOT contain any //export directives on Go functions.
+// See testx.go for exports.
+
+package cgotest
+
+/*
+#include <complex.h>
+#include <math.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#cgo LDFLAGS: -lm
+
+#ifndef WIN32
+#include <pthread.h>
+#include <signal.h>
+#endif
+
+// alignment tests
+
+typedef unsigned char Uint8;
+typedef unsigned short Uint16;
+
+typedef enum {
+ MOD1 = 0x0000,
+ MODX = 0x8000
+} SDLMod;
+
+typedef enum {
+ A1 = 1,
+ B1 = 322,
+ SDLK_LAST
+} SDLKey;
+
+typedef struct SDL_keysym {
+ Uint8 scancode;
+ SDLKey sym;
+ SDLMod mod;
+ Uint16 unicode;
+} SDL_keysym;
+
+typedef struct SDL_KeyboardEvent {
+ Uint8 typ;
+ Uint8 which;
+ Uint8 state;
+ SDL_keysym keysym;
+} SDL_KeyboardEvent;
+
+void makeEvent(SDL_KeyboardEvent *event) {
+ unsigned char *p;
+ int i;
+
+ p = (unsigned char*)event;
+ for (i=0; i<sizeof *event; i++) {
+ p[i] = i;
+ }
+}
+
+int same(SDL_KeyboardEvent* e, Uint8 typ, Uint8 which, Uint8 state, Uint8 scan, SDLKey sym, SDLMod mod, Uint16 uni) {
+ return e->typ == typ && e->which == which && e->state == state && e->keysym.scancode == scan && e->keysym.sym == sym && e->keysym.mod == mod && e->keysym.unicode == uni;
+}
+
+void cTest(SDL_KeyboardEvent *event) {
+ printf("C: %#x %#x %#x %#x %#x %#x %#x\n", event->typ, event->which, event->state,
+ event->keysym.scancode, event->keysym.sym, event->keysym.mod, event->keysym.unicode);
+ fflush(stdout);
+}
+
+// api
+
+const char *greeting = "hello, world";
+
+// basic test cases
+
+#define SHIFT(x, y) ((x)<<(y))
+#define KILO SHIFT(1, 10)
+#define UINT32VAL 0xc008427bU
+
+enum E {
+ Enum1 = 1,
+ Enum2 = 2,
+};
+
+typedef unsigned char cgo_uuid_t[20];
+
+void uuid_generate(cgo_uuid_t x) {
+ x[0] = 0;
+}
+
+struct S {
+ int x;
+};
+
+const char *cstr = "abcefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+
+extern enum E myConstFunc(struct S* const ctx, int const id, struct S **const filter);
+
+enum E myConstFunc(struct S *const ctx, int const id, struct S **const filter) { return 0; }
+
+int add(int x, int y) {
+ return x+y;
+};
+
+// Following mimicks vulkan complex definitions for benchmarking cgocheck overhead.
+
+typedef uint32_t VkFlags;
+typedef VkFlags VkDeviceQueueCreateFlags;
+typedef uint32_t VkStructureType;
+
+typedef struct VkDeviceQueueCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceQueueCreateFlags flags;
+ uint32_t queueFamilyIndex;
+ uint32_t queueCount;
+ const float* pQueuePriorities;
+} VkDeviceQueueCreateInfo;
+
+typedef struct VkPhysicalDeviceFeatures {
+ uint32_t bools[56];
+} VkPhysicalDeviceFeatures;
+
+typedef struct VkDeviceCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkFlags flags;
+ uint32_t queueCreateInfoCount;
+ const VkDeviceQueueCreateInfo* pQueueCreateInfos;
+ uint32_t enabledLayerCount;
+ const char* const* ppEnabledLayerNames;
+ uint32_t enabledExtensionCount;
+ const char* const* ppEnabledExtensionNames;
+ const VkPhysicalDeviceFeatures* pEnabledFeatures;
+} VkDeviceCreateInfo;
+
+void handleComplexPointer(VkDeviceCreateInfo *a0) {}
+void handleComplexPointer8(
+ VkDeviceCreateInfo *a0, VkDeviceCreateInfo *a1, VkDeviceCreateInfo *a2, VkDeviceCreateInfo *a3,
+ VkDeviceCreateInfo *a4, VkDeviceCreateInfo *a5, VkDeviceCreateInfo *a6, VkDeviceCreateInfo *a7
+) {}
+
+// complex alignment
+
+struct {
+ float x;
+ _Complex float y;
+} cplxAlign = { 3.14, 2.17 };
+
+// constants and pointer checking
+
+#define CheckConstVal 0
+
+typedef struct {
+ int *p;
+} CheckConstStruct;
+
+static void CheckConstFunc(CheckConstStruct *p, int e) {}
+
+// duplicate symbol
+
+int base_symbol = 0;
+#define alias_one base_symbol
+#define alias_two base_symbol
+
+// function pointer variables
+
+typedef int (*intFunc) ();
+
+int
+bridge_int_func(intFunc f)
+{
+ return f();
+}
+
+int fortytwo()
+{
+ return 42;
+}
+
+// issue 1222
+typedef union {
+ long align;
+} xxpthread_mutex_t;
+struct ibv_async_event {
+ union {
+ int x;
+ } element;
+};
+struct ibv_context {
+ xxpthread_mutex_t mutex;
+};
+
+// issue 1635
+// Mac OS X's gcc will generate scattered relocation 2/1 for
+// this function on Darwin/386, and 8l couldn't handle it.
+// this example is in issue 1635
+void scatter() {
+ void *p = scatter;
+ printf("scatter = %p\n", p);
+}
+
+// Adding this explicit extern declaration makes this a test for
+// https://gcc.gnu.org/PR68072 aka https://golang.org/issue/13344 .
+// It used to cause a cgo error when building with GCC 6.
+extern int hola;
+
+// this example is in issue 3253
+int hola = 0;
+int testHola() { return hola; }
+
+// issue 3250
+#ifdef WIN32
+void testSendSIG() {}
+#else
+static void *thread(void *p) {
+ const int M = 100;
+ int i;
+ (void)p;
+ for (i = 0; i < M; i++) {
+ pthread_kill(pthread_self(), SIGCHLD);
+ usleep(rand() % 20 + 5);
+ }
+ return NULL;
+}
+void testSendSIG() {
+ const int N = 20;
+ int i;
+ pthread_t tid[N];
+ for (i = 0; i < N; i++) {
+ usleep(rand() % 200 + 100);
+ pthread_create(&tid[i], 0, thread, NULL);
+ }
+ for (i = 0; i < N; i++)
+ pthread_join(tid[i], 0);
+}
+#endif
+
+// issue 3261
+// libgcc on ARM might be compiled as thumb code, but our 5l
+// can't handle that, so we have to disable this test on arm.
+#ifdef __ARMEL__
+int vabs(int x) {
+ puts("testLibgcc is disabled on ARM because 5l cannot handle thumb library.");
+ return (x < 0) ? -x : x;
+}
+#elif defined(__arm64__) && defined(__clang__)
+int vabs(int x) {
+ puts("testLibgcc is disabled on ARM64 with clang due to lack of libgcc.");
+ return (x < 0) ? -x : x;
+}
+#else
+int __absvsi2(int); // dummy prototype for libgcc function
+// we shouldn't name the function abs, as gcc might use
+// the builtin one.
+int vabs(int x) { return __absvsi2(x); }
+#endif
+
+
+// issue 3729
+// access errno from void C function
+const char _expA = 0x42;
+const float _expB = 3.14159;
+const short _expC = 0x55aa;
+const int _expD = 0xdeadbeef;
+
+#ifdef WIN32
+void g(void) {}
+void g2(int x, char a, float b, short c, int d) {}
+#else
+
+void g(void) {
+ errno = E2BIG;
+}
+
+// try to pass some non-trivial arguments to function g2
+void g2(int x, char a, float b, short c, int d) {
+ if (a == _expA && b == _expB && c == _expC && d == _expD)
+ errno = x;
+ else
+ errno = -1;
+}
+#endif
+
+// issue 3945
+// Test that cgo reserves enough stack space during cgo call.
+// See https://golang.org/issue/3945 for details.
+void say() {
+ printf("%s from C\n", "hello");
+}
+
+// issue 4054 part 1 - other half in testx.go
+
+typedef enum {
+ A = 0,
+ B,
+ C,
+ D,
+ E,
+ F,
+ G,
+ H,
+ II,
+ J,
+} issue4054a;
+
+// issue 4339
+// We've historically permitted #include <>, so test it here. Issue 29333.
+// Also see issue 41059.
+#include <issue4339.h>
+
+// issue 4417
+// cmd/cgo: bool alignment/padding issue.
+// bool alignment is wrong and causing wrong arguments when calling functions.
+static int c_bool(bool a, bool b, int c, bool d, bool e) {
+ return c;
+}
+
+// issue 4857
+#cgo CFLAGS: -Werror
+const struct { int a; } *issue4857() { return (void *)0; }
+
+// issue 5224
+// Test that the #cgo CFLAGS directive works,
+// with and without platform filters.
+#cgo CFLAGS: -DCOMMON_VALUE=123
+#cgo windows CFLAGS: -DIS_WINDOWS=1
+#cgo !windows CFLAGS: -DIS_WINDOWS=0
+int common = COMMON_VALUE;
+int is_windows = IS_WINDOWS;
+
+// issue 5227
+// linker incorrectly treats common symbols and
+// leaves them undefined.
+
+typedef struct {
+ int Count;
+} Fontinfo;
+
+Fontinfo SansTypeface;
+
+extern void init();
+
+Fontinfo loadfont() {
+ Fontinfo f = {0};
+ return f;
+}
+
+void init() {
+ SansTypeface = loadfont();
+}
+
+// issue 5242
+// Cgo incorrectly computed the alignment of structs
+// with no Go accessible fields as 0, and then panicked on
+// modulo-by-zero computations.
+
+// issue 50987
+// disable arm64 GCC warnings
+#cgo CFLAGS: -Wno-psabi -Wno-unknown-warning-option
+
+typedef struct {
+} foo;
+
+typedef struct {
+ int x : 1;
+} bar;
+
+int issue5242(foo f, bar b) {
+ return 5242;
+}
+
+// issue 5337
+// Verify that we can withstand SIGPROF received on foreign threads
+
+#ifdef WIN32
+void test5337() {}
+#else
+static void *thread1(void *p) {
+ (void)p;
+ pthread_kill(pthread_self(), SIGPROF);
+ return NULL;
+}
+void test5337() {
+ pthread_t tid;
+ pthread_create(&tid, 0, thread1, NULL);
+ pthread_join(tid, 0);
+}
+#endif
+
+// issue 5603
+
+const long long issue5603exp = 0x12345678;
+long long issue5603foo0() { return issue5603exp; }
+long long issue5603foo1(void *p) { return issue5603exp; }
+long long issue5603foo2(void *p, void *q) { return issue5603exp; }
+long long issue5603foo3(void *p, void *q, void *r) { return issue5603exp; }
+long long issue5603foo4(void *p, void *q, void *r, void *s) { return issue5603exp; }
+
+// issue 5740
+
+int test5740a(void), test5740b(void);
+
+// issue 5986
+static void output5986()
+{
+ int current_row = 0, row_count = 0;
+ double sum_squares = 0;
+ double d;
+ do {
+ if (current_row == 10) {
+ current_row = 0;
+ }
+ ++row_count;
+ }
+ while (current_row++ != 1);
+ d = sqrt(sum_squares / row_count);
+ printf("sqrt is: %g\n", d);
+}
+
+// issue 6128
+// Test handling of #defined names in clang.
+// NOTE: Must use hex, or else a shortcut for decimals
+// in cgo avoids trying to pass this to clang.
+#define X 0x1
+
+// issue 6472
+typedef struct
+{
+ struct
+ {
+ int x;
+ } y[16];
+} z;
+
+// issue 6612
+// Test new scheme for deciding whether C.name is an expression, type, constant.
+// Clang silences some warnings when the name is a #defined macro, so test those too
+// (even though we now use errors exclusively, not warnings).
+
+void myfunc(void) {}
+int myvar = 5;
+const char *mytext = "abcdef";
+typedef int mytype;
+enum {
+ myenum = 1234,
+};
+
+#define myfunc_def myfunc
+#define myvar_def myvar
+#define mytext_def mytext
+#define mytype_def mytype
+#define myenum_def myenum
+#define myint_def 12345
+#define myfloat_def 1.5
+#define mystring_def "hello"
+
+// issue 6907
+char* Issue6907CopyString(_GoString_ s) {
+ size_t n;
+ const char *p;
+ char *r;
+
+ n = _GoStringLen(s);
+ p = _GoStringPtr(s);
+ r = malloc(n + 1);
+ memmove(r, p, n);
+ r[n] = '\0';
+ return r;
+}
+
+// issue 7560
+typedef struct {
+ char x;
+ long y;
+} __attribute__((__packed__)) misaligned;
+
+int
+offset7560(void)
+{
+ return (uintptr_t)&((misaligned*)0)->y;
+}
+
+// issue 7786
+// No runtime test, just make sure that typedef and struct/union/class are interchangeable at compile time.
+
+struct test7786;
+typedef struct test7786 typedef_test7786;
+void f7786(struct test7786 *ctx) {}
+void g7786(typedef_test7786 *ctx) {}
+
+typedef struct body7786 typedef_body7786;
+struct body7786 { int x; };
+void b7786(struct body7786 *ctx) {}
+void c7786(typedef_body7786 *ctx) {}
+
+typedef union union7786 typedef_union7786;
+void u7786(union union7786 *ctx) {}
+void v7786(typedef_union7786 *ctx) {}
+
+// issue 8092
+// Test that linker defined symbols (e.g., text, data) don't
+// conflict with C symbols.
+char text[] = "text";
+char data[] = "data";
+char *ctext(void) { return text; }
+char *cdata(void) { return data; }
+
+// issue 8428
+// Cgo inconsistently translated zero size arrays.
+
+struct issue8428one {
+ char b;
+ char rest[];
+};
+
+struct issue8428two {
+ void *p;
+ char b;
+ char rest[0];
+ char pad;
+};
+
+struct issue8428three {
+ char w[1][2][3][0];
+ char x[2][3][0][1];
+ char y[3][0][1][2];
+ char z[0][1][2][3];
+};
+
+// issue 8331 part 1 - part 2 in testx.go
+// A typedef of an unnamed struct is the same struct when
+// #include'd twice. No runtime test; just make sure it compiles.
+#include "issue8331.h"
+
+// issue 8368 and 8441
+// Recursive struct definitions didn't work.
+// No runtime test; just make sure it compiles.
+typedef struct one one;
+typedef struct two two;
+struct one {
+ two *x;
+};
+struct two {
+ one *x;
+};
+
+// issue 8811
+
+extern int issue8811Initialized;
+extern void issue8811Init();
+
+void issue8811Execute() {
+ if(!issue8811Initialized)
+ issue8811Init();
+}
+
+// issue 8945
+
+typedef void (*PFunc8945)();
+PFunc8945 func8945;
+
+// issue 9557
+
+struct issue9557_t {
+ int a;
+} test9557bar = { 42 };
+struct issue9557_t *issue9557foo = &test9557bar;
+
+// issue 10303
+// Pointers passed to C were not marked as escaping (bug in cgo).
+
+typedef int *intptr;
+
+void setintstar(int *x) {
+ *x = 1;
+}
+
+void setintptr(intptr x) {
+ *x = 1;
+}
+
+void setvoidptr(void *x) {
+ *(int*)x = 1;
+}
+
+typedef struct Struct Struct;
+struct Struct {
+ int *P;
+};
+
+void setstruct(Struct s) {
+ *s.P = 1;
+}
+
+// issue 11925
+// Structs with zero-length trailing fields are now padded by the Go compiler.
+
+struct a11925 {
+ int i;
+ char a[0];
+ char b[0];
+};
+
+struct b11925 {
+ int i;
+ char a[0];
+ char b[];
+};
+
+// issue 12030
+void issue12030conv(char *buf, double x) {
+ sprintf(buf, "d=%g", x);
+}
+
+// issue 14838
+
+int check_cbytes(char *b, size_t l) {
+ int i;
+ for (i = 0; i < l; i++) {
+ if (b[i] != i) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+// issue 17065
+// Test that C symbols larger than a page play nicely with the race detector.
+int ii[65537];
+
+// issue 17537
+// The void* cast introduced by cgo to avoid problems
+// with const/volatile qualifiers breaks C preprocessor macros that
+// emulate functions.
+
+typedef struct {
+ int i;
+} S17537;
+
+int I17537(S17537 *p);
+
+#define I17537(p) ((p)->i)
+
+// Calling this function used to fail without the cast.
+const int F17537(const char **p) {
+ return **p;
+}
+
+// issue 17723
+// API compatibility checks
+
+typedef char *cstring_pointer;
+static void cstring_pointer_fun(cstring_pointer dummy) { }
+const char *api_hello = "hello!";
+
+// Calling this function used to trigger an error from the C compiler
+// (issue 18298).
+void F18298(const void *const *p) {
+}
+
+// Test that conversions between typedefs work as they used to.
+typedef const void *T18298_1;
+struct S18298 { int i; };
+typedef const struct S18298 *T18298_2;
+void G18298(T18298_1 t) {
+}
+
+// issue 18126
+// cgo check of void function returning errno.
+void Issue18126C(void **p) {}
+
+// issue 18720
+
+#define HELLO "hello"
+#define WORLD "world"
+#define HELLO_WORLD HELLO "\000" WORLD
+
+struct foo { char c; };
+#define SIZE_OF(x) sizeof(x)
+#define SIZE_OF_FOO SIZE_OF(struct foo)
+#define VAR1 VAR
+#define VAR var
+int var = 5;
+
+#define ADDR &var
+
+#define CALL fn()
+int fn(void) {
+ return ++var;
+}
+
+// issue 20129
+
+int issue20129 = 0;
+typedef void issue20129Void;
+issue20129Void issue20129Foo() {
+ issue20129 = 1;
+}
+typedef issue20129Void issue20129Void2;
+issue20129Void2 issue20129Bar() {
+ issue20129 = 2;
+}
+
+// issue 20369
+#define XUINT64_MAX 18446744073709551615ULL
+
+// issue 21668
+// Fail to guess the kind of the constant "x".
+// No runtime test; just make sure it compiles.
+const int x21668 = 42;
+
+// issue 21708
+#define CAST_TO_INT64 (int64_t)(-1)
+
+// issue 21809
+// Compile C `typedef` to go type aliases.
+
+typedef long MySigned_t;
+// tests alias-to-alias
+typedef MySigned_t MySigned2_t;
+long takes_long(long x) { return x * x; }
+MySigned_t takes_typedef(MySigned_t x) { return x * x; }
+
+// issue 22906
+
+// It's going to be hard to include a whole real JVM to test this.
+// So we'll simulate a really easy JVM using just the parts we need.
+// This is the relevant part of jni.h.
+
+struct _jobject;
+
+typedef struct _jobject *jobject;
+typedef jobject jclass;
+typedef jobject jthrowable;
+typedef jobject jstring;
+typedef jobject jarray;
+typedef jarray jbooleanArray;
+typedef jarray jbyteArray;
+typedef jarray jcharArray;
+typedef jarray jshortArray;
+typedef jarray jintArray;
+typedef jarray jlongArray;
+typedef jarray jfloatArray;
+typedef jarray jdoubleArray;
+typedef jarray jobjectArray;
+
+typedef jobject jweak;
+
+// Note: jvalue is already a non-pointer type due to it being a C union.
+
+// issue 22958
+
+typedef struct {
+ unsigned long long f8 : 8;
+ unsigned long long f16 : 16;
+ unsigned long long f24 : 24;
+ unsigned long long f32 : 32;
+ unsigned long long f40 : 40;
+ unsigned long long f48 : 48;
+ unsigned long long f56 : 56;
+ unsigned long long f64 : 64;
+} issue22958Type;
+
+// issue 23356
+int a(void) { return 5; };
+int r(void) { return 3; };
+
+// issue 23720
+typedef int *issue23720A;
+typedef const int *issue23720B;
+void issue23720F(issue23720B a) {}
+
+// issue 24206
+#if defined(__linux__) && defined(__x86_64__)
+#include <sys/mman.h>
+// Returns string with null byte at the last valid address
+char* dangerousString1() {
+ int pageSize = 4096;
+ char *data = mmap(0, 2 * pageSize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, 0, 0);
+ mprotect(data + pageSize,pageSize,PROT_NONE);
+ int start = pageSize - 123 - 1; // last 123 bytes of first page + 1 null byte
+ int i = start;
+ for (; i < pageSize; i++) {
+ data[i] = 'x';
+ }
+ data[pageSize -1 ] = 0;
+ return data+start;
+}
+
+char* dangerousString2() {
+ int pageSize = 4096;
+ char *data = mmap(0, 3 * pageSize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, 0, 0);
+ mprotect(data + 2 * pageSize,pageSize,PROT_NONE);
+ int start = pageSize - 123 - 1; // last 123 bytes of first page + 1 null byte
+ int i = start;
+ for (; i < 2 * pageSize; i++) {
+ data[i] = 'x';
+ }
+ data[2*pageSize -1 ] = 0;
+ return data+start;
+}
+#else
+char *dangerousString1() { return NULL; }
+char *dangerousString2() { return NULL; }
+#endif
+
+// issue 26066
+const unsigned long long int issue26066 = (const unsigned long long) -1;
+
+// issue 26517
+// Introduce two pointer types which are distinct, but have the same
+// base type. Make sure that both of those pointer types get resolved
+// correctly. Before the fix for 26517 if one of these pointer types
+// was resolved before the other one was processed, the second one
+// would never be resolved.
+// Before this issue was fixed this test failed on Windows,
+// where va_list expands to a named char* type.
+typedef va_list TypeOne;
+typedef char *TypeTwo;
+
+// issue 28540
+
+static void twoargs1(void *p, int n) {}
+static void *twoargs2() { return 0; }
+static int twoargs3(void * p) { return 0; }
+
+// issue 28545
+// Failed to add type conversion for negative constant.
+
+static void issue28545F(char **p, int n, complex double a) {}
+
+// issue 28772 part 1 - part 2 in testx.go
+// Failed to add type conversion for Go constant set to C constant.
+// No runtime test; just make sure it compiles.
+
+#define issue28772Constant 1
+
+// issue 28896
+// cgo was incorrectly adding padding after a packed struct.
+typedef struct {
+ void *f1;
+ uint32_t f2;
+} __attribute__((__packed__)) innerPacked;
+
+typedef struct {
+ innerPacked g1;
+ uint64_t g2;
+} outerPacked;
+
+typedef struct {
+ void *f1;
+ uint32_t f2;
+} innerUnpacked;
+
+typedef struct {
+ innerUnpacked g1;
+ uint64_t g2;
+} outerUnpacked;
+
+size_t offset(int x) {
+ switch (x) {
+ case 0:
+ return offsetof(innerPacked, f2);
+ case 1:
+ return offsetof(outerPacked, g2);
+ case 2:
+ return offsetof(innerUnpacked, f2);
+ case 3:
+ return offsetof(outerUnpacked, g2);
+ default:
+ abort();
+ }
+}
+
+// issue 29748
+
+typedef struct { char **p; } S29748;
+static int f29748(S29748 *p) { return 0; }
+
+// issue 29781
+// Error with newline inserted into constant expression.
+// Compilation test only, nothing to run.
+
+static void issue29781F(char **p, int n) {}
+#define ISSUE29781C 0
+
+// issue 31093
+static uint16_t issue31093F(uint16_t v) { return v; }
+
+// issue 32579
+typedef struct S32579 { unsigned char data[1]; } S32579;
+
+// issue 37033, cgo.Handle
+extern void GoFunc37033(uintptr_t handle);
+void cFunc37033(uintptr_t handle) { GoFunc37033(handle); }
+
+// issue 38649
+// Test that #define'd type aliases work.
+#define netbsd_gid unsigned int
+
+// issue 40494
+// Inconsistent handling of tagged enum and union types.
+enum Enum40494 { X_40494 };
+union Union40494 { int x; };
+void issue40494(enum Enum40494 e, union Union40494* up) {}
+
+// Issue 45451, bad handling of go:notinheap types.
+typedef struct issue45451Undefined issue45451;
+
+// Issue 49633, example of cgo.Handle with void*.
+extern void GoFunc49633(void*);
+void cfunc49633(void *context) { GoFunc49633(context); }
+
+*/
+import "C"
+
+import (
+ "context"
+ "fmt"
+ "math"
+ "math/rand"
+ "os"
+ "os/signal"
+ "reflect"
+ "runtime"
+ "runtime/cgo"
+ "sync"
+ "syscall"
+ "testing"
+ "time"
+ "unsafe"
+)
+
+// alignment
+
+func testAlign(t *testing.T) {
+ var evt C.SDL_KeyboardEvent
+ C.makeEvent(&evt)
+ if C.same(&evt, evt.typ, evt.which, evt.state, evt.keysym.scancode, evt.keysym.sym, evt.keysym.mod, evt.keysym.unicode) == 0 {
+ t.Error("*** bad alignment")
+ C.cTest(&evt)
+ t.Errorf("Go: %#x %#x %#x %#x %#x %#x %#x\n",
+ evt.typ, evt.which, evt.state, evt.keysym.scancode,
+ evt.keysym.sym, evt.keysym.mod, evt.keysym.unicode)
+ t.Error(evt)
+ }
+}
+
+// api
+
+const greeting = "hello, world"
+
+type testPair struct {
+ Name string
+ Got, Want interface{}
+}
+
+var testPairs = []testPair{
+ {"GoString", C.GoString(C.greeting), greeting},
+ {"GoStringN", C.GoStringN(C.greeting, 5), greeting[:5]},
+ {"GoBytes", C.GoBytes(unsafe.Pointer(C.greeting), 5), []byte(greeting[:5])},
+}
+
+func testHelpers(t *testing.T) {
+ for _, pair := range testPairs {
+ if !reflect.DeepEqual(pair.Got, pair.Want) {
+ t.Errorf("%s: got %#v, want %#v", pair.Name, pair.Got, pair.Want)
+ }
+ }
+}
+
+// basic test cases
+
+const EINVAL = C.EINVAL /* test #define */
+
+var KILO = C.KILO
+
+func uuidgen() {
+ var uuid C.cgo_uuid_t
+ C.uuid_generate(&uuid[0])
+}
+
+func Strtol(s string, base int) (int, error) {
+ p := C.CString(s)
+ n, err := C.strtol(p, nil, C.int(base))
+ C.free(unsafe.Pointer(p))
+ return int(n), err
+}
+
+func Atol(s string) int {
+ p := C.CString(s)
+ n := C.atol(p)
+ C.free(unsafe.Pointer(p))
+ return int(n)
+}
+
+func testConst(t *testing.T) {
+ C.myConstFunc(nil, 0, nil)
+}
+
+func testEnum(t *testing.T) {
+ if C.Enum1 != 1 || C.Enum2 != 2 {
+ t.Error("bad enum", C.Enum1, C.Enum2)
+ }
+}
+
+func testNamedEnum(t *testing.T) {
+ e := new(C.enum_E)
+
+ *e = C.Enum1
+ if *e != 1 {
+ t.Error("bad enum", C.Enum1)
+ }
+
+ *e = C.Enum2
+ if *e != 2 {
+ t.Error("bad enum", C.Enum2)
+ }
+}
+
+func testCastToEnum(t *testing.T) {
+ e := C.enum_E(C.Enum1)
+ if e != 1 {
+ t.Error("bad enum", C.Enum1)
+ }
+
+ e = C.enum_E(C.Enum2)
+ if e != 2 {
+ t.Error("bad enum", C.Enum2)
+ }
+}
+
+func testAtol(t *testing.T) {
+ l := Atol("123")
+ if l != 123 {
+ t.Error("Atol 123: ", l)
+ }
+}
+
+func testErrno(t *testing.T) {
+ p := C.CString("no-such-file")
+ m := C.CString("r")
+ f, err := C.fopen(p, m)
+ C.free(unsafe.Pointer(p))
+ C.free(unsafe.Pointer(m))
+ if err == nil {
+ C.fclose(f)
+ t.Fatalf("C.fopen: should fail")
+ }
+ if err != syscall.ENOENT {
+ t.Fatalf("C.fopen: unexpected error: %v", err)
+ }
+}
+
+func testMultipleAssign(t *testing.T) {
+ p := C.CString("234")
+ n, m := C.strtol(p, nil, 345), C.strtol(p, nil, 10)
+ if runtime.GOOS == "openbsd" {
+ // Bug in OpenBSD strtol(3) - base > 36 succeeds.
+ if (n != 0 && n != 239089) || m != 234 {
+ t.Fatal("Strtol x2: ", n, m)
+ }
+ } else if n != 0 || m != 234 {
+ t.Fatal("Strtol x2: ", n, m)
+ }
+ C.free(unsafe.Pointer(p))
+}
+
+var (
+ cuint = (C.uint)(0)
+ culong C.ulong
+ cchar C.char
+)
+
+type Context struct {
+ ctx *C.struct_ibv_context
+}
+
+func benchCgoCall(b *testing.B) {
+ b.Run("add-int", func(b *testing.B) {
+ const x = C.int(2)
+ const y = C.int(3)
+
+ for i := 0; i < b.N; i++ {
+ C.add(x, y)
+ }
+ })
+
+ b.Run("one-pointer", func(b *testing.B) {
+ var a0 C.VkDeviceCreateInfo
+ for i := 0; i < b.N; i++ {
+ C.handleComplexPointer(&a0)
+ }
+ })
+ b.Run("eight-pointers", func(b *testing.B) {
+ var a0, a1, a2, a3, a4, a5, a6, a7 C.VkDeviceCreateInfo
+ for i := 0; i < b.N; i++ {
+ C.handleComplexPointer8(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7)
+ }
+ })
+ b.Run("eight-pointers-nil", func(b *testing.B) {
+ var a0, a1, a2, a3, a4, a5, a6, a7 *C.VkDeviceCreateInfo
+ for i := 0; i < b.N; i++ {
+ C.handleComplexPointer8(a0, a1, a2, a3, a4, a5, a6, a7)
+ }
+ })
+ b.Run("eight-pointers-array", func(b *testing.B) {
+ var a [8]C.VkDeviceCreateInfo
+ for i := 0; i < b.N; i++ {
+ C.handleComplexPointer8(&a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7])
+ }
+ })
+ b.Run("eight-pointers-slice", func(b *testing.B) {
+ a := make([]C.VkDeviceCreateInfo, 8)
+ for i := 0; i < b.N; i++ {
+ C.handleComplexPointer8(&a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7])
+ }
+ })
+}
+
+// Benchmark measuring overhead from Go to C and back to Go (via a callback)
+func benchCallback(b *testing.B) {
+ var x = false
+ for i := 0; i < b.N; i++ {
+ nestedCall(func() { x = true })
+ }
+ if !x {
+ b.Fatal("nestedCall was not invoked")
+ }
+}
+
+var sinkString string
+
+func benchGoString(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ sinkString = C.GoString(C.cstr)
+ }
+ const want = "abcefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890"
+ if sinkString != want {
+ b.Fatalf("%q != %q", sinkString, want)
+ }
+}
+
+// Static (build-time) test that syntax traversal visits all operands of s[i:j:k].
+func sliceOperands(array [2000]int) {
+ _ = array[C.KILO:C.KILO:C.KILO] // no type error
+}
+
+// set in cgo_thread_lock.go init
+var testThreadLockFunc = func(*testing.T) {}
+
+// complex alignment
+
+func TestComplexAlign(t *testing.T) {
+ if C.cplxAlign.x != 3.14 {
+ t.Errorf("got %v, expected 3.14", C.cplxAlign.x)
+ }
+ if C.cplxAlign.y != 2.17 {
+ t.Errorf("got %v, expected 2.17", C.cplxAlign.y)
+ }
+}
+
+// constants and pointer checking
+
+func testCheckConst(t *testing.T) {
+ // The test is that this compiles successfully.
+ p := C.malloc(C.size_t(unsafe.Sizeof(C.int(0))))
+ defer C.free(p)
+ C.CheckConstFunc(&C.CheckConstStruct{(*C.int)(p)}, C.CheckConstVal)
+}
+
+// duplicate symbol
+
+func duplicateSymbols() {
+ fmt.Printf("%v %v %v\n", C.base_symbol, C.alias_one, C.alias_two)
+}
+
+// environment
+
+// This is really an os package test but here for convenience.
+func testSetEnv(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ // Go uses SetEnvironmentVariable on windows. However,
+ // C runtime takes a *copy* at process startup of the
+ // OS environment, and stores it in environ/envp.
+ // It is this copy that getenv/putenv manipulate.
+ t.Logf("skipping test")
+ return
+ }
+ const key = "CGO_OS_TEST_KEY"
+ const val = "CGO_OS_TEST_VALUE"
+ os.Setenv(key, val)
+ keyc := C.CString(key)
+ defer C.free(unsafe.Pointer(keyc))
+ v := C.getenv(keyc)
+ if uintptr(unsafe.Pointer(v)) == 0 {
+ t.Fatal("getenv returned NULL")
+ }
+ vs := C.GoString(v)
+ if vs != val {
+ t.Fatalf("getenv() = %q; want %q", vs, val)
+ }
+}
+
+// function pointer variables
+
+func callBridge(f C.intFunc) int {
+ return int(C.bridge_int_func(f))
+}
+
+func callCBridge(f C.intFunc) C.int {
+ return C.bridge_int_func(f)
+}
+
+func testFpVar(t *testing.T) {
+ const expected = 42
+ f := C.intFunc(C.fortytwo)
+ res1 := C.bridge_int_func(f)
+ if r1 := int(res1); r1 != expected {
+ t.Errorf("got %d, want %d", r1, expected)
+ }
+ res2 := callCBridge(f)
+ if r2 := int(res2); r2 != expected {
+ t.Errorf("got %d, want %d", r2, expected)
+ }
+ r3 := callBridge(f)
+ if r3 != expected {
+ t.Errorf("got %d, want %d", r3, expected)
+ }
+}
+
+// issue 1222
+type AsyncEvent struct {
+ event C.struct_ibv_async_event
+}
+
+// issue 1635
+
+func test1635(t *testing.T) {
+ C.scatter()
+ if v := C.hola; v != 0 {
+ t.Fatalf("C.hola is %d, should be 0", v)
+ }
+ if v := C.testHola(); v != 0 {
+ t.Fatalf("C.testHola() is %d, should be 0", v)
+ }
+}
+
+// issue 2470
+
+func testUnsignedInt(t *testing.T) {
+ a := (int64)(C.UINT32VAL)
+ b := (int64)(0xc008427b)
+ if a != b {
+ t.Errorf("Incorrect unsigned int - got %x, want %x", a, b)
+ }
+}
+
+// issue 3250
+
+func test3250(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("not applicable on windows")
+ }
+
+ t.Skip("skipped, see golang.org/issue/5885")
+ var (
+ thres = 1
+ sig = syscall_dot_SIGCHLD
+ )
+ type result struct {
+ n int
+ sig os.Signal
+ }
+ var (
+ sigCh = make(chan os.Signal, 10)
+ waitStart = make(chan struct{})
+ waitDone = make(chan result)
+ )
+
+ signal.Notify(sigCh, sig)
+
+ go func() {
+ n := 0
+ alarm := time.After(time.Second * 3)
+ for {
+ select {
+ case <-waitStart:
+ waitStart = nil
+ case v := <-sigCh:
+ n++
+ if v != sig || n > thres {
+ waitDone <- result{n, v}
+ return
+ }
+ case <-alarm:
+ waitDone <- result{n, sig}
+ return
+ }
+ }
+ }()
+
+ waitStart <- struct{}{}
+ C.testSendSIG()
+ r := <-waitDone
+ if r.sig != sig {
+ t.Fatalf("received signal %v, but want %v", r.sig, sig)
+ }
+ t.Logf("got %d signals\n", r.n)
+ if r.n <= thres {
+ t.Fatalf("expected more than %d", thres)
+ }
+}
+
+// issue 3261
+
+func testLibgcc(t *testing.T) {
+ var table = []struct {
+ in, out C.int
+ }{
+ {0, 0},
+ {1, 1},
+ {-42, 42},
+ {1000300, 1000300},
+ {1 - 1<<31, 1<<31 - 1},
+ }
+ for _, v := range table {
+ if o := C.vabs(v.in); o != v.out {
+ t.Fatalf("abs(%d) got %d, should be %d", v.in, o, v.out)
+ return
+ }
+ }
+}
+
+// issue 3729
+
+func test3729(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("skipping on windows")
+ }
+
+ _, e := C.g()
+ if e != syscall.E2BIG {
+ t.Errorf("got %q, expect %q", e, syscall.E2BIG)
+ }
+ _, e = C.g2(C.EINVAL, C._expA, C._expB, C._expC, C._expD)
+ if e != syscall.EINVAL {
+ t.Errorf("got %q, expect %q", e, syscall.EINVAL)
+ }
+}
+
+// issue 3945
+
+func testPrintf(t *testing.T) {
+ C.say()
+}
+
+// issue 4054
+
+var issue4054a = []int{C.A, C.B, C.C, C.D, C.E, C.F, C.G, C.H, C.I, C.J}
+
+// issue 4339
+
+func test4339(t *testing.T) {
+ C.handle4339(&C.exported4339)
+}
+
+// issue 4417
+
+func testBoolAlign(t *testing.T) {
+ b := C.c_bool(true, true, 10, true, false)
+ if b != 10 {
+ t.Fatalf("found %d expected 10\n", b)
+ }
+ b = C.c_bool(true, true, 5, true, true)
+ if b != 5 {
+ t.Fatalf("found %d expected 5\n", b)
+ }
+ b = C.c_bool(true, true, 3, true, false)
+ if b != 3 {
+ t.Fatalf("found %d expected 3\n", b)
+ }
+ b = C.c_bool(false, false, 1, true, false)
+ if b != 1 {
+ t.Fatalf("found %d expected 1\n", b)
+ }
+ b = C.c_bool(false, true, 200, true, false)
+ if b != 200 {
+ t.Fatalf("found %d expected 200\n", b)
+ }
+}
+
+// issue 4857
+
+func test4857() {
+ _ = C.issue4857()
+}
+
+// issue 5224
+
+func testCflags(t *testing.T) {
+ is_windows := C.is_windows == 1
+ if is_windows != (runtime.GOOS == "windows") {
+ t.Errorf("is_windows: %v, runtime.GOOS: %s", is_windows, runtime.GOOS)
+ }
+ if C.common != 123 {
+ t.Errorf("common: %v (expected 123)", C.common)
+ }
+}
+
+// issue 5227
+
+func test5227(t *testing.T) {
+ C.init()
+}
+
+func selectfont() C.Fontinfo {
+ return C.SansTypeface
+}
+
+// issue 5242
+
+func test5242(t *testing.T) {
+ if got := C.issue5242(C.foo{}, C.bar{}); got != 5242 {
+ t.Errorf("got %v", got)
+ }
+}
+
+func test5603(t *testing.T) {
+ var x [5]int64
+ exp := int64(C.issue5603exp)
+ x[0] = int64(C.issue5603foo0())
+ x[1] = int64(C.issue5603foo1(nil))
+ x[2] = int64(C.issue5603foo2(nil, nil))
+ x[3] = int64(C.issue5603foo3(nil, nil, nil))
+ x[4] = int64(C.issue5603foo4(nil, nil, nil, nil))
+ for i, v := range x {
+ if v != exp {
+ t.Errorf("issue5603foo%d() returns %v, expected %v", i, v, exp)
+ }
+ }
+}
+
+// issue 5337
+
+func test5337(t *testing.T) {
+ C.test5337()
+}
+
+// issue 5740
+
+func test5740(t *testing.T) {
+ if v := C.test5740a() + C.test5740b(); v != 5 {
+ t.Errorf("expected 5, got %v", v)
+ }
+}
+
+// issue 5986
+
+func test5986(t *testing.T) {
+ C.output5986()
+}
+
+// issue 6128
+
+func test6128() {
+ // nothing to run, just make sure this compiles.
+ _ = C.X
+}
+
+// issue 6390
+
+func test6390(t *testing.T) {
+ p1 := C.malloc(1024)
+ if p1 == nil {
+ t.Fatalf("C.malloc(1024) returned nil")
+ }
+ p2 := C.malloc(0)
+ if p2 == nil {
+ t.Fatalf("C.malloc(0) returned nil")
+ }
+ C.free(p1)
+ C.free(p2)
+}
+
+func test6472() {
+ // nothing to run, just make sure this compiles
+ s := new(C.z)
+ println(s.y[0].x)
+}
+
+// issue 6506
+
+func test6506() {
+ // nothing to run, just make sure this compiles
+ var x C.size_t
+
+ C.calloc(x, x)
+ C.malloc(x)
+ C.realloc(nil, x)
+ C.memcpy(nil, nil, x)
+ C.memcmp(nil, nil, x)
+ C.memmove(nil, nil, x)
+ C.strncpy(nil, nil, x)
+ C.strncmp(nil, nil, x)
+ C.strncat(nil, nil, x)
+ x = C.strxfrm(nil, nil, x)
+ C.memchr(nil, 0, x)
+ x = C.strcspn(nil, nil)
+ x = C.strspn(nil, nil)
+ C.memset(nil, 0, x)
+ x = C.strlen(nil)
+ _ = x
+}
+
+// issue 6612
+
+func testNaming(t *testing.T) {
+ C.myfunc()
+ C.myfunc_def()
+ if v := C.myvar; v != 5 {
+ t.Errorf("C.myvar = %d, want 5", v)
+ }
+ if v := C.myvar_def; v != 5 {
+ t.Errorf("C.myvar_def = %d, want 5", v)
+ }
+ if s := C.GoString(C.mytext); s != "abcdef" {
+ t.Errorf("C.mytext = %q, want %q", s, "abcdef")
+ }
+ if s := C.GoString(C.mytext_def); s != "abcdef" {
+ t.Errorf("C.mytext_def = %q, want %q", s, "abcdef")
+ }
+ if c := C.myenum; c != 1234 {
+ t.Errorf("C.myenum = %v, want 1234", c)
+ }
+ if c := C.myenum_def; c != 1234 {
+ t.Errorf("C.myenum_def = %v, want 1234", c)
+ }
+ {
+ const c = C.myenum
+ if c != 1234 {
+ t.Errorf("C.myenum as const = %v, want 1234", c)
+ }
+ }
+ {
+ const c = C.myenum_def
+ if c != 1234 {
+ t.Errorf("C.myenum as const = %v, want 1234", c)
+ }
+ }
+ if c := C.myint_def; c != 12345 {
+ t.Errorf("C.myint_def = %v, want 12345", c)
+ }
+ {
+ const c = C.myint_def
+ if c != 12345 {
+ t.Errorf("C.myint as const = %v, want 12345", c)
+ }
+ }
+
+ if c := C.myfloat_def; c != 1.5 {
+ t.Errorf("C.myint_def = %v, want 1.5", c)
+ }
+ {
+ const c = C.myfloat_def
+ if c != 1.5 {
+ t.Errorf("C.myint as const = %v, want 1.5", c)
+ }
+ }
+
+ if s := C.mystring_def; s != "hello" {
+ t.Errorf("C.mystring_def = %q, want %q", s, "hello")
+ }
+}
+
+// issue 6907
+
+func test6907(t *testing.T) {
+ want := "yarn"
+ if got := C.GoString(C.Issue6907CopyString(want)); got != want {
+ t.Errorf("C.GoString(C.Issue6907CopyString(%q)) == %q, want %q", want, got, want)
+ }
+}
+
+// issue 7560
+
+func test7560(t *testing.T) {
+ // some mingw don't implement __packed__ correctly.
+ if C.offset7560() != 1 {
+ t.Skip("C compiler did not pack struct")
+ }
+
+ // C.misaligned should have x but then a padding field to get to the end of the struct.
+ // There should not be a field named 'y'.
+ var v C.misaligned
+ rt := reflect.TypeOf(&v).Elem()
+ if rt.NumField() != 2 || rt.Field(0).Name != "x" || rt.Field(1).Name != "_" {
+ t.Errorf("unexpected fields in C.misaligned:\n")
+ for i := 0; i < rt.NumField(); i++ {
+ t.Logf("%+v\n", rt.Field(i))
+ }
+ }
+}
+
+// issue 7786
+
+func f() {
+ var x1 *C.typedef_test7786
+ var x2 *C.struct_test7786
+ x1 = x2
+ x2 = x1
+ C.f7786(x1)
+ C.f7786(x2)
+ C.g7786(x1)
+ C.g7786(x2)
+
+ var b1 *C.typedef_body7786
+ var b2 *C.struct_body7786
+ b1 = b2
+ b2 = b1
+ C.b7786(b1)
+ C.b7786(b2)
+ C.c7786(b1)
+ C.c7786(b2)
+
+ var u1 *C.typedef_union7786
+ var u2 *C.union_union7786
+ u1 = u2
+ u2 = u1
+ C.u7786(u1)
+ C.u7786(u2)
+ C.v7786(u1)
+ C.v7786(u2)
+}
+
+// issue 8092
+
+func test8092(t *testing.T) {
+ tests := []struct {
+ s string
+ a, b *C.char
+ }{
+ {"text", &C.text[0], C.ctext()},
+ {"data", &C.data[0], C.cdata()},
+ }
+ for _, test := range tests {
+ if test.a != test.b {
+ t.Errorf("%s: pointer mismatch: %v != %v", test.s, test.a, test.b)
+ }
+ if got := C.GoString(test.a); got != test.s {
+ t.Errorf("%s: points at %#v, want %#v", test.s, got, test.s)
+ }
+ }
+}
+
+// issues 8368 and 8441
+
+func issue8368(one *C.struct_one, two *C.struct_two) {
+}
+
+func issue8441(one *C.one, two *C.two) {
+ issue8441(two.x, one.x)
+}
+
+// issue 8428
+
+var _ = C.struct_issue8428one{
+ b: C.char(0),
+ // The trailing rest field is not available in cgo.
+ // See issue 11925.
+ // rest: [0]C.char{},
+}
+
+var _ = C.struct_issue8428two{
+ p: unsafe.Pointer(nil),
+ b: C.char(0),
+ rest: [0]C.char{},
+}
+
+var _ = C.struct_issue8428three{
+ w: [1][2][3][0]C.char{},
+ x: [2][3][0][1]C.char{},
+ y: [3][0][1][2]C.char{},
+ z: [0][1][2][3]C.char{},
+}
+
+// issue 8811
+
+func test8811(t *testing.T) {
+ C.issue8811Execute()
+}
+
+// issue 9557
+
+func test9557(t *testing.T) {
+ // implicitly dereference a Go variable
+ foo := C.issue9557foo
+ if v := foo.a; v != 42 {
+ t.Fatalf("foo.a expected 42, but got %d", v)
+ }
+
+ // explicitly dereference a C variable
+ if v := (*C.issue9557foo).a; v != 42 {
+ t.Fatalf("(*C.issue9557foo).a expected 42, but is %d", v)
+ }
+
+ // implicitly dereference a C variable
+ if v := C.issue9557foo.a; v != 42 {
+ t.Fatalf("C.issue9557foo.a expected 42, but is %d", v)
+ }
+}
+
+// issue 8331 part 1
+
+func issue8331a() C.issue8331 {
+ return issue8331Var
+}
+
+// issue 10303
+
+func test10303(t *testing.T, n int) {
+ if runtime.Compiler == "gccgo" {
+ t.Skip("gccgo permits C pointers on the stack")
+ }
+
+ // Run at a few different stack depths just to avoid an unlucky pass
+ // due to variables ending up on different pages.
+ if n > 0 {
+ test10303(t, n-1)
+ }
+ if t.Failed() {
+ return
+ }
+ var x, y, z, v, si C.int
+ var s C.Struct
+ C.setintstar(&x)
+ C.setintptr(&y)
+ C.setvoidptr(unsafe.Pointer(&v))
+ s.P = &si
+ C.setstruct(s)
+
+ if uintptr(unsafe.Pointer(&x))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
+ t.Error("C int* argument on stack")
+ }
+ if uintptr(unsafe.Pointer(&y))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
+ t.Error("C intptr argument on stack")
+ }
+ if uintptr(unsafe.Pointer(&v))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
+ t.Error("C void* argument on stack")
+ }
+ if uintptr(unsafe.Pointer(&si))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
+ t.Error("C struct field pointer on stack")
+ }
+}
+
+// issue 11925
+
+func test11925(t *testing.T) {
+ if C.sizeof_struct_a11925 != unsafe.Sizeof(C.struct_a11925{}) {
+ t.Errorf("size of a changed: C %d, Go %d", C.sizeof_struct_a11925, unsafe.Sizeof(C.struct_a11925{}))
+ }
+ if C.sizeof_struct_b11925 != unsafe.Sizeof(C.struct_b11925{}) {
+ t.Errorf("size of b changed: C %d, Go %d", C.sizeof_struct_b11925, unsafe.Sizeof(C.struct_b11925{}))
+ }
+}
+
+// issue 12030
+
+func test12030(t *testing.T) {
+ buf := (*C.char)(C.malloc(256))
+ defer C.free(unsafe.Pointer(buf))
+ for _, f := range []float64{1.0, 2.0, 3.14} {
+ C.issue12030conv(buf, C.double(f))
+ got := C.GoString(buf)
+ if want := fmt.Sprintf("d=%g", f); got != want {
+ t.Fatalf("C.sprintf failed for %g: %q != %q", f, got, want)
+ }
+ }
+}
+
+// issue 13402
+
+var _ C.complexfloat
+var _ C.complexdouble
+
+// issue 13930
+// Test that cgo's multiple-value special form for
+// C function calls works in variable declaration statements.
+
+var _, _ = C.abs(0)
+
+// issue 14838
+
+func test14838(t *testing.T) {
+ data := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
+ cData := C.CBytes(data)
+ defer C.free(cData)
+
+ if C.check_cbytes((*C.char)(cData), C.size_t(len(data))) == 0 {
+ t.Fatalf("mismatched data: expected %v, got %v", data, (*(*[10]byte)(unsafe.Pointer(cData)))[:])
+ }
+}
+
+// issue 17065
+
+var sink C.int
+
+func test17065(t *testing.T) {
+ if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
+ t.Skip("broken on darwin; issue 17065")
+ }
+ for i := range C.ii {
+ sink = C.ii[i]
+ }
+}
+
+// issue 17537
+
+func test17537(t *testing.T) {
+ v := C.S17537{i: 17537}
+ if got, want := C.I17537(&v), C.int(17537); got != want {
+ t.Errorf("got %d, want %d", got, want)
+ }
+
+ p := (*C.char)(C.malloc(1))
+ *p = 17
+ if got, want := C.F17537(&p), C.int(17); got != want {
+ t.Errorf("got %d, want %d", got, want)
+ }
+
+ C.F18298(nil)
+ var v18298 C.T18298_2
+ C.G18298(C.T18298_1(v18298))
+}
+
+// issue 17723
+
+func testAPI() {
+ var cs *C.char
+ cs = C.CString("hello")
+ defer C.free(unsafe.Pointer(cs))
+ var s string
+ s = C.GoString((*C.char)(C.api_hello))
+ s = C.GoStringN((*C.char)(C.api_hello), C.int(6))
+ var b []byte
+ b = C.GoBytes(unsafe.Pointer(C.api_hello), C.int(6))
+ _, _ = s, b
+ C.cstring_pointer_fun(nil)
+}
+
+// issue 18126
+
+func test18126(t *testing.T) {
+ p := C.malloc(1)
+ _, err := C.Issue18126C(&p)
+ C.free(p)
+ _ = err
+}
+
+// issue 18720
+
+func test18720(t *testing.T) {
+ if got, want := C.HELLO_WORLD, "hello\000world"; got != want {
+ t.Errorf("C.HELLO_WORLD == %q, expected %q", got, want)
+ }
+
+ if got, want := C.VAR1, C.int(5); got != want {
+ t.Errorf("C.VAR1 == %v, expected %v", got, want)
+ }
+
+ if got, want := *C.ADDR, C.int(5); got != want {
+ t.Errorf("*C.ADDR == %v, expected %v", got, want)
+ }
+
+ if got, want := C.CALL, C.int(6); got != want {
+ t.Errorf("C.CALL == %v, expected %v", got, want)
+ }
+
+ if got, want := C.CALL, C.int(7); got != want {
+ t.Errorf("C.CALL == %v, expected %v", got, want)
+ }
+
+ // Issue 20125.
+ if got, want := C.SIZE_OF_FOO, 1; got != want {
+ t.Errorf("C.SIZE_OF_FOO == %v, expected %v", got, want)
+ }
+}
+
+// issue 20129
+
+func test20129(t *testing.T) {
+ if C.issue20129 != 0 {
+ t.Fatal("test is broken")
+ }
+ C.issue20129Foo()
+ if C.issue20129 != 1 {
+ t.Errorf("got %v but expected %v", C.issue20129, 1)
+ }
+ C.issue20129Bar()
+ if C.issue20129 != 2 {
+ t.Errorf("got %v but expected %v", C.issue20129, 2)
+ }
+}
+
+// issue 20369
+
+func test20369(t *testing.T) {
+ if C.XUINT64_MAX != math.MaxUint64 {
+ t.Fatalf("got %v, want %v", uint64(C.XUINT64_MAX), uint64(math.MaxUint64))
+ }
+}
+
+// issue 21668
+
+var issue21668_X = C.x21668
+
+// issue 21708
+
+func test21708(t *testing.T) {
+ if got, want := C.CAST_TO_INT64, -1; got != want {
+ t.Errorf("C.CAST_TO_INT64 == %v, expected %v", got, want)
+ }
+}
+
+// issue 21809
+
+func test21809(t *testing.T) {
+ longVar := C.long(3)
+ typedefVar := C.MySigned_t(4)
+ typedefTypedefVar := C.MySigned2_t(5)
+
+ // all three should be considered identical to `long`
+ if ret := C.takes_long(longVar); ret != 9 {
+ t.Errorf("got %v but expected %v", ret, 9)
+ }
+ if ret := C.takes_long(typedefVar); ret != 16 {
+ t.Errorf("got %v but expected %v", ret, 16)
+ }
+ if ret := C.takes_long(typedefTypedefVar); ret != 25 {
+ t.Errorf("got %v but expected %v", ret, 25)
+ }
+
+ // They should also be identical to the typedef'd type
+ if ret := C.takes_typedef(longVar); ret != 9 {
+ t.Errorf("got %v but expected %v", ret, 9)
+ }
+ if ret := C.takes_typedef(typedefVar); ret != 16 {
+ t.Errorf("got %v but expected %v", ret, 16)
+ }
+ if ret := C.takes_typedef(typedefTypedefVar); ret != 25 {
+ t.Errorf("got %v but expected %v", ret, 25)
+ }
+}
+
+// issue 22906
+
+func test22906(t *testing.T) {
+ var x1 C.jobject = 0 // Note: 0, not nil. That makes sure we use uintptr for these types.
+ _ = x1
+ var x2 C.jclass = 0
+ _ = x2
+ var x3 C.jthrowable = 0
+ _ = x3
+ var x4 C.jstring = 0
+ _ = x4
+ var x5 C.jarray = 0
+ _ = x5
+ var x6 C.jbooleanArray = 0
+ _ = x6
+ var x7 C.jbyteArray = 0
+ _ = x7
+ var x8 C.jcharArray = 0
+ _ = x8
+ var x9 C.jshortArray = 0
+ _ = x9
+ var x10 C.jintArray = 0
+ _ = x10
+ var x11 C.jlongArray = 0
+ _ = x11
+ var x12 C.jfloatArray = 0
+ _ = x12
+ var x13 C.jdoubleArray = 0
+ _ = x13
+ var x14 C.jobjectArray = 0
+ _ = x14
+ var x15 C.jweak = 0
+ _ = x15
+}
+
+// issue 22958
+// Nothing to run, just make sure this compiles.
+var Vissue22958 C.issue22958Type
+
+func test23356(t *testing.T) {
+ if got, want := C.a(), C.int(5); got != want {
+ t.Errorf("C.a() == %v, expected %v", got, want)
+ }
+ if got, want := C.r(), C.int(3); got != want {
+ t.Errorf("C.r() == %v, expected %v", got, want)
+ }
+}
+
+// issue 23720
+
+func Issue23720F() {
+ var x C.issue23720A
+ C.issue23720F(x)
+}
+
+// issue 24206
+
+func test24206(t *testing.T) {
+ if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
+ t.Skipf("skipping on %s/%s", runtime.GOOS, runtime.GOARCH)
+ }
+
+ if l := len(C.GoString(C.dangerousString1())); l != 123 {
+ t.Errorf("Incorrect string length - got %d, want 123", l)
+ }
+ if l := len(C.GoString(C.dangerousString2())); l != 4096+123 {
+ t.Errorf("Incorrect string length - got %d, want %d", l, 4096+123)
+ }
+}
+
+// issue 25143
+
+func issue25143sum(ns ...C.int) C.int {
+ total := C.int(0)
+ for _, n := range ns {
+ total += n
+ }
+ return total
+}
+
+func test25143(t *testing.T) {
+ if got, want := issue25143sum(1, 2, 3), C.int(6); got != want {
+ t.Errorf("issue25143sum(1, 2, 3) == %v, expected %v", got, want)
+ }
+}
+
+// issue 26066
+// Wrong type of constant with GCC 8 and newer.
+
+func test26066(t *testing.T) {
+ var i = int64(C.issue26066)
+ if i != -1 {
+ t.Errorf("got %d, want -1", i)
+ }
+}
+
+// issue 26517
+var a C.TypeOne
+var b C.TypeTwo
+
+// issue 27660
+// Stress the interaction between the race detector and cgo in an
+// attempt to reproduce the memory corruption described in #27660.
+// The bug was very timing sensitive; at the time of writing this
+// test would only trigger the bug about once out of every five runs.
+
+func test27660(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ ints := make([]int, 100)
+ locks := make([]sync.Mutex, 100)
+ // Slowly create threads so that ThreadSanitizer is forced to
+ // frequently resize its SyncClocks.
+ for i := 0; i < 100; i++ {
+ go func() {
+ for ctx.Err() == nil {
+ // Sleep in C for long enough that it is likely that the runtime
+ // will retake this goroutine's currently wired P.
+ C.usleep(1000 /* 1ms */)
+ runtime.Gosched() // avoid starvation (see #28701)
+ }
+ }()
+ go func() {
+ // Trigger lots of synchronization and memory reads/writes to
+ // increase the likelihood that the race described in #27660
+ // results in corruption of ThreadSanitizer's internal state
+ // and thus an assertion failure or segfault.
+ i := 0
+ for ctx.Err() == nil {
+ j := rand.Intn(100)
+ locks[j].Lock()
+ ints[j]++
+ locks[j].Unlock()
+ // needed for gccgo, to avoid creation of an
+ // unpreemptible "fast path" in this loop. Choice
+ // of (1<<24) is somewhat arbitrary.
+ if i%(1<<24) == 0 {
+ runtime.Gosched()
+ }
+ i++
+
+ }
+ }()
+ time.Sleep(time.Millisecond)
+ }
+}
+
+// issue 28540
+
+func twoargsF() {
+ v := []string{}
+ C.twoargs1(C.twoargs2(), C.twoargs3(unsafe.Pointer(&v)))
+}
+
+// issue 28545
+
+func issue28545G(p **C.char) {
+ C.issue28545F(p, -1, (0))
+ C.issue28545F(p, 2+3, complex(1, 1))
+ C.issue28545F(p, issue28772Constant, issue28772Constant2)
+}
+
+// issue 28772 part 1 - part 2 in testx.go
+
+const issue28772Constant = C.issue28772Constant
+
+// issue 28896
+
+func offset(i int) uintptr {
+ var pi C.innerPacked
+ var po C.outerPacked
+ var ui C.innerUnpacked
+ var uo C.outerUnpacked
+ switch i {
+ case 0:
+ return unsafe.Offsetof(pi.f2)
+ case 1:
+ return unsafe.Offsetof(po.g2)
+ case 2:
+ return unsafe.Offsetof(ui.f2)
+ case 3:
+ return unsafe.Offsetof(uo.g2)
+ default:
+ panic("can't happen")
+ }
+}
+
+func test28896(t *testing.T) {
+ for i := 0; i < 4; i++ {
+ c := uintptr(C.offset(C.int(i)))
+ g := offset(i)
+ if c != g {
+ t.Errorf("%d: C: %d != Go %d", i, c, g)
+ }
+ }
+}
+
+// issue 29383
+// cgo's /*line*/ comments failed when inserted after '/',
+// because the result looked like a "//" comment.
+// No runtime test; just make sure it compiles.
+
+func Issue29383(n, size uint) int {
+ if ^C.size_t(0)/C.size_t(n) < C.size_t(size) {
+ return 0
+ }
+ return 0
+}
+
+// issue 29748
+// Error handling a struct initializer that requires pointer checking.
+// Compilation test only, nothing to run.
+
+var Vissue29748 = C.f29748(&C.S29748{
+ nil,
+})
+
+func Fissue299748() {
+ C.f29748(&C.S29748{
+ nil,
+ })
+}
+
+// issue 29781
+
+var issue29781X struct{ X int }
+
+func issue29781F(...int) int { return 0 }
+
+func issue29781G() {
+ var p *C.char
+ C.issue29781F(&p, C.ISSUE29781C+1)
+ C.issue29781F(nil, (C.int)(
+ 0))
+ C.issue29781F(&p, (C.int)(0))
+ C.issue29781F(&p, (C.int)(
+ 0))
+ C.issue29781F(&p, (C.int)(issue29781X.
+ X))
+}
+
+// issue 30065
+
+func test30065(t *testing.T) {
+ var a [256]byte
+ b := []byte("a")
+ C.memcpy(unsafe.Pointer(&a), unsafe.Pointer(&b[0]), 1)
+ if a[0] != 'a' {
+ t.Errorf("&a failed: got %c, want %c", a[0], 'a')
+ }
+
+ b = []byte("b")
+ C.memcpy(unsafe.Pointer(&a[0]), unsafe.Pointer(&b[0]), 1)
+ if a[0] != 'b' {
+ t.Errorf("&a[0] failed: got %c, want %c", a[0], 'b')
+ }
+
+ d := make([]byte, 256)
+ b = []byte("c")
+ C.memcpy(unsafe.Pointer(&d[0]), unsafe.Pointer(&b[0]), 1)
+ if d[0] != 'c' {
+ t.Errorf("&d[0] failed: got %c, want %c", d[0], 'c')
+ }
+}
+
+// issue 31093
+// No runtime test; just make sure it compiles.
+
+func Issue31093() {
+ C.issue31093F(C.ushort(0))
+}
+
+// issue 32579
+
+func test32579(t *testing.T) {
+ var s [1]C.struct_S32579
+ C.memset(unsafe.Pointer(&s[0].data[0]), 1, 1)
+ if s[0].data[0] != 1 {
+ t.Errorf("&s[0].data[0] failed: got %d, want %d", s[0].data[0], 1)
+ }
+}
+
+// issue 37033, check if cgo.Handle works properly
+
+func testHandle(t *testing.T) {
+ ch := make(chan int)
+
+ for i := 0; i < 42; i++ {
+ h := cgo.NewHandle(ch)
+ go func() {
+ C.cFunc37033(C.uintptr_t(h))
+ }()
+ if v := <-ch; issue37033 != v {
+ t.Fatalf("unexpected receiving value: got %d, want %d", v, issue37033)
+ }
+ h.Delete()
+ }
+}
+
+// issue 38649
+
+var issue38649 C.netbsd_gid = 42
+
+// issue 39877
+
+var issue39877 *C.void = nil
+
+// issue 40494
+// No runtime test; just make sure it compiles.
+
+func Issue40494() {
+ C.issue40494(C.enum_Enum40494(C.X_40494), (*C.union_Union40494)(nil))
+}
+
+// Issue 45451.
+func test45451(t *testing.T) {
+ var u *C.issue45451
+ typ := reflect.ValueOf(u).Type().Elem()
+
+ // The type is undefined in C so allocating it should panic.
+ defer func() {
+ if r := recover(); r == nil {
+ t.Error("expected panic")
+ }
+ }()
+
+ _ = reflect.New(typ)
+ t.Errorf("reflect.New(%v) should have panicked", typ)
+}
+
+// issue 52542
+
+func func52542[T ~[]C.int]() {}
+
+type type52542[T ~*C.float] struct{}
diff --git a/misc/cgo/test/test26213.go b/misc/cgo/test/test26213.go
new file mode 100644
index 0000000..f8149cd
--- /dev/null
+++ b/misc/cgo/test/test26213.go
@@ -0,0 +1,15 @@
+// Copyright 2018 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.
+
+package cgotest
+
+import (
+ "testing"
+
+ "misc/cgo/test/issue26213"
+)
+
+func test26213(t *testing.T) {
+ issue26213.Test26213(t)
+}
diff --git a/misc/cgo/test/test_unix.go b/misc/cgo/test/test_unix.go
new file mode 100644
index 0000000..831b9ca
--- /dev/null
+++ b/misc/cgo/test/test_unix.go
@@ -0,0 +1,12 @@
+// Copyright 2019 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 !windows
+// +build !windows
+
+package cgotest
+
+import "syscall"
+
+var syscall_dot_SIGCHLD = syscall.SIGCHLD
diff --git a/misc/cgo/test/test_windows.go b/misc/cgo/test/test_windows.go
new file mode 100644
index 0000000..7bfb33a
--- /dev/null
+++ b/misc/cgo/test/test_windows.go
@@ -0,0 +1,9 @@
+// Copyright 2019 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.
+
+package cgotest
+
+import "syscall"
+
+var syscall_dot_SIGCHLD syscall.Signal
diff --git a/misc/cgo/test/testx.c b/misc/cgo/test/testx.c
new file mode 100644
index 0000000..1258e32
--- /dev/null
+++ b/misc/cgo/test/testx.c
@@ -0,0 +1,24 @@
+// Copyright 2021 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.
+
+#include "_cgo_export.h"
+
+void lockOSThreadC(void) {
+ lockOSThreadCallback();
+}
+
+void issue7978c(uint32_t *sync) {
+ while(__atomic_load_n(sync, __ATOMIC_SEQ_CST) != 0)
+ ;
+ __atomic_add_fetch(sync, 1, __ATOMIC_SEQ_CST);
+ while(__atomic_load_n(sync, __ATOMIC_SEQ_CST) != 2)
+ ;
+ issue7978cb();
+ __atomic_add_fetch(sync, 1, __ATOMIC_SEQ_CST);
+ while(__atomic_load_n(sync, __ATOMIC_SEQ_CST) != 6)
+ ;
+}
+
+void f7665(void) {
+}
diff --git a/misc/cgo/test/testx.go b/misc/cgo/test/testx.go
new file mode 100644
index 0000000..6a8e97d
--- /dev/null
+++ b/misc/cgo/test/testx.go
@@ -0,0 +1,583 @@
+// Copyright 2011 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.
+
+// Test cases for cgo.
+// Both the import "C" prologue and the main file are sorted by issue number.
+// This file contains //export directives on Go functions
+// and so it must NOT contain C definitions (only declarations).
+// See test.go for C definitions.
+
+package cgotest
+
+import (
+ "runtime"
+ "runtime/cgo"
+ "runtime/debug"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "testing"
+ "unsafe"
+)
+
+/*
+// threads
+extern void doAdd(int, int);
+
+// issue 1328
+void IntoC(void);
+
+// issue 1560
+extern void Issue1560InC(void);
+
+// twoSleep returns the absolute start time of the first sleep
+// in ms.
+long long twoSleep(int);
+
+// issue 3775
+void lockOSThreadC(void);
+int usleep(unsigned usec);
+
+// issue 4054 part 2 - part 1 in test.go
+typedef enum {
+ A = 0,
+ B,
+ C,
+ D,
+ E,
+ F,
+ G,
+ H,
+ II,
+ J,
+} issue4054b;
+
+// issue 5548
+
+extern int issue5548_in_c(void);
+
+// issue 6833
+
+extern unsigned long long issue6833Func(unsigned int, unsigned long long);
+
+// issue 6907
+
+extern int CheckIssue6907C(_GoString_);
+
+// issue 7665
+
+extern void f7665(void);
+
+// issue 7978
+// Stack tracing didn't work during cgo code after calling a Go
+// callback. Make sure GC works and the stack trace is correct.
+
+#include <stdint.h>
+
+// use ugly atomic variable sync since that doesn't require calling back into
+// Go code or OS dependencies
+void issue7978c(uint32_t *sync);
+
+// issue 8331 part 2 - part 1 in test.go
+// A typedef of an unnamed struct is the same struct when
+// #include'd twice. No runtime test; just make sure it compiles.
+#include "issue8331.h"
+
+// issue 8945
+
+typedef void (*PFunc8945)();
+extern PFunc8945 func8945; // definition is in test.go
+
+// issue 20910
+void callMulti(void);
+
+// issue 28772 part 2 - part 1 in issuex.go
+#define issue28772Constant2 2
+
+
+// issue 31891
+typedef struct {
+ long obj;
+} Issue31891A;
+
+typedef struct {
+ long obj;
+} Issue31891B;
+
+void callIssue31891(void);
+
+typedef struct {
+ int i;
+} Issue38408, *PIssue38408;
+
+extern void cfunc49633(void*); // definition is in test.go
+*/
+import "C"
+
+// exports
+
+//export ReturnIntLong
+func ReturnIntLong() (int, C.long) {
+ return 1, 2
+}
+
+//export gc
+func gc() {
+ runtime.GC()
+}
+
+// threads
+
+var sum struct {
+ sync.Mutex
+ i int
+}
+
+//export Add
+func Add(x int) {
+ defer func() {
+ recover()
+ }()
+ sum.Lock()
+ sum.i += x
+ sum.Unlock()
+ var p *int
+ *p = 2
+}
+
+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")
+ }
+ sum.i = 0
+ C.doAdd(10, 6)
+
+ want := 10 * (10 - 1) / 2 * 6
+ if sum.i != want {
+ t.Fatalf("sum=%d, want %d", sum.i, want)
+ }
+}
+
+// issue 1328
+
+//export BackIntoGo
+func BackIntoGo() {
+ x := 1
+
+ for i := 0; i < 10000; i++ {
+ xvariadic(x)
+ if x != 1 {
+ panic("x is not 1?")
+ }
+ }
+}
+
+func xvariadic(x ...interface{}) {
+}
+
+func test1328(t *testing.T) {
+ C.IntoC()
+}
+
+// issue 1560
+// Test that C functions and Go functions run in parallel.
+
+var (
+ issue1560 int32
+
+ issue1560Ch = make(chan bool, 2)
+)
+
+//export Issue1560FromC
+func Issue1560FromC() {
+ for atomic.LoadInt32(&issue1560) != 1 {
+ runtime.Gosched()
+ }
+ atomic.AddInt32(&issue1560, 1)
+ for atomic.LoadInt32(&issue1560) != 3 {
+ runtime.Gosched()
+ }
+ issue1560Ch <- true
+}
+
+func Issue1560FromGo() {
+ atomic.AddInt32(&issue1560, 1)
+ for atomic.LoadInt32(&issue1560) != 2 {
+ runtime.Gosched()
+ }
+ atomic.AddInt32(&issue1560, 1)
+ issue1560Ch <- true
+}
+
+func test1560(t *testing.T) {
+ go Issue1560FromGo()
+ go C.Issue1560InC()
+ <-issue1560Ch
+ <-issue1560Ch
+}
+
+// issue 2462
+
+//export exportbyte
+func exportbyte() byte {
+ return 0
+}
+
+//export exportbool
+func exportbool() bool {
+ return false
+}
+
+//export exportrune
+func exportrune() rune {
+ return 0
+}
+
+//export exporterror
+func exporterror() error {
+ return nil
+}
+
+//export exportint
+func exportint() int {
+ return 0
+}
+
+//export exportuint
+func exportuint() uint {
+ return 0
+}
+
+//export exportuintptr
+func exportuintptr() uintptr {
+ return (uintptr)(0)
+}
+
+//export exportint8
+func exportint8() int8 {
+ return 0
+}
+
+//export exportuint8
+func exportuint8() uint8 {
+ return 0
+}
+
+//export exportint16
+func exportint16() int16 {
+ return 0
+}
+
+//export exportuint16
+func exportuint16() uint16 {
+ return 0
+}
+
+//export exportint32
+func exportint32() int32 {
+ return 0
+}
+
+//export exportuint32
+func exportuint32() uint32 {
+ return 0
+}
+
+//export exportint64
+func exportint64() int64 {
+ return 0
+}
+
+//export exportuint64
+func exportuint64() uint64 {
+ return 0
+}
+
+//export exportfloat32
+func exportfloat32() float32 {
+ return 0
+}
+
+//export exportfloat64
+func exportfloat64() float64 {
+ return 0
+}
+
+//export exportcomplex64
+func exportcomplex64() complex64 {
+ return 0
+}
+
+//export exportcomplex128
+func exportcomplex128() complex128 {
+ return 0
+}
+
+// issue 3741
+
+//export exportSliceIn
+func exportSliceIn(s []byte) bool {
+ return len(s) == cap(s)
+}
+
+//export exportSliceOut
+func exportSliceOut() []byte {
+ return []byte{1}
+}
+
+//export exportSliceInOut
+func exportSliceInOut(s []byte) []byte {
+ return s
+}
+
+// issue 3775
+
+func init() {
+ if runtime.GOOS == "android" {
+ return
+ }
+ // Same as test3775 but run during init so that
+ // there are two levels of internal runtime lock
+ // (1 for init, 1 for cgo).
+ // This would have been broken by CL 11663043.
+ C.lockOSThreadC()
+}
+
+func test3775(t *testing.T) {
+ if runtime.GOOS == "android" {
+ return
+ }
+ // Used to panic because of the UnlockOSThread below.
+ C.lockOSThreadC()
+}
+
+//export lockOSThreadCallback
+func lockOSThreadCallback() {
+ runtime.LockOSThread()
+ runtime.UnlockOSThread()
+ go C.usleep(10000)
+ runtime.Gosched()
+}
+
+// issue 4054 part 2 - part 1 in test.go
+
+var issue4054b = []int{C.A, C.B, C.C, C.D, C.E, C.F, C.G, C.H, C.II, C.J}
+
+//export issue5548FromC
+func issue5548FromC(s string, i int) int {
+ if len(s) == 4 && s == "test" && i == 42 {
+ return 12345
+ }
+ println("got", len(s), i)
+ return 9876
+}
+
+func test5548(t *testing.T) {
+ if x := C.issue5548_in_c(); x != 12345 {
+ t.Errorf("issue5548_in_c = %d, want %d", x, 12345)
+ }
+}
+
+// issue 6833
+
+//export GoIssue6833Func
+func GoIssue6833Func(aui uint, aui64 uint64) uint64 {
+ return aui64 + uint64(aui)
+}
+
+func test6833(t *testing.T) {
+ ui := 7
+ ull := uint64(0x4000300020001000)
+ v := uint64(C.issue6833Func(C.uint(ui), C.ulonglong(ull)))
+ exp := uint64(ui) + ull
+ if v != exp {
+ t.Errorf("issue6833Func() returns %x, expected %x", v, exp)
+ }
+}
+
+// issue 6907
+
+const CString = "C string"
+
+//export CheckIssue6907Go
+func CheckIssue6907Go(s string) C.int {
+ if s == CString {
+ return 1
+ }
+ return 0
+}
+
+func test6907Go(t *testing.T) {
+ if got := C.CheckIssue6907C(CString); got != 1 {
+ t.Errorf("C.CheckIssue6907C() == %d, want %d", got, 1)
+ }
+}
+
+// issue 7665
+
+var bad7665 unsafe.Pointer = C.f7665
+var good7665 uintptr = uintptr(C.f7665)
+
+func test7665(t *testing.T) {
+ if bad7665 == nil || uintptr(bad7665) != good7665 {
+ t.Errorf("ptrs = %p, %#x, want same non-nil pointer", bad7665, good7665)
+ }
+}
+
+// issue 7978
+
+var issue7978sync uint32
+
+func issue7978check(t *testing.T, wantFunc string, badFunc string, depth int) {
+ runtime.GC()
+ buf := make([]byte, 65536)
+ trace := string(buf[:runtime.Stack(buf, true)])
+ for _, goroutine := range strings.Split(trace, "\n\n") {
+ if strings.Contains(goroutine, "test.issue7978go") {
+ trace := strings.Split(goroutine, "\n")
+ // look for the expected function in the stack
+ for i := 0; i < depth; i++ {
+ if badFunc != "" && strings.Contains(trace[1+2*i], badFunc) {
+ t.Errorf("bad stack: found %s in the stack:\n%s", badFunc, goroutine)
+ return
+ }
+ if strings.Contains(trace[1+2*i], wantFunc) {
+ return
+ }
+ }
+ t.Errorf("bad stack: didn't find %s in the stack:\n%s", wantFunc, goroutine)
+ return
+ }
+ }
+ t.Errorf("bad stack: goroutine not found. Full stack dump:\n%s", trace)
+}
+
+func issue7978wait(store uint32, wait uint32) {
+ if store != 0 {
+ atomic.StoreUint32(&issue7978sync, store)
+ }
+ for atomic.LoadUint32(&issue7978sync) != wait {
+ runtime.Gosched()
+ }
+}
+
+//export issue7978cb
+func issue7978cb() {
+ // Force a stack growth from the callback to put extra
+ // pressure on the runtime. See issue #17785.
+ growStack(64)
+ issue7978wait(3, 4)
+}
+
+func growStack(n int) int {
+ var buf [128]int
+ if n == 0 {
+ return 0
+ }
+ return buf[growStack(n-1)]
+}
+
+func issue7978go() {
+ C.issue7978c((*C.uint32_t)(&issue7978sync))
+ issue7978wait(7, 8)
+}
+
+func test7978(t *testing.T) {
+ if runtime.Compiler == "gccgo" {
+ t.Skip("gccgo can not do stack traces of C code")
+ }
+ debug.SetTraceback("2")
+ issue7978sync = 0
+ go issue7978go()
+ // test in c code, before callback
+ issue7978wait(0, 1)
+ issue7978check(t, "_Cfunc_issue7978c(", "", 1)
+ // test in go code, during callback
+ issue7978wait(2, 3)
+ issue7978check(t, "test.issue7978cb(", "test.issue7978go", 3)
+ // test in c code, after callback
+ issue7978wait(4, 5)
+ issue7978check(t, "_Cfunc_issue7978c(", "_cgoexpwrap", 1)
+ // test in go code, after return from cgo
+ issue7978wait(6, 7)
+ issue7978check(t, "test.issue7978go(", "", 3)
+ atomic.StoreUint32(&issue7978sync, 8)
+}
+
+// issue 8331 part 2
+
+var issue8331Var C.issue8331
+
+// issue 8945
+
+//export Test8945
+func Test8945() {
+ _ = C.func8945
+}
+
+// issue 20910
+
+//export multi
+func multi() (*C.char, C.int) {
+ return C.CString("multi"), 0
+}
+
+func test20910(t *testing.T) {
+ C.callMulti()
+}
+
+// issue 28772 part 2
+
+const issue28772Constant2 = C.issue28772Constant2
+
+// issue 31891
+
+//export useIssue31891A
+func useIssue31891A(c *C.Issue31891A) {}
+
+//export useIssue31891B
+func useIssue31891B(c *C.Issue31891B) {}
+
+func test31891(t *testing.T) {
+ C.callIssue31891()
+}
+
+// issue 37033, check if cgo.Handle works properly
+
+var issue37033 = 42
+
+//export GoFunc37033
+func GoFunc37033(handle C.uintptr_t) {
+ h := cgo.Handle(handle)
+ ch := h.Value().(chan int)
+ ch <- issue37033
+}
+
+// issue 38408
+// A typedef pointer can be used as the element type.
+// No runtime test; just make sure it compiles.
+var _ C.PIssue38408 = &C.Issue38408{i: 1}
+
+// issue 49633, example use of cgo.Handle with void*
+
+type data49633 struct {
+ msg string
+}
+
+//export GoFunc49633
+func GoFunc49633(context unsafe.Pointer) {
+ h := *(*cgo.Handle)(context)
+ v := h.Value().(*data49633)
+ v.msg = "hello"
+}
+
+func test49633(t *testing.T) {
+ v := &data49633{}
+ h := cgo.NewHandle(v)
+ defer h.Delete()
+ C.cfunc49633(unsafe.Pointer(&h))
+ if v.msg != "hello" {
+ t.Errorf("msg = %q, want 'hello'", v.msg)
+ }
+}
diff --git a/misc/cgo/test/typeparam.go b/misc/cgo/test/typeparam.go
new file mode 100644
index 0000000..5f766c2
--- /dev/null
+++ b/misc/cgo/test/typeparam.go
@@ -0,0 +1,17 @@
+// Copyright 2021 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.
+
+package cgotest
+
+// #include <stddef.h>
+import "C"
+
+func generic[T, U any](t T, u U) {}
+
+func useGeneric() {
+ const zero C.size_t = 0
+
+ generic(zero, zero)
+ generic[C.size_t, C.size_t](0, 0)
+}