go.sys/unix: use syscall.Errno for errors

If we use a local type, it won't compare properly with errors from
the rest of the standard library. Errors are the one type from syscall
that propagates through the system, so it's important to have only
one type for them.

Ditto for syscall.Signal.

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/123490043
This commit is contained in:
Rob Pike
2014-08-15 09:57:24 -07:00
parent 70c4b52aa0
commit dc3c21c62b
58 changed files with 2546 additions and 2491 deletions
+8 -7
View File
@@ -7,6 +7,7 @@ package unix
import (
"sync"
"sync/atomic"
"syscall"
"unsafe"
)
@@ -20,11 +21,11 @@ type soError struct {
func (e *soError) Error() string { return e.Msg }
// Implemented in runtime/syscall_solaris.goc.
func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) // TODO: export
func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) // TODO: export
func dlclose(handle uintptr) (err Errno) // TODO: export
func dlopen(name *uint8, mode uintptr) (handle uintptr, err Errno) // TODO: export
func dlsym(handle uintptr, name *uint8) (proc uintptr, err Errno) // TODO: export
func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
func dlclose(handle uintptr) (err syscall.Errno)
func dlopen(name *uint8, mode uintptr) (handle uintptr, err syscall.Errno)
func dlsym(handle uintptr, name *uint8) (proc uintptr, err syscall.Errno)
// A so implements access to a single shared library object.
type so struct {
@@ -119,7 +120,7 @@ func (p *proc) Addr() uintptr {
// GetLastError. Callers must inspect the primary return value to decide
// whether an error occurred (according to the semantics of the specific
// function being called) before consulting the error. The error will be
// guaranteed to contain unix.Errno.
// guaranteed to contain syscall.Errno.
func (p *proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
switch len(a) {
case 0:
@@ -253,7 +254,7 @@ func (p *lazyProc) Addr() uintptr {
// GetLastError. Callers must inspect the primary return value to decide
// whether an error occurred (according to the semantics of the specific
// function being called) before consulting the error. The error will be
// guaranteed to contain unix.Errno.
// guaranteed to contain syscall.Errno.
func (p *lazyProc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
p.mustFind()
return p.proc.Call(a...)