diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-10-25 00:47:47 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-10-25 00:47:47 +0200 |
| commit | c6cc0108ca7738023b45e0eeac0fa2390532dd93 (patch) | |
| tree | 36890e6cd3091bbab8efbe686cc56f467f645bfd /vendor/golang.org/x/sys/unix/fdset.go | |
| parent | 0130404a1dc663d4aa68d780c9bcb23a4243e68d (diff) | |
| download | jbmafp-c6cc0108ca7738023b45e0eeac0fa2390532dd93.tar.gz | |
Diffstat (limited to 'vendor/golang.org/x/sys/unix/fdset.go')
| -rw-r--r-- | vendor/golang.org/x/sys/unix/fdset.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/fdset.go b/vendor/golang.org/x/sys/unix/fdset.go new file mode 100644 index 0000000..a8068f9 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/fdset.go | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | // Copyright 2019 The Go Authors. All rights reserved. | ||
| 2 | // Use of this source code is governed by a BSD-style | ||
| 3 | // license that can be found in the LICENSE file. | ||
| 4 | |||
| 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos | ||
| 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos | ||
| 7 | |||
| 8 | package unix | ||
| 9 | |||
| 10 | // Set adds fd to the set fds. | ||
| 11 | func (fds *FdSet) Set(fd int) { | ||
| 12 | fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS)) | ||
| 13 | } | ||
| 14 | |||
| 15 | // Clear removes fd from the set fds. | ||
| 16 | func (fds *FdSet) Clear(fd int) { | ||
| 17 | fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS)) | ||
| 18 | } | ||
| 19 | |||
| 20 | // IsSet returns whether fd is in the set fds. | ||
| 21 | func (fds *FdSet) IsSet(fd int) bool { | ||
| 22 | return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0 | ||
| 23 | } | ||
| 24 | |||
| 25 | // Zero clears the set fds. | ||
| 26 | func (fds *FdSet) Zero() { | ||
| 27 | for i := range fds.Bits { | ||
| 28 | fds.Bits[i] = 0 | ||
| 29 | } | ||
| 30 | } | ||
