You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
842 B

  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. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
  5. // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
  6. package unix
  7. // Set adds fd to the set fds.
  8. func (fds *FdSet) Set(fd int) {
  9. fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
  10. }
  11. // Clear removes fd from the set fds.
  12. func (fds *FdSet) Clear(fd int) {
  13. fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
  14. }
  15. // IsSet returns whether fd is in the set fds.
  16. func (fds *FdSet) IsSet(fd int) bool {
  17. return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
  18. }
  19. // Zero clears the set fds.
  20. func (fds *FdSet) Zero() {
  21. for i := range fds.Bits {
  22. fds.Bits[i] = 0
  23. }
  24. }