Rainer Orth <r...@cebitec.uni-bielefeld.de> writes: > Apart from the lack of wait4, libgo on IRIX 6.5 contained an undefined > reference to strerror_r. This patch provides a replacement, based on > gnulib/lib/strerror_r.c, but massively simplified.
I addressed this in a different way, with a new variant of syscall.Errstr written in Go. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian
diff -r ad3d14acbce1 libgo/Makefile.am --- a/libgo/Makefile.am Wed Mar 30 14:45:29 2011 -0700 +++ b/libgo/Makefile.am Wed Mar 30 15:31:01 2011 -0700 @@ -1264,7 +1264,11 @@ if LIBGO_IS_RTEMS syscall_errstr_file = syscalls/errstr_rtems.go else +if HAVE_STRERROR_R syscall_errstr_file = syscalls/errstr.go +else +syscall_errstr_file = syscalls/errstr_nor.go +endif endif # Declare libc_strerror_r which is the Go name for strerror_r. @@ -1273,7 +1277,7 @@ syscall_errstr_decl_file = syscalls/errstr_decl_rtems.go else if LIBGO_IS_LINUX -# In Linux the POSIX strerror_r is called __xpg_strerror_r. +# On GNU/Linux the POSIX strerror_r is called __xpg_strerror_r. syscall_errstr_decl_file = syscalls/errstr_decl_linux.go else # On other systems we hope strerror_r is just strerror_r. diff -r ad3d14acbce1 libgo/configure.ac --- a/libgo/configure.ac Wed Mar 30 14:45:29 2011 -0700 +++ b/libgo/configure.ac Wed Mar 30 15:31:01 2011 -0700 @@ -380,7 +380,9 @@ AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h) AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes) -AC_CHECK_FUNCS(srandom random strsignal) + +AC_CHECK_FUNCS(srandom random strerror_r strsignal) +AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes) AC_CACHE_CHECK([for __sync_bool_compare_and_swap_4], [libgo_cv_func___sync_bool_compare_and_swap_4], diff -r ad3d14acbce1 libgo/syscalls/errstr_nor.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/syscalls/errstr_nor.go Wed Mar 30 15:31:01 2011 -0700 @@ -0,0 +1,32 @@ +// errstr.go -- Error strings when there is no strerror_r. + +// Copyright 2011 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 + +import ( + "sync" + "unsafe" +) + +func libc_strerror(int) *byte __asm__ ("strerror") + +var errstr_lock sync.Mutex + +func Errstr(errno int) string { + errstr_lock.Lock() + + bp := libc_strerror(errno) + b := (*[1000]byte)(unsafe.Pointer(bp)) + i := 0 + for b[i] != 0 { + i++ + } + s := string(b[:i]) + + errstr_lock.Unlock() + + return s +}