summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2008-04-06 14:34:50 +0000
committerroot <root>2008-04-06 14:34:50 +0000
commit3d0af358d5546af2152aceb584947b9647499967 (patch)
tree1fd0037775a4dc90a4c6c87d4068263c50861f7e
parent226209f9a7f9890de15359d7e50cad68fe45283b (diff)
*** empty log message ***
-rw-r--r--Changes4
-rw-r--r--ev.c2
-rw-r--r--ev.h40
-rw-r--r--ev.pod10
4 files changed, 46 insertions, 10 deletions
diff --git a/Changes b/Changes
index 544a113..e98af8a 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,10 @@ Revision history for libev, a high-performance and full-featured event loop.
- added linux eventfd support.
- try to autodetect epoll and inotify support
by libc header version if not using autoconf.
+ - new symbols: EV_DEFAULT_UC and EV_DEFAULT_UC_.
+ - declare functions defined in ev.h as inline if
+ C99 or gcc are available.
+ - enable inlining with gcc versions 2 and 3.
3.2 Wed Apr 2 17:11:19 CEST 2008
- fix a 64 bit overflow issue in the select backend,
diff --git a/ev.c b/ev.c
index 41fab78..68adb7e 100644
--- a/ev.c
+++ b/ev.c
@@ -302,7 +302,7 @@ int eventfd (unsigned int initval, int flags);
#else
# define expect(expr,value) (expr)
# define noinline
-# if __STDC_VERSION__ < 199901L
+# if __STDC_VERSION__ < 199901L && __GNUC__ < 2
# define inline
# endif
#endif
diff --git a/ev.h b/ev.h
index 11b7cc2..213e20c 100644
--- a/ev.h
+++ b/ev.h
@@ -100,6 +100,8 @@ struct ev_loop;
# define EV_P_ EV_P,
# define EV_A loop
# define EV_A_ EV_A,
+# define EV_DEFAULT_UC ev_default_loop_uc ()
+# define EV_DEFAULT_UC_ EV_DEFAULT_UC,
# define EV_DEFAULT ev_default_loop (0)
# define EV_DEFAULT_ EV_DEFAULT,
#else
@@ -109,10 +111,19 @@ struct ev_loop;
# define EV_A_
# define EV_DEFAULT
# define EV_DEFAULT_
-
+# define EV_DEFAULT_UC
+# define EV_DEFAULT_UC_
# undef EV_EMBED_ENABLE
#endif
+#if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3
+# define EV_INLINE static inline
+#else
+# define EV_INLINE static
+#endif
+
+/*****************************************************************************/
+
/* eventmask, revents, events... */
#define EV_UNDEF -1L /* guaranteed to be invalid */
#define EV_NONE 0x00L /* no events */
@@ -400,18 +411,29 @@ void ev_set_allocator (void *(*cb)(void *ptr, long size));
void ev_set_syserr_cb (void (*cb)(const char *msg));
# if EV_MULTIPLICITY
+EV_INLINE struct ev_loop *
+ev_default_loop_uc (void)
+{
+ extern struct ev_loop *ev_default_loop_ptr;
+
+ return ev_default_loop_ptr;
+}
+
/* the default loop is the only one that handles signals and child watchers */
/* you can call this as often as you like */
-static struct ev_loop *
+EV_INLINE struct ev_loop *
ev_default_loop (unsigned int flags)
{
- extern struct ev_loop *ev_default_loop_ptr;
- extern struct ev_loop *ev_default_loop_init (unsigned int flags);
+ struct ev_loop *loop = ev_default_loop_uc ();
- if (!ev_default_loop_ptr)
- ev_default_loop_init (flags);
+ if (!loop)
+ {
+ extern struct ev_loop *ev_default_loop_init (unsigned int flags);
- return ev_default_loop_ptr;
+ loop = ev_default_loop_init (flags);
+ }
+
+ return loop;
}
/* create and destroy alternative loops that don't handle signals */
@@ -425,7 +447,7 @@ ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after
int ev_default_loop (unsigned int flags); /* returns true when successful */
-static ev_tstamp
+EV_INLINE ev_tstamp
ev_now (void)
{
extern ev_tstamp ev_rt_now;
@@ -434,7 +456,7 @@ ev_now (void)
}
# endif
-static int
+EV_INLINE int
ev_is_default_loop (EV_P)
{
#if EV_MULTIPLICITY
diff --git a/ev.pod b/ev.pod
index 72cf388..b904e2b 100644
--- a/ev.pod
+++ b/ev.pod
@@ -2635,6 +2635,16 @@ suitable for use with C<EV_A>.
Similar to the other two macros, this gives you the value of the default
loop, if multiple loops are supported ("ev loop default").
+=item C<EV_DEFAULT_UC>, C<EV_DEFAULT_UC_>
+
+Usage identical to C<EV_DEFAULT> and C<EV_DEFAULT_>, but requires that the
+default loop has been initialised (C<UC> == unchecked). Their behaviour
+is undefined when the default loop has not been initialised by a previous
+execution of C<EV_DEFAULT>, C<EV_DEFAULT_> or C<ev_default_init (...)>.
+
+It is often prudent to use C<EV_DEFAULT> when initialising the first
+watcher in a function but use C<EV_DEFAULT_UC> afterwards.
+
=back
Example: Declare and initialise a check watcher, utilising the above