select.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* `fd_set' type and related macros, and `select'/`pselect' declarations.
  2. Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. /* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
  17. #ifndef _SYS_SELECT_H
  18. #define _SYS_SELECT_H 1
  19. #include <features.h>
  20. /* Get definition of needed basic types. */
  21. #include <bits/types.h>
  22. /* Get __FD_* definitions. */
  23. #include <bits/select.h>
  24. /* Get __sigset_t. */
  25. #include <bits/sigset.h>
  26. /* Get definition of timer specification structures. */
  27. #define __need_timespec
  28. #include <time.h>
  29. __BEGIN_DECLS
  30. /* This declaration puts `struct timeval' in global scope even if
  31. <sys/time.h> has not been included to define it. That way the
  32. `select' prototype below will not conflict with a later definition
  33. of `struct timeval'. */
  34. struct timeval;
  35. typedef __fd_mask fd_mask;
  36. /* Representation of a set of file descriptors. */
  37. typedef __fd_set fd_set;
  38. /* Maximum number of file descriptors in `fd_set'. */
  39. #define FD_SETSIZE __FD_SETSIZE
  40. #ifdef __USE_MISC
  41. /* Number of bits per word of `fd_set' (some code assumes this is 32). */
  42. # define NFDBITS __NFDBITS
  43. #endif
  44. /* Access macros for `fd_set'. */
  45. #define FD_SET(fd, fdsetp) __FD_SET ((fd), (fdsetp))
  46. #define FD_CLR(fd, fdsetp) __FD_CLR ((fd), (fdsetp))
  47. #define FD_ISSET(fd, fdsetp) __FD_ISSET ((fd), (fdsetp))
  48. #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
  49. /* Check the first NFDS descriptors each in READFDS (if not NULL) for read
  50. readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
  51. (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
  52. after waiting the interval specified therein. Returns the number of ready
  53. descriptors, or -1 for errors. */
  54. extern int __select __P ((int __nfds, __fd_set *__readfds,
  55. __fd_set *__writefds, __fd_set *__exceptfds,
  56. struct timeval *__timeout));
  57. extern int select __P ((int __nfds, __fd_set *__readfds,
  58. __fd_set *__writefds, __fd_set *__exceptfds,
  59. struct timeval *__timeout));
  60. #ifdef __USE_GNU
  61. /* XXX Once/if POSIX.1g gets official this prototype will be available
  62. when defining __USE_POSIX. */
  63. /* Same as above only that the TIMEOUT value is given with higher
  64. resolution and a sigmask which is been set temporarily. This version
  65. should be used. */
  66. extern int pselect __P ((int __nfds, __fd_set *__readfds,
  67. __fd_set *__writefds, __fd_set *__exceptfds,
  68. const struct timespec *__timeout,
  69. const __sigset_t *__sigmask));
  70. #endif
  71. __END_DECLS
  72. #endif /* sys/select.h */