Dont use the syscall package

This commit is contained in:
Kovid Goyal
2022-08-25 05:46:51 +05:30
parent e68b5fa504
commit 9be2247081
5 changed files with 25 additions and 39 deletions

View File

@@ -2,26 +2,13 @@ package utils
import (
"io"
"syscall"
"time"
"golang.org/x/sys/unix"
)
const (
DEFAULT_IO_BUFFER_SIZE = 8192
)
func NsecToTimespec(d time.Duration) unix.Timespec {
nv := syscall.NsecToTimespec(int64(d))
return unix.Timespec{Sec: nv.Sec, Nsec: nv.Nsec}
}
func NsecToTimeval(d time.Duration) unix.Timeval {
nv := syscall.NsecToTimeval(int64(d))
return unix.Timeval{Sec: nv.Sec, Usec: nv.Usec}
}
type BytesReader struct {
Data []byte
}

View File

@@ -12,6 +12,6 @@ func Select(nfd int, r *unix.FdSet, w *unix.FdSet, e *unix.FdSet, timeout time.D
if timeout < 0 {
return unix.Pselect(nfd, r, w, e, nil, nil)
}
ts := NsecToTimespec(timeout)
ts := unix.NsecToTimespec(int64(timeout))
return unix.Pselect(nfd, r, w, e, &ts, nil)
}

View File

@@ -14,6 +14,6 @@ func Select(nfd int, r *unix.FdSet, w *unix.FdSet, e *unix.FdSet, timeout time.D
if timeout < 0 {
return unix.Select(nfd, r, w, e, nil)
}
ts := NsecToTimeval(timeout)
ts := unix.NsecToTimeval(int64(timeout))
return unix.Select(nfd, r, w, e, &ts)
}