From 9195aa172bbc20627f23bfb1612180c83a0a7bab Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 19 Mar 2019 14:00:59 +0000 Subject: [PATCH] libgo: fix build on AIX Since aix/ppc64 has been added to GC toolchain, a mix between new and old files were created in gcc toolchain. This commit corrects this merge for aix/ppc64 and aix/ppc. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167658 From-SVN: r269797 --- gcc/go/gofrontend/MERGE | 2 +- libgo/go/archive/tar/stat_actime1.go | 2 +- .../internal/filelock/filelock_fcntl.go | 6 ++- .../go/internal/syscall/unix/at_largefile.go | 2 +- libgo/go/internal/syscall/unix/at_regfile.go | 1 - libgo/go/internal/syscall/unix/ioctl_aix.go | 13 ++---- libgo/go/net/interface_aix.go | 8 ++-- libgo/go/net/interface_stub.go | 2 +- libgo/go/net/sockoptip_aix.go | 15 ------- libgo/go/os/dir_gccgo.go | 3 -- libgo/go/os/dir_libc64_gccgo.go | 3 ++ libgo/go/os/dir_libc_gccgo.go | 3 ++ libgo/go/os/sys_aix.go | 26 ----------- libgo/go/runtime/malloc.go | 6 +-- libgo/go/runtime/mem_gccgo.go | 5 +++ libgo/go/runtime/netpoll_aix.go | 1 - libgo/go/runtime/os_aix.go | 17 ++++--- libgo/go/runtime/stubs2.go | 1 - libgo/go/runtime/timestub2.go | 2 - libgo/go/syscall/exec_aix_test.go | 37 --------------- libgo/go/syscall/exec_unix.go | 6 +-- libgo/go/syscall/flock_aix.go | 18 -------- libgo/go/syscall/libcall_aix.go | 6 +++ libgo/go/syscall/syscall_funcs.go | 45 +++++++++++++++++++ libgo/go/syscall/syscall_funcs_stubs.go | 29 ++++++++++++ libgo/go/syscall/syscall_stubs.go | 29 ------------ libgo/go/syscall/syscall_unix.go | 38 ---------------- libgo/mksysinfo.sh | 12 +++++ libgo/runtime/go-varargs.c | 4 ++ 29 files changed, 140 insertions(+), 202 deletions(-) delete mode 100644 libgo/go/net/sockoptip_aix.go delete mode 100644 libgo/go/os/sys_aix.go delete mode 100644 libgo/go/syscall/exec_aix_test.go delete mode 100644 libgo/go/syscall/flock_aix.go create mode 100644 libgo/go/syscall/syscall_funcs.go create mode 100644 libgo/go/syscall/syscall_funcs_stubs.go delete mode 100644 libgo/go/syscall/syscall_stubs.go diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index a09733f8c46..006da8c77fe 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -87945b620b2100d33e27f33e6276a4e4e5890659 +069afe85f38c099660c5d81950d65248ed4fc516 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/archive/tar/stat_actime1.go b/libgo/go/archive/tar/stat_actime1.go index e2c79a55880..2a7f7f36ab0 100644 --- a/libgo/go/archive/tar/stat_actime1.go +++ b/libgo/go/archive/tar/stat_actime1.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build hurd linux dragonfly openbsd solaris +// +build aix hurd linux dragonfly openbsd solaris package tar diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go index 2831975c0c6..a14362bdc7d 100644 --- a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go @@ -35,7 +35,9 @@ const ( writeLock lockType = syscall.F_WRLCK ) -type inode = uint64 // type of syscall.Stat_t.Ino +// type of syscall.Stat_t.Ino for 64 bits architectures. +// For 32 bits architecture, it's easier to cast it instead. +type inode = uint64 type inodeLock struct { owner File @@ -59,7 +61,7 @@ func lock(f File, lt lockType) (err error) { if err != nil { return err } - ino := fi.Sys().(*syscall.Stat_t).Ino + ino := uint64(fi.Sys().(*syscall.Stat_t).Ino) mu.Lock() if i, dup := inodes[f]; dup && i != ino { diff --git a/libgo/go/internal/syscall/unix/at_largefile.go b/libgo/go/internal/syscall/unix/at_largefile.go index 5318d234ae3..82e0dcfd074 100644 --- a/libgo/go/internal/syscall/unix/at_largefile.go +++ b/libgo/go/internal/syscall/unix/at_largefile.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix hurd linux solaris,386 solaris,sparc +// +build hurd linux solaris,386 solaris,sparc package unix diff --git a/libgo/go/internal/syscall/unix/at_regfile.go b/libgo/go/internal/syscall/unix/at_regfile.go index 004c801a8ab..14fdb70be71 100644 --- a/libgo/go/internal/syscall/unix/at_regfile.go +++ b/libgo/go/internal/syscall/unix/at_regfile.go @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix // +build !hurd // +build !linux // +build !solaris !386 diff --git a/libgo/go/internal/syscall/unix/ioctl_aix.go b/libgo/go/internal/syscall/unix/ioctl_aix.go index 19d56c36a13..af105d6158b 100644 --- a/libgo/go/internal/syscall/unix/ioctl_aix.go +++ b/libgo/go/internal/syscall/unix/ioctl_aix.go @@ -9,17 +9,12 @@ import ( "unsafe" ) -//go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o" -//go:linkname libc_ioctl libc_ioctl -var libc_ioctl uintptr - -// Implemented in syscall/syscall_aix.go. -func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) +//extern __go_ioctl_ptr +func ioctl(int32, int32, unsafe.Pointer) int32 func Ioctl(fd int, cmd int, args uintptr) (err error) { - _, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_ioctl)), 3, uintptr(fd), uintptr(cmd), uintptr(args), 0, 0, 0) - if e1 != 0 { - err = e1 + if ioctl(int32(fd), int32(cmd), unsafe.Pointer(args)) < 0 { + return syscall.GetErrno() } return } diff --git a/libgo/go/net/interface_aix.go b/libgo/go/net/interface_aix.go index 9a8b5bbdb1b..1fe9bbaf696 100644 --- a/libgo/go/net/interface_aix.go +++ b/libgo/go/net/interface_aix.go @@ -32,6 +32,8 @@ const _RTAX_NETMASK = 2 const _RTAX_IFA = 5 const _RTAX_MAX = 8 +const _SIOCGIFMTU = -0x3fd796aa + func getIfList() ([]byte, error) { needed, err := syscall.Getkerninfo(_KINFO_RT_IFLIST, 0, 0, 0) if err != nil { @@ -62,7 +64,7 @@ func interfaceTable(ifindex int) ([]Interface, error) { } if ifm.Type == syscall.RTM_IFINFO { if ifindex == 0 || ifindex == int(ifm.Index) { - sdl := (*rawSockaddrDatalink)(unsafe.Pointer(&tab[syscall.SizeofIfMsghdr])) + sdl := (*rawSockaddrDatalink)(unsafe.Pointer(&tab[unsafe.Sizeof(syscall.IfMsgHdr)])) ifi := &Interface{Index: int(ifm.Index), Flags: linkFlags(ifm.Flags)} ifi.Name = string(sdl.Data[:sdl.Nlen]) @@ -75,7 +77,7 @@ func interfaceTable(ifindex int) ([]Interface, error) { if err != nil { return nil, err } - err = unix.Ioctl(sock, syscall.SIOCGIFMTU, uintptr(unsafe.Pointer(ifr))) + err = unix.Ioctl(sock, _SIOCGIFMTU, uintptr(unsafe.Pointer(ifr))) if err != nil { return nil, err } @@ -131,7 +133,7 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) { if ifm.Type == syscall.RTM_NEWADDR { if ifi == nil || ifi.Index == int(ifm.Index) { mask := ifm.Addrs - off := uint(syscall.SizeofIfMsghdr) + off := uint(unsafe.Sizeof(syscall.IfMsgHdr)) var iprsa, nmrsa *syscall.RawSockaddr for i := uint(0); i < _RTAX_MAX; i++ { diff --git a/libgo/go/net/interface_stub.go b/libgo/go/net/interface_stub.go index 0b3580ec6e6..d8afd5e7519 100644 --- a/libgo/go/net/interface_stub.go +++ b/libgo/go/net/interface_stub.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix nacl hurd js,wasm +// +build nacl hurd js,wasm package net diff --git a/libgo/go/net/sockoptip_aix.go b/libgo/go/net/sockoptip_aix.go deleted file mode 100644 index 1e28fe6aade..00000000000 --- a/libgo/go/net/sockoptip_aix.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 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 net - -import "syscall" - -func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error { - return syscall.ENOPROTOOPT -} - -func setIPv4MulticastLoopback(fd *netFD, v bool) error { - return syscall.ENOPROTOOPT -} diff --git a/libgo/go/os/dir_gccgo.go b/libgo/go/os/dir_gccgo.go index 60f70aa034d..ad77a406840 100644 --- a/libgo/go/os/dir_gccgo.go +++ b/libgo/go/os/dir_gccgo.go @@ -16,9 +16,6 @@ import ( //extern pathconf func libc_pathconf(*byte, int) int -//extern fdopendir -func libc_fdopendir(int32) *syscall.DIR - func clen(n []byte) int { for i := 0; i < len(n); i++ { if n[i] == 0 { diff --git a/libgo/go/os/dir_libc64_gccgo.go b/libgo/go/os/dir_libc64_gccgo.go index dc3ba7f9228..3582243ba0d 100644 --- a/libgo/go/os/dir_libc64_gccgo.go +++ b/libgo/go/os/dir_libc64_gccgo.go @@ -10,3 +10,6 @@ import "syscall" //extern closedir64 func libc_closedir(*syscall.DIR) int + +//extern fdopendir64 +func libc_fdopendir(int32) *syscall.DIR diff --git a/libgo/go/os/dir_libc_gccgo.go b/libgo/go/os/dir_libc_gccgo.go index b46eb4cd891..a3be43bd15c 100644 --- a/libgo/go/os/dir_libc_gccgo.go +++ b/libgo/go/os/dir_libc_gccgo.go @@ -10,3 +10,6 @@ import "syscall" //extern closedir func libc_closedir(*syscall.DIR) int + +//extern fdopendir +func libc_fdopendir(int32) *syscall.DIR diff --git a/libgo/go/os/sys_aix.go b/libgo/go/os/sys_aix.go deleted file mode 100644 index 53a40f26772..00000000000 --- a/libgo/go/os/sys_aix.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 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 os - -import "syscall" - -// gethostname syscall cannot be used because it also returns the domain. -// Therefore, hostname is retrieve with uname syscall and the Nodename field. - -func hostname() (name string, err error) { - var u syscall.Utsname - if errno := syscall.Uname(&u); errno != nil { - return "", NewSyscallError("uname", errno) - } - b := make([]byte, len(u.Nodename)) - i := 0 - for ; i < len(u.Nodename); i++ { - if u.Nodename[i] == 0 { - break - } - b[i] = byte(u.Nodename[i]) - } - return string(b[:i]), nil -} diff --git a/libgo/go/runtime/malloc.go b/libgo/go/runtime/malloc.go index b6a7ee11e90..c0b4caab32a 100644 --- a/libgo/go/runtime/malloc.go +++ b/libgo/go/runtime/malloc.go @@ -218,7 +218,7 @@ const ( // we further limit it to 31 bits. // // WebAssembly currently has a limit of 4GB linear memory. - heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*sys.GoosAix + heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*(sys.GoosAix*_64bit) // maxAlloc is the maximum size of an allocation. On 64-bit, // it's theoretically possible to allocate 1<= 1e9 { - ts.tv_sec++ - ts.tv_nsec -= 1e9 + + sec := int64(ts.tv_sec) + ns/1e9 + nsec := int64(ts.tv_nsec) + ns%1e9 + if nsec >= 1e9 { + sec++ + nsec -= 1e9 + } + if sec != int64(timespec_sec_t(sec)) { + // Handle overflows (timespec_sec_t is 32-bit in 32-bit applications) + sec = 1<<31 - 1 } + ts.tv_sec = timespec_sec_t(sec) + ts.tv_nsec = timespec_nsec_t(nsec) if sem_timedwait((*semt)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 { err := errno() diff --git a/libgo/go/runtime/stubs2.go b/libgo/go/runtime/stubs2.go index 304c8e4da37..1cb910cd111 100644 --- a/libgo/go/runtime/stubs2.go +++ b/libgo/go/runtime/stubs2.go @@ -7,7 +7,6 @@ // +build !nacl // +build !js // +build !darwin -// +build !aix package runtime diff --git a/libgo/go/runtime/timestub2.go b/libgo/go/runtime/timestub2.go index 00c2c55f461..7a28603d45e 100644 --- a/libgo/go/runtime/timestub2.go +++ b/libgo/go/runtime/timestub2.go @@ -5,8 +5,6 @@ // +build !darwin // +build !windows // +build !freebsd -// +build !aix - package runtime func walltime() (sec int64, nsec int32) diff --git a/libgo/go/syscall/exec_aix_test.go b/libgo/go/syscall/exec_aix_test.go deleted file mode 100644 index 22b752cf271..00000000000 --- a/libgo/go/syscall/exec_aix_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 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. - -// +build aix - -package syscall - -import "unsafe" - -//go:cgo_import_dynamic libc_Getpgid getpgid "libc.a/shr_64.o" -//go:cgo_import_dynamic libc_Getpgrp getpgrp "libc.a/shr_64.o" - -//go:linkname libc_Getpgid libc_Getpgid -//go:linkname libc_Getpgrp libc_Getpgrp - -var ( - libc_Getpgid, - libc_Getpgrp libcFunc -) - -func Getpgid(pid int) (pgid int, err error) { - r0, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_Getpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) - pgid = int(r0) - if e1 != 0 { - err = e1 - } - return -} - -func Getpgrp() (pgrp int) { - r0, _, _ := syscall6(uintptr(unsafe.Pointer(&libc_Getpgrp)), 0, 0, 0, 0, 0, 0, 0) - pgrp = int(r0) - return -} - -var Ioctl = ioctl diff --git a/libgo/go/syscall/exec_unix.go b/libgo/go/syscall/exec_unix.go index bad2ce44302..ec21f8014dd 100644 --- a/libgo/go/syscall/exec_unix.go +++ b/libgo/go/syscall/exec_unix.go @@ -299,7 +299,6 @@ func runtime_AfterExec() // execveLibc is non-nil on OS using libc syscall, set to execve in exec_libc.go; this // avoids a build dependency for other platforms. -var execveLibc func(path uintptr, argv uintptr, envp uintptr) Errno var execveDarwin func(path *byte, argv **byte, envp **byte) error // Exec invokes the execve(2) system call. @@ -321,10 +320,7 @@ func Exec(argv0 string, argv []string, envv []string) (err error) { var err1 error if runtime.GOOS == "solaris" || runtime.GOOS == "aix" || runtime.GOOS == "hurd" { // RawSyscall should never be used on Solaris or AIX. - err1 = execveLibc( - uintptr(unsafe.Pointer(argv0p)), - uintptr(unsafe.Pointer(&argvp[0])), - uintptr(unsafe.Pointer(&envvp[0]))) + err1 = raw_execve(argv0p, &argvp[0], &envvp[0]) } else if runtime.GOOS == "darwin" { // Similarly on Darwin. err1 = execveDarwin(argv0p, &argvp[0], &envvp[0]) diff --git a/libgo/go/syscall/flock_aix.go b/libgo/go/syscall/flock_aix.go deleted file mode 100644 index c9eab43b6bc..00000000000 --- a/libgo/go/syscall/flock_aix.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 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 "unsafe" - -// On AIX, there is no flock() system call. - -// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. -func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) (err error) { - _, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_fcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/libgo/go/syscall/libcall_aix.go b/libgo/go/syscall/libcall_aix.go index 072f92a8151..8d9f59eb62f 100644 --- a/libgo/go/syscall/libcall_aix.go +++ b/libgo/go/syscall/libcall_aix.go @@ -10,6 +10,9 @@ import ( "unsafe" ) +// For exec_unix.go. +const SYS_EXECVE = 0 + //sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) //open64at(dirfd _C_int, path *byte, flags _C_int, mode Mode_t) _C_int @@ -139,3 +142,6 @@ func ReadDirent(fd int, buf []byte) (n int, err error) { func Unlinkat(dirfd int, path string) (err error) { return unlinkat(dirfd, path, 0) } + +//sys Getkerninfo(op int32, where uintptr, size uintptr, arg int64) (i int32, err error) +//getkerninfo(op _C_int, where *byte, size *byte, arg _C_long) _C_int diff --git a/libgo/go/syscall/syscall_funcs.go b/libgo/go/syscall/syscall_funcs.go new file mode 100644 index 00000000000..4b1ee321668 --- /dev/null +++ b/libgo/go/syscall/syscall_funcs.go @@ -0,0 +1,45 @@ +// Copyright 2009 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. + +// +build darwin dragonfly freebsd hurd linux netbsd openbsd solaris + +package syscall + +//extern __go_syscall6 +func syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr + +// Do a system call. We look at the size of uintptr to see how to pass +// 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() + SetErrno(0) + r := syscall6(trap, a1, a2, a3, 0, 0, 0) + err = GetErrno() + Exitsyscall() + return r, 0, err +} + +func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { + Entersyscall() + SetErrno(0) + r := syscall6(trap, a1, a2, a3, a4, a5, a6) + err = GetErrno() + Exitsyscall() + return r, 0, err +} + +func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { + SetErrno(0) + r := syscall6(trap, a1, a2, a3, 0, 0, 0) + err = GetErrno() + return r, 0, err +} + +func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { + SetErrno(0) + r := syscall6(trap, a1, a2, a3, a4, a5, a6) + err = GetErrno() + return r, 0, err +} diff --git a/libgo/go/syscall/syscall_funcs_stubs.go b/libgo/go/syscall/syscall_funcs_stubs.go new file mode 100644 index 00000000000..c68ab267dd0 --- /dev/null +++ b/libgo/go/syscall/syscall_funcs_stubs.go @@ -0,0 +1,29 @@ +// 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. + +// +build aix rtems + +// These are stubs. + +package syscall + +func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { + z := -1 + return uintptr(z), 0, ENOSYS +} + +func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { + z := -1 + return uintptr(z), 0, ENOSYS +} + +func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { + z := -1 + return uintptr(z), 0, ENOSYS +} + +func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { + z := -1 + return uintptr(z), 0, ENOSYS +} diff --git a/libgo/go/syscall/syscall_stubs.go b/libgo/go/syscall/syscall_stubs.go deleted file mode 100644 index 00288ee5ea7..00000000000 --- a/libgo/go/syscall/syscall_stubs.go +++ /dev/null @@ -1,29 +0,0 @@ -// 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. - -// +build rtems - -// These are stubs. - -package syscall - -func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} - -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} - -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} - -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} diff --git a/libgo/go/syscall/syscall_unix.go b/libgo/go/syscall/syscall_unix.go index b786dc5228b..ec8f343dccd 100644 --- a/libgo/go/syscall/syscall_unix.go +++ b/libgo/go/syscall/syscall_unix.go @@ -19,9 +19,6 @@ var ( Stderr = 2 ) -//extern __go_syscall6 -func syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr - const ( darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 @@ -29,41 +26,6 @@ const ( solaris64Bit = runtime.GOOS == "solaris" && sizeofPtr == 8 ) -// Do a system call. We look at the size of uintptr to see how to pass -// 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() - SetErrno(0) - r := syscall6(trap, a1, a2, a3, 0, 0, 0) - err = GetErrno() - Exitsyscall() - return r, 0, err -} - -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - Entersyscall() - SetErrno(0) - r := syscall6(trap, a1, a2, a3, a4, a5, a6) - err = GetErrno() - Exitsyscall() - return r, 0, err -} - -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - SetErrno(0) - r := syscall6(trap, a1, a2, a3, 0, 0, 0) - err = GetErrno() - return r, 0, err -} - -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - SetErrno(0) - r := syscall6(trap, a1, a2, a3, a4, a5, a6) - err = GetErrno() - return r, 0, err -} - // clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte. func clen(n []byte) int { for i := 0; i < len(n); i++ { diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 418ba2cfdef..c9dd8d494a9 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -1024,6 +1024,18 @@ grep '^type _ifinfomsg ' gen-sysinfo.go | \ -e 's/ifi_change/Change/' \ >> ${OUT} +# The if_msghdr struct. +grep '^type _if_msghdr ' gen-sysinfo.go | \ + sed -e 's/_if_msghdr/IfMsgHdr/' \ + -e 's/ifm_msglen/Msglen/' \ + -e 's/ifm_version/Version/' \ + -e 's/ifm_type/Type/' \ + -e 's/ifm_addrs/Addrs/' \ + -e 's/ifm_flags/Flags/' \ + -e 's/ifm_index/Index/' \ + -e 's/ifm_addrlen/Addrlen/' \ + >> ${OUT} + # The interface information types and flags. grep '^const _IFA' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} diff --git a/libgo/runtime/go-varargs.c b/libgo/runtime/go-varargs.c index cf033afbbd3..2b186ef8b81 100644 --- a/libgo/runtime/go-varargs.c +++ b/libgo/runtime/go-varargs.c @@ -96,6 +96,8 @@ __go_openat (int fd, char *path, int flags, mode_t mode) #endif +#ifdef HAVE_SYSCALL + // __go_syscall6 is called by both the runtime and syscall packages. // We use uintptr_t to make sure that the types match, since the Go // and C "int" types are not the same. @@ -106,3 +108,5 @@ __go_syscall6(uintptr_t flag, uintptr_t a1, uintptr_t a2, uintptr_t a3, { return syscall (flag, a1, a2, a3, a4, a5, a6); } + +#endif -- 2.30.2