diff options
author | Russ Cox <rsc@golang.org> | 2014-11-11 17:05:37 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-11-11 17:05:37 -0500 |
commit | 4341f082b01ba446d416cb5cbaacc55ff0fefe13 (patch) | |
tree | b8b1cdd1a626b458c95ce044a1a741e2a0330a2a /src/runtime/cgocall.go | |
parent | f693cb489b88fb4ac9aab878cdc62629021c5bf4 (diff) | |
download | go-4341f082b01ba446d416cb5cbaacc55ff0fefe13.tar.gz |
[dev.cc] runtime/cgo: convert from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]
LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://codereview.appspot.com/168500043
Diffstat (limited to 'src/runtime/cgocall.go')
-rw-r--r-- | src/runtime/cgocall.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go index 7fd91469e..a1fc06d39 100644 --- a/src/runtime/cgocall.go +++ b/src/runtime/cgocall.go @@ -127,9 +127,9 @@ func cgocall_errno(fn, arg unsafe.Pointer) int32 { * so it is safe to call while "in a system call", outside * the $GOMAXPROCS accounting. */ - entersyscall() + entersyscall(0) errno := asmcgocall_errno(fn, arg) - exitsyscall() + exitsyscall(0) return errno } @@ -153,17 +153,13 @@ func endcgo(mp *m) { // Helper functions for cgo code. -// Filled by schedinit from corresponding C variables, -// which are in turn filled in by dynamic linker when Cgo is available. -var cgoMalloc, cgoFree unsafe.Pointer - func cmalloc(n uintptr) unsafe.Pointer { var args struct { n uint64 ret unsafe.Pointer } args.n = uint64(n) - cgocall(cgoMalloc, unsafe.Pointer(&args)) + cgocall(_cgo_malloc, unsafe.Pointer(&args)) if args.ret == nil { gothrow("C malloc failed") } @@ -171,7 +167,7 @@ func cmalloc(n uintptr) unsafe.Pointer { } func cfree(p unsafe.Pointer) { - cgocall(cgoFree, p) + cgocall(_cgo_free, p) } // Call from C back to Go. @@ -189,10 +185,10 @@ func cgocallbackg() { // save syscall* and let reentersyscall restore them. savedsp := unsafe.Pointer(gp.syscallsp) savedpc := gp.syscallpc - exitsyscall() // coming out of cgo call + exitsyscall(0) // coming out of cgo call cgocallbackg1() // going back to cgo call - reentersyscall(savedpc, savedsp) + reentersyscall(savedpc, uintptr(savedsp)) } func cgocallbackg1() { |