diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-15 17:56:01 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-15 17:56:01 -0700 |
commit | 6ca5d5d722b07977cd2865337d4a9e6cf6d75d5f (patch) | |
tree | 4b19e181f958ece091fc4c2c2199fe02d96a8ddf /Lib/go | |
parent | 4461c443cf86493851b25c5052dc01800371cef6 (diff) | |
download | swig-6ca5d5d722b07977cd2865337d4a9e6cf6d75d5f.tar.gz |
swig -go: don't use crosscall2 for panicking
Instead rely only on documented and exported interfaces.
Diffstat (limited to 'Lib/go')
-rw-r--r-- | Lib/go/goruntime.swg | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg index 667cc35ca..c3401b1a8 100644 --- a/Lib/go/goruntime.swg +++ b/Lib/go/goruntime.swg @@ -88,52 +88,7 @@ typedef struct { void* array; intgo len; intgo cap; } _goslice_; %} -#ifndef SWIGGO_GCCGO -/* Boilerplate for C/C++ code when using 6g/8g. This code is compiled - with gcc. */ -%insert(runtime) %{ - -#define swiggo_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1]; -#define swiggo_size_assert(t, n) swiggo_size_assert_eq(sizeof(t), n, swiggo_sizeof_##t##_is_not_##n) - -swiggo_size_assert(char, 1) -swiggo_size_assert(short, 2) -swiggo_size_assert(int, 4) -typedef long long swiggo_long_long; -swiggo_size_assert(swiggo_long_long, 8) -swiggo_size_assert(float, 4) -swiggo_size_assert(double, 8) - -#ifdef __cplusplus -extern "C" { -#endif -extern void crosscall2(void (*fn)(void *, int), void *, int); -extern char* _cgo_topofstack(void) __attribute__ ((weak)); -extern void _cgo_allocate(void *, int); -extern void _cgo_panic(void *, int); -#ifdef __cplusplus -} -#endif - -static char *_swig_topofstack() { - if (_cgo_topofstack) { - return _cgo_topofstack(); - } else { - return 0; - } -} - -static void _swig_gopanic(const char *p) { - struct { - const char *p; - } SWIGSTRUCTPACKED a; - a.p = p; - crosscall2(_cgo_panic, &a, (int) sizeof a); -} - -%} - -#else +#ifdef SWIGGO_GCCGO /* Boilerplate for C/C++ code when using gccgo. */ %insert(runtime) %{ @@ -154,12 +109,6 @@ extern void _cgo_panic(const char *); #endif -%insert(runtime) %{ - -#define SWIG_contract_assert(expr, msg) \ - if (!(expr)) { _swig_gopanic(msg); } else -%} - #ifndef SWIGGO_GCCGO %go_import("unsafe", _ "runtime/cgo") |