Restore the "GPL licensing not permitted" in GLUT license headers.
[haiku.git] / headers / posix / sys / select.h
blob3f41e137ce98014534338a62c0f868c192acfb38
1 /*
2 * Copyright 2002-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _SYS_SELECT_H
6 #define _SYS_SELECT_H
9 #include <config/types.h>
11 #include <sys/time.h>
12 #include <signal.h>
15 /* If FD_SET is already defined, only the select() prototype is
16 * exported in this header.
18 #ifndef FD_SET
20 /* You can define your own FDSETSIZE if you need more bits - but
21 * it should be enough for most uses.
23 #ifndef FD_SETSIZE
24 # define FD_SETSIZE 1024
25 #endif
27 typedef __haiku_uint32 fd_mask;
29 #ifndef _howmany
30 # define _howmany(x, y) (((x) + ((y) - 1)) / (y))
31 #endif
33 #ifndef howmany
34 # define howmany(x, y) (((x) + ((y) - 1)) / (y))
35 #endif
37 #define NFDBITS (sizeof(fd_mask) * 8) /* bits per mask */
39 typedef struct fd_set {
40 fd_mask bits[_howmany(FD_SETSIZE, NFDBITS)];
41 } fd_set;
43 #define _FD_BITSINDEX(fd) ((fd) / NFDBITS)
44 #define _FD_BIT(fd) (1L << ((fd) % NFDBITS))
46 /* FD_ZERO uses memset */
47 #include <string.h>
49 #define FD_ZERO(set) memset((set), 0, sizeof(fd_set))
50 #define FD_SET(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] |= _FD_BIT(fd))
51 #define FD_CLR(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] &= ~_FD_BIT(fd))
52 #define FD_ISSET(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] & _FD_BIT(fd))
53 #define FD_COPY(source, target) (*(target) = *(source))
55 #endif /* FD_SET */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
61 extern int pselect(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
62 struct fd_set *errorBits, const struct timespec *timeout, const sigset_t *sigMask);
63 extern int select(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
64 struct fd_set *errorBits, struct timeval *timeout);
66 #ifdef __cplusplus
68 #endif
70 #endif /* _SYS_SELECT_H */