summaryrefslogtreecommitdiff
path: root/libgo/go/syscall/errstr.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/syscall/errstr.go')
-rw-r--r--libgo/go/syscall/errstr.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go
new file mode 100644
index 00000000000..d9f3fe82eb4
--- /dev/null
+++ b/libgo/go/syscall/errstr.go
@@ -0,0 +1,27 @@
+// errstr.go -- Error strings.
+
+// Copyright 2009 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 syscall
+
+//sysnb strerror_r(errnum int, buf []byte) (errno int)
+//strerror_r(errnum int, buf *byte, buflen Size_t) int
+
+func Errstr(errnum int) string {
+ for len := 128; ; len *= 2 {
+ b := make([]byte, len)
+ err := strerror_r(errnum, b)
+ if err == 0 {
+ i := 0
+ for b[i] != 0 {
+ i++
+ }
+ return string(b[:i])
+ }
+ if err != ERANGE {
+ return "Errstr failure"
+ }
+ }
+}