From 43a123c1ae6613b3efeed291fa552ecd909d3acf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 16 Apr 2024 21:23:18 +0200 Subject: Adding upstream version 1.20.14. Signed-off-by: Daniel Baumann --- misc/cgo/test/callback_c_gc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 misc/cgo/test/callback_c_gc.c (limited to 'misc/cgo/test/callback_c_gc.c') diff --git a/misc/cgo/test/callback_c_gc.c b/misc/cgo/test/callback_c_gc.c new file mode 100644 index 0000000..eb720eb --- /dev/null +++ b/misc/cgo/test/callback_c_gc.c @@ -0,0 +1,25 @@ +// Copyright 2013 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. + +// +build gc + +#include "_cgo_export.h" +#include +#include +#include + +/* Test calling panic from C. This is what SWIG does. */ + +extern void crosscall2(void (*fn)(void *, int), void *, int); +extern void _cgo_panic(void *, int); +extern void _cgo_allocate(void *, int); + +void +callPanic(void) +{ + struct { const char *p; } a; + a.p = "panic from C"; + crosscall2(_cgo_panic, &a, sizeof a); + *(int*)1 = 1; +} -- cgit v1.2.3