mirror of
https://github.com/golang/go
synced 2024-11-13 17:00:22 -07:00
syscall: implement Sendfile for Darwin.
Update #5847 Summary: syscall: implement Sendfile for OpenBSD and NetBSD R=golang-dev, rsc, dave CC=golang-dev https://golang.org/cl/10980043
This commit is contained in:
parent
555e51f27b
commit
72faa4bc51
@ -23,4 +23,5 @@ go/build: support including C++ code with cgo (CL 8248043).
|
|||||||
io: Copy prioritizes WriterTo over ReaderFrom (CL 9462044).
|
io: Copy prioritizes WriterTo over ReaderFrom (CL 9462044).
|
||||||
net: new build tag netgo for building a pure Go net package (CL 7100050).
|
net: new build tag netgo for building a pure Go net package (CL 7100050).
|
||||||
sort: new Stable function provides stable sort (CL 9612044).
|
sort: new Stable function provides stable sort (CL 9612044).
|
||||||
|
syscall: implemented Sendfile for Darwin, added Syscall9 for Darwin/amd64 (CL 10980043).
|
||||||
testing: AllocsPerRun is now quantized to an integer (the type is still float64) (CL 9837049).
|
testing: AllocsPerRun is now quantized to an integer (the type is still float64) (CL 9837049).
|
||||||
|
@ -96,11 +96,6 @@ func Pipe(p []int) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
|
||||||
return -1, ENOSYS
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wrapped
|
* Wrapped
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
func Getpagesize() int { return 4096 }
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
@ -52,4 +54,17 @@ func (cmsg *Cmsghdr) SetLen(length int) {
|
|||||||
cmsg.Len = uint32(length)
|
cmsg.Len = uint32(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var length = uint64(count)
|
||||||
|
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 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 Errno) // sic
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // sic
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
func Getpagesize() int { return 4096 }
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
@ -51,3 +53,18 @@ func (msghdr *Msghdr) SetControllen(length int) {
|
|||||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
cmsg.Len = uint32(length)
|
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 Errno) // sic
|
||||||
|
Loading…
Reference in New Issue
Block a user