2011-10-08 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libgo / syscalls / errstr.go
bloba95abc686f3177c224d02bff590e323b6efb95b0
1 // errstr.go -- Error strings.
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 package syscall
9 func Errstr(errno int) string {
10 for len := Size_t(128); ; len *= 2 {
11 b := make([]byte, len)
12 r := libc_strerror_r(errno, &b[0], len)
13 if r >= 0 {
14 i := 0
15 for b[i] != 0 {
16 i++
18 return string(b[:i])
20 if GetErrno() != ERANGE {
21 return "Errstr failure"