aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-09-24 11:43:19 -0700
committerRuss Cox <rsc@golang.org>2009-09-24 11:43:19 -0700
commit12fc21733625e119dc4e9a3228d5bc0ab56d1988 (patch)
tree73c8825a090387162f85a1fdd2d26f4882a8a5ea /src/pkg
parentffe83e582ea3a01450d23c17eefa036b52bc7788 (diff)
downloadgo-12fc21733625e119dc4e9a3228d5bc0ab56d1988.tar.xz
cgo checkpoint.
can write all 3 output files and then compile them by hand. R=r DELTA=919 (841 added, 16 deleted, 62 changed) OCL=34954 CL=34973
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/runtime/cgocall.c23
-rw-r--r--src/pkg/runtime/cgocall.h5
2 files changed, 27 insertions, 1 deletions
diff --git a/src/pkg/runtime/cgocall.c b/src/pkg/runtime/cgocall.c
index 3c9819b09d..9022267a1f 100644
--- a/src/pkg/runtime/cgocall.c
+++ b/src/pkg/runtime/cgocall.c
@@ -47,3 +47,26 @@ runtime·Cgocalls(int64 ret)
FLUSH(&ret);
}
+void (*_cgo_malloc)(void*);
+void (*_cgo_free)(void*);
+
+void*
+cmalloc(uintptr n)
+{
+ struct a {
+ uint64 n;
+ void *ret;
+ } a;
+
+ a.n = n;
+ a.ret = nil;
+ cgocall(_cgo_malloc, &a);
+ return a.ret;
+}
+
+void
+cfree(void *p)
+{
+ cgocall(_cgo_free, p);
+}
+
diff --git a/src/pkg/runtime/cgocall.h b/src/pkg/runtime/cgocall.h
index bf3cf77278..5352a2f92e 100644
--- a/src/pkg/runtime/cgocall.h
+++ b/src/pkg/runtime/cgocall.h
@@ -5,7 +5,8 @@
/*
* Cgo interface.
* Dynamically linked shared libraries compiled with gcc
- * know these data structures too. See ../../libcgo/cgocall.c
+ * know these data structures and functions too.
+ * See ../../libcgo/cgocall.c
*/
typedef struct CgoWork CgoWork;
@@ -37,3 +38,5 @@ struct CgoWork
void cgocall(void (*fn)(void*), void*);
+void *cmalloc(uintptr);
+void cfree(void*);