diff options
author | pk33 <pk33@pk33.space> | 2024-11-01 23:51:15 +0100 |
---|---|---|
committer | pk33 <pk33@pk33.space> | 2024-11-01 23:51:15 +0100 |
commit | 294b585994da4427ac98a8353ff41aed5f301d54 (patch) | |
tree | aafcd885c1fe28819ef1a511da5e6344411b5597 /include/musl/sys/select.h | |
parent | f0958551b43959174d28b2056f584d2081494e6c (diff) | |
download | engine33-294b585994da4427ac98a8353ff41aed5f301d54.tar.gz |
Import and fix old code
Diffstat (limited to 'include/musl/sys/select.h')
-rw-r--r-- | include/musl/sys/select.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/include/musl/sys/select.h b/include/musl/sys/select.h new file mode 100644 index 0000000..b3bab1d --- /dev/null +++ b/include/musl/sys/select.h @@ -0,0 +1,46 @@ +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include <features.h> + +#define __NEED_size_t +#define __NEED_time_t +#define __NEED_suseconds_t +#define __NEED_struct_timeval +#define __NEED_struct_timespec +#define __NEED_sigset_t + +#include <bits/alltypes.h> + +#define FD_SETSIZE 1024 + +typedef unsigned long fd_mask; + +typedef struct { + unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)]; +} fd_set; + +#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) +#define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long))))) +#define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long))))) +#define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long))))) + +int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict); +int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict); + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define NFDBITS (8*(int)sizeof(long)) +#endif + +#if _REDIR_TIME64 +__REDIR(select, __select_time64); +__REDIR(pselect, __pselect_time64); +#endif + +#ifdef __cplusplus +} +#endif +#endif |