@@ -1110,6 +1110,7 @@
syscall_sysfile_os_file = syscalls/sysfile_rtems.go
syscall_syscall_file = syscalls/syscall_stubs.go
syscall_errstr_file = syscalls/errstr_rtems.go
+syscall_errstr_decl_file = syscalls/errstr_decl_rtems.go
else
syscall_exec_os_file = syscalls/exec.go
syscall_socket_os_file = syscalls/socket_linux.go
@@ -1117,10 +1118,16 @@
syscall_sysfile_os_file = syscalls/sysfile_linux.go
syscall_syscall_file = syscalls/syscall.go
syscall_errstr_file = syscalls/errstr.go
+if LIBGO_IS_LINUX
+syscall_errstr_decl_file = syscalls/errstr_decl_linux.go
+else
+syscall_errstr_decl_file = syscalls/errstr_decl.go
+endif
endif
go_syscall_files = \
$(syscall_errstr_file) \
+ $(syscall_errstr_decl_file) \
syscalls/exec_helpers.go \
$(syscall_exec_os_file) \
syscalls/socket.go \
@@ -6,26 +6,24 @@
package syscall
-const ENONE = 0;
+const ENONE = 0
-// FIXME: The name is only right for glibc.
-func libc_strerror_r(int, *byte, Size_t) int __asm__ ("__xpg_strerror_r")
func GetErrno() int
func SetErrno(int)
func Errstr(errno int) string {
for len := Size_t(128); ; len *= 2 {
- b := make([]byte, len);
- r := libc_strerror_r(errno, &b[0], len);
+ b := make([]byte, len)
+ r := libc_strerror_r(errno, &b[0], len)
if r >= 0 {
- i := 0;
+ i := 0
for b[i] != 0 {
- i++;
+ i++
}
- return string(b[0:i]);
+ return string(b[:i])
}
if GetErrno() != ERANGE {
- return "Errstr failure";
+ return "Errstr failure"
}
}
}
@@ -0,0 +1,9 @@
+// errstr.go -- Declare strerror_r.
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func libc_strerror_r(int, *byte, Size_t) int __asm__ ("strerror_r")
@@ -0,0 +1,9 @@
+// errstr_decl_linux.go -- Declare strerror_r for GNU/Linux.
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func libc_strerror_r(int, *byte, Size_t) int __asm__ ("__xpg_strerror_r")
@@ -0,0 +1,10 @@
+// errstr.go -- Declare strerror_r for RTEMS.
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+// RTEMS uses strerror_r in newlib, which is a GNU extension returning a char *.
+func libc_strerror_r(int, *byte, Size_t) *byte __asm__ ("strerror_r")
@@ -8,8 +8,6 @@
const ENONE = 0
-// RTEMS uses strerror_r in newlib, which is a GNU extension returning a char *.
-func libc_strerror_r(int, *byte, Size_t) int __asm__ ("strerror_r")
func GetErrno() int
func SetErrno(int)