Print this page
libc: only have one select implementation, and move the pollfds onto the heap if they cross some threshold


  61  * now allows the visibility of signal.h in this header, however
  62  * an order of inclusion problem occurs as a result of inclusion
  63  * of <sys/select.h> in <signal.h> under certain conditions.
  64  * Rather than include <sys/signal.h> here, we've duplicated
  65  * the sigset_t type instead. This type is required for the XPG6
  66  * introduced pselect() function also declared in this header.
  67  */
  68 #ifndef _SIGSET_T
  69 #define _SIGSET_T
  70 typedef struct {                /* signal set type */
  71         unsigned int    __sigbits[4];
  72 } sigset_t;
  73 #endif  /* _SIGSET_T */
  74 
  75 #endif /* #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */
  76 
  77 /*
  78  * Select uses bit masks of file descriptors in longs.
  79  * These macros manipulate such bit fields.
  80  * FD_SETSIZE may be defined by the user, but the default here
  81  * should be >= NOFILE (param.h).
  82  */
  83 #ifndef FD_SETSIZE
  84 #ifdef _LP64
  85 #define FD_SETSIZE      65536
  86 #else
  87 #define FD_SETSIZE      1024
  88 #endif  /* _LP64 */
  89 #elif FD_SETSIZE > 1024 && !defined(_LP64)
  90 #ifdef __PRAGMA_REDEFINE_EXTNAME
  91 #pragma redefine_extname        select  select_large_fdset
  92 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
  93 #pragma redefine_extname        pselect pselect_large_fdset
  94 #endif
  95 #else   /* __PRAGMA_REDEFINE_EXTNAME */
  96 #define select  select_large_fdset
  97 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
  98 #define pselect pselect_large_fdset
  99 #endif
 100 #endif  /* __PRAGMA_REDEFINE_EXTNAME */
 101 #endif  /* FD_SETSIZE */
 102 
 103 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 104 typedef long    fd_mask;
 105 #endif
 106 typedef long    fds_mask;
 107 
 108 /*
 109  *  The value of _NBBY needs to be consistant with the value
 110  *  of NBBY in <sys/param.h>.
 111  */
 112 #define _NBBY 8
 113 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 114 #ifndef NBBY            /* number of bits per byte */
 115 #define NBBY _NBBY
 116 #endif
 117 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
 118 
 119 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 120 #define NFDBITS         (sizeof (fd_mask) * NBBY)       /* bits per mask */




  61  * now allows the visibility of signal.h in this header, however
  62  * an order of inclusion problem occurs as a result of inclusion
  63  * of <sys/select.h> in <signal.h> under certain conditions.
  64  * Rather than include <sys/signal.h> here, we've duplicated
  65  * the sigset_t type instead. This type is required for the XPG6
  66  * introduced pselect() function also declared in this header.
  67  */
  68 #ifndef _SIGSET_T
  69 #define _SIGSET_T
  70 typedef struct {                /* signal set type */
  71         unsigned int    __sigbits[4];
  72 } sigset_t;
  73 #endif  /* _SIGSET_T */
  74 
  75 #endif /* #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */
  76 
  77 /*
  78  * Select uses bit masks of file descriptors in longs.
  79  * These macros manipulate such bit fields.
  80  * FD_SETSIZE may be defined by the user, but the default here
  81  * should be >= RLIM_FD_MAX.
  82  */
  83 #ifndef FD_SETSIZE

  84 #define FD_SETSIZE      65536















  85 #endif  /* FD_SETSIZE */
  86 
  87 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
  88 typedef long    fd_mask;
  89 #endif
  90 typedef long    fds_mask;
  91 
  92 /*
  93  *  The value of _NBBY needs to be consistant with the value
  94  *  of NBBY in <sys/param.h>.
  95  */
  96 #define _NBBY 8
  97 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
  98 #ifndef NBBY            /* number of bits per byte */
  99 #define NBBY _NBBY
 100 #endif
 101 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
 102 
 103 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 104 #define NFDBITS         (sizeof (fd_mask) * NBBY)       /* bits per mask */