1
0
mirror of https://github.com/golang/go synced 2024-11-19 14:54:43 -07:00

runtime: remove cgocall and asmcgocall

In preparation for rename of cgocall_errno into cgocall and
asmcgocall_errno into asmcgocall in the fllowinng CL.
rsc requested CL 9387 to be split into two parts. This is first part.

Change-Id: I7434f0e4b44dd37017540695834bfcb1eebf0b2f
Reviewed-on: https://go-review.googlesource.com/11166
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Alex Brainman 2015-06-17 16:48:02 +10:00
parent 24db235deb
commit 2858b73843
15 changed files with 38 additions and 82 deletions

View File

@ -665,12 +665,6 @@ TEXT gosave<>(SB),NOSPLIT,$0
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
// See cgocall.c for more details.
TEXT ·asmcgocall(SB),NOSPLIT,$0-8
MOVL fn+0(FP), AX
MOVL arg+4(FP), BX
CALL asmcgocall<>(SB)
RET
TEXT ·asmcgocall_errno(SB),NOSPLIT,$0-12
MOVL fn+0(FP), AX
MOVL arg+4(FP), BX

View File

@ -645,12 +645,6 @@ TEXT gosave<>(SB),NOSPLIT,$0
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
// See cgocall.c for more details.
TEXT ·asmcgocall(SB),NOSPLIT,$0-16
MOVQ fn+0(FP), AX
MOVQ arg+8(FP), BX
CALL asmcgocall<>(SB)
RET
TEXT ·asmcgocall_errno(SB),NOSPLIT,$0-20
MOVQ fn+0(FP), AX
MOVQ arg+8(FP), BX

View File

@ -582,12 +582,6 @@ TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8
MOVL 0(DX), BX
JMP BX // but first run the deferred function
// asmcgocall(void(*fn)(void*), void *arg)
// Not implemented.
TEXT runtime·asmcgocall(SB),NOSPLIT,$0-8
MOVL 0, AX
RET
// asmcgocall(void(*fn)(void*), void *arg)
// Not implemented.
TEXT runtime·asmcgocall_errno(SB),NOSPLIT,$0-12

View File

@ -478,12 +478,6 @@ TEXT gosave<>(SB),NOSPLIT,$0
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
// See cgocall.c for more details.
TEXT ·asmcgocall(SB),NOSPLIT,$0-8
MOVW fn+0(FP), R1
MOVW arg+4(FP), R0
BL asmcgocall<>(SB)
RET
TEXT ·asmcgocall_errno(SB),NOSPLIT,$0-12
MOVW fn+0(FP), R1
MOVW arg+4(FP), R0

View File

@ -549,12 +549,6 @@ TEXT gosave<>(SB),NOSPLIT,$-8
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
// See cgocall.go for more details.
TEXT ·asmcgocall(SB),NOSPLIT,$0-16
MOVD fn+0(FP), R1
MOVD arg+8(FP), R0
BL asmcgocall<>(SB)
RET
TEXT ·asmcgocall_errno(SB),NOSPLIT,$0-20
MOVD fn+0(FP), R1
MOVD arg+8(FP), R0

View File

@ -698,12 +698,6 @@ TEXT gosave<>(SB),NOSPLIT,$-8
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
// See cgocall.c for more details.
TEXT ·asmcgocall(SB),NOSPLIT,$0-16
MOVD fn+0(FP), R3
MOVD arg+8(FP), R4
BL asmcgocall<>(SB)
RET
TEXT ·asmcgocall_errno(SB),NOSPLIT,$0-20
MOVD fn+0(FP), R3
MOVD arg+8(FP), R4

View File

@ -82,11 +82,6 @@ package runtime
import "unsafe"
// Call from Go to C.
//go:nosplit
func cgocall(fn, arg unsafe.Pointer) {
cgocall_errno(fn, arg)
}
//go:nosplit
func cgocall_errno(fn, arg unsafe.Pointer) int32 {
if !iscgo && GOOS != "solaris" && GOOS != "windows" {
@ -148,7 +143,7 @@ func cmalloc(n uintptr) unsafe.Pointer {
ret unsafe.Pointer
}
args.n = uint64(n)
cgocall(_cgo_malloc, unsafe.Pointer(&args))
cgocall_errno(_cgo_malloc, unsafe.Pointer(&args))
if args.ret == nil {
throw("C malloc failed")
}
@ -156,7 +151,7 @@ func cmalloc(n uintptr) unsafe.Pointer {
}
func cfree(p unsafe.Pointer) {
cgocall(_cgo_free, p)
cgocall_errno(_cgo_free, p)
}
// Call from C back to Go.

View File

@ -32,7 +32,7 @@ func syscall_setenv_c(k string, v string) {
return
}
arg := [2]unsafe.Pointer{cstring(k), cstring(v)}
asmcgocall(unsafe.Pointer(_cgo_setenv), unsafe.Pointer(&arg))
asmcgocall_errno(unsafe.Pointer(_cgo_setenv), unsafe.Pointer(&arg))
}
// Update the C environment if cgo is loaded.
@ -43,7 +43,7 @@ func syscall_unsetenv_c(k string) {
return
}
arg := [1]unsafe.Pointer{cstring(k)}
asmcgocall(unsafe.Pointer(_cgo_unsetenv), unsafe.Pointer(&arg))
asmcgocall_errno(unsafe.Pointer(_cgo_unsetenv), unsafe.Pointer(&arg))
}
func cstring(s string) unsafe.Pointer {

View File

@ -372,7 +372,7 @@ func stdcall(fn stdFunction) uintptr {
// all three values to be non-zero, it will use them
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
}
asmcgocall(asmstdcallAddr, unsafe.Pointer(&mp.libcall))
asmcgocall_errno(asmstdcallAddr, unsafe.Pointer(&mp.libcall))
mp.libcallsp = 0
return mp.libcall.r1
}

View File

@ -201,7 +201,7 @@ func msigsave(mp *m) {
// Called on the new thread, can not allocate memory.
func minit() {
_g_ := getg()
asmcgocall(unsafe.Pointer(funcPC(miniterrno)), unsafe.Pointer(&libc____errno))
asmcgocall_errno(unsafe.Pointer(funcPC(miniterrno)), unsafe.Pointer(&libc____errno))
// Initialize signal handling
signalstack(&_g_.m.gsignal.stack)
@ -317,7 +317,7 @@ func semacreate() uintptr {
memclr(unsafe.Pointer(&_g_.m.scratch), uintptr(len(_g_.m.scratch.v)))
_g_.m.scratch.v[0] = unsafe.Sizeof(*sem)
_g_.m.libcall.args = uintptr(unsafe.Pointer(&_g_.m.scratch))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&_g_.m.libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&_g_.m.libcall))
sem = (*semt)(unsafe.Pointer(_g_.m.libcall.r1))
if sem_init(sem, 0, 0) != 0 {
throw("sem_init")
@ -338,7 +338,7 @@ func semasleep(ns int64) int32 {
_m_.scratch.v[0] = _m_.waitsema
_m_.scratch.v[1] = uintptr(unsafe.Pointer(&_m_.ts))
_m_.libcall.args = uintptr(unsafe.Pointer(&_m_.scratch))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&_m_.libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&_m_.libcall))
if *_m_.perrno != 0 {
if *_m_.perrno == _ETIMEDOUT || *_m_.perrno == _EAGAIN || *_m_.perrno == _EINTR {
return -1
@ -353,7 +353,7 @@ func semasleep(ns int64) int32 {
memclr(unsafe.Pointer(&_m_.scratch), uintptr(len(_m_.scratch.v)))
_m_.scratch.v[0] = _m_.waitsema
_m_.libcall.args = uintptr(unsafe.Pointer(&_m_.scratch))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&_m_.libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&_m_.libcall))
if _m_.libcall.r1 == 0 {
break
}

View File

@ -19,7 +19,7 @@ func sysvicall0(fn *libcFunc) uintptr {
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.n = 0
libcall.args = uintptr(unsafe.Pointer(fn)) // it's unused but must be non-nil, otherwise crashes
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
@ -30,7 +30,7 @@ func sysvicall1(fn *libcFunc, a1 uintptr) uintptr {
libcall.n = 1
// TODO(rsc): Why is noescape necessary here and below?
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
@ -40,7 +40,7 @@ func sysvicall2(fn *libcFunc, a1, a2 uintptr) uintptr {
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.n = 2
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
@ -50,7 +50,7 @@ func sysvicall3(fn *libcFunc, a1, a2, a3 uintptr) uintptr {
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.n = 3
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
@ -60,7 +60,7 @@ func sysvicall4(fn *libcFunc, a1, a2, a3, a4 uintptr) uintptr {
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.n = 4
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
@ -70,7 +70,7 @@ func sysvicall5(fn *libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr {
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.n = 5
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
@ -80,6 +80,6 @@ func sysvicall6(fn *libcFunc, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.n = 6
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}

View File

@ -94,7 +94,7 @@ func main() {
if _cgo_notify_runtime_init_done == nil {
throw("_cgo_notify_runtime_init_done missing")
}
cgocall(_cgo_notify_runtime_init_done, nil)
cgocall_errno(_cgo_notify_runtime_init_done, nil)
}
main_init()

View File

@ -1093,7 +1093,7 @@ func newm(fn func(), _p_ *p) {
ts.g.set(mp.g0)
ts.tls = (*uint64)(unsafe.Pointer(&mp.tls[0]))
ts.fn = unsafe.Pointer(funcPC(mstart))
asmcgocall(_cgo_thread_start, unsafe.Pointer(&ts))
asmcgocall_errno(_cgo_thread_start, unsafe.Pointer(&ts))
return
}
newosproc(mp, unsafe.Pointer(mp.g0.stack.hi))

View File

@ -204,9 +204,6 @@ func getcallerpc(argp unsafe.Pointer) uintptr
//go:noescape
func getcallersp(argp unsafe.Pointer) uintptr
//go:noescape
func asmcgocall(fn, arg unsafe.Pointer)
//go:noescape
func asmcgocall_errno(fn, arg unsafe.Pointer) int32

View File

@ -34,7 +34,7 @@ func syscall_sysvicall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err
args: uintptr(unsafe.Pointer(&a1)),
}
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall(0)
return call.r1, call.r2, call.err
}
@ -46,7 +46,7 @@ func syscall_rawsysvicall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, e
n: nargs,
args: uintptr(unsafe.Pointer(&a1)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.r2, call.err
}
@ -61,7 +61,7 @@ func syscall_chdir(path uintptr) (err uintptr) {
n: 1,
args: uintptr(unsafe.Pointer(&path)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -72,7 +72,7 @@ func syscall_chroot(path uintptr) (err uintptr) {
n: 1,
args: uintptr(unsafe.Pointer(&path)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -89,7 +89,7 @@ func syscall_execve(path, argv, envp uintptr) (err uintptr) {
n: 3,
args: uintptr(unsafe.Pointer(&path)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -106,7 +106,7 @@ func syscall_fcntl(fd, cmd, arg uintptr) (val, err uintptr) {
n: 3,
args: uintptr(unsafe.Pointer(&fd)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.err
}
@ -117,7 +117,7 @@ func syscall_forkx(flags uintptr) (pid uintptr, err uintptr) {
n: 1,
args: uintptr(unsafe.Pointer(&flags)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.err
}
@ -130,7 +130,7 @@ func syscall_gethostname() (name string, err uintptr) {
args: uintptr(unsafe.Pointer(&args[0])),
}
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall(0)
if call.r1 != 0 {
return "", call.err
@ -146,7 +146,7 @@ func syscall_getpid() (pid, err uintptr) {
n: 0,
args: uintptr(unsafe.Pointer(&libc_getpid)), // it's unused but must be non-nil, otherwise crashes
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.err
}
@ -157,7 +157,7 @@ func syscall_ioctl(fd, req, arg uintptr) (err uintptr) {
n: 3,
args: uintptr(unsafe.Pointer(&fd)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -168,7 +168,7 @@ func syscall_pipe() (r, w, err uintptr) {
args: uintptr(unsafe.Pointer(&pipe1)), // it's unused but must be non-nil, otherwise crashes
}
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall(0)
return call.r1, call.r2, call.err
}
@ -185,7 +185,7 @@ func syscall_rawsyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
n: 4,
args: uintptr(unsafe.Pointer(&trap)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.r2, call.err
}
@ -196,7 +196,7 @@ func syscall_setgid(gid uintptr) (err uintptr) {
n: 1,
args: uintptr(unsafe.Pointer(&gid)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -207,7 +207,7 @@ func syscall_setgroups(ngid, gid uintptr) (err uintptr) {
n: 2,
args: uintptr(unsafe.Pointer(&ngid)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -218,7 +218,7 @@ func syscall_setsid() (pid, err uintptr) {
n: 0,
args: uintptr(unsafe.Pointer(&libc_setsid)), // it's unused but must be non-nil, otherwise crashes
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.err
}
@ -229,7 +229,7 @@ func syscall_setuid(uid uintptr) (err uintptr) {
n: 1,
args: uintptr(unsafe.Pointer(&uid)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -240,7 +240,7 @@ func syscall_setpgid(pid, pgid uintptr) (err uintptr) {
n: 2,
args: uintptr(unsafe.Pointer(&pid)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.err
}
@ -257,7 +257,7 @@ func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
args: uintptr(unsafe.Pointer(&trap)),
}
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall(0)
return call.r1, call.r2, call.err
}
@ -269,7 +269,7 @@ func syscall_wait4(pid uintptr, wstatus *uint32, options uintptr, rusage unsafe.
args: uintptr(unsafe.Pointer(&pid)),
}
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall(0)
return int(call.r1), call.err
}
@ -281,6 +281,6 @@ func syscall_write(fd, buf, nbyte uintptr) (n, err uintptr) {
n: 3,
args: uintptr(unsafe.Pointer(&fd)),
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
asmcgocall_errno(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.err
}