change the sysroot and c++ include path to fix the bugs the application cannot find...
[platform/upstream/gcc48.git] / libgo / go / syscall / errstr_nor.go
1 // errstr.go -- Error strings when there is no strerror_r.
2
3 // Copyright 2011 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 import (
10         "sync"
11         "unsafe"
12 )
13
14 //sysnb strerror(errnum int) (buf *byte)
15 //strerror(errnum _C_int) *byte
16
17 var errstr_lock sync.Mutex
18
19 func Errstr(errno int) string {
20         errstr_lock.Lock()
21
22         bp := strerror(errno)
23         b := (*[1000]byte)(unsafe.Pointer(bp))
24         i := 0
25         for b[i] != 0 {
26                 i++
27         }
28
29         // Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
30         var s string
31         if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
32                 c := b[0] + 'a' - 'A'
33                 s = string(c) + string(b[1:i])
34         } else {
35                 s = string(b[:i])
36         }
37
38         errstr_lock.Unlock()
39
40         return s
41 }