aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-09-04 14:40:40 -0400
committerRuss Cox <rsc@golang.org>2014-09-04 14:40:40 -0400
commitc08d8834ddf8d69daba989a4ee0b5e144fce973d (patch)
treec30ab5fd1536d35187b1868f55bee07a2eebd6bf /src/pkg/runtime/proc.c
parent503bcd464e8974b3295177c1a0ed5a4ba5bc5a01 (diff)
downloadgo-c08d8834ddf8d69daba989a4ee0b5e144fce973d.tar.xz
runtime: convert cgocall to Go
LGTM=khr, rsc R=golang-codereviews, khr, rsc CC=golang-codereviews https://golang.org/cl/131670043
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index d75c210c5a..45ae1bc2a8 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -132,6 +132,21 @@ static void dropg(void);
extern String runtime·buildVersion;
+// For cgo-using programs with external linking,
+// export "main" (defined in assembly) so that libc can handle basic
+// C runtime startup and call the Go program as if it were
+// the C main function.
+#pragma cgo_export_static main
+
+// Filled in by dynamic linker when Cgo is available.
+void* _cgo_init;
+void* _cgo_malloc;
+void* _cgo_free;
+
+// Copy for Go code.
+void* runtime·cgoMalloc;
+void* runtime·cgoFree;
+
// The bootstrap sequence is:
//
// call osinit
@@ -192,6 +207,9 @@ runtime·schedinit(void)
runtime·buildVersion.str = (uint8*)"unknown";
runtime·buildVersion.len = 7;
}
+
+ runtime·cgoMalloc = _cgo_malloc;
+ runtime·cgoFree = _cgo_free;
}
extern void main·init(void);