select.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef _SYS_SELECT_H
  2. #define _SYS_SELECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #if __STDC_VERSION__ >= 199901L
  7. #define __restrict restrict
  8. #elif !defined(__GNUC__)
  9. #define __restrict
  10. #endif
  11. #define __NEED_size_t
  12. #define __NEED_time_t
  13. #define __NEED_suseconds_t
  14. #define __NEED_struct_timeval
  15. #define __NEED_struct_timespec
  16. #define __NEED_sigset_t
  17. #include <bits/alltypes.h>
  18. #define FD_SETSIZE 1024
  19. typedef unsigned long fd_mask;
  20. typedef struct
  21. {
  22. unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
  23. } fd_set;
  24. #define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)
  25. #define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
  26. #define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
  27. #define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
  28. int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
  29. int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
  30. #ifdef __cplusplus
  31. }
  32. #endif
  33. #endif