summaryrefslogtreecommitdiff
path: root/Lib/go/goruntime.swg
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/go/goruntime.swg')
-rw-r--r--Lib/go/goruntime.swg150
1 files changed, 40 insertions, 110 deletions
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index 057f81d01..6aeeab730 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -30,57 +30,32 @@ swiggo_size_assert(swiggo_long_long, 8)
swiggo_size_assert(float, 4)
swiggo_size_assert(double, 8)
-extern
#ifdef __cplusplus
-"C"
+extern "C" {
#endif
-void crosscall2(void (*fn)(void *, int), void *, int);
-
-extern
+extern void crosscall2(void (*fn)(void *, int), void *, int);
+extern void _cgo_allocate(void *, int);
+extern void _cgo_panic(void *, int);
#ifdef __cplusplus
-"C"
+}
#endif
-void _swig_gc_allocate(void *, int);
-static void *_swig_allocate(int len) {
+
+static void *_swig_goallocate(size_t len) {
struct {
- int len;
+ size_t len;
void *ret;
} a;
a.len = len;
- crosscall2(_swig_gc_allocate, &a, (int) sizeof a);
+ crosscall2(_cgo_allocate, &a, (int) sizeof a);
return a.ret;
}
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_makegostring(void *, int);
-static _gostring_ _swig_makegostring(const char *p, size_t l) {
- struct {
- const char *p;
- int l;
- _gostring_ ret;
- } a;
- a.p = p;
- a.l = l;
- crosscall2(_swig_gc_makegostring, &a, (int) sizeof a);
- return a.ret;
-}
-
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_gopanic(void *, int);
static void _swig_gopanic(const char *p) {
struct {
const char *p;
- int l;
} a;
a.p = p;
- a.l = strlen(p);
- crosscall2(_swig_gc_gopanic, &a, (int) sizeof a);
+ crosscall2(_cgo_panic, &a, (int) sizeof a);
}
%}
@@ -91,10 +66,6 @@ static void _swig_gopanic(const char *p) {
#include "runtime.h"
#include "cgocall.h"
-#pragma dynimport initcgo initcgo "libcgo.so"
-#pragma dynimport libcgo_thread_start libcgo_thread_start "libcgo.so"
-#pragma dynimport libcgo_set_scheduler libcgo_set_scheduler "libcgo.so"
-
#ifdef _64BIT
#define SWIG_PARM_SIZE 8
#else
@@ -102,97 +73,56 @@ static void _swig_gopanic(const char *p) {
#endif
%}
-/* 6g/8g C boilerplate that is only needed once in a program. This
- only gets added to the file if nothing is imported. */
-%insert(gc_once) %{
-
-extern void ·_swig_internal_allocate(void);
-#pragma dynexport _swig_gc_allocate _swig_gc_allocate
-void _swig_gc_allocate(void *a, int32 n) {
- cgocallback(·_swig_internal_allocate, a, n);
-}
-
-void ·_swig_allocatememory(int32 len, byte *ret) {
- ret = mal(len);
- FLUSH(&ret);
-}
-
-extern void ·_swig_internal_makegostring(void);
-#pragma dynexport _swig_gc_makegostring _swig_gc_makegostring
-void _swig_gc_makegostring(void *a, int32 n) {
- cgocallback(·_swig_internal_makegostring, a, n);
-}
-
-void ·_swig_allocatestring(byte *p, int32 l, String ret) {
- ret.str = mal(l+1);
- mcpy(ret.str, p, l);
- ret.len = l;
- FLUSH(&ret);
-}
-
-extern void ·_swig_internal_gopanic(void);
-#pragma dynexport _swig_gc_gopanic _swig_gc_gopanic
-void _swig_gc_gopanic(void *a, int32 n) {
- cgocallback(·_swig_internal_gopanic, a, n);
-}
-
-%}
-
-/* Go code that is only needed once in a program. This is only added
- to the file if nothing is imported. */
-%insert(go_once) %{
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-%}
-
#else
/* Boilerplate for C/C++ code when using gccgo. */
%insert(runtime) %{
#define SWIGGO_GCCGO
-extern
#ifdef __cplusplus
-"C"
+extern "C" {
#endif
-void *__go_alloc (size_t);
-
-static void *_swig_allocate(int len) {
- return __go_alloc(len);
+extern void *_cgo_allocate(size_t);
+extern void _cgo_panic(const char *);
+#ifdef __cplusplus
}
+#endif
+
+#define _swig_goallocate _cgo_allocate
+#define _swig_gopanic _cgo_panic
+
+%}
+
+#endif
+
+%insert(runtime) %{
static _gostring_ _swig_makegostring(const char *p, size_t l) {
_gostring_ ret;
- ret.p = (char*)__go_alloc(l);
+ ret.p = (char*)_swig_goallocate(l + 1);
memcpy(ret.p, p, l);
ret.n = l;
return ret;
}
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void __go_panic_msg(const char *);
-#define _swig_gopanic __go_panic_msg
+#define SWIG_contract_assert(expr, msg) \
+ if (!(expr)) { _swig_gopanic(msg); } else
+%}
+
+#ifndef SWIGGO_GCCGO
+
+%insert(go_header) %{
+
+import _ "runtime/cgo"
%}
#endif
-%insert(runtime) %{
-#define SWIG_contract_assert(expr, msg) \
- if (!(expr)) { _swig_gopanic(msg); } else
-%}
+/* Function pointers are translated by the code in go.cxx into
+ _swig_fnptr. Member pointers are translated to _swig_memberptr. */
+%insert(go_header) %{
+type _swig_fnptr *byte
+type _swig_memberptr *byte
+%}