OSDN Git Service

2011-01-13 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libgo / syscalls / errstr_rtems.go
1 // errstr_rtems.go -- RTEMS specific error strings.
2
3 // Copyright 2010 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.
6
7 package syscall
8
9 func Errstr(errno int) string {
10         for len := Size_t(128); ; len *= 2 {
11                 b := make([]byte, len+1)
12
13                 // The newlib strerror_r always returns the string in buffer.
14                 libc_strerror_r(errno, &b[0], len)
15                 b[len] = 0
16
17                 i := 0
18                 for b[i] != 0 {
19                         i++
20                 }
21
22                 if Size_t(i) < len {
23                         return string(b[0:i])
24                 }
25         }
26 }