home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / wizards / 3861 < prev    next >
Encoding:
Text File  |  1992-09-09  |  2.7 KB  |  66 lines

  1. Xref: sparky comp.unix.wizards:3861 comp.unix.programmer:4587 comp.unix.internals:1779
  2. Newsgroups: comp.unix.wizards,comp.unix.programmer,comp.unix.internals
  3. Path: sparky!uunet!ddssuprs!lpc
  4. From: lpc@dickens.com (Luis P Caamano)
  5. Subject: Re: Implementation of Sys V. based message queues
  6. Message-ID: <1992Sep9.151216.25028@dickens.com>
  7. Date: Wed, 9 Sep 1992 15:12:16 GMT
  8. References: <1992Sep3.232807.18181@noao.edu> <1992Sep8.171014.21414@dickens.com> <1992Sep8.202405.24405@noao.edu>
  9. Organization: Dickens Data Systems, Inc.
  10. Lines: 54
  11.  
  12. In article <1992Sep8.202405.24405@noao.edu> rstevens@noao.edu (W. Richard Stevens) writes:
  13.  
  14. [ some stuff deleted ]
  15.  
  16. >
  17. >My bottom line is that it appears that I would have to take every
  18. >program using select that doesn't give a hoot about System V message
  19. >queues and recode the selects to conform to this new interface.  Yuck.
  20. >(Maybe they have some #defined constant that brings in the BSD-style
  21.                        ^^^^^^^^
  22.  
  23. In fact, you don't notice the change in select until you read the
  24. man page, and then you jump off your seat :-) 
  25.  
  26. No. You don't have to change the code and yes, /usr/include/sys/select.h
  27. contains some #define's to simplify the use of low/high bits separation but
  28. no special kludges to make it look BSD.  (fd_set it's still there).
  29.  
  30. ----excerpt from /usr/include/sys/select.h (AIX 3.2)-----
  31. #include <sys/time.h>
  32.  
  33. extern    int select(
  34.     unsigned long nfdsmsgs,    /* #file descriptors/message queues */
  35.     void *readlist,        /* file descriptors to check for read */
  36.     void *writelist,    /* file descriptors to check for write */
  37.     void *exceptlist,    /* file descriptors to check for exceptions */
  38.     struct timeval *timeout);    /* length of time to wait for events */
  39.  
  40. ...
  41.  
  42. typedef unsigned int    fd_mask;
  43. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  44. #ifndef howmany
  45. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  46. #endif
  47.  
  48. typedef    struct fd_set {
  49.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  50. } fd_set;
  51.  
  52. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  53. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  54. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  55. #define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  56. ----------------------------------------
  57.  
  58. -- 
  59. ---------------------------------------------------------------------------
  60. Luis P. Caamano                    |         lpc@dickens.com
  61. Dickens Data Systems, Inc.         |         uunet!dickens.com!lpc
  62. Atlanta, GA                        |         (404) 475-8860
  63. ---------------------------------------------------------------------------
  64. If I think I know it all, I'll stop learning. -myself
  65. The more I learn, the more I know I know nothing. -somebody else
  66.