Skip to content

Commit

Permalink
make windows happy
Browse files Browse the repository at this point in the history
  • Loading branch information
winglq committed Nov 5, 2024
1 parent 3abc6b3 commit a7fea37
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 27 deletions.
18 changes: 0 additions & 18 deletions splice/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package splice

import (
"fmt"
"syscall"
)

type Pair struct {
Expand Down Expand Up @@ -42,23 +41,6 @@ func (p *Pair) Cap() int {
return p.size
}

func (p *Pair) Close() error {
err1 := syscall.Close(p.r)
err2 := syscall.Close(p.w)
if err1 != nil {
return err1
}
return err2
}

func (p *Pair) Read(d []byte) (n int, err error) {
return syscall.Read(p.r, d)
}

func (p *Pair) Write(d []byte) (n int, err error) {
return syscall.Write(p.w, d)
}

func (p *Pair) ReadFd() uintptr {
return uintptr(p.r)
}
Expand Down
12 changes: 12 additions & 0 deletions splice/pair_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ func (p *Pair) WriteTo(fd uintptr, n int) (int, error) {
func (p *Pair) discard() {
panic("not implemented")
}

func (p *Pair) Close() error {
panic("not implemented")
}

func (p *Pair) Read(d []byte) (n int, err error) {
panic("not implemented")
}

func (p *Pair) Write(d []byte) (n int, err error) {
panic("not implemented")
}
17 changes: 17 additions & 0 deletions splice/pair_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,20 @@ func (p *Pair) discard() {
log.Panicf("splicing into /dev/null: %v (close R %d '%v', close W %d '%v')", err, p.r, errR, p.w, errW)
}
}

func (p *Pair) Close() error {
err1 := syscall.Close(p.r)
err2 := syscall.Close(p.w)
if err1 != nil {
return err1
}
return err2
}

func (p *Pair) Read(d []byte) (n int, err error) {
return syscall.Read(p.r, d)
}

func (p *Pair) Write(d []byte) (n int, err error) {
return syscall.Write(p.w, d)
}
33 changes: 33 additions & 0 deletions splice/pair_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2016 the Go-FUSE Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package splice

func (p *Pair) LoadFromAt(fd uintptr, sz int, off int64) (int, error) {
panic("not implemented")
}

func (p *Pair) LoadFrom(fd uintptr, sz int) (int, error) {
panic("not implemented")
}

func (p *Pair) WriteTo(fd uintptr, n int) (int, error) {
panic("not implemented")
}

func (p *Pair) discard() {
panic("not implemented")
}

func (p *Pair) Close() error {
panic("not implemented")
}

func (p *Pair) Read(d []byte) (n int, err error) {
panic("not implemented")
}

func (p *Pair) Write(d []byte) (n int, err error) {
panic("not implemented")
}
8 changes: 0 additions & 8 deletions splice/splice.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ func init() {
devNullFD = uintptr(fd)
}

// copy & paste from syscall.
func fcntl(fd uintptr, cmd int, arg int) (val int, errno syscall.Errno) {
r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), uintptr(arg))
val = int(r0)
errno = syscall.Errno(e1)
return
}

const F_SETPIPE_SZ = 1031
const F_GETPIPE_SZ = 1032

Expand Down
13 changes: 12 additions & 1 deletion splice/splice_darwin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
package splice

import "fmt"
import (
"fmt"
"syscall"
)

// copy & paste from syscall.
func fcntl(fd uintptr, cmd int, arg int) (val int, errno syscall.Errno) {
r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), uintptr(arg))
val = int(r0)
errno = syscall.Errno(e1)
return
}

func osPipe() (int, int, error) {
return 0, 0, fmt.Errorf("not implemented")
Expand Down
8 changes: 8 additions & 0 deletions splice/splice_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ package splice

import "syscall"

// copy & paste from syscall.
func fcntl(fd uintptr, cmd int, arg int) (val int, errno syscall.Errno) {
r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), uintptr(arg))
val = int(r0)
errno = syscall.Errno(e1)
return
}

func osPipe() (int, int, error) {
var fds [2]int
err := syscall.Pipe2(fds[:], syscall.O_NONBLOCK)
Expand Down
14 changes: 14 additions & 0 deletions splice/splice_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package splice

import (
"fmt"
"syscall"
)

func osPipe() (int, int, error) {
return 0, 0, fmt.Errorf("not implemented")
}

func fcntl(fd uintptr, cmd int, arg int) (val int, errno syscall.Errno) {
return 0, syscall.Errno(1)
}

0 comments on commit a7fea37

Please sign in to comment.