2011-05-31 Gabriel Charette <gchare@google.com>
[official-gcc.git] / libgo / syscalls / errstr_nor.go
blob358b3ee9cf6a6cb4158582e24c4b5b6b1cfaccfb
1 // errstr.go -- Error strings when there is no strerror_r.
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.
7 package syscall
9 import (
10 "sync"
11 "unsafe"
14 func libc_strerror(int) *byte __asm__ ("strerror")
16 var errstr_lock sync.Mutex
18 func Errstr(errno int) string {
19 errstr_lock.Lock()
21 bp := libc_strerror(errno)
22 b := (*[1000]byte)(unsafe.Pointer(bp))
23 i := 0
24 for b[i] != 0 {
25 i++
27 s := string(b[:i])
29 errstr_lock.Unlock()
31 return s