1
0

select.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef _SYS_SELECT_H
  2. #define _SYS_SELECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #define __NEED_size_t
  8. #define __NEED_time_t
  9. #define __NEED_suseconds_t
  10. #define __NEED_struct_timeval
  11. #define __NEED_struct_timespec
  12. #define __NEED_sigset_t
  13. #include <bits/alltypes.h>
  14. #define FD_SETSIZE 1024
  15. typedef unsigned long fd_mask;
  16. typedef struct {
  17. unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
  18. } fd_set;
  19. #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)
  20. #define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
  21. #define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
  22. #define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
  23. int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
  24. int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
  25. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  26. #define NFDBITS (8*(int)sizeof(long))
  27. #endif
  28. #if _REDIR_TIME64
  29. __REDIR(select, __select_time64);
  30. __REDIR(pselect, __pselect_time64);
  31. #endif
  32. #ifdef __cplusplus
  33. }
  34. #endif
  35. #endif