//go:build !tinygo

package sysfs

import (
	
	
	

	
)

// pollFd is the struct to query for file descriptor events using poll.
type pollFd struct {
	// fd is the file descriptor.
	fd int32
	// events is a bitmap containing the requested events.
	events int16
	// revents is a bitmap containing the returned events.
	revents int16
}

// newPollFd is a constructor for pollFd that abstracts the platform-specific type of file descriptors.
func newPollFd( uintptr, ,  int16) pollFd {
	return pollFd{fd: int32(), events: , revents: }
}

// _POLLIN subscribes a notification when any readable data is available.
const _POLLIN = 0x0001

// _poll implements poll on Linux via ppoll.
func _poll( []pollFd,  int32) ( int,  sys.Errno) {
	var  syscall.Timespec
	if  >= 0 {
		 = syscall.NsecToTimespec(int64(time.Duration() * time.Millisecond))
	}
	return ppoll(, &)
}

// ppoll is a poll variant that allows to subscribe to a mask of signals.
// However, we do not need such mask, so the corresponding argument is always nil.
func ppoll( []pollFd,  *syscall.Timespec) ( int,  sys.Errno) {
	var  *pollFd
	 := len()
	if  != 0 {
		 = &[0]
	}

	, ,  := syscall.Syscall6(
		uintptr(syscall.SYS_PPOLL),
		uintptr(unsafe.Pointer()),
		uintptr(),
		uintptr(unsafe.Pointer()),
		uintptr(unsafe.Pointer(nil)), // sigmask is currently always ignored
		uintptr(unsafe.Pointer(nil)),
		uintptr(unsafe.Pointer(nil)))

	return int(), sys.UnwrapOSError()
}