ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
select.h
Go to the documentation of this file.
1#pragma once
2
3#include <sys/socket.h>
4
6
7/* Number of file descriptors that fit in fd_set */
8#define FD_SETSIZE 1024
9
10typedef struct {
11 unsigned long fds_bits[FD_SETSIZE / (8 * sizeof(unsigned long))];
12} fd_set;
13
14#define FD_ZERO(set) \
15 do { \
16 unsigned int __i; \
17 for (__i = 0; __i < sizeof(fd_set) / sizeof(unsigned long); __i++) \
18 ((fd_set *)(set))->fds_bits[__i] = 0; \
19 } while (0)
20
21#define FD_SET(fd, set) \
22 ((fd_set *)(set))->fds_bits[(fd) / (8 * sizeof(unsigned long))] \
23 |= (1UL << ((fd) % (8 * sizeof(unsigned long))))
24
25#define FD_CLR(fd, set) \
26 ((fd_set *)(set))->fds_bits[(fd) / (8 * sizeof(unsigned long))] \
27 &= ~(1UL << ((fd) % (8 * sizeof(unsigned long))))
28
29#define FD_ISSET(fd, set) \
30 (((fd_set *)(set))->fds_bits[(fd) / (8 * sizeof(unsigned long))] \
31 & (1UL << ((fd) % (8 * sizeof(unsigned long)))))
32
33/* Guard with the macros both libcs use -- glibc's __timeval_defined
34 * (bits/types/struct_timeval.h) and Apple's _STRUCT_TIMEVAL
35 * (sys/_types/_timeval.h). Defining theirs makes any SDK header that would
36 * define timeval skip it; honouring theirs stops us redefining it when a
37 * system header we do not shadow got there first. */
38#if !defined(__timeval_defined) && !defined(_STRUCT_TIMEVAL)
39#define __timeval_defined 1
40#define _STRUCT_TIMEVAL struct timeval
41struct timeval {
42 long tv_sec; // cppcheck-suppress unusedStructMember
43 long tv_usec; // cppcheck-suppress unusedStructMember
44};
45#endif
46
47int select(int nfds, fd_set *readfds, fd_set *writefds,
48 fd_set *exceptfds, struct timeval *timeout);
49
50/* poll */
51struct pollfd {
52 int fd; // cppcheck-suppress unusedStructMember
53 short events; // cppcheck-suppress unusedStructMember
54 short revents; // cppcheck-suppress unusedStructMember
55};
56
57#define POLLIN 0x0001
58#define POLLPRI 0x0002
59#define POLLOUT 0x0004
60#define POLLERR 0x0008
61#define POLLHUP 0x0010
62#define POLLNVAL 0x0020
63#define POLLRDNORM 0x0040
64#define POLLWRNORM 0x0100
65
66int poll(struct pollfd *fds, unsigned long nfds, int timeout);
67
#define FD_SETSIZE
Definition select.h:8
int poll(struct pollfd *fds, unsigned long nfds, int timeout)
Definition socket_lib.c:457
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Definition socket_lib.c:425
#define __ESBMC_C_CPP_END
Definition stddefs.h:9
#define __ESBMC_C_CPP_BEGIN
Definition stddefs.h:8
Definition select.h:10
unsigned long fds_bits[FD_SETSIZE/(8 *sizeof(unsigned long))]
Definition select.h:11
Definition select.h:51
int fd
Definition select.h:52
short revents
Definition select.h:54
short events
Definition select.h:53
Definition select.h:41
long tv_sec
Definition select.h:42
long tv_usec
Definition select.h:43