summaryrefslogtreecommitdiff
path: root/src/libcgo/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcgo/util.c')
-rw-r--r--src/libcgo/util.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libcgo/util.c b/src/libcgo/util.c
new file mode 100644
index 000000000..a814e018b
--- /dev/null
+++ b/src/libcgo/util.c
@@ -0,0 +1,35 @@
+// Copyright 2009 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 "libcgo.h"
+
+/* Stub for calling malloc from the other world */
+void
+_cgo_malloc(void *p)
+{
+ struct a {
+ long long n;
+ void *ret;
+ } *a = p;
+
+ a->ret = malloc(a->n);
+}
+
+/* Stub for creating a new thread */
+void
+libcgo_thread_start(ThreadStart *arg)
+{
+ ThreadStart *ts;
+
+ /* Make our own copy that can persist after we return. */
+ ts = malloc(sizeof *ts);
+ if(ts == nil) {
+ fprintf(stderr, "libcgo: out of memory in thread_start\n");
+ abort();
+ }
+ *ts = *arg;
+
+ libcgo_sys_thread_start(ts); /* OS-dependent half */
+}
+