… | |
… | |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
30 | */ |
31 | |
31 | |
32 | /* for unix systems */ |
32 | /* for unix systems */ |
33 | #ifdef WIN32 |
33 | #if WIN32 |
34 | typedef unsigned int uint32_t; |
34 | typedef unsigned int uint32_t; |
|
|
35 | # ifndef EV_SELECT_USE_FD_SET |
35 | # define EV_SELECT_USE_FD_SET 1 |
36 | # define EV_SELECT_USE_FD_SET 1 |
|
|
37 | # endif |
36 | #else |
38 | #else |
37 | # include <sys/select.h> |
39 | # include <sys/select.h> |
38 | # include <inttypes.h> |
40 | # include <inttypes.h> |
39 | #endif |
41 | #endif |
40 | |
42 | |
|
|
43 | #if EV_SELECT_USE_WIN32_HANDLES |
|
|
44 | # undef EV_SELECT_USE_FD_SET |
|
|
45 | # define EV_SELECT_USE_FD_SET 1 |
|
|
46 | #else |
|
|
47 | #endif |
|
|
48 | |
41 | #include <string.h> |
49 | #include <string.h> |
42 | |
50 | |
43 | static void |
51 | static void |
44 | select_modify (EV_P_ int fd, int oev, int nev) |
52 | select_modify (EV_P_ int fd, int oev, int nev) |
45 | { |
53 | { |
46 | if (oev == nev) |
54 | if (oev == nev) |
47 | return; |
55 | return; |
48 | |
56 | |
49 | #if EV_SELECT_USE_FD_SET |
57 | #if EV_SELECT_USE_FD_SET |
|
|
58 | # if EV_SELECT_USE_WIN32_HANDLES |
|
|
59 | fd = _get_osfhandle (fd); |
|
|
60 | if (fd < 0) |
|
|
61 | return; |
|
|
62 | # endif |
|
|
63 | |
50 | if (nev & EV_READ) |
64 | if (nev & EV_READ) |
51 | FD_SET (fd, (struct fd_set *)vec_ri); |
65 | FD_SET (fd, (struct fd_set *)vec_ri); |
52 | else |
66 | else |
53 | FD_CLR (fd, (struct fd_set *)vec_ri); |
67 | FD_CLR (fd, (struct fd_set *)vec_ri); |
54 | |
68 | |
… | |
… | |
122 | |
136 | |
123 | return; |
137 | return; |
124 | } |
138 | } |
125 | |
139 | |
126 | #if EV_SELECT_USE_FD_SET |
140 | #if EV_SELECT_USE_FD_SET |
|
|
141 | # if EV_SELECT_USE_WIN32_HANDLES |
|
|
142 | for (word = 0; word < anfdmax; ++word) |
|
|
143 | { |
|
|
144 | if (!anfd [word].events) |
|
|
145 | { |
|
|
146 | int fd = _get_osfhandle (word); |
|
|
147 | |
|
|
148 | if (fd >= 0) |
|
|
149 | { |
|
|
150 | int events = 0; |
|
|
151 | |
|
|
152 | if (FD_ISSET (fd, (struct fd_set *)vec_ro)) events |= EV_READ; |
|
|
153 | if (FD_ISSET (fd, (struct fd_set *)vec_wo)) events |= EV_WRITE; |
|
|
154 | |
|
|
155 | if (events) |
|
|
156 | fd_event (EV_A_ word, events); |
|
|
157 | } |
|
|
158 | } |
|
|
159 | } |
|
|
160 | # else |
127 | for (word = 0; word < FD_SETSIZE; ++word) |
161 | for (word = 0; word < FD_SETSIZE; ++word) |
128 | { |
162 | { |
129 | int events = 0; |
163 | int events = 0; |
130 | if (FD_ISSET (word, (struct fd_set *)vec_ro)) events |= EV_READ; |
164 | if (FD_ISSET (word, (struct fd_set *)vec_ro)) events |= EV_READ; |
131 | if (FD_ISSET (word, (struct fd_set *)vec_wo)) events |= EV_WRITE; |
165 | if (FD_ISSET (word, (struct fd_set *)vec_wo)) events |= EV_WRITE; |
132 | |
166 | |
133 | if (events) |
167 | if (events) |
134 | fd_event (EV_A_ word, events); |
168 | fd_event (EV_A_ word, events); |
135 | } |
169 | } |
|
|
170 | # endif |
136 | #else |
171 | #else |
137 | for (word = vec_max; word--; ) |
172 | for (word = vec_max; word--; ) |
138 | { |
173 | { |
139 | if (((uint32_t *)vec_ro) [word] | ((uint32_t *)vec_wo) [word]) |
174 | if (((uint32_t *)vec_ro) [word] | ((uint32_t *)vec_wo) [word]) |
140 | for (offs = 4; offs--; ) |
175 | for (offs = 4; offs--; ) |