2020-02-19 15:09:24 +00:00
|
|
|
// +build !windows
|
|
|
|
|
2019-01-02 00:55:51 +00:00
|
|
|
/* SPDX-License-Identifier: MIT
|
2018-05-17 22:58:54 +00:00
|
|
|
*
|
2019-01-02 00:55:51 +00:00
|
|
|
* Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
|
2018-05-17 22:58:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package rwcancel
|
|
|
|
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
|
|
|
|
type fdSet struct {
|
2019-01-03 18:04:00 +00:00
|
|
|
unix.FdSet
|
2018-05-17 22:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fdset *fdSet) set(i int) {
|
|
|
|
bits := 32 << (^uint(0) >> 63)
|
2019-01-03 18:04:00 +00:00
|
|
|
fdset.Bits[i/bits] |= 1 << uint(i%bits)
|
2018-05-17 22:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fdset *fdSet) check(i int) bool {
|
|
|
|
bits := 32 << (^uint(0) >> 63)
|
2019-01-03 18:04:00 +00:00
|
|
|
return (fdset.Bits[i/bits] & (1 << uint(i%bits))) != 0
|
2018-05-17 22:58:54 +00:00
|
|
|
}
|