]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: fix FreeBSD 386 sendfile
authorDavid G. Andersen <dave.andersen@gmail.com>
Tue, 3 Jul 2012 15:16:43 +0000 (08:16 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 3 Jul 2012 15:16:43 +0000 (08:16 -0700)
The previous version was not handling an off_t (64 bit)
parameter on 32 bit i386 systems.  This patch splits sendfile
into two implementations in their respective arch-specific files.
Tested on FreeBSD amd64 and i386.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6356048

src/pkg/syscall/syscall_freebsd.go
src/pkg/syscall/syscall_freebsd_386.go
src/pkg/syscall/syscall_freebsd_amd64.go

index a206ec0c7b7cd90d711a9a6356a226fa8f876e2a..903e5b6d1c27790a96a0dc760b322590aea2e0c7 100644 (file)
@@ -89,18 +89,6 @@ func Pipe(p []int) (err error) {
        return
 }
 
-func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
-       var writtenOut uint64 = 0
-       _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
-
-       written = int(writtenOut)
-
-       if e1 != 0 {
-               err = e1
-       }
-       return
-}
-
 func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
        var value IPMreqn
        vallen := _Socklen(SizeofIPMreqn)
index fa322c5961890bd7c4bfe8c44899720827189a3e..de670e67cbb16ba7cf5599f1e9d1c40a85fc1889 100644 (file)
@@ -4,6 +4,8 @@
 
 package syscall
 
+import "unsafe"
+
 func Getpagesize() int { return 4096 }
 
 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
@@ -41,4 +43,16 @@ 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 writtenOut uint64 = 0
+       _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
+
+       written = int(writtenOut)
+
+       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
index 488c0b9ad869c69626b7ebcce3dacedb23fd6156..46bb5c6b0e0c214f1f325d135cee90c6035138fc 100644 (file)
@@ -4,6 +4,8 @@
 
 package syscall
 
+import "unsafe"
+
 func Getpagesize() int { return 4096 }
 
 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
@@ -41,4 +43,16 @@ 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 writtenOut uint64 = 0
+       _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
+
+       written = int(writtenOut)
+
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)