summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2010-10-22 09:24:11 +0000
committerroot <root>2010-10-22 09:24:11 +0000
commita845b56899a44cf9b543f861159164777738be37 (patch)
treed0ab94d8ff9d7c719b76e3d042874c650ab023c2
parent952fe6b3afa24195745e5fac8156b7abd2575aae (diff)
*** empty log message ***
-rw-r--r--Changes4
-rw-r--r--ev.c26
-rw-r--r--ev.h63
3 files changed, 34 insertions, 59 deletions
diff --git a/Changes b/Changes
index 81cae25..3aaaa77 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
Revision history for libev, a high-performance and full-featured event loop.
TODO: include ev_xyz_start in each example?
+TODO: ev_pdef stupid idea?
+TODO: EVRUN_XXX?
- "PORTING FROM LIBEV 3.X TO 4.X" (in ev.pod) is recommended reading.
- ev_embed_stop did not correctly stop the watcher (very good
testcase by Vladimir Timofeev).
@@ -46,8 +48,6 @@ TODO: include ev_xyz_start in each example?
- improve compatibility to older C++ compilers.
- (experimental) ev_run/ev_default_loop/ev_break/ev_loop_new have now
default arguments when compiled as C++.
- - (experimental) all ev_functions that accept only a loop argument
- default that to EV_DEFAULT_UC when compiled as C++.
3.9 Thu Dec 31 07:59:59 CET 2009
- signalfd is no longer used by default and has to be requested
diff --git a/ev.c b/ev.c
index 27274b4..a8ab136 100644
--- a/ev.c
+++ b/ev.c
@@ -37,10 +37,6 @@
* either the BSD or the GPL.
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* this big block deduces configuration from config.h */
#ifndef EV_STANDALONE
# ifdef EV_CONFIG_H
@@ -184,6 +180,8 @@ extern "C" {
# include "ev.h"
#endif
+EV_CPP(extern "C" {)
+
#ifndef _WIN32
# include <sys/time.h>
# include <sys/wait.h>
@@ -413,13 +411,7 @@ extern "C" {
# define EFD_CLOEXEC 02000000
# endif
# endif
-# ifdef __cplusplus
-extern "C" {
-# endif
-int (eventfd) (unsigned int initval, int flags);
-# ifdef __cplusplus
-}
-# endif
+EV_CPP(extern "C") int (eventfd) (unsigned int initval, int flags);
#endif
#if EV_USE_SIGNALFD
@@ -435,19 +427,13 @@ int (eventfd) (unsigned int initval, int flags);
# define SFD_CLOEXEC 02000000
# endif
# endif
-# ifdef __cplusplus
-extern "C" {
-# endif
-int signalfd (int fd, const sigset_t *mask, int flags);
+EV_CPP (extern "C") int signalfd (int fd, const sigset_t *mask, int flags);
struct signalfd_siginfo
{
uint32_t ssi_signo;
char pad[128 - sizeof (uint32_t)];
};
-# ifdef __cplusplus
-}
-# endif
#endif
/**/
@@ -3809,7 +3795,5 @@ ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w))
#include "ev_wrap.h"
#endif
-#ifdef __cplusplus
-}
-#endif
+EV_CPP(})
diff --git a/ev.h b/ev.h
index 0922bb6..ae82f76 100644
--- a/ev.h
+++ b/ev.h
@@ -41,9 +41,13 @@
#define EV_H_
#ifdef __cplusplus
-extern "C" {
+# define EV_CPP(x) x
+#else
+# define EV_CPP(x)
#endif
+EV_CPP(extern "C" {)
+
/*****************************************************************************/
/* pre-4.0 compatibility */
@@ -147,13 +151,6 @@ typedef double ev_tstamp;
# include <sys/stat.h>
#endif
-/* in C++ we can use this to provide default arguments */
-#ifdef __cplusplus
-# define EV_DEFARG(x) = x
-#else
-# define EV_DEFARG(x)
-#endif
-
/* support multiple event loops? */
#if EV_MULTIPLICITY
struct ev_loop;
@@ -165,8 +162,6 @@ struct ev_loop;
# define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */
# define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */
# define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */
-# define EV_PDEF EV_P EV_DEFARG (EV_DEFAULT_UC) /* EV_P, but with default argument in C++ */
-# define EV_PDEF_ EV_P EV_DEFARG (EV_DEFAULT_UC), /* EV_P_, but with default argument in C++ */
#else
# define EV_P void
# define EV_P_
@@ -176,8 +171,6 @@ struct ev_loop;
# define EV_DEFAULT_
# define EV_DEFAULT_UC
# define EV_DEFAULT_UC_
-# define EV_PDEF EV_P
-# define EV_PDEF_ EV_P_
# undef EV_EMBED_ENABLE
#endif
@@ -528,7 +521,7 @@ ev_default_loop_uc (void)
/* the default loop is the only one that handles signals and child watchers */
/* you can call this as often as you like */
EV_INLINE struct ev_loop *
-ev_default_loop (unsigned int flags EV_DEFARG (0))
+ev_default_loop (unsigned int flags EV_CPP (= 0))
{
struct ev_loop *loop = ev_default_loop_uc ();
@@ -543,15 +536,15 @@ ev_default_loop (unsigned int flags EV_DEFARG (0))
}
/* create and destroy alternative loops that don't handle signals */
-struct ev_loop *ev_loop_new (unsigned int flags EV_DEFARG (0));
-void ev_loop_destroy (EV_PDEF);
-void ev_loop_fork (EV_PDEF);
+struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0));
+void ev_loop_destroy (EV_P);
+void ev_loop_fork (EV_P);
-ev_tstamp ev_now (EV_PDEF); /* time w.r.t. timers and the eventloop, updated after each poll */
+ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */
#else
-int ev_default_loop (unsigned int flags EV_DEFARG (0)); /* returns true when successful */
+int ev_default_loop (unsigned int flags EV_CPP (= 0)); /* returns true when successful */
EV_INLINE ev_tstamp
ev_now (void)
@@ -563,7 +556,7 @@ ev_now (void)
#endif /* multiplicity */
EV_INLINE int
-ev_is_default_loop (EV_PDEF)
+ev_is_default_loop (EV_P)
{
#if EV_MULTIPLICITY
extern struct ev_loop *ev_default_loop_ptr;
@@ -581,9 +574,9 @@ void ev_default_destroy (void); /* destroy the default loop */
/* you can actually call it at any time, anywhere :) */
void ev_default_fork (void);
-unsigned int ev_backend (EV_PDEF); /* backend in use by loop */
+unsigned int ev_backend (EV_P); /* backend in use by loop */
-void ev_now_update (EV_PDEF); /* update event loop time */
+void ev_now_update (EV_P); /* update event loop time */
#if EV_WALK_ENABLE
/* walk (almost) all watchers in the loop of a given type, invoking the */
@@ -608,16 +601,16 @@ enum {
};
#if EV_PROTOTYPES
-void ev_run (EV_PDEF_ int flags EV_DEFARG (0));
-void ev_break (EV_PDEF_ int how EV_DEFARG (EVBREAK_ONE)); /* break out of the loop */
+void ev_run (EV_P_ int flags EV_CPP (= 0));
+void ev_break (EV_P_ int how EV_CPP (= EVBREAK_ONE)); /* break out of the loop */
/*
* ref/unref can be used to add or remove a refcount on the mainloop. every watcher
* keeps one reference. if you have a long-running watcher you never unregister that
* should not keep ev_loop from running, unref() after starting, and ref() before stopping.
*/
-void ev_ref (EV_PDEF);
-void ev_unref (EV_PDEF);
+void ev_ref (EV_P);
+void ev_unref (EV_P);
/*
* convenience function, wait for a single event, without registering an event watcher
@@ -626,27 +619,27 @@ void ev_unref (EV_PDEF);
void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
# if EV_FEATURE_API
-unsigned int ev_iteration (EV_PDEF); /* number of loop iterations */
-unsigned int ev_depth (EV_PDEF); /* #ev_loop enters - #ev_loop leaves */
-void ev_verify (EV_PDEF); /* abort if loop data corrupted */
+unsigned int ev_iteration (EV_P); /* number of loop iterations */
+unsigned int ev_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */
+void ev_verify (EV_P); /* abort if loop data corrupted */
void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
/* advanced stuff for threading etc. support, see docs */
void ev_set_userdata (EV_P_ void *data);
-void *ev_userdata (EV_PDEF);
+void *ev_userdata (EV_P);
void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P));
void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P));
-unsigned int ev_pending_count (EV_PDEF); /* number of pending events, if any */
-void ev_invoke_pending (EV_PDEF); /* invoke all pending watchers */
+unsigned int ev_pending_count (EV_P); /* number of pending events, if any */
+void ev_invoke_pending (EV_P); /* invoke all pending watchers */
/*
* stop/start the timer handling.
*/
-void ev_suspend (EV_PDEF);
-void ev_resume (EV_PDEF);
+void ev_suspend (EV_P);
+void ev_resume (EV_P);
#endif
#endif
@@ -807,9 +800,7 @@ void ev_async_send (EV_P_ ev_async *w);
#endif
-#ifdef __cplusplus
-}
-#endif
+EV_CPP(})
#endif