Commit 9195aa17 by Ian Lance Taylor

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
parent 3b595eca
87945b620b2100d33e27f33e6276a4e4e5890659 069afe85f38c099660c5d81950d65248ed4fc516
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build hurd linux dragonfly openbsd solaris // +build aix hurd linux dragonfly openbsd solaris
package tar package tar
......
...@@ -35,7 +35,9 @@ const ( ...@@ -35,7 +35,9 @@ const (
writeLock lockType = syscall.F_WRLCK 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 { type inodeLock struct {
owner File owner File
...@@ -59,7 +61,7 @@ func lock(f File, lt lockType) (err error) { ...@@ -59,7 +61,7 @@ func lock(f File, lt lockType) (err error) {
if err != nil { if err != nil {
return err return err
} }
ino := fi.Sys().(*syscall.Stat_t).Ino ino := uint64(fi.Sys().(*syscall.Stat_t).Ino)
mu.Lock() mu.Lock()
if i, dup := inodes[f]; dup && i != ino { if i, dup := inodes[f]; dup && i != ino {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package unix
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build !aix
// +build !hurd // +build !hurd
// +build !linux // +build !linux
// +build !solaris !386 // +build !solaris !386
......
...@@ -9,17 +9,12 @@ import ( ...@@ -9,17 +9,12 @@ import (
"unsafe" "unsafe"
) )
//go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o" //extern __go_ioctl_ptr
//go:linkname libc_ioctl libc_ioctl func ioctl(int32, int32, unsafe.Pointer) int32
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)
func Ioctl(fd int, cmd int, args uintptr) (err error) { 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 ioctl(int32(fd), int32(cmd), unsafe.Pointer(args)) < 0 {
if e1 != 0 { return syscall.GetErrno()
err = e1
} }
return return
} }
...@@ -32,6 +32,8 @@ const _RTAX_NETMASK = 2 ...@@ -32,6 +32,8 @@ const _RTAX_NETMASK = 2
const _RTAX_IFA = 5 const _RTAX_IFA = 5
const _RTAX_MAX = 8 const _RTAX_MAX = 8
const _SIOCGIFMTU = -0x3fd796aa
func getIfList() ([]byte, error) { func getIfList() ([]byte, error) {
needed, err := syscall.Getkerninfo(_KINFO_RT_IFLIST, 0, 0, 0) needed, err := syscall.Getkerninfo(_KINFO_RT_IFLIST, 0, 0, 0)
if err != nil { if err != nil {
...@@ -62,7 +64,7 @@ func interfaceTable(ifindex int) ([]Interface, error) { ...@@ -62,7 +64,7 @@ func interfaceTable(ifindex int) ([]Interface, error) {
} }
if ifm.Type == syscall.RTM_IFINFO { if ifm.Type == syscall.RTM_IFINFO {
if ifindex == 0 || ifindex == int(ifm.Index) { 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 := &Interface{Index: int(ifm.Index), Flags: linkFlags(ifm.Flags)}
ifi.Name = string(sdl.Data[:sdl.Nlen]) ifi.Name = string(sdl.Data[:sdl.Nlen])
...@@ -75,7 +77,7 @@ func interfaceTable(ifindex int) ([]Interface, error) { ...@@ -75,7 +77,7 @@ func interfaceTable(ifindex int) ([]Interface, error) {
if err != nil { if err != nil {
return nil, err 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 { if err != nil {
return nil, err return nil, err
} }
...@@ -131,7 +133,7 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) { ...@@ -131,7 +133,7 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) {
if ifm.Type == syscall.RTM_NEWADDR { if ifm.Type == syscall.RTM_NEWADDR {
if ifi == nil || ifi.Index == int(ifm.Index) { if ifi == nil || ifi.Index == int(ifm.Index) {
mask := ifm.Addrs mask := ifm.Addrs
off := uint(syscall.SizeofIfMsghdr) off := uint(unsafe.Sizeof(syscall.IfMsgHdr))
var iprsa, nmrsa *syscall.RawSockaddr var iprsa, nmrsa *syscall.RawSockaddr
for i := uint(0); i < _RTAX_MAX; i++ { for i := uint(0); i < _RTAX_MAX; i++ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build aix nacl hurd js,wasm // +build nacl hurd js,wasm
package net package net
......
// 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
}
...@@ -16,9 +16,6 @@ import ( ...@@ -16,9 +16,6 @@ import (
//extern pathconf //extern pathconf
func libc_pathconf(*byte, int) int func libc_pathconf(*byte, int) int
//extern fdopendir
func libc_fdopendir(int32) *syscall.DIR
func clen(n []byte) int { func clen(n []byte) int {
for i := 0; i < len(n); i++ { for i := 0; i < len(n); i++ {
if n[i] == 0 { if n[i] == 0 {
......
...@@ -10,3 +10,6 @@ import "syscall" ...@@ -10,3 +10,6 @@ import "syscall"
//extern closedir64 //extern closedir64
func libc_closedir(*syscall.DIR) int func libc_closedir(*syscall.DIR) int
//extern fdopendir64
func libc_fdopendir(int32) *syscall.DIR
...@@ -10,3 +10,6 @@ import "syscall" ...@@ -10,3 +10,6 @@ import "syscall"
//extern closedir //extern closedir
func libc_closedir(*syscall.DIR) int func libc_closedir(*syscall.DIR) int
//extern fdopendir
func libc_fdopendir(int32) *syscall.DIR
// 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
}
...@@ -218,7 +218,7 @@ const ( ...@@ -218,7 +218,7 @@ const (
// we further limit it to 31 bits. // we further limit it to 31 bits.
// //
// WebAssembly currently has a limit of 4GB linear memory. // 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, // maxAlloc is the maximum size of an allocation. On 64-bit,
// it's theoretically possible to allocate 1<<heapAddrBits bytes. On // it's theoretically possible to allocate 1<<heapAddrBits bytes. On
...@@ -259,7 +259,7 @@ const ( ...@@ -259,7 +259,7 @@ const (
// logHeapArenaBytes is log_2 of heapArenaBytes. For clarity, // logHeapArenaBytes is log_2 of heapArenaBytes. For clarity,
// prefer using heapArenaBytes where possible (we need the // prefer using heapArenaBytes where possible (we need the
// constant to compute some other constants). // constant to compute some other constants).
logHeapArenaBytes = (6+20)*(_64bit*(1-sys.GoosWindows)*(1-sys.GoosAix)) + (2+20)*(_64bit*sys.GoosWindows) + (2+20)*(1-_64bit) + (8+20)*sys.GoosAix logHeapArenaBytes = (6+20)*(_64bit*(1-sys.GoosWindows)*(1-sys.GoosAix)) + (2+20)*(_64bit*sys.GoosWindows) + (2+20)*(1-_64bit) + (8+20)*(sys.GoosAix*_64bit)
// heapArenaBitmapBytes is the size of each heap arena's bitmap. // heapArenaBitmapBytes is the size of each heap arena's bitmap.
heapArenaBitmapBytes = heapArenaBytes / (sys.PtrSize * 8 / 2) heapArenaBitmapBytes = heapArenaBytes / (sys.PtrSize * 8 / 2)
...@@ -282,7 +282,7 @@ const ( ...@@ -282,7 +282,7 @@ const (
// //
// We use the L1 map on aix/ppc64 to keep the same L2 value // We use the L1 map on aix/ppc64 to keep the same L2 value
// as on Linux. // as on Linux.
arenaL1Bits = 6*(_64bit*sys.GoosWindows) + 12*sys.GoosAix arenaL1Bits = 6*(_64bit*sys.GoosWindows) + 12*(sys.GoosAix*_64bit)
// arenaL2Bits is the number of bits of the arena number // arenaL2Bits is the number of bits of the arena number
// covered by the second level arena index. // covered by the second level arena index.
......
...@@ -187,6 +187,11 @@ func sysReserve(v unsafe.Pointer, n uintptr) unsafe.Pointer { ...@@ -187,6 +187,11 @@ func sysReserve(v unsafe.Pointer, n uintptr) unsafe.Pointer {
func sysMap(v unsafe.Pointer, n uintptr, sysStat *uint64) { func sysMap(v unsafe.Pointer, n uintptr, sysStat *uint64) {
mSysStatInc(sysStat, n) mSysStatInc(sysStat, n)
if GOOS == "aix" {
// AIX does not allow mapping a range that is already mapped.
// So always unmap first even if it is already unmapped.
munmap(v, n)
}
p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, mmapFD, 0) p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, mmapFD, 0)
if err == _ENOMEM { if err == _ENOMEM {
throw("runtime: out of memory") throw("runtime: out of memory")
......
...@@ -37,7 +37,6 @@ const _POLLIN = 0x0001 ...@@ -37,7 +37,6 @@ const _POLLIN = 0x0001
const _POLLOUT = 0x0002 const _POLLOUT = 0x0002
const _POLLHUP = 0x2000 const _POLLHUP = 0x2000
const _POLLERR = 0x4000 const _POLLERR = 0x4000
const _O_NONBLOCK = 0x4
var ( var (
pfds []pollfd pfds []pollfd
......
...@@ -62,12 +62,19 @@ func semasleep(ns int64) int32 { ...@@ -62,12 +62,19 @@ func semasleep(ns int64) int32 {
if clock_gettime(_CLOCK_REALTIME, &ts) != 0 { if clock_gettime(_CLOCK_REALTIME, &ts) != 0 {
throw("clock_gettime") throw("clock_gettime")
} }
ts.tv_sec += ns / 1e9
ts.tv_nsec += ns % 1e9 sec := int64(ts.tv_sec) + ns/1e9
if ts.tv_nsec >= 1e9 { nsec := int64(ts.tv_nsec) + ns%1e9
ts.tv_sec++ if nsec >= 1e9 {
ts.tv_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 { if sem_timedwait((*semt)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 {
err := errno() err := errno()
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
// +build !nacl // +build !nacl
// +build !js // +build !js
// +build !darwin // +build !darwin
// +build !aix
package runtime package runtime
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
// +build !darwin // +build !darwin
// +build !windows // +build !windows
// +build !freebsd // +build !freebsd
// +build !aix
package runtime package runtime
func walltime() (sec int64, nsec int32) func walltime() (sec int64, nsec int32)
// 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
...@@ -299,7 +299,6 @@ func runtime_AfterExec() ...@@ -299,7 +299,6 @@ func runtime_AfterExec()
// execveLibc is non-nil on OS using libc syscall, set to execve in exec_libc.go; this // execveLibc is non-nil on OS using libc syscall, set to execve in exec_libc.go; this
// avoids a build dependency for other platforms. // 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 var execveDarwin func(path *byte, argv **byte, envp **byte) error
// Exec invokes the execve(2) system call. // Exec invokes the execve(2) system call.
...@@ -321,10 +320,7 @@ func Exec(argv0 string, argv []string, envv []string) (err error) { ...@@ -321,10 +320,7 @@ func Exec(argv0 string, argv []string, envv []string) (err error) {
var err1 error var err1 error
if runtime.GOOS == "solaris" || runtime.GOOS == "aix" || runtime.GOOS == "hurd" { if runtime.GOOS == "solaris" || runtime.GOOS == "aix" || runtime.GOOS == "hurd" {
// RawSyscall should never be used on Solaris or AIX. // RawSyscall should never be used on Solaris or AIX.
err1 = execveLibc( err1 = raw_execve(argv0p, &argvp[0], &envvp[0])
uintptr(unsafe.Pointer(argv0p)),
uintptr(unsafe.Pointer(&argvp[0])),
uintptr(unsafe.Pointer(&envvp[0])))
} else if runtime.GOOS == "darwin" { } else if runtime.GOOS == "darwin" {
// Similarly on Darwin. // Similarly on Darwin.
err1 = execveDarwin(argv0p, &argvp[0], &envvp[0]) err1 = execveDarwin(argv0p, &argvp[0], &envvp[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
}
...@@ -10,6 +10,9 @@ import ( ...@@ -10,6 +10,9 @@ import (
"unsafe" "unsafe"
) )
// For exec_unix.go.
const SYS_EXECVE = 0
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) //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 //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) { ...@@ -139,3 +142,6 @@ func ReadDirent(fd int, buf []byte) (n int, err error) {
func Unlinkat(dirfd int, path string) (err error) { func Unlinkat(dirfd int, path string) (err error) {
return unlinkat(dirfd, path, 0) 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
// 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
}
...@@ -2,28 +2,28 @@ ...@@ -2,28 +2,28 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build rtems // +build aix rtems
// These are stubs. // These are stubs.
package syscall package syscall
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) { func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
z := -1 z := -1
return uintptr(z), 0, uintptr(ENOSYS) return uintptr(z), 0, ENOSYS
} }
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
z := -1 z := -1
return uintptr(z), 0, uintptr(ENOSYS) return uintptr(z), 0, ENOSYS
} }
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) { func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
z := -1 z := -1
return uintptr(z), 0, uintptr(ENOSYS) return uintptr(z), 0, ENOSYS
} }
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
z := -1 z := -1
return uintptr(z), 0, uintptr(ENOSYS) return uintptr(z), 0, ENOSYS
} }
...@@ -19,9 +19,6 @@ var ( ...@@ -19,9 +19,6 @@ var (
Stderr = 2 Stderr = 2
) )
//extern __go_syscall6
func syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr
const ( const (
darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8
dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8
...@@ -29,41 +26,6 @@ const ( ...@@ -29,41 +26,6 @@ const (
solaris64Bit = runtime.GOOS == "solaris" && sizeofPtr == 8 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. // 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 { func clen(n []byte) int {
for i := 0; i < len(n); i++ { for i := 0; i < len(n); i++ {
......
...@@ -1024,6 +1024,18 @@ grep '^type _ifinfomsg ' gen-sysinfo.go | \ ...@@ -1024,6 +1024,18 @@ grep '^type _ifinfomsg ' gen-sysinfo.go | \
-e 's/ifi_change/Change/' \ -e 's/ifi_change/Change/' \
>> ${OUT} >> ${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. # The interface information types and flags.
grep '^const _IFA' gen-sysinfo.go | \ grep '^const _IFA' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
......
...@@ -96,6 +96,8 @@ __go_openat (int fd, char *path, int flags, mode_t mode) ...@@ -96,6 +96,8 @@ __go_openat (int fd, char *path, int flags, mode_t mode)
#endif #endif
#ifdef HAVE_SYSCALL
// __go_syscall6 is called by both the runtime and syscall packages. // __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 // We use uintptr_t to make sure that the types match, since the Go
// and C "int" types are not the same. // 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, ...@@ -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); return syscall (flag, a1, a2, a3, a4, a5, a6);
} }
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment