From a785d8d860cd69c7d1b7e8d2d1fa0fa1461cd6e5 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Wed, 26 Jul 2023 16:34:06 +0200 Subject: [PATCH] formatting Signed-off-by: Edoardo Vacchi --- internal/sysfs/osfile.go | 16 +++------------- internal/sysfs/poll_darwin.go | 34 +++------------------------------- internal/sysfs/poll_linux.go | 22 +--------------------- 3 files changed, 7 insertions(+), 65 deletions(-) diff --git a/internal/sysfs/osfile.go b/internal/sysfs/osfile.go index 48c98a284a8..31b7f6917ea 100644 --- a/internal/sysfs/osfile.go +++ b/internal/sysfs/osfile.go @@ -183,22 +183,12 @@ func (f *osFile) Seek(offset int64, whence int) (newOffset int64, errno experime // PollRead implements the same method as documented on fsapi.File func (f *osFile) PollRead(timeout *time.Duration) (ready bool, errno experimentalsys.Errno) { - // fdSet := platform.FdSet{} - // fd := int(f.fd) - // fdSet.Set(fd) - // nfds := fd + 1 // See https://man7.org/linux/man-pages/man2/select.2.html#:~:text=condition%20has%20occurred.-,nfds,-This%20argument%20should - // count, err := _select(nfds, &fdSet, nil, nil, timeout) - fds := PollFd{ + fds := []PollFd{{ fd: int32(f.fd), events: _POLLIN, revents: 0, - } - - count, errno := Poll([]PollFd{fds}, timeout) - //if errno = experimentalsys.UnwrapOSError(err); errno != 0 { - // // Defer validation overhead until we've already had an error. - // errno = fileError(f, f.closed, errno) - //} + }} + count, errno := Poll(fds, timeout) return count > 0, errno } diff --git a/internal/sysfs/poll_darwin.go b/internal/sysfs/poll_darwin.go index 01fb731722b..6881101f87b 100644 --- a/internal/sysfs/poll_darwin.go +++ b/internal/sysfs/poll_darwin.go @@ -7,35 +7,8 @@ import ( ) const ( - _POLLIN = 0x0001 /* any readable data available */ - _POLLPRI = 0x0002 /* OOB/Urgent readable data */ - _POLLOUT = 0x0004 /* file descriptor is writeable */ - _POLLRDNORM = 0x0040 /* non-OOB/URG data available */ - _POLLWRNORM = _POLLOUT /* no write type differentiation */ - _POLLRDBAND = 0x0080 /* OOB/Urgent readable data */ - _POLLWRBAND = 0x0100 /* OOB/Urgent data can be written */) - -// -///* -// * FreeBSD extensions: polling on a regular file might return one -// * of these events (currently only supported on local filesystems). -// */ -//const ( -// _POLLEXTEND = 0x0200 /* file may have been extended */ -// _POLLATTRIB = 0x0400 /* file attributes may have changed */ -// _POLLNLINK = 0x0800 /* (un)link/rename may have happened */ -// _POLLWRITE = 0x1000 /* file's contents may have changed */) - -///* -// * These events are set if they occur regardless of whether they were -// * requested. -// */ -//const ( -// _POLLERR = 0x0008 /* some poll error occurred */ -// _POLLHUP = 0x0010 /* file descriptor was "hung up" */ -// _POLLNVAL = 0x0020 /* requested events "invalid" */) -// -//const _POLLSTANDARD = (_POLLIN | _POLLPRI | _POLLOUT | _POLLRDNORM | _POLLRDBAND | _POLLWRBAND | _POLLERR | _POLLHUP | _POLLNVAL) + _POLLIN = 0x0001 /* any readable data available */ +) func poll(fds []PollFd, timeout int) (n int, err sys.Errno) { nilptr := unsafe.Pointer(nil) @@ -45,7 +18,6 @@ func poll(fds []PollFd, timeout int) (n int, err sys.Errno) { } n1, _, errno := syscall_syscall6( libc_poll_trampoline_addr, - // 417, uintptr(fdptr), uintptr(len(fds)), uintptr(timeout), @@ -61,7 +33,7 @@ func poll(fds []PollFd, timeout int) (n int, err sys.Errno) { // We use this to invoke the syscall through syscall_syscall6 imported below. var libc_poll_trampoline_addr uintptr -// Imports the select symbol from libc as `libc_select`. +// Imports the select symbol from libc as `libc_poll`. // // Note: CGO mechanisms are used in darwin regardless of the CGO_ENABLED value // or the "cgo" build flag. See /RATIONALE.md for why. diff --git a/internal/sysfs/poll_linux.go b/internal/sysfs/poll_linux.go index b550b12634b..83ecd7c4311 100644 --- a/internal/sysfs/poll_linux.go +++ b/internal/sysfs/poll_linux.go @@ -9,29 +9,9 @@ import ( /* These are specified by iBCS2 */ const ( - _POLLIN = 0x0001 - _POLLPRI = 0x0002 - _POLLOUT = 0x0004 - _POLLERR = 0x0008 - _POLLHUP = 0x0010 - _POLLNVAL = 0x0020 + _POLLIN = 0x0001 ) -/* The rest seem to be more-or-less nonstandard. Check them! */ -const ( - _POLLRDNORM = 0x0040 - _POLLRDBAND = 0x0080 - _POLLWRNORM = 0x0100 - _POLLWRBAND = 0x0200 - _POLLMSG = 0x0400 - _POLLREMOVE = 0x1000 - _POLLRDHUP = 0x2000 -) - -const _POLLFREE = 0x4000 /* currently only for epoll */ - -const _POLL_BUSY_LOOP = 0x8000 - const ( _NSIG = 64 _NSIG_BPW = 32