Skip to content

Commit 7c4c994

Browse files
committed
unix: remove raw syscall from Sendfile
Update golang/go#17490 Change-Id: Iaec54b8ffda1a24d4c8b5671185d570fb8683155 Reviewed-on: https://go-review.googlesource.com/c/154663 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 8588221 commit 7c4c994

25 files changed

+165
-62
lines changed

unix/syscall_aix.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ func Gettimeofday(tv *Timeval) (err error) {
268268
return
269269
}
270270

271+
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
272+
if raceenabled {
273+
raceReleaseMerge(unsafe.Pointer(&ioSync))
274+
}
275+
return sendfile(outfd, infd, offset, count)
276+
}
277+
271278
// TODO
272279
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
273280
return -1, ENOSYS

unix/syscall_darwin.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,18 @@ func Uname(uname *Utsname) error {
394394
return nil
395395
}
396396

397+
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
398+
if raceenabled {
399+
raceReleaseMerge(unsafe.Pointer(&ioSync))
400+
}
401+
var length = int64(count)
402+
err = sendfile(infd, outfd, *offset, &length, nil, 0)
403+
written = int(length)
404+
return
405+
}
406+
407+
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
408+
397409
/*
398410
* Exposed directly
399411
*/

unix/syscall_darwin_386.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {
4848
cmsg.Len = uint32(length)
4949
}
5050

51-
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52-
var length = uint64(count)
53-
54-
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
55-
56-
written = int(length)
57-
58-
if e1 != 0 {
59-
err = e1
60-
}
61-
return
62-
}
63-
6451
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
6552

6653
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions

unix/syscall_darwin_amd64.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package unix
88

99
import (
1010
"syscall"
11-
"unsafe"
1211
)
1312

1413
func setTimespec(sec, nsec int64) Timespec {
@@ -48,19 +47,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {
4847
cmsg.Len = uint32(length)
4948
}
5049

51-
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52-
var length = uint64(count)
53-
54-
_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
55-
56-
written = int(length)
57-
58-
if e1 != 0 {
59-
err = e1
60-
}
61-
return
62-
}
63-
6450
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
6551

6652
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions

unix/syscall_darwin_arm.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package unix
66

77
import (
88
"syscall"
9-
"unsafe"
109
)
1110

1211
func setTimespec(sec, nsec int64) Timespec {
@@ -46,19 +45,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {
4645
cmsg.Len = uint32(length)
4746
}
4847

49-
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50-
var length = uint64(count)
51-
52-
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
53-
54-
written = int(length)
55-
56-
if e1 != 0 {
57-
err = e1
58-
}
59-
return
60-
}
61-
6248
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
6349

6450
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions

unix/syscall_darwin_arm64.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package unix
88

99
import (
1010
"syscall"
11-
"unsafe"
1211
)
1312

1413
func setTimespec(sec, nsec int64) Timespec {
@@ -48,19 +47,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {
4847
cmsg.Len = uint32(length)
4948
}
5049

51-
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52-
var length = uint64(count)
53-
54-
_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
55-
56-
written = int(length)
57-
58-
if e1 != 0 {
59-
err = e1
60-
}
61-
return
62-
}
63-
6450
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
6551

6652
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions

unix/syscall_dragonfly.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ func Uname(uname *Utsname) error {
234234
return nil
235235
}
236236

237+
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
238+
if raceenabled {
239+
raceReleaseMerge(unsafe.Pointer(&ioSync))
240+
}
241+
return sendfile(outfd, infd, offset, count)
242+
}
243+
237244
/*
238245
* Exposed directly
239246
*/

unix/syscall_freebsd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ func convertFromDirents11(buf []byte, old []byte) int {
500500
return dstPos
501501
}
502502

503+
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
504+
if raceenabled {
505+
raceReleaseMerge(unsafe.Pointer(&ioSync))
506+
}
507+
return sendfile(outfd, infd, offset, count)
508+
}
509+
503510
/*
504511
* Exposed directly
505512
*/

unix/syscall_linux.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,13 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
13601360
return mount(source, target, fstype, flags, datap)
13611361
}
13621362

1363+
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
1364+
if raceenabled {
1365+
raceReleaseMerge(unsafe.Pointer(&ioSync))
1366+
}
1367+
return sendfile(outfd, infd, offset, count)
1368+
}
1369+
13631370
// Sendto
13641371
// Recvfrom
13651372
// Socketpair

unix/syscall_netbsd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ func Uname(uname *Utsname) error {
244244
return nil
245245
}
246246

247+
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
248+
if raceenabled {
249+
raceReleaseMerge(unsafe.Pointer(&ioSync))
250+
}
251+
return sendfile(outfd, infd, offset, count)
252+
}
253+
247254
/*
248255
* Exposed directly
249256
*/

0 commit comments

Comments
 (0)