blob: a8068f94f290c052eb8426a0748cbb293fd13728 [file] [log] [blame]
Andrea Campanella3614a922021-02-25 12:40:42 +01001// 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
khenaidood948f772021-08-11 17:49:24 -04005//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
6// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
Andrea Campanella3614a922021-02-25 12:40:42 +01007
8package unix
9
10// Set adds fd to the set fds.
11func (fds *FdSet) Set(fd int) {
12 fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
13}
14
15// Clear removes fd from the set fds.
16func (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.
21func (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.
26func (fds *FdSet) Zero() {
27 for i := range fds.Bits {
28 fds.Bits[i] = 0
29 }
30}