Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!aplcen!haven!uvaarpa!mmdf From: mdb@kosciusko.esd.3com.com (Mark D. Baushke) Newsgroups: comp.lang.perl Subject: Re: do_select() bug Message-ID: <1870@uvaarpa.virginia.edu> Date: 20 Dec 89 04:59:01 GMT Sender: mmdf@uvaarpa.virginia.edu Reply-To: mdb@kosciusko.esd.3com.com Lines: 59 On 19 Dec 89 07:04:01 GMT, lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) said: Larry> I've got a do_select for patch 7 that should work everwhere Larry> that uses bitmaps composed of ints or longs. Even places that Larry> don't have FD_SET(), etc. (if there are any such). There are indeed machines without FD_SET(). For example, SunOS 3.x does NOT have it. I believe that at least some versions Ultrix (e.g., 2.0) also do not have it. I have seen something like the following code used on SunOS 3.x and Ultrix 2.0 machines as a workaround. /* * Ultrix 2.0/SunOS 3.x File Descriptor Compatibility Macros * * BIG NOTE!!! This will only allow fd_sets of 32 bits (assuming that's * the size of an int). Also, SunOS 3.x only allows 30 FDs in any case. * */ #ifndef FD_SET #define NBBY 8 /* number of bits in a byte */ #define NFDBITS (sizeof(int) * NBBY) /* * This is for Ultrix 2.0 and SunOS 3.x where fd_sets only have 1 element. */ /* I'm assuming that the only use of howmany is howmany(FD_SETSIZE, NFDBITS), which should always return 1. The following code will need to be uncommented otherwise. #define howmany(x, y) (((x)+((y)-1))/(y)) */ #define howmany(x,y) 1 #ifndef FD_SETSIZE #define FD_SETSIZE NFDBITS #endif #define FD_SET(n, p) ((p)->fds_bits[0] |= (1 << ((n) % NFDBITS))) #define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1 << ((n) % NFDBITS))) #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1 << ((n) % NFDBITS))) #define FD_ZERO(p) ((p)->fds_bits[0] = 0) #endif /* FD_SET */ Larry> Someone will have to tell me about "sellist" structures, Larry> though. Hope this helps, -- Mark D. Baushke mdb@ESD.3Com.COM