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