From b8ef4d11fe0d00ce0884ccf982675845b20c3ce9 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 30 May 2024 16:00:32 +0200 Subject: software: Implement serial port detection --- .../vendor/github.com/creack/goselect/fdset.go | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 software/vendor/github.com/creack/goselect/fdset.go (limited to 'software/vendor/github.com/creack/goselect/fdset.go') diff --git a/software/vendor/github.com/creack/goselect/fdset.go b/software/vendor/github.com/creack/goselect/fdset.go new file mode 100644 index 0000000..2ff3f6c --- /dev/null +++ b/software/vendor/github.com/creack/goselect/fdset.go @@ -0,0 +1,33 @@ +// +build !freebsd,!windows,!plan9 + +package goselect + +import "syscall" + +const FD_SETSIZE = syscall.FD_SETSIZE + +// FDSet wraps syscall.FdSet with convenience methods +type FDSet syscall.FdSet + +// Set adds the fd to the set +func (fds *FDSet) Set(fd uintptr) { + fds.Bits[fd/NFDBITS] |= (1 << (fd % NFDBITS)) +} + +// Clear remove the fd from the set +func (fds *FDSet) Clear(fd uintptr) { + fds.Bits[fd/NFDBITS] &^= (1 << (fd % NFDBITS)) +} + +// IsSet check if the given fd is set +func (fds *FDSet) IsSet(fd uintptr) bool { + return fds.Bits[fd/NFDBITS]&(1<<(fd%NFDBITS)) != 0 +} + +// Keep a null set to avoid reinstatiation +var nullFdSet = &FDSet{} + +// Zero empties the Set +func (fds *FDSet) Zero() { + copy(fds.Bits[:], (nullFdSet).Bits[:]) +} -- cgit v1.2.3-70-g09d2