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