summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ev.c29
-rw-r--r--ev.h12
2 files changed, 26 insertions, 15 deletions
diff --git a/ev.c b/ev.c
index d04f786..e10b360 100644
--- a/ev.c
+++ b/ev.c
@@ -260,8 +260,8 @@ typedef struct
};
#include "ev_wrap.h"
- struct ev_loop default_loop_struct;
- static struct ev_loop *default_loop;
+ static struct ev_loop default_loop_struct;
+ struct ev_loop *ev_default_loop_ptr;
#else
@@ -270,7 +270,7 @@ typedef struct
#include "ev_vars.h"
#undef VAR
- static int default_loop;
+ static int ev_default_loop_ptr;
#endif
@@ -616,7 +616,7 @@ ev_feed_signal_event (EV_P_ int signum)
WL w;
#if EV_MULTIPLICITY
- assert (("feeding signal events is only supported in the default loop", loop == default_loop));
+ assert (("feeding signal events is only supported in the default loop", loop == ev_default_loop_ptr));
#endif
--signum;
@@ -893,21 +893,22 @@ ev_loop_fork (EV_P)
#if EV_MULTIPLICITY
struct ev_loop *
+ev_default_loop_ (unsigned int flags)
#else
int
-#endif
ev_default_loop (unsigned int flags)
+#endif
{
if (sigpipe [0] == sigpipe [1])
if (pipe (sigpipe))
return 0;
- if (!default_loop)
+ if (!ev_default_loop_ptr)
{
#if EV_MULTIPLICITY
- struct ev_loop *loop = default_loop = &default_loop_struct;
+ struct ev_loop *loop = ev_default_loop_ptr = &default_loop_struct;
#else
- default_loop = 1;
+ ev_default_default_loop_ptr = 1;
#endif
loop_init (EV_A_ flags);
@@ -924,17 +925,17 @@ ev_default_loop (unsigned int flags)
#endif
}
else
- default_loop = 0;
+ ev_default_loop_ptr = 0;
}
- return default_loop;
+ return ev_default_loop_ptr;
}
void
ev_default_destroy (void)
{
#if EV_MULTIPLICITY
- struct ev_loop *loop = default_loop;
+ struct ev_loop *loop = ev_default_loop_ptr;
#endif
#ifndef _WIN32
@@ -955,7 +956,7 @@ void
ev_default_fork (void)
{
#if EV_MULTIPLICITY
- struct ev_loop *loop = default_loop;
+ struct ev_loop *loop = ev_default_loop_ptr;
#endif
if (method)
@@ -1518,7 +1519,7 @@ void
ev_signal_start (EV_P_ struct ev_signal *w)
{
#if EV_MULTIPLICITY
- assert (("signal watchers are only supported in the default loop", loop == default_loop));
+ assert (("signal watchers are only supported in the default loop", loop == ev_default_loop_ptr));
#endif
if (ev_is_active (w))
return;
@@ -1561,7 +1562,7 @@ void
ev_child_start (EV_P_ struct ev_child *w)
{
#if EV_MULTIPLICITY
- assert (("child watchers are only supported in the default loop", loop == default_loop));
+ assert (("child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
#endif
if (ev_is_active (w))
return;
diff --git a/ev.h b/ev.h
index f2ec3f2..af6c2da 100644
--- a/ev.h
+++ b/ev.h
@@ -269,7 +269,17 @@ void ev_set_syserr_cb (void (*cb)(const char *msg));
# if EV_MULTIPLICITY
/* the default loop is the only one that handles signals and child watchers */
/* you can call this as often as you like */
-struct ev_loop *ev_default_loop (unsigned int flags); /* returns default loop */
+static struct ev_loop *
+ev_default_loop (unsigned int flags)
+{
+ extern struct ev_loop *ev_default_loop_ptr;
+ extern struct ev_loop *ev_default_loop_ (unsigned int flags);
+
+ if (!ev_default_loop_ptr)
+ ev_default_loop_ (flags);
+
+ return ev_default_loop_ptr;
+}
/* create and destroy alternative loops that don't handle signals */
struct ev_loop *ev_loop_new (unsigned int flags);