From: Ian Lance Taylor Date: Fri, 11 Oct 2013 18:24:54 +0000 (-0700) Subject: misc/cgo/test: fix C panic test to work with gccgo X-Git-Tag: go1.2rc2~32 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cd61565ffc003506c9544eb670eed195825bf4da;p=gostls13.git misc/cgo/test: fix C panic test to work with gccgo R=golang-dev, minux.ma CC=golang-dev https://golang.org/cl/14611043 --- diff --git a/misc/cgo/test/callback_c.c b/misc/cgo/test/callback_c.c index 4bfeb7163e..dcd4ddd4ee 100644 --- a/misc/cgo/test/callback_c.c +++ b/misc/cgo/test/callback_c.c @@ -64,17 +64,3 @@ callGoStackCheck(void) extern void goStackCheck(void); goStackCheck(); } - -/* 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); - -void -callPanic(void) -{ - struct { const char *p; } a; - a.p = "panic from C"; - crosscall2(_cgo_panic, &a, sizeof a); - *(int*)1 = 1; -} diff --git a/misc/cgo/test/callback_c_gc.c b/misc/cgo/test/callback_c_gc.c new file mode 100644 index 0000000000..8953b74a67 --- /dev/null +++ b/misc/cgo/test/callback_c_gc.c @@ -0,0 +1,21 @@ +// 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" + +/* 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); + +void +callPanic(void) +{ + struct { const char *p; } a; + a.p = "panic from C"; + crosscall2(_cgo_panic, &a, sizeof a); + *(int*)1 = 1; +} diff --git a/misc/cgo/test/callback_c_gccgo.c b/misc/cgo/test/callback_c_gccgo.c new file mode 100644 index 0000000000..0ea7296c62 --- /dev/null +++ b/misc/cgo/test/callback_c_gccgo.c @@ -0,0 +1,17 @@ +// 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 gccgo + +#include "_cgo_export.h" + +/* Test calling panic from C. This is what SWIG does. */ + +extern void _cgo_panic(const char *); + +void +callPanic(void) +{ + _cgo_panic("panic from C"); +}