1
0
mirror of https://github.com/golang/go synced 2024-11-14 08:30:25 -07:00

cgo: In _cgo_main.c define all provided symbols as functions.

This defines crosscall2 in a way that matches that real
definition, and also defines _cgo_allocate and _cgo_panic to
indicate that they are available to be called by code compiled
with gcc.

R=rsc
CC=golang-dev
https://golang.org/cl/4026041
This commit is contained in:
Ian Lance Taylor 2011-01-14 10:52:08 -08:00
parent b97005c1d3
commit 5adfe93752

View File

@ -34,7 +34,9 @@ func (p *Package) writeDefs() {
// Write C main file for using gcc to resolve imports. // Write C main file for using gcc to resolve imports.
fmt.Fprintf(fm, "int main() { return 0; }\n") fmt.Fprintf(fm, "int main() { return 0; }\n")
fmt.Fprintf(fm, "int crosscall2;\n\n") fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*, int), void *a, int c) { }\n")
fmt.Fprintf(fm, "void _cgo_allocate(void *a, int c) { }\n")
fmt.Fprintf(fm, "void _cgo_panic(void *a, int c) { }\n")
// Write second Go output: definitions of _C_xxx. // Write second Go output: definitions of _C_xxx.
// In a separate file so that the import of "unsafe" does not // In a separate file so that the import of "unsafe" does not