Fix "PR c++/92804 ICE trying to use concept as a nested-name-specifier"
[official-gcc.git] / libgo / go / syscall / errstr_glibc.go
blob5b19e6f202d8475c99e0633b41844550c02bb26d
1 // errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
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.
7 // We use this rather than errstr.go because on GNU/Linux sterror_r
8 // returns a pointer to the error message, and may not use buf at all.
10 // +build hurd linux
12 package syscall
14 import "unsafe"
16 //sysnb strerror_r(errnum int, b []byte) (errstr *byte)
17 //strerror_r(errnum _C_int, b *byte, len Size_t) *byte
19 func Errstr(errnum int) string {
20 a := make([]byte, 128)
21 p := strerror_r(errnum, a)
22 b := (*[1000]byte)(unsafe.Pointer(p))
23 i := 0
24 for b[i] != 0 {
25 i++
27 // Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
28 if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
29 c := b[0] + 'a' - 'A'
30 return string(c) + string(b[1:i])
32 return string(b[:i])