libgo/syscalls: Use _C_long as the type of the select bits array.
From-SVN: r171799
This commit is contained in:
parent
c454d74afc
commit
35ca26acc6
|
@ -181,20 +181,22 @@ func Gettimeofday(tv *Timeval) (errno int) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nfdbits = unsafe.Sizeof(_C_long) * 8
|
||||||
|
|
||||||
type FdSet_t struct {
|
type FdSet_t struct {
|
||||||
Fds_bits [(FD_SETSIZE + 63) / 64]int64;
|
Fds_bits [(FD_SETSIZE + nfdbits - 1) / nfdbits]_C_long
|
||||||
}
|
}
|
||||||
|
|
||||||
func FDSet(fd int, set *FdSet_t) {
|
func FDSet(fd int, set *FdSet_t) {
|
||||||
set.Fds_bits[fd / 64] |= (1 << (uint)(fd % 64))
|
set.Fds_bits[fd / nfdbits] |= (1 << (uint)(fd % nfdbits))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FDClr(fd int, set *FdSet_t) {
|
func FDClr(fd int, set *FdSet_t) {
|
||||||
set.Fds_bits[fd / 64] &= ^(1 << (uint)(fd % 64))
|
set.Fds_bits[fd / nfdbits] &^= (1 << (uint)(fd % nfdbits))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FDIsSet(fd int, set *FdSet_t) bool {
|
func FDIsSet(fd int, set *FdSet_t) bool {
|
||||||
if set.Fds_bits[fd / 64] & (1 << (uint)(fd % 64)) != 0 {
|
if set.Fds_bits[fd / nfdbits] & (1 << (uint)(fd % nfdbits)) != 0 {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
@ -202,7 +204,7 @@ func FDIsSet(fd int, set *FdSet_t) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func FDZero(set *FdSet_t) {
|
func FDZero(set *FdSet_t) {
|
||||||
for i := 0; i < ((FD_SETSIZE + 63) / 64); i++ {
|
for i := range set.Fds_bits {
|
||||||
set.Fds_bits[i] = 0
|
set.Fds_bits[i] = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue