2020-02-19 16:09:24 +01:00
|
|
|
// +build !windows
|
|
|
|
|
2019-01-02 01:55:51 +01:00
|
|
|
/* SPDX-License-Identifier: MIT
|
2018-05-18 00:58:54 +02:00
|
|
|
*
|
2020-05-02 10:08:26 +02:00
|
|
|
* Copyright (C) 2017-2020 WireGuard LLC. All Rights Reserved.
|
2018-05-18 00:58:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package rwcancel
|
|
|
|
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
|
|
|
|
type fdSet struct {
|
2019-01-03 19:04:00 +01:00
|
|
|
unix.FdSet
|
2018-05-18 00:58:54 +02: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-18 00:58:54 +02: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-18 00:58:54 +02:00
|
|
|
}
|