1
0
mirror of https://github.com/golang/go synced 2024-09-25 01:20:13 -06:00

misc/cgo/test: fix C panic test to work with gccgo

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14611043
This commit is contained in:
Ian Lance Taylor 2013-10-11 11:24:54 -07:00
parent db3374e24d
commit cd61565ffc
3 changed files with 38 additions and 14 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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");
}