Thread overview
[Issue 5209] New: posix/sys/select.d: FD_ISSET function should return bool
Nov 13, 2010
Iain Buclaw
Nov 13, 2010
Iain Buclaw
Dec 21, 2010
Iain Buclaw
Dec 21, 2010
Brad Roberts
Dec 22, 2010
Iain Buclaw
Dec 22, 2010
Brad Roberts
November 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5209

           Summary: posix/sys/select.d: FD_ISSET function should return
                    bool
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: druntime
        AssignedTo: sean@invisibleduck.org
        ReportedBy: ibuclaw@ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-11-13 06:17:34 PST ---
This is how FD_ISSET is defined on Linux

#define __FD_ISSET(d, set) \
  ((__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d)) != 0)


So druntime should do the same (patch supplied). This is also a blocker for 64bit, where you would get an implicit cast from long to int message.

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5209



--- Comment #1 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-11-13 06:18:41 PST ---
Created an attachment (id=809)
patch for 5209

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5209


Iain Buclaw <ibuclaw@ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |critical


--- Comment #2 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-12-21 13:33:04 PST ---
Bumping priority:

It appears *ONE* of the functions has been changed to a boolean. But what's utterly worse is that:


extern (D) bool FD_ISSET( int fd, fd_set* fdset )
{
    return (fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd )) == 0;
}

should be "!= 0"

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5209


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr@puremagic.com


--- Comment #3 from Brad Roberts <braddr@puremagic.com> 2010-12-21 13:43:47 PST ---
Would you do me a favor and write up a block of unit tests for those functions?
 I'll apply both together.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5209



--- Comment #4 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-12-21 16:33:12 PST ---
Created an attachment (id=852)
unittest for sys.select

Well the most obvious thing it affects is std.socket;


import std.socket;

unittest
{
    SocketSet sset = new SocketSet(24);

    // All socket descriptors should not be set before using them.
    for (socket_t i = 0; i < sset.max; i++)
    {
        assert(! sset.isSet(i));
    }
}


Is the attached file OK? :~)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5209


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
         AssignedTo|sean@invisibleduck.org      |braddr@puremagic.com


--- Comment #5 from Brad Roberts <braddr@puremagic.com> 2010-12-21 16:54:21 PST ---
Checked in both the fix and the unittests in r453 and r454.

Thanks for the patches.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------