Avoid is_constant calls in vectorizable_bswap
[official-gcc.git] / libgo / go / syscall / errstr.go
blob25b0063e76f49e3b0d5d1da234dac3feb654f539
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 // +build !linux
9 package syscall
11 //sysnb strerror_r(errnum int, buf []byte) (err Errno)
12 //strerror_r(errnum _C_int, buf *byte, buflen Size_t) _C_int
14 func Errstr(errnum int) string {
15 for len := 128; ; len *= 2 {
16 b := make([]byte, len)
17 errno := strerror_r(errnum, b)
18 if errno == 0 {
19 i := 0
20 for b[i] != 0 {
21 i++
23 // Lowercase first letter: Bad -> bad, but
24 // STREAM -> STREAM.
25 if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
26 b[0] += 'a' - 'A'
28 return string(b[:i])
30 if errno != ERANGE {
31 return "errstr failure"