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 callback(void * f)10callback(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 callGoFoo(void)21callGoFoo(void) 22 { 23 extern void goFoo(void); 24 goFoo(); 25 } 26 27 void IntoC(void)28IntoC(void) 29 { 30 BackIntoGo(); 31 } 32 33 void Issue1560InC(void)34Issue1560InC(void) 35 { 36 Issue1560FromC(); 37 } 38 39 void callGoStackCheck(void)40callGoStackCheck(void) 41 { 42 extern void goStackCheck(void); 43 goStackCheck(); 44 } 45 46 int returnAfterGrow(void)47returnAfterGrow(void) 48 { 49 extern int goReturnVal(void); 50 goReturnVal(); 51 return 123456; 52 } 53 54 int returnAfterGrowFromGo(void)55returnAfterGrowFromGo(void) 56 { 57 extern int goReturnVal(void); 58 return goReturnVal(); 59 } 60 61 void callGoWithString(void)62callGoWithString(void) 63 { 64 extern void goWithString(GoString); 65 const char *str = "string passed from C to Go"; 66 goWithString((GoString){str, strlen(str)}); 67 } 68