ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.66 by root, Sun Nov 4 23:30:53 2007 UTC vs.
Revision 1.68 by root, Mon Nov 5 20:19:00 2007 UTC

145typedef struct ev_watcher_list *WL; 145typedef struct ev_watcher_list *WL;
146typedef struct ev_watcher_time *WT; 146typedef struct ev_watcher_time *WT;
147 147
148static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ 148static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
149 149
150#if WIN32
151/* note: the comment below could not be substantiated, but what would I care */
152/* MSDN says this is required to handle SIGFPE */
153volatile double SIGFPE_REQ = 0.0f;
154#endif
155
150/*****************************************************************************/ 156/*****************************************************************************/
151 157
152typedef struct 158typedef struct
153{ 159{
154 struct ev_watcher_list *head; 160 WL head;
155 unsigned char events; 161 unsigned char events;
156 unsigned char reify; 162 unsigned char reify;
157} ANFD; 163} ANFD;
158 164
159typedef struct 165typedef struct
232 base = realloc (base, sizeof (*base) * (newcnt)); \ 238 base = realloc (base, sizeof (*base) * (newcnt)); \
233 init (base + cur, newcnt - cur); \ 239 init (base + cur, newcnt - cur); \
234 cur = newcnt; \ 240 cur = newcnt; \
235 } 241 }
236 242
243#define array_slim(stem) \
244 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \
245 { \
246 stem ## max = array_roundsize (stem ## cnt >> 1); \
247 base = realloc (base, sizeof (*base) * (stem ## max)); \
248 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\
249 }
250
237#define array_free(stem, idx) \ 251#define array_free(stem, idx) \
238 free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; 252 free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0;
239 253
240/*****************************************************************************/ 254/*****************************************************************************/
241 255
362 int fd; 376 int fd;
363 377
364 for (fd = anfdmax; fd--; ) 378 for (fd = anfdmax; fd--; )
365 if (anfds [fd].events) 379 if (anfds [fd].events)
366 { 380 {
367 close (fd);
368 fd_kill (EV_A_ fd); 381 fd_kill (EV_A_ fd);
369 return; 382 return;
370 } 383 }
371} 384}
372 385
430 443
431/*****************************************************************************/ 444/*****************************************************************************/
432 445
433typedef struct 446typedef struct
434{ 447{
435 struct ev_watcher_list *head; 448 WL head;
436 sig_atomic_t volatile gotsig; 449 sig_atomic_t volatile gotsig;
437} ANSIG; 450} ANSIG;
438 451
439static ANSIG *signals; 452static ANSIG *signals;
440static int signalmax; 453static int signalmax;
456} 469}
457 470
458static void 471static void
459sighandler (int signum) 472sighandler (int signum)
460{ 473{
474#if WIN32
475 signal (signum, sighandler);
476#endif
477
461 signals [signum - 1].gotsig = 1; 478 signals [signum - 1].gotsig = 1;
462 479
463 if (!gotsig) 480 if (!gotsig)
464 { 481 {
465 int old_errno = errno; 482 int old_errno = errno;
470} 487}
471 488
472static void 489static void
473sigcb (EV_P_ struct ev_io *iow, int revents) 490sigcb (EV_P_ struct ev_io *iow, int revents)
474{ 491{
475 struct ev_watcher_list *w; 492 WL w;
476 int signum; 493 int signum;
477 494
478 read (sigpipe [0], &revents, 1); 495 read (sigpipe [0], &revents, 1);
479 gotsig = 0; 496 gotsig = 0;
480 497
1310 array_needsize (signals, signalmax, w->signum, signals_init); 1327 array_needsize (signals, signalmax, w->signum, signals_init);
1311 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1328 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
1312 1329
1313 if (!((WL)w)->next) 1330 if (!((WL)w)->next)
1314 { 1331 {
1332#if WIN32
1333 signal (w->signum, sighandler);
1334#else
1315 struct sigaction sa; 1335 struct sigaction sa;
1316 sa.sa_handler = sighandler; 1336 sa.sa_handler = sighandler;
1317 sigfillset (&sa.sa_mask); 1337 sigfillset (&sa.sa_mask);
1318 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ 1338 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */
1319 sigaction (w->signum, &sa, 0); 1339 sigaction (w->signum, &sa, 0);
1340#endif
1320 } 1341 }
1321} 1342}
1322 1343
1323void 1344void
1324ev_signal_stop (EV_P_ struct ev_signal *w) 1345ev_signal_stop (EV_P_ struct ev_signal *w)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines