From: Ian Lance Taylor Date: Thu, 31 Mar 2011 20:37:31 +0000 (+0000) Subject: libgo/syscalls: Use _C_long as the type of the select bits array. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35ca26acc659500991b2119a0b6d9526605ca168;p=gcc.git libgo/syscalls: Use _C_long as the type of the select bits array. From-SVN: r171799 --- diff --git a/libgo/syscalls/sysfile_posix.go b/libgo/syscalls/sysfile_posix.go index 46ac0e07e1d..d0700574111 100644 --- a/libgo/syscalls/sysfile_posix.go +++ b/libgo/syscalls/sysfile_posix.go @@ -181,20 +181,22 @@ func Gettimeofday(tv *Timeval) (errno int) { return; } +const nfdbits = unsafe.Sizeof(_C_long) * 8 + 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) { - 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) { - 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 { - if set.Fds_bits[fd / 64] & (1 << (uint)(fd % 64)) != 0 { + if set.Fds_bits[fd / nfdbits] & (1 << (uint)(fd % nfdbits)) != 0 { return true } else { return false @@ -202,7 +204,7 @@ func FDIsSet(fd int, set *FdSet_t) bool { } 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 } }