home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!eff!world!jrs
- From: jrs@world.std.com (Rick Sladkey)
- Subject: Re: definition of fd_set is a trouble spot
- In-Reply-To: quale@spock.cs.wisc.edu's message of Sun, 8 Nov 1992 07:31:30 GMT
- Message-ID: <JRS.92Nov8100442@lepton.world.std.com>
- Sender: jrs@world.std.com (Rick Sladkey)
- Organization: The Internet
- References: <1992Nov8.073130.25220@daffy.cs.wisc.edu>
- Date: Sun, 8 Nov 1992 15:04:42 GMT
- Lines: 35
-
- >>>>> On Sun, 8 Nov 1992 07:31:30 GMT, quale@spock.cs.wisc.edu (Doug
- >>>>> Quale) said:
-
- Doug> The definition of fd_set in <linux/types.h> is a bit of a
- Doug> trouble spot. BSD makes fd_set an integer array to allow more
- Doug> open files/process than bits/word. Linux allows only 32 open
- Doug> files/process, so fd_set is made an unsigned long.
-
- Doug> If I haven't bored you to death and you're with me this far, the
- Doug> problem is that some programs expect fd_set to be an array, not
- Doug> a scalar. For example, BSD rshd.c has the code sequence
-
- Doug> fd_set ready, readfrom;
-
- Doug> ...
-
- Doug> ready = readfrom;
-
- Doug> The intent is that ready be an alias for readfrom, but this
- Doug> won't work if fd_set is a scalar as in Linux. (BSD documents
- Doug> fd_set as an array in the man pages, so I would say that this
- Doug> coding is legitimate.)
-
- The intent is not for ready to be an alias for readfrom. Let's say
- fd_set is really an array. Then the above assignment is illegal
- because ready is not an lvalue. In most select implementations,
- fd_set is either a scalar (e.g. Linux, BSD 4.2) or a structure
- containing a vector (e.g. BSD 4.3, SunOS). If it is a structure,
- then the assignent causes the structure to be copied, so it is still
- not an alias. Either implementation is correct and does not cause
- portability problems as long as programs only use the predefined
- macros for manipulating them.
- --
- Rick Sladkey
- jrs@world.std.com
-