From 781a09387b575fbc446657fe573233dff0eac864 Mon Sep 17 00:00:00 2001 From: Qing Liu Date: Fri, 1 Nov 2024 16:58:34 +0800 Subject: [PATCH] support compiling on darwin --- splice/pair_darwin.go | 9 ++++----- splice/splice.go | 6 ------ splice/splice_darwin.go | 7 +++++++ splice/splice_linux.go | 9 +++++++++ 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 splice/splice_darwin.go create mode 100644 splice/splice_linux.go diff --git a/splice/pair_darwin.go b/splice/pair_darwin.go index 8780bb1a2..f09f6c091 100644 --- a/splice/pair_darwin.go +++ b/splice/pair_darwin.go @@ -4,19 +4,18 @@ package splice -import () - func (p *Pair) LoadFromAt(fd uintptr, sz int, off int64) (int, error) { panic("not implemented") - return 0, nil } func (p *Pair) LoadFrom(fd uintptr, sz int) (int, error) { panic("not implemented") - return 0, nil } func (p *Pair) WriteTo(fd uintptr, n int) (int, error) { panic("not implemented") - return 0, nil +} + +func (p *Pair) discard() { + panic("not implemented") } diff --git a/splice/splice.go b/splice/splice.go index 86560a49e..826ba552f 100644 --- a/splice/splice.go +++ b/splice/splice.go @@ -71,12 +71,6 @@ func fcntl(fd uintptr, cmd int, arg int) (val int, errno syscall.Errno) { const F_SETPIPE_SZ = 1031 const F_GETPIPE_SZ = 1032 -func osPipe() (int, int, error) { - var fds [2]int - err := syscall.Pipe2(fds[:], syscall.O_NONBLOCK) - return fds[0], fds[1], err -} - func newSplicePair() (p *Pair, err error) { p = &Pair{} p.r, p.w, err = osPipe() diff --git a/splice/splice_darwin.go b/splice/splice_darwin.go new file mode 100644 index 000000000..2a2c75369 --- /dev/null +++ b/splice/splice_darwin.go @@ -0,0 +1,7 @@ +package splice + +import "fmt" + +func osPipe() (int, int, error) { + return 0, 0, fmt.Errorf("not implemented") +} diff --git a/splice/splice_linux.go b/splice/splice_linux.go new file mode 100644 index 000000000..45ce92e66 --- /dev/null +++ b/splice/splice_linux.go @@ -0,0 +1,9 @@ +package splice + +import "syscall" + +func osPipe() (int, int, error) { + var fds [2]int + err := syscall.Pipe2(fds[:], syscall.O_NONBLOCK) + return fds[0], fds[1], err +}