summaryrefslogtreecommitdiff
path: root/libgo/go/syscall/syscall_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/syscall/syscall_unix.go')
-rw-r--r--libgo/go/syscall/syscall_unix.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/libgo/go/syscall/syscall_unix.go b/libgo/go/syscall/syscall_unix.go
index 74f10c29da5..21bf6eafb11 100644
--- a/libgo/go/syscall/syscall_unix.go
+++ b/libgo/go/syscall/syscall_unix.go
@@ -172,6 +172,30 @@ func Munmap(b []byte) (err error) {
return mapper.Munmap(b)
}
+// Do the interface allocations only once for common
+// Errno values.
+var (
+ errEAGAIN error = EAGAIN
+ errEINVAL error = EINVAL
+ errENOENT error = ENOENT
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e Errno) error {
+ switch e {
+ case 0:
+ return nil
+ case EAGAIN:
+ return errEAGAIN
+ case EINVAL:
+ return errEINVAL
+ case ENOENT:
+ return errENOENT
+ }
+ return e
+}
+
// A Signal is a number describing a process signal.
// It implements the os.Signal interface.
type Signal int