… | |
… | |
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 | #endif |
|
|
47 | |
41 | #include <string.h> |
48 | #include <string.h> |
42 | |
49 | |
43 | static void |
50 | static void |
44 | select_modify (EV_P_ int fd, int oev, int nev) |
51 | select_modify (EV_P_ int fd, int oev, int nev) |
45 | { |
52 | { |
46 | if (oev == nev) |
53 | if (oev == nev) |
47 | return; |
54 | return; |
48 | |
55 | |
49 | #if EV_SELECT_USE_FD_SET |
56 | #if EV_SELECT_USE_FD_SET |
|
|
57 | # if EV_SELECT_USE_WIN32_HANDLES |
|
|
58 | fd = _get_osfhandle (fd); |
|
|
59 | if (fd < 0) |
|
|
60 | return; |
|
|
61 | # endif |
|
|
62 | |
50 | if (nev & EV_READ) |
63 | if (nev & EV_READ) |
51 | FD_SET (fd, (struct fd_set *)vec_ri); |
64 | FD_SET (fd, (struct fd_set *)vec_ri); |
52 | else |
65 | else |
53 | FD_CLR (fd, (struct fd_set *)vec_ri); |
66 | FD_CLR (fd, (struct fd_set *)vec_ri); |
54 | |
67 | |
… | |
… | |
122 | |
135 | |
123 | return; |
136 | return; |
124 | } |
137 | } |
125 | |
138 | |
126 | #if EV_SELECT_USE_FD_SET |
139 | #if EV_SELECT_USE_FD_SET |
|
|
140 | # if EV_SELECT_USE_WIN32_HANDLES |
|
|
141 | for (word = 0; word < anfdmax; ++word) |
|
|
142 | { |
|
|
143 | if (!anfd [word].events) |
|
|
144 | { |
|
|
145 | int fd = _get_osfhandle (word); |
|
|
146 | |
|
|
147 | if (fd >= 0) |
|
|
148 | { |
|
|
149 | int events = 0; |
|
|
150 | |
|
|
151 | if (FD_ISSET (fd, (struct fd_set *)vec_ro)) events |= EV_READ; |
|
|
152 | if (FD_ISSET (fd, (struct fd_set *)vec_wo)) events |= EV_WRITE; |
|
|
153 | |
|
|
154 | if (events) |
|
|
155 | fd_event (EV_A_ word, events); |
|
|
156 | } |
|
|
157 | } |
|
|
158 | } |
|
|
159 | # else |
127 | for (word = 0; word < FD_SETSIZE; ++word) |
160 | for (word = 0; word < FD_SETSIZE; ++word) |
128 | { |
161 | { |
129 | int events = 0; |
162 | int events = 0; |
130 | if (FD_ISSET (word, (struct fd_set *)vec_ro)) events |= EV_READ; |
163 | 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; |
164 | if (FD_ISSET (word, (struct fd_set *)vec_wo)) events |= EV_WRITE; |
132 | |
165 | |
133 | if (events) |
166 | if (events) |
134 | fd_event (EV_A_ word, events); |
167 | fd_event (EV_A_ word, events); |
135 | } |
168 | } |
|
|
169 | # endif |
136 | #else |
170 | #else |
137 | for (word = vec_max; word--; ) |
171 | for (word = vec_max; word--; ) |
138 | { |
172 | { |
139 | if (((uint32_t *)vec_ro) [word] | ((uint32_t *)vec_wo) [word]) |
173 | if (((uint32_t *)vec_ro) [word] | ((uint32_t *)vec_wo) [word]) |
140 | for (offs = 4; offs--; ) |
174 | for (offs = 4; offs--; ) |