-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes golang/go#10239. Change-Id: I3ae657b57ca7bef31207780477c44939c0bdc8b5 Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/10185 Reviewed-by: Rob Pike <r@golang.org>
- Loading branch information
Showing
7 changed files
with
3,645 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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 !gccgo | ||
// +build arm64,darwin | ||
|
||
#include "textflag.h" | ||
|
||
// | ||
// System call support for AMD64, Darwin | ||
// | ||
|
||
// Just jump to package syscall's implementation for all these functions. | ||
// The runtime may know about them. | ||
|
||
TEXT ·Syscall(SB),NOSPLIT,$0-56 | ||
B syscall·Syscall(SB) | ||
|
||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 | ||
B syscall·Syscall6(SB) | ||
|
||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 | ||
B syscall·Syscall9(SB) | ||
|
||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 | ||
B syscall·RawSyscall(SB) | ||
|
||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 | ||
B syscall·RawSyscall6(SB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,11 @@ darwin_arm) | |
mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h" | ||
mktypes="GOARCH=$GOARCH go tool cgo -godefs" | ||
;; | ||
darwin_arm64) | ||
mkerrors="$mkerrors -m64" | ||
mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
minux
via email
Author
Member
|
||
mktypes="GOARCH=$GOARCH go tool cgo -godefs" | ||
;; | ||
dragonfly_386) | ||
mkerrors="$mkerrors -m32" | ||
mksyscall="./mksyscall.pl -l32 -dragonfly" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// 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 arm64,darwin | ||
|
||
package unix | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
func Getpagesize() int { return 16384 } | ||
|
||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } | ||
|
||
func NsecToTimespec(nsec int64) (ts Timespec) { | ||
ts.Sec = nsec / 1e9 | ||
ts.Nsec = nsec % 1e9 | ||
return | ||
} | ||
|
||
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } | ||
|
||
func NsecToTimeval(nsec int64) (tv Timeval) { | ||
nsec += 999 // round up to microsecond | ||
tv.Usec = int32(nsec % 1e9 / 1e3) | ||
tv.Sec = int64(nsec / 1e9) | ||
return | ||
} | ||
|
||
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) | ||
func Gettimeofday(tv *Timeval) (err error) { | ||
// The tv passed to gettimeofday must be non-nil | ||
// but is otherwise unused. The answers come back | ||
// in the two registers. | ||
sec, usec, err := gettimeofday(tv) | ||
tv.Sec = sec | ||
tv.Usec = usec | ||
return err | ||
} | ||
|
||
func SetKevent(k *Kevent_t, fd, mode, flags int) { | ||
k.Ident = uint64(fd) | ||
k.Filter = int16(mode) | ||
k.Flags = uint16(flags) | ||
} | ||
|
||
func (iov *Iovec) SetLen(length int) { | ||
iov.Len = uint64(length) | ||
} | ||
|
||
func (msghdr *Msghdr) SetControllen(length int) { | ||
msghdr.Controllen = uint32(length) | ||
} | ||
|
||
func (cmsg *Cmsghdr) SetLen(length int) { | ||
cmsg.Len = uint32(length) | ||
} | ||
|
||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { | ||
var length = uint64(count) | ||
|
||
_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) | ||
|
||
written = int(length) | ||
|
||
if e1 != 0 { | ||
err = e1 | ||
} | ||
return | ||
} | ||
|
||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic |
Oops, something went wrong.
@minux (or anybody else who can answer), can you help me with two questions?
/usr/include
?