Commit 0d9c1abb authored by Russ Cox's avatar Russ Cox

replace assembly casts with unsafe.pointer

R=r
DELTA=178  (18 added, 101 deleted, 59 changed)
OCL=20822
CL=20826
parent f58567d6
......@@ -7,7 +7,8 @@ package net
import (
"os";
"syscall";
"net"
"net";
"unsafe";
)
export func IPv4ToSockaddr(p *[]byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
......@@ -23,7 +24,7 @@ export func IPv4ToSockaddr(p *[]byte, port int) (sa1 *syscall.Sockaddr, err *os.
for i := 0; i < IPv4len; i++ {
sa.addr[i] = p[i]
}
return syscall.SockaddrInet4ToSockaddr(sa), nil
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
}
export func IPv6ToSockaddr(p *[]byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
......@@ -39,20 +40,20 @@ export func IPv6ToSockaddr(p *[]byte, port int) (sa1 *syscall.Sockaddr, err *os.
for i := 0; i < IPv6len; i++ {
sa.addr[i] = p[i]
}
return syscall.SockaddrInet6ToSockaddr(sa), nil
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
}
export func SockaddrToIP(sa1 *syscall.Sockaddr) (p *[]byte, port int, err *os.Error) {
switch sa1.family {
case syscall.AF_INET:
sa := syscall.SockaddrToSockaddrInet4(sa1);
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet4);
a := ToIPv6(&sa.addr);
if a == nil {
return nil, 0, os.EINVAL
}
return a, int(sa.port[0])<<8 + int(sa.port[1]), nil;
case syscall.AF_INET6:
sa := syscall.SockaddrToSockaddrInet6(sa1);
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet6);
a := ToIPv6(&sa.addr);
if a == nil {
return nil, 0, os.EINVAL
......
......@@ -7,7 +7,8 @@ package net
import (
"os";
"syscall";
"net"
"net";
"unsafe";
)
export func IPv4ToSockaddr(p *[]byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
......@@ -22,7 +23,7 @@ export func IPv4ToSockaddr(p *[]byte, port int) (sa1 *syscall.Sockaddr, err *os.
for i := 0; i < IPv4len; i++ {
sa.addr[i] = p[i]
}
return syscall.SockaddrInet4ToSockaddr(sa), nil
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
}
var IPv6zero [16]byte;
......@@ -47,20 +48,20 @@ export func IPv6ToSockaddr(p *[]byte, port int) (sa1 *syscall.Sockaddr, err *os.
for i := 0; i < IPv6len; i++ {
sa.addr[i] = p[i]
}
return syscall.SockaddrInet6ToSockaddr(sa), nil
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
}
export func SockaddrToIP(sa1 *syscall.Sockaddr) (p *[]byte, port int, err *os.Error) {
switch sa1.family {
case syscall.AF_INET:
sa := syscall.SockaddrToSockaddrInet4(sa1);
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet4);
a := ToIPv6(&sa.addr);
if a == nil {
return nil, 0, os.EINVAL
}
return a, int(sa.port[0])<<8 + int(sa.port[1]), nil;
case syscall.AF_INET6:
sa := syscall.SockaddrToSockaddrInet6(sa1);
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet6);
a := ToIPv6(&sa.addr);
if a == nil {
return nil, 0, os.EINVAL
......
......@@ -5,7 +5,7 @@
# DO NOT EDIT. Automatically generated by gobuild.
# gobuild -m errstr_darwin.go file_darwin.go socket_darwin.go\
# syscall_amd64_darwin.go time_amd64_darwin.go types_amd64_darwin.go\
# asm_amd64_darwin.s cast_amd64.s syscall.go signal_amd64_darwin.go >Makefile
# asm_amd64_darwin.s syscall.go signal_amd64_darwin.go >Makefile
O=6
GC=$(O)g
CC=$(O)c -w
......@@ -38,7 +38,6 @@ O1=\
syscall_$(GOARCH)_$(GOOS).$O\
types_$(GOARCH)_$(GOOS).$O\
asm_$(GOARCH)_$(GOOS).$O\
cast_$(GOARCH).$O\
syscall.$O\
signal_$(GOARCH)_$(GOOS).$O\
......@@ -50,7 +49,7 @@ O2=\
syscall.a: a1 a2
a1: $(O1)
$(AR) grc syscall.a errstr_$(GOOS).$O syscall_$(GOARCH)_$(GOOS).$O types_$(GOARCH)_$(GOOS).$O asm_$(GOARCH)_$(GOOS).$O cast_$(GOARCH).$O syscall.$O signal_$(GOARCH)_$(GOOS).$O
$(AR) grc syscall.a errstr_$(GOOS).$O syscall_$(GOARCH)_$(GOOS).$O types_$(GOARCH)_$(GOOS).$O asm_$(GOARCH)_$(GOOS).$O syscall.$O signal_$(GOARCH)_$(GOOS).$O
rm -f $(O1)
a2: $(O2)
......
// 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.
// conversion operators - really just casts
TEXT syscall·BytePtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·BytePtrPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·Int32Ptr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·Int64Ptr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·KeventPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·EpollEventPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·LingerPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·SockaddrPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·StatPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·TimespecPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·TimevalPtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·RusagePtr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·SockaddrToSockaddrInet4(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·SockaddrToSockaddrInet6(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·SockaddrInet4ToSockaddr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
TEXT syscall·SockaddrInet6ToSockaddr(SB),7,$-8
MOVQ 8(SP), AX
MOVQ AX, 16(SP)
RET
......@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
// File operations for Darwin
import syscall "syscall"
package syscall
import (
"syscall";
"unsafe";
)
const NameBufsize = 512
......@@ -15,7 +18,7 @@ export func open(name string, mode int64, perm int64) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]), mode, perm);
r1, r2, err := Syscall(SYS_OPEN, int64(uintptr(unsafe.pointer(&namebuf[0]))), mode, perm);
return r1, err;
}
......@@ -24,7 +27,7 @@ export func creat(name string, perm int64) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]), O_CREAT|O_WRONLY|O_TRUNC, perm);
r1, r2, err := Syscall(SYS_OPEN, int64(uintptr(unsafe.pointer(&namebuf[0]))), O_CREAT|O_WRONLY|O_TRUNC, perm);
return r1, err;
}
......@@ -34,12 +37,12 @@ export func close(fd int64) (ret int64, errno int64) {
}
export func read(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_READ, fd, BytePtr(buf), nbytes);
r1, r2, err := Syscall(SYS_READ, fd, int64(uintptr(unsafe.pointer(buf))), nbytes);
return r1, err;
}
export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_WRITE, fd, BytePtr(buf), nbytes);
r1, r2, err := Syscall(SYS_WRITE, fd, int64(uintptr(unsafe.pointer(buf))), nbytes);
return r1, err;
}
......@@ -58,17 +61,17 @@ export func stat(name string, buf *Stat) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_STAT64, BytePtr(&namebuf[0]), StatPtr(buf), 0);
r1, r2, err := Syscall(SYS_STAT64, int64(uintptr(unsafe.pointer(&namebuf[0]))), int64(uintptr(unsafe.pointer(buf))), 0);
return r1, err;
}
export func lstat(name *byte, buf *Stat) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_LSTAT, BytePtr(name), StatPtr(buf), 0);
r1, r2, err := Syscall(SYS_LSTAT, int64(uintptr(unsafe.pointer(name))), int64(uintptr(unsafe.pointer(buf))), 0);
return r1, err;
}
export func fstat(fd int64, buf *Stat) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_FSTAT, fd, StatPtr(buf), 0);
r1, r2, err := Syscall(SYS_FSTAT, fd, int64(uintptr(unsafe.pointer(buf))), 0);
return r1, err;
}
......@@ -77,7 +80,7 @@ export func unlink(name string) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_UNLINK, BytePtr(&namebuf[0]), 0, 0);
r1, r2, err := Syscall(SYS_UNLINK, int64(uintptr(unsafe.pointer(&namebuf[0]))), 0, 0);
return r1, err;
}
......@@ -91,7 +94,7 @@ export func mkdir(name string, perm int64) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_MKDIR, BytePtr(&namebuf[0]), perm, 0);
r1, r2, err := Syscall(SYS_MKDIR, int64(uintptr(unsafe.pointer(&namebuf[0]))), perm, 0);
return r1, err;
}
......
......@@ -6,7 +6,10 @@ package syscall
// File operations for Linux
import syscall "syscall"
import (
"syscall";
"unsafe";
)
const NameBufsize = 512
......@@ -15,7 +18,7 @@ export func open(name string, mode int64, perm int64) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]), mode, perm);
r1, r2, err := Syscall(SYS_OPEN, int64(uintptr(unsafe.pointer(&namebuf[0]))), mode, perm);
return r1, err;
}
......@@ -24,7 +27,7 @@ export func creat(name string, perm int64) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]), O_CREAT|O_WRONLY|O_TRUNC, perm);
r1, r2, err := Syscall(SYS_OPEN, int64(uintptr(unsafe.pointer(&namebuf[0]))), O_CREAT|O_WRONLY|O_TRUNC, perm);
return r1, err;
}
......@@ -34,18 +37,18 @@ export func close(fd int64) (ret int64, errno int64) {
}
export func read(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_READ, fd, BytePtr(buf), nbytes);
r1, r2, err := Syscall(SYS_READ, fd, int64(uintptr(unsafe.pointer(buf))), nbytes);
return r1, err;
}
export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_WRITE, fd, BytePtr(buf), nbytes);
r1, r2, err := Syscall(SYS_WRITE, fd, int64(uintptr(unsafe.pointer(buf))), nbytes);
return r1, err;
}
export func pipe(fds *[2]int64) (ret int64, errno int64) {
var t [2] int32;
r1, r2, err := Syscall(SYS_PIPE, Int32Ptr(&t[0]), 0, 0);
r1, r2, err := Syscall(SYS_PIPE, int64(uintptr(unsafe.pointer(&t[0]))), 0, 0);
if r1 < 0 {
return r1, err;
}
......@@ -59,17 +62,17 @@ export func stat(name string, buf *Stat) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_STAT, BytePtr(&namebuf[0]), StatPtr(buf), 0);
r1, r2, err := Syscall(SYS_STAT, int64(uintptr(unsafe.pointer(&namebuf[0]))), int64(uintptr(unsafe.pointer(buf))), 0);
return r1, err;
}
export func lstat(name *byte, buf *Stat) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_LSTAT, BytePtr(name), StatPtr(buf), 0);
r1, r2, err := Syscall(SYS_LSTAT, int64(uintptr(unsafe.pointer(name))), int64(uintptr(unsafe.pointer(buf))), 0);
return r1, err;
}
export func fstat(fd int64, buf *Stat) (ret int64, errno int64) {
r1, r2, err := Syscall(SYS_FSTAT, fd, StatPtr(buf), 0);
r1, r2, err := Syscall(SYS_FSTAT, fd, int64(uintptr(unsafe.pointer(buf))), 0);
return r1, err;
}
......@@ -78,7 +81,7 @@ export func unlink(name string) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_UNLINK, BytePtr(&namebuf[0]), 0, 0);
r1, r2, err := Syscall(SYS_UNLINK, int64(uintptr(unsafe.pointer(&namebuf[0]))), 0, 0);
return r1, err;
}
......@@ -92,7 +95,7 @@ export func mkdir(name string, perm int64) (ret int64, errno int64) {
if !StringToBytes(&namebuf, name) {
return -1, ENAMETOOLONG
}
r1, r2, err := Syscall(SYS_MKDIR, BytePtr(&namebuf[0]), perm, 0);
r1, r2, err := Syscall(SYS_MKDIR, int64(uintptr(unsafe.pointer(&namebuf[0]))), perm, 0);
return r1, err;
}
......
......@@ -7,7 +7,10 @@
// DO NOT USE DIRECTLY.
package syscall
import "syscall"
import (
"syscall";
"unsafe";
)
export func SockaddrToSockaddrInet4(s *Sockaddr) *SockaddrInet4;
export func SockaddrToSockaddrInet6(s *Sockaddr) *SockaddrInet6;
......@@ -20,12 +23,12 @@ export func socket(domain, proto, typ int64) (ret int64, err int64) {
}
export func connect(fd int64, sa *Sockaddr) (ret int64, err int64) {
r1, r2, e := Syscall(SYS_CONNECT, fd, SockaddrPtr(sa), int64(sa.len));
r1, r2, e := Syscall(SYS_CONNECT, fd, int64(uintptr(unsafe.pointer(sa))), int64(sa.len));
return r1, e
}
export func bind(fd int64, sa *Sockaddr) (ret int64, err int64) {
r1, r2, e := Syscall(SYS_BIND, fd, SockaddrPtr(sa), int64(sa.len));
r1, r2, e := Syscall(SYS_BIND, fd, int64(uintptr(unsafe.pointer(sa))), int64(sa.len));
return r1, e
}
......@@ -36,7 +39,7 @@ export func listen(fd, n int64) (ret int64, err int64) {
export func accept(fd int64, sa *Sockaddr) (ret int64, err int64) {
var n int32 = SizeofSockaddr;
r1, r2, e := Syscall(SYS_ACCEPT, fd, SockaddrPtr(sa), Int32Ptr(&n));
r1, r2, e := Syscall(SYS_ACCEPT, fd, int64(uintptr(unsafe.pointer(sa))), int64(uintptr(unsafe.pointer(&n))));
return r1, e
}
......@@ -50,7 +53,7 @@ export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err i
export func setsockopt_int(fd, level, opt int64, value int) int64 {
var n int32 = int32(opt);
r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4);
r1, e := setsockopt(fd, level, opt, int64(uintptr(unsafe.pointer(&n))), 4);
return e
}
......@@ -59,7 +62,7 @@ export func setsockopt_tv(fd, level, opt, nsec int64) int64 {
nsec += 999;
tv.sec = int64(nsec/1000000000);
tv.usec = uint32(nsec%1000000000);
r1, e := setsockopt(fd, level, opt, TimevalPtr(&tv), 4);
r1, e := setsockopt(fd, level, opt, int64(uintptr(unsafe.pointer(&tv))), 4);
return e
}
......@@ -72,7 +75,7 @@ export func setsockopt_linger(fd, level, opt int64, sec int) int64 {
l.yes = 0;
l.sec = 0;
}
r1, err := setsockopt(fd, level, opt, LingerPtr(&l), 8);
r1, err := setsockopt(fd, level, opt, int64(uintptr(unsafe.pointer(&l))), 8);
return err
}
......@@ -95,15 +98,15 @@ export func kevent(kq int64, changes, events *[]Kevent, timeout *Timespec) (ret
nevent = 0;
eventptr = 0;
if changes != nil && len(changes) > 0 {
changeptr = KeventPtr(&changes[0]);
changeptr = int64(uintptr(unsafe.pointer(&changes[0])));
nchange = int64(len(changes))
}
if events != nil && len(events) > 0 {
eventptr = KeventPtr(&events[0]);
eventptr = int64(uintptr(unsafe.pointer(&events[0])));
nevent = int64(len(events))
}
r1, r2, err := Syscall6(SYS_KEVENT, kq, changeptr, nchange,
eventptr, nevent, TimespecPtr(timeout));
eventptr, nevent, int64(uintptr(unsafe.pointer(timeout))));
return r1, err
}
......@@ -7,7 +7,10 @@
// DO NOT USE DIRECTLY.
package syscall
import "syscall"
import (
"syscall";
"unsafe";
)
export func SockaddrToSockaddrInet4(s *Sockaddr) *SockaddrInet4;
export func SockaddrToSockaddrInet6(s *Sockaddr) *SockaddrInet6;
......@@ -32,12 +35,12 @@ export func socket(domain, proto, typ int64) (ret int64, err int64) {
}
export func connect(fd int64, sa *Sockaddr) (ret int64, err int64) {
r1, r2, e := Syscall(SYS_CONNECT, fd, SockaddrPtr(sa), Len(sa));
r1, r2, e := Syscall(SYS_CONNECT, fd, int64(uintptr(unsafe.pointer(sa))), Len(sa));
return r1, e
}
export func bind(fd int64, sa *Sockaddr) (ret int64, err int64) {
r1, r2, e := Syscall(SYS_BIND, fd, SockaddrPtr(sa), Len(sa));
r1, r2, e := Syscall(SYS_BIND, fd, int64(uintptr(unsafe.pointer(sa))), Len(sa));
return r1, e
}
......@@ -48,7 +51,7 @@ export func listen(fd, n int64) (ret int64, err int64) {
export func accept(fd int64, sa *Sockaddr) (ret int64, err int64) {
var n int32 = SizeofSockaddr;
r1, r2, e := Syscall(SYS_ACCEPT, fd, SockaddrPtr(sa), Int32Ptr(&n));
r1, r2, e := Syscall(SYS_ACCEPT, fd, int64(uintptr(unsafe.pointer(sa))), int64(uintptr(unsafe.pointer(&n))));
return r1, e
}
......@@ -62,7 +65,7 @@ export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err i
export func setsockopt_int(fd, level, opt int64, value int) int64 {
n := int32(opt);
r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4);
r1, e := setsockopt(fd, level, opt, int64(uintptr(unsafe.pointer(&n))), 4);
return e
}
......@@ -71,7 +74,7 @@ export func setsockopt_tv(fd, level, opt, nsec int64) int64 {
nsec += 999;
tv.sec = int64(nsec/1000000000);
tv.usec = uint64(nsec%1000000000);
r1, e := setsockopt(fd, level, opt, TimevalPtr(&tv), 4);
r1, e := setsockopt(fd, level, opt, int64(uintptr(unsafe.pointer(&tv))), 4);
return e
}
......@@ -84,7 +87,7 @@ export func setsockopt_linger(fd, level, opt int64, sec int) int64 {
l.yes = 0;
l.sec = 0
}
r1, err := setsockopt(fd, level, opt, LingerPtr(&l), 8);
r1, err := setsockopt(fd, level, opt, int64(uintptr(unsafe.pointer(&l))), 8);
return err
}
......@@ -101,7 +104,7 @@ export func epoll_create(size int64) (ret int64, errno int64) {
}
export func epoll_ctl(epfd, op, fd int64, ev *EpollEvent) int64 {
r1, r2, err := syscall.Syscall6(SYS_EPOLL_CTL, epfd, op, fd, EpollEventPtr(ev), 0, 0);
r1, r2, err := syscall.Syscall6(SYS_EPOLL_CTL, epfd, op, fd, int64(uintptr(unsafe.pointer(ev))), 0, 0);
return err
}
......@@ -109,7 +112,7 @@ export func epoll_wait(epfd int64, ev *[]EpollEvent, msec int64) (ret int64, err
var evptr, nev int64;
if ev != nil && len(ev) > 0 {
nev = int64(len(ev));
evptr = EpollEventPtr(&ev[0])
evptr = int64(uintptr(unsafe.pointer(&ev[0])))
}
r1, r2, err1 := syscall.Syscall6(SYS_EPOLL_WAIT, epfd, evptr, nev, msec, 0, 0);
return r1, err1
......
......@@ -12,11 +12,6 @@ export func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
export func Syscall6(trap int64, a1, a2, a3, a4, a5, a6 int64) (r1, r2, err int64);
export func RawSyscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
export func BytePtr(b *byte) int64;
export func Int32Ptr(p *int32) int64;
export func Int64Ptr(p *int64) int64;
export func BytePtrPtr(b **byte) int64;
/*
* Used to convert file names to byte arrays for passing to kernel,
* but useful elsewhere too.
......
......@@ -4,11 +4,14 @@
package syscall
import syscall "syscall"
import (
"syscall";
"unsafe";
)
export func gettimeofday() (sec, nsec, errno int64) {
var tv Timeval;
r1, r2, e := Syscall(SYS_GETTIMEOFDAY, TimevalPtr(&tv), 0, 0);
r1, r2, e := Syscall(SYS_GETTIMEOFDAY, int64(uintptr(unsafe.pointer(&tv))), 0, 0);
if e != 0 {
return 0, 0, e
}
......
......@@ -14,13 +14,11 @@ export type Timespec struct {
sec int64;
nsec uint64;
}
export func TimespecPtr(t *Timespec) int64;
export type Timeval struct {
sec int64;
usec uint32;
}
export func TimevalPtr(t *Timeval) int64;
// Processes
......@@ -43,7 +41,6 @@ export type Rusage struct {
nvcsw int64;
nivcsw int64;
}
export func RusagePtr(r *Rusage) int64;
// Files
......@@ -91,7 +88,6 @@ export type Stat struct {
lspare uint32;
qspare [2]uint64;
}
export func StatPtr(s *Stat) int64;
// Sockets
......@@ -163,13 +159,11 @@ export type Sockaddr struct {
opaque [126]byte
}
export const SizeofSockaddr = 128
export func SockaddrPtr(s *Sockaddr) int64;
export type Linger struct {
yes int32;
sec int32;
}
export func LingerPtr(l *Linger) int64;
// Events (kqueue, kevent)
......@@ -215,5 +209,4 @@ export type Kevent struct {
data int64;
udata int64;
}
export func KeventPtr(e *Kevent) int64;
......@@ -14,13 +14,11 @@ export type Timespec struct {
sec int64;
nsec uint64;
}
export func TimespecPtr(t *Timespec) int64;
export type Timeval struct {
sec int64;
usec uint64;
}
export func TimevalPtr(t *Timeval) int64;
// Processes
......@@ -43,7 +41,6 @@ export type Rusage struct {
nvcsw int64;
nivcsw int64;
}
export func RusagePtr(r *Rusage) int64;
// Files
......@@ -87,7 +84,6 @@ export type Stat struct {
ctime Timespec;
_unused [3]int64
}
export func StatPtr(s *Stat) int64;
// Sockets
......@@ -165,13 +161,11 @@ export type Sockaddr struct {
opaque [126]byte
}
export const SizeofSockaddr = 128
export func SockaddrPtr(s *Sockaddr) int64;
export type Linger struct {
yes int32;
sec int32;
}
export func LingerPtr(l *Linger) int64;
// Events (epoll)
......@@ -197,4 +191,3 @@ export type EpollEvent struct {
fd int32;
pad int32;
}
export func EpollEventPtr(ev *EpollEvent) int64;
......@@ -6,7 +6,8 @@ package time
import (
"syscall";
"time"
"time";
"unsafe";
)
// TODO(rsc): This implementation of time.Tick is a
......@@ -42,7 +43,7 @@ func Ticker(ns int64, c *chan int64) {
}
syscall.nstotimeval(when - now, &tv);
syscall.Syscall6(syscall.SYS_SELECT, 0, 0, 0, 0, syscall.TimevalPtr(&tv), 0);
syscall.Syscall6(syscall.SYS_SELECT, 0, 0, 0, 0, int64(uintptr(unsafe.pointer(&tv))), 0);
now = time.Nanoseconds();
c <- now;
}
......
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