home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / linux / 16060 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.9 KB  |  48 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!eff!world!jrs
  3. From: jrs@world.std.com (Rick Sladkey)
  4. Subject: Re: definition of fd_set is a trouble spot
  5. In-Reply-To: quale@spock.cs.wisc.edu's message of Sun, 8 Nov 1992 07:31:30 GMT
  6. Message-ID: <JRS.92Nov8100442@lepton.world.std.com>
  7. Sender: jrs@world.std.com (Rick Sladkey)
  8. Organization: The Internet
  9. References: <1992Nov8.073130.25220@daffy.cs.wisc.edu>
  10. Date: Sun, 8 Nov 1992 15:04:42 GMT
  11. Lines: 35
  12.  
  13. >>>>> On Sun, 8 Nov 1992 07:31:30 GMT, quale@spock.cs.wisc.edu (Doug
  14. >>>>> Quale) said:
  15.  
  16. Doug> The definition of fd_set in <linux/types.h> is a bit of a
  17. Doug> trouble spot.  BSD makes fd_set an integer array to allow more
  18. Doug> open files/process than bits/word.  Linux allows only 32 open
  19. Doug> files/process, so fd_set is made an unsigned long.
  20.  
  21. Doug> If I haven't bored you to death and you're with me this far, the
  22. Doug> problem is that some programs expect fd_set to be an array, not
  23. Doug> a scalar.  For example, BSD rshd.c has the code sequence
  24.  
  25. Doug> fd_set ready, readfrom;
  26.  
  27. Doug> ...
  28.  
  29. Doug> ready = readfrom;
  30.  
  31. Doug> The intent is that ready be an alias for readfrom, but this
  32. Doug> won't work if fd_set is a scalar as in Linux.  (BSD documents
  33. Doug> fd_set as an array in the man pages, so I would say that this
  34. Doug> coding is legitimate.)
  35.  
  36. The intent is not for ready to be an alias for readfrom.  Let's say
  37. fd_set is really an array.  Then the above assignment is illegal
  38. because ready is not an lvalue.  In most select implementations,
  39. fd_set is either a scalar (e.g. Linux, BSD 4.2) or a structure
  40. containing a vector (e.g.  BSD 4.3, SunOS).  If it is a structure,
  41. then the assignent causes the structure to be copied, so it is still
  42. not an alias.  Either implementation is correct and does not cause
  43. portability problems as long as programs only use the predefined
  44. macros for manipulating them.
  45. --
  46. Rick Sladkey
  47. jrs@world.std.com
  48.