github.com/bir3/gocompiler@v0.9.2202/src/cmd/cgo/internal/test/callback_c.c (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include <string.h> 6 7 #include "_cgo_export.h" 8 9 void 10 callback(void *f) 11 { 12 // use some stack space 13 volatile char data[64*1024]; 14 15 data[0] = 0; 16 goCallback(f); 17 data[sizeof(data)-1] = 0; 18 } 19 20 void 21 callGoFoo(void) 22 { 23 extern void goFoo(void); 24 goFoo(); 25 } 26 27 void 28 IntoC(void) 29 { 30 BackIntoGo(); 31 } 32 33 void 34 Issue1560InC(void) 35 { 36 Issue1560FromC(); 37 } 38 39 void 40 callGoStackCheck(void) 41 { 42 extern void goStackCheck(void); 43 goStackCheck(); 44 } 45 46 int 47 returnAfterGrow(void) 48 { 49 extern int goReturnVal(void); 50 goReturnVal(); 51 return 123456; 52 } 53 54 int 55 returnAfterGrowFromGo(void) 56 { 57 extern int goReturnVal(void); 58 return goReturnVal(); 59 } 60 61 void 62 callGoWithString(void) 63 { 64 extern void goWithString(GoString); 65 const char *str = "string passed from C to Go"; 66 goWithString((GoString){str, strlen(str)}); 67 }