You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 satır
2.3KB

  1. #ifndef _SYS_SELECT_H
  2. #define _SYS_SELECT_H
  3. /* We don't define fd_set and friends if we are compiling POSIX
  4. source, or if we have included (or may include as indicated
  5. by __USE_W32_SOCKETS) the W32api winsock[2].h header which
  6. defines Windows versions of them. Note that a program which
  7. includes the W32api winsock[2].h header must know what it is doing;
  8. it must not call the Cygwin select function.
  9. */
  10. # if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
  11. #include <sys/cdefs.h>
  12. #include <sys/_sigset.h>
  13. #include <sys/_timeval.h>
  14. #include <sys/timespec.h>
  15. #if !defined(_SIGSET_T_DECLARED)
  16. #define _SIGSET_T_DECLARED
  17. typedef __sigset_t sigset_t;
  18. #endif
  19. # define _SYS_TYPES_FD_SET
  20. /*
  21. * Select uses bit masks of file descriptors in longs.
  22. * These macros manipulate such bit fields (the filesystem macros use chars).
  23. * FD_SETSIZE may be defined by the user, but the default here
  24. * should be >= NOFILE (param.h).
  25. */
  26. # ifndef FD_SETSIZE
  27. # define FD_SETSIZE 64
  28. # endif
  29. typedef unsigned long fd_mask;
  30. # define NFDBITS (sizeof (fd_mask) * 8) /* bits per mask */
  31. # ifndef _howmany
  32. # define _howmany(x,y) (((x)+((y)-1))/(y))
  33. # endif
  34. /* We use a macro for fd_set so that including Sockets.h afterwards
  35. can work. */
  36. typedef struct _types_fd_set {
  37. fd_mask fds_bits[_howmany(FD_SETSIZE, NFDBITS)];
  38. } _types_fd_set;
  39. #define fd_set _types_fd_set
  40. # define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
  41. # define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
  42. # define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
  43. # define FD_ZERO(p) (__extension__ (void)({ \
  44. size_t __i; \
  45. char *__tmp = (char *)p; \
  46. for (__i = 0; __i < sizeof (*(p)); ++__i) \
  47. *__tmp++ = 0; \
  48. }))
  49. #if !defined (__INSIDE_CYGWIN_NET__)
  50. __BEGIN_DECLS
  51. int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,
  52. fd_set *__exceptfds, struct timeval *__timeout));
  53. #if __POSIX_VISIBLE >= 200112
  54. int pselect __P ((int __n, fd_set *__readfds, fd_set *__writefds,
  55. fd_set *__exceptfds, const struct timespec *__timeout,
  56. const sigset_t *__set));
  57. #endif
  58. __END_DECLS
  59. #endif /* !__INSIDE_CYGWIN_NET__ */
  60. #endif /* !(_WINSOCK_H || _WINSOCKAPI_ || __USE_W32_SOCKETS) */
  61. #endif /* sys/select.h */