mirror of https://github.com/golang/go.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
This commit is contained in:
parent
db3374e24d
commit
cd61565ffc
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
Loading…
Reference in New Issue