From 27cb3ef1ff02831eeeed79ca85087075513db536 Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 15 Mar 2012 18:09:39 +0000 Subject: [PATCH] libgo: Export {enter,exit}syscall and use it for getaddrinfo. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@185440 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/go/net/cgo_unix.go | 7 ++++++- libgo/go/syscall/libcall_linux.go | 4 ++-- libgo/go/syscall/libcall_support.go | 4 ++-- libgo/go/syscall/mksyscall.awk | 4 ++-- libgo/go/syscall/syscall_unix.go | 8 ++++---- libgo/runtime/runtime.h | 4 ++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/libgo/go/net/cgo_unix.go b/libgo/go/net/cgo_unix.go index e96df669f33..6751b8cc0e5 100644 --- a/libgo/go/net/cgo_unix.go +++ b/libgo/go/net/cgo_unix.go @@ -75,7 +75,10 @@ func cgoLookupPort(net, service string) (port int, err error, completed bool) { } s := syscall.StringBytePtr(service) - if libc_getaddrinfo(nil, s, &hints, &res) == 0 { + syscall.Entersyscall() + gerrno := libc_getaddrinfo(nil, s, &hints, &res) + syscall.Exitsyscall() + if gerrno == 0 { defer libc_freeaddrinfo(res) for r := res; r != nil; r = r.Ai_next { switch r.Ai_family { @@ -108,7 +111,9 @@ func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err error, complet hints.Ai_flags = int32((syscall.AI_ALL | syscall.AI_V4MAPPED | syscall.AI_CANONNAME) & cgoAddrInfoMask()) h := syscall.StringBytePtr(name) + syscall.Entersyscall() gerrno := libc_getaddrinfo(h, nil, &hints, &res) + syscall.Exitsyscall() if gerrno != 0 { var str string if gerrno == syscall.EAI_NONAME { diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go index bb960731f75..f5358f53d9b 100644 --- a/libgo/go/syscall/libcall_linux.go +++ b/libgo/go/syscall/libcall_linux.go @@ -202,13 +202,13 @@ func Getdents(fd int, buf []byte) (n int, err error) { } else { p = (*byte)(unsafe.Pointer(&_zero)) } - entersyscall() + Entersyscall() r1, _, errno := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(len(buf))) n = int(r1) if n < 0 { err = errno } - exitsyscall() + Exitsyscall() return } diff --git a/libgo/go/syscall/libcall_support.go b/libgo/go/syscall/libcall_support.go index 7449a0adf79..7746cc2fa2a 100644 --- a/libgo/go/syscall/libcall_support.go +++ b/libgo/go/syscall/libcall_support.go @@ -6,7 +6,7 @@ package syscall -func entersyscall() -func exitsyscall() +func Entersyscall() +func Exitsyscall() func GetErrno() Errno func SetErrno(Errno) diff --git a/libgo/go/syscall/mksyscall.awk b/libgo/go/syscall/mksyscall.awk index 8da02349e6a..5e30e863231 100644 --- a/libgo/go/syscall/mksyscall.awk +++ b/libgo/go/syscall/mksyscall.awk @@ -190,7 +190,7 @@ BEGIN { } if (blocking) { - print "\tentersyscall()" + print "\tEntersyscall()" } printf("\t") @@ -240,7 +240,7 @@ BEGIN { } if (blocking) { - print "\texitsyscall()" + print "\tExitsyscall()" } if (gofnresults != "") { diff --git a/libgo/go/syscall/syscall_unix.go b/libgo/go/syscall/syscall_unix.go index 85182b764b0..e3c6629ed07 100644 --- a/libgo/go/syscall/syscall_unix.go +++ b/libgo/go/syscall/syscall_unix.go @@ -30,7 +30,7 @@ const darwinAMD64 = runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" // the arguments, so that we don't pass a 64-bit value when the function // expects a 32-bit one. func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - entersyscall() + Entersyscall() var r uintptr if unsafe.Sizeof(r) == 4 { r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0) @@ -40,12 +40,12 @@ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { r = uintptr(r1) } err = GetErrno() - exitsyscall() + Exitsyscall() return r, 0, err } func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - entersyscall() + Entersyscall() var r uintptr if unsafe.Sizeof(r) == 4 { r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), @@ -57,7 +57,7 @@ func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) r = uintptr(r1) } err = GetErrno() - exitsyscall() + Exitsyscall() return r, 0, err } diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index e012e1833bb..2deb46ec8b4 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -298,8 +298,8 @@ void runtime_gosched(void); void runtime_tsleep(int64); M* runtime_newm(void); void runtime_goexit(void); -void runtime_entersyscall(void) __asm__("libgo_syscall.syscall.entersyscall"); -void runtime_exitsyscall(void) __asm__("libgo_syscall.syscall.exitsyscall"); +void runtime_entersyscall(void) __asm__("libgo_syscall.syscall.Entersyscall"); +void runtime_exitsyscall(void) __asm__("libgo_syscall.syscall.Exitsyscall"); void siginit(void); bool __go_sigsend(int32 sig); int32 runtime_callers(int32, uintptr*, int32); -- 2.11.0