Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Edoardo Vacchi <[email protected]>
  • Loading branch information
evacchi committed Jul 26, 2023
1 parent 361be79 commit a785d8d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 65 deletions.
16 changes: 3 additions & 13 deletions internal/sysfs/osfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
34 changes: 3 additions & 31 deletions internal/sysfs/poll_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
Expand All @@ -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.
Expand Down
22 changes: 1 addition & 21 deletions internal/sysfs/poll_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a785d8d

Please sign in to comment.