aboutsummaryrefslogtreecommitdiffstats
path: root/rwcancel/fdset.go
blob: 28746e66e82ac4dbc61708ab290c9555c16963d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* SPDX-License-Identifier: MIT
 *
 * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
 */

package rwcancel

import "golang.org/x/sys/unix"

type fdSet struct {
	unix.FdSet
}

func (fdset *fdSet) set(i int) {
	bits := 32 << (^uint(0) >> 63)
	fdset.Bits[i/bits] |= 1 << uint(i%bits)
}

func (fdset *fdSet) check(i int) bool {
	bits := 32 << (^uint(0) >> 63)
	return (fdset.Bits[i/bits] & (1 << uint(i%bits))) != 0
}