1 | /* sys/select.h (emx+gcc) */
|
---|
2 |
|
---|
3 | #ifndef _SYS_SELECT_H
|
---|
4 | #define _SYS_SELECT_H
|
---|
5 | #define _SYS_SELECT_H_
|
---|
6 |
|
---|
7 | #if defined (__cplusplus)
|
---|
8 | extern "C" {
|
---|
9 | #endif
|
---|
10 |
|
---|
11 | #include <sys/cdefs.h>
|
---|
12 | #include <sys/_sigset.h>
|
---|
13 |
|
---|
14 | #ifndef _SIGSET_T_DECLARED
|
---|
15 | #define _SIGSET_T_DECLARED
|
---|
16 | /** Signal set. */
|
---|
17 | typedef __sigset_t sigset_t;
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | /** Define the number of file handles in the select buffer.
|
---|
21 | * @remark we might wanna bump this one up a bit... */
|
---|
22 | #if !defined (FD_SETSIZE)
|
---|
23 | #define FD_SETSIZE 2048
|
---|
24 | #elif FD_SETSIZE < 256
|
---|
25 | #error FD_SETSIZE must be at least 256
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | /** BSD thingy to figure out the size of a bitmap array. */
|
---|
29 | #ifndef _howmany
|
---|
30 | #define _howmany(a,b) (((a) + ((b) - 1)) / (b))
|
---|
31 | #endif
|
---|
32 | #if defined(TCPV40HDRS) && !defined(howmany)
|
---|
33 | #define howmany(a,b) (((a) + ((b) - 1)) / (b))
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #if !defined (_FD_SET_T)
|
---|
37 | #define _FD_SET_T
|
---|
38 | /** The base type for the select file descriptor bitmap. */
|
---|
39 | typedef unsigned long __fd_mask;
|
---|
40 | /** Number of bits in a byte. */
|
---|
41 | #define NBBY 8
|
---|
42 | /** Number of bits in a byte. */
|
---|
43 | #define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */
|
---|
44 | /** Select set. */
|
---|
45 | typedef struct fd_set
|
---|
46 | {
|
---|
47 | __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
|
---|
48 | } fd_set;
|
---|
49 |
|
---|
50 | #if defined(__BSD_VISIBLE) || defined(TCPV40HDRS)
|
---|
51 | typedef __fd_mask fd_mask;
|
---|
52 | #define fds_bits __fds_bits
|
---|
53 | #define NFDBITS _NFDBITS
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #ifndef FD_SET
|
---|
59 | /** Set a bit in the select file descriptor bitmap. */
|
---|
60 | #define FD_SET(n,s) ((s)->__fds_bits[(n)/_NFDBITS] |= (1L << ((n) & (_NFDBITS - 1))))
|
---|
61 | /** Clear a bit in the select file descriptor bitmap. */
|
---|
62 | #define FD_CLR(n,s) ((s)->__fds_bits[(n)/_NFDBITS] &= ~(1L << ((n) & (_NFDBITS - 1))))
|
---|
63 | /** Test if a bit in the select file descriptor bitmap is set. */
|
---|
64 | #define FD_ISSET(n,s) ((s)->__fds_bits[(n)/_NFDBITS] & (1L << ((n) & (_NFDBITS - 1))))
|
---|
65 | /** Initialize the select file descriptor bitmap clearing all bits. */
|
---|
66 | #define FD_ZERO(s) (void)memset(s, 0, sizeof(*(s)))
|
---|
67 | #if __BSD_VISIBLE
|
---|
68 | /** Copy a select file descriptor bitmap. */
|
---|
69 | #define FD_COPY(src,trg) (void)(*(trg) = *(src))
|
---|
70 | #endif
|
---|
71 | #endif /* !FD_SET */
|
---|
72 |
|
---|
73 | /* bird: baka baka! need memset prototype which needs size_t. */
|
---|
74 | #include <sys/_types.h>
|
---|
75 | #if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: emx */
|
---|
76 | typedef __size_t size_t;
|
---|
77 | #define _SIZE_T_DECLARED
|
---|
78 | #define _SIZE_T /* bird: emx */
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | struct timeval;
|
---|
82 | int select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
|
---|
83 | int _select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
|
---|
84 | void *memset (void *, int, size_t); /* Used by FD_ZERO */
|
---|
85 | #ifdef _LIBC_TODO
|
---|
86 | /** A slightly different select call which have better time precision and signal support. */
|
---|
87 | #warning int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *);
|
---|
88 | #endif
|
---|
89 |
|
---|
90 |
|
---|
91 | /** This is the bsd styled select.
|
---|
92 | * Normally it's mapped to select(), but since we don't want any such
|
---|
93 | * confusion we don't.
|
---|
94 | * @remark The normal select() doesn't have socket capabilities since the sys style libc.
|
---|
95 | */
|
---|
96 | int _System bsdselect(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
|
---|
97 | /** This is the TCPIP OS/2 styled select. */
|
---|
98 | int _System os2_select(int *, int, int, int, long);
|
---|
99 |
|
---|
100 | /* toolkit BSD pollution: */
|
---|
101 | #ifndef TCPV40HDRS
|
---|
102 | #include <sys/_types.h>
|
---|
103 | #if !defined(_PID_T_DECLARED) && !defined(_PID_T) /* bird:emx */
|
---|
104 | typedef __pid_t pid_t; /* process id */
|
---|
105 | #define _PID_T_DECLARED
|
---|
106 | #define _PID_T /* bird: emx */
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | /*
|
---|
110 | * Used to maintain information about processes that wish to be
|
---|
111 | * notified when I/O becomes possible.
|
---|
112 | */
|
---|
113 | #pragma pack(1)
|
---|
114 | struct selinfo {
|
---|
115 | pid_t si_pid; /* process to be notified */
|
---|
116 | short si_flags; /* see below */
|
---|
117 | };
|
---|
118 | #pragma pack()
|
---|
119 | #define SI_COLL 0x0001 /* collision occurred */
|
---|
120 | #endif /* !TCPV40HDRS */
|
---|
121 |
|
---|
122 | #if defined (__cplusplus)
|
---|
123 | }
|
---|
124 | #endif
|
---|
125 |
|
---|
126 | #endif /* not _SYS_SELECT_H */
|
---|