mirror of
https://github.com/golang/go
synced 2024-11-23 02:00:03 -07:00
misc/cgo/test: get rid of the backdoor package
For Go 1.5, we can use go:linkname rather than assembly thunk for gc. Gccgo already has support for //extern. Change-Id: I5505aa247dd5b555112f7261ed2f192c81cf0bdf Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/1888 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
958e0792b5
commit
04cf881fbe
11
misc/cgo/test/backdoor.go
Normal file
11
misc/cgo/test/backdoor.go
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
package cgotest
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname lockedOSThread runtime.lockedOSThread
|
||||
//extern runtime_lockedOSThread
|
||||
func lockedOSThread() bool
|
@ -1,7 +0,0 @@
|
||||
// Copyright 2012 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.
|
||||
|
||||
package backdoor
|
||||
|
||||
func LockedOSThread() bool // in thunk.s or runtime_gccgo.c
|
@ -1,18 +0,0 @@
|
||||
// Copyright 2012 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.
|
||||
|
||||
// Expose some runtime functions for testing.
|
||||
// This is the gccgo version of thunk.s.
|
||||
|
||||
// +build gccgo
|
||||
|
||||
_Bool runtime_lockedOSThread(void);
|
||||
|
||||
_Bool LockedOSThread(void) asm(GOPKGPATH ".LockedOSThread");
|
||||
|
||||
_Bool
|
||||
LockedOSThread(void)
|
||||
{
|
||||
return runtime_lockedOSThread();
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
// Assembly to get into package runtime without using exported symbols.
|
||||
|
||||
// +build amd64 amd64p32 arm 386
|
||||
// +build gc
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
#ifdef GOARCH_arm
|
||||
#define JMP B
|
||||
#endif
|
||||
|
||||
TEXT ·LockedOSThread(SB),NOSPLIT,$0-0
|
||||
JMP runtime·lockedOSThread(SB)
|
@ -22,8 +22,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"./backdoor"
|
||||
)
|
||||
|
||||
// nestedCall calls into C, back into Go, and finally to f.
|
||||
@ -50,8 +48,6 @@ func testCallbackGC(t *testing.T) {
|
||||
nestedCall(runtime.GC)
|
||||
}
|
||||
|
||||
var lockedOSThread = backdoor.LockedOSThread
|
||||
|
||||
func testCallbackPanic(t *testing.T) {
|
||||
// Make sure panic during callback unwinds properly.
|
||||
if lockedOSThread() {
|
||||
|
Loading…
Reference in New Issue
Block a user