Rainer Orth <r...@cebitec.uni-bielefeld.de> writes: > Ian Lance Taylor <i...@google.com> writes: > >> Thanks. I'm going to try gambling that every uses the type "long" for >> the fds_bits array. If so, I think this patch will work. Bootstrapped >> and ran Go testsuite on x86_64-unknown-linux-gnu (forcing the use of >> select). Committed to mainline. > > I fear you lost ;-) > > * On Solaris, it's always long (i.e. either 32 or 64-bit). > > * On IRIX 6.5, it's long for 32-bit and int for 64-bit (i.e. always > 32-bit), while 64-bit long is 64-bit. > > * On Tru64 UNIX V5.1, it's always int (i.e. 32-bit), while long is > 64-bit. > > This has to be system-dependent, I fear.
Bother. OK, for my next attempt I committed the appended patch, in which mksysinfo tries to guess the right type to use. Let me know where this fails. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian
diff -r fa0bb5137d66 libgo/configure.ac --- a/libgo/configure.ac Thu Mar 31 22:09:27 2011 -0700 +++ b/libgo/configure.ac Fri Apr 01 15:47:05 2011 -0700 @@ -417,7 +417,7 @@ ;; esac -AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h) +AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h) AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes) AC_CHECK_FUNCS(srandom random strerror_r strsignal wait4) diff -r fa0bb5137d66 libgo/mksysinfo.sh --- a/libgo/mksysinfo.sh Thu Mar 31 22:09:27 2011 -0700 +++ b/libgo/mksysinfo.sh Fri Apr 01 15:47:05 2011 -0700 @@ -73,6 +73,9 @@ #if defined(HAVE_SYS_UTSNAME_H) #include <sys/utsname.h> #endif +#if defined(HAVE_SYS_SELECT_H) +#include <sys/select.h> +#endif #include <unistd.h> EOF @@ -438,4 +441,12 @@ -e 's/_in_addr/[4]byte/g' \ >> ${OUT} +# Try to guess the type to use for fd_set. +fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true` +fds_bits_type="_C_long" +if test "$fd_set" != ""; then + fds_bits_type=`echo $fd_set | sed -e 's/.*[]]\([^;]*\); }$/\1/'` +fi +echo "type fds_bits_type $fds_bits_type" >> ${OUT} + exit $? diff -r fa0bb5137d66 libgo/syscalls/sysfile_posix.go --- a/libgo/syscalls/sysfile_posix.go Thu Mar 31 22:09:27 2011 -0700 +++ b/libgo/syscalls/sysfile_posix.go Fri Apr 01 15:47:05 2011 -0700 @@ -181,10 +181,10 @@ return; } -const nfdbits = unsafe.Sizeof(_C_long) * 8 +const nfdbits = unsafe.Sizeof(fds_bits_type) * 8 type FdSet_t struct { - Fds_bits [(FD_SETSIZE + nfdbits - 1) / nfdbits]_C_long + Fds_bits [(FD_SETSIZE + nfdbits - 1) / nfdbits]fds_bits_type } func FDSet(fd int, set *FdSet_t) {