X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/22b2a449105d7604f715c1afafeb4fe5ac473f1b..d5b686568688adf526735190000d81a260db6c36:/ev.c?ds=inline diff --git a/ev.c b/ev.c index 2db968e..53491e1 100644 --- a/ev.c +++ b/ev.c @@ -147,6 +147,12 @@ typedef struct ev_watcher_time *WT; static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ +#if WIN32 +/* note: the comment below could not be substantiated, but what would I care */ +/* MSDN says this is required to handle SIGFPE */ +volatile double SIGFPE_REQ = 0.0f; +#endif + /*****************************************************************************/ typedef struct @@ -234,6 +240,17 @@ ev_now (EV_P) cur = newcnt; \ } +#define array_slim(stem) \ + if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ + { \ + stem ## max = array_roundsize (stem ## cnt >> 1); \ + base = realloc (base, sizeof (*base) * (stem ## max)); \ + fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ + } + +#define array_free(stem, idx) \ + free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; + /*****************************************************************************/ static void @@ -455,6 +472,10 @@ signals_init (ANSIG *base, int count) static void sighandler (int signum) { +#if WIN32 + signal (signum, sighandler); +#endif + signals [signum - 1].gotsig = 1; if (!gotsig) @@ -636,6 +657,8 @@ loop_init (EV_P_ int methods) void loop_destroy (EV_P) { + int i; + #if EV_USE_WIN32 if (method == EVMETHOD_WIN32 ) win32_destroy (EV_A); #endif @@ -652,6 +675,16 @@ loop_destroy (EV_P) if (method == EVMETHOD_SELECT) select_destroy (EV_A); #endif + for (i = NUMPRI; i--; ) + array_free (pending, [i]); + + array_free (fdchange, ); + array_free (timer, ); + array_free (periodic, ); + array_free (idle, ); + array_free (prepare, ); + array_free (check, ); + method = 0; /*TODO*/ } @@ -795,8 +828,7 @@ call_pending (EV_P) if (p->w) { p->w->pending = 0; - - (*(void (**)(EV_P_ W, int))&p->w->cb) (EV_A_ p->w, p->events); + p->w->cb (EV_A_ p->w, p->events); } } } @@ -1298,11 +1330,15 @@ ev_signal_start (EV_P_ struct ev_signal *w) if (!((WL)w)->next) { +#if WIN32 + signal (w->signum, sighandler); +#else struct sigaction sa; sa.sa_handler = sighandler; sigfillset (&sa.sa_mask); sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ sigaction (w->signum, &sa, 0); +#endif } }