diff mbox

[libgo] Use _nuname on 32-bit Solaris 2/x86

Message ID yddvczvw5pm.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth March 7, 2011, 11:05 a.m. UTC
The libgo os test used to fail on 32-bit Solaris 2/x86 only:

--- FAIL: os_test.TestHostname
       Hostname() = "", want "fuego"

Running the test under gdb, I find that syscall.Uname is entered with
errno = 4 and left the same, even if I reset errno = ENONE on entry.
Further investigation led to this snippet from <sys/utsname.h>:

#if defined(__i386) && !defined(__amd64)

static int
uname(struct utsname *_buf)
{
        return (_nuname(_buf));
}

#endif

The following patch reflects this and fixes the testcase.

	Rainer


2011-03-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* syscalls/syscall_solaris_386.go (libc_uname): Declare.
	* syscalls/syscall_unix.go (libc_uname): Move ...
	* syscalls/syscall_uname.go: ... here.
	New file.
	* Makefile.am (syscall_uname_file) [!LIBGO_IS_SOLARIS &&
	!LIBGO_IS_386]: Use it.
	(go_syscall_files): Use it.
	* Makefile.in: Regenerate.

Comments

Ian Lance Taylor March 7, 2011, 10:40 p.m. UTC | #1
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> The libgo os test used to fail on 32-bit Solaris 2/x86 only:
>
> --- FAIL: os_test.TestHostname
>        Hostname() = "", want "fuego"
>
> Running the test under gdb, I find that syscall.Uname is entered with
> errno = 4 and left the same, even if I reset errno = ENONE on entry.
> Further investigation led to this snippet from <sys/utsname.h>:
>
> #if defined(__i386) && !defined(__amd64)
>
> static int
> uname(struct utsname *_buf)
> {
>         return (_nuname(_buf));
> }
>
> #endif
>
> The following patch reflects this and fixes the testcase.

Thanks.

Committed.

Ian
diff mbox

Patch

diff -r cd964439e0b3 libgo/Makefile.am
--- a/libgo/Makefile.am	Sat Mar 05 20:51:22 2011 +0100
+++ b/libgo/Makefile.am	Sat Mar 05 23:32:30 2011 +0100
@@ -1205,6 +1205,18 @@ 
 syscall_socket_epoll_file =
 endif
 
+# Support for uname.
+if LIBGO_IS_SOLARIS
+if LIBGO_IS_386
+# 32-bit Solaris 2/x86 needs _nuname, handled in syscall_solaris_386.go.
+syscall_uname_file =
+else # !LIBGO_IS_386 && LIBGO_IS_SOLARIS
+syscall_uname_file = syscalls/syscall_uname.go
+endif
+else # !LIBGO_IS_SOLARIS
+syscall_uname_file = syscalls/syscall_uname.go
+endif
+
 syscall_arch.go: s-syscall_arch; @true
 s-syscall_arch: Makefile
 	rm -f syscall_arch.go.tmp
@@ -1226,6 +1238,7 @@ 
 	$(syscall_socket_os_file) \
 	$(syscall_socket_epoll_file) \
 	$(syscall_syscall_file) \
+	$(syscall_uname_file) \
 	syscalls/syscall_unix.go \
 	syscalls/stringbyte.go \
 	syscalls/syscall_$(GOOS).go \
diff -r cd964439e0b3 libgo/syscalls/syscall_solaris_386.go
--- a/libgo/syscalls/syscall_solaris_386.go	Sat Mar 05 20:51:22 2011 +0100
+++ b/libgo/syscalls/syscall_solaris_386.go	Sat Mar 05 23:32:30 2011 +0100
@@ -15,3 +15,6 @@ 
 
 var dummy *byte
 const sizeofPtr uintptr = uintptr(unsafe.Sizeof(dummy))
+
+// 32-bit Solaris 2/x86 needs to use _nuname internally, cf. <sys/utsname.h>.
+func libc_uname(buf *Utsname) (errno int) __asm__("_nuname")
diff -r cd964439e0b3 libgo/syscalls/syscall_uname.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/syscalls/syscall_uname.go	Sat Mar 05 23:32:30 2011 +0100
@@ -0,0 +1,7 @@ 
+// 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
+
+func libc_uname(buf *Utsname) (errno int) __asm__("uname")
diff -r cd964439e0b3 libgo/syscalls/syscall_unix.go
--- a/libgo/syscalls/syscall_unix.go	Sat Mar 05 20:51:22 2011 +0100
+++ b/libgo/syscalls/syscall_unix.go	Sat Mar 05 23:32:30 2011 +0100
@@ -15,8 +15,6 @@ 
 func GetErrno() int
 func SetErrno(int)
 
-func libc_uname(buf *Utsname) (errno int) __asm__("uname")
-
 func Uname(buf *Utsname) (errno int) {
 	r := libc_uname(buf)
 	if r < 0 {