From: Ian Lance Taylor <iant@google.com>
To: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Cc: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com
Subject: Re: [libgo] Account for 32-bit fds_bits on Solaris 2
Date: Thu, 31 Mar 2011 20:53:00 -0000 [thread overview]
Message-ID: <mcr4o6jqb5d.fsf@google.com> (raw)
In-Reply-To: <yddei5njo16.fsf@manam.CeBiTec.Uni-Bielefeld.DE> (Rainer Orth's message of "Thu, 31 Mar 2011 17:41:09 +0200")
[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
> While debugging why several libgo tests on Solaris 2/SPARC were hanging
> in select (cf. PR go/48242, go/48243), I found that fd_set is
>
> typedef struct fd_set {
> long fds_bits[__howmany(FD_SETSIZE, FD_NFDBITS)];
> } fd_set;
>
> The current implementation of the FD* funcs in sysfile_posix.go assumes
> 64-bit fds_bits. While this doesn't make a difference on little-endian
> hosts, on big-endian SPARC the wrong bits are set, leading to the
> observed hang since there is no activity on those random fds.
>
> The following patch fixes this by moving the FD* implementation to two
> new sysfile_fdset{32, 64}.go files to fix this. There's almost
> certainly a cleaner/shorter implemenation, but this worked for me.
> While the affected tests don't hang anymore now, they still don't finish
> successfully, among others due to PR go/48222.
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.
Ian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1085 bytes --]
diff -r bc59115c58cf libgo/syscalls/sysfile_posix.go
--- a/libgo/syscalls/sysfile_posix.go Thu Mar 31 09:48:32 2011 -0700
+++ b/libgo/syscalls/sysfile_posix.go Thu Mar 31 13:35:30 2011 -0700
@@ -181,20 +181,22 @@
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 FDZero(set *FdSet_t) {
- for i := 0; i < ((FD_SETSIZE + 63) / 64); i++ {
+ for i := range set.Fds_bits {
set.Fds_bits[i] = 0
}
}
next prev parent reply other threads:[~2011-03-31 20:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-31 15:50 Rainer Orth
2011-03-31 16:05 ` Ian Lance Taylor
2011-03-31 16:12 ` Rainer Orth
2011-03-31 20:09 ` Richard Henderson
2011-03-31 20:12 ` Ian Lance Taylor
2011-03-31 20:53 ` Ian Lance Taylor [this message]
2011-04-01 7:53 ` Rainer Orth
2011-04-01 22:54 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mcr4o6jqb5d.fsf@google.com \
--to=iant@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gofrontend-dev@googlegroups.com \
--cc=ro@CeBiTec.Uni-Bielefeld.DE \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).