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

Comparing libev/ev.h (file contents):
Revision 1.177 by root, Tue Sep 9 13:34:46 2014 UTC vs.
Revision 1.184 by root, Sun Dec 20 01:35:55 2015 UTC

1/* 1/*
2 * libev native API header 2 * libev native API header
3 * 3 *
4 * Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010,2011,2012,2015 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
40#ifndef EV_H_ 40#ifndef EV_H_
41#define EV_H_ 41#define EV_H_
42 42
43#ifdef __cplusplus 43#ifdef __cplusplus
44# define EV_CPP(x) x 44# define EV_CPP(x) x
45# if __cplusplus >= 201103L
46# define EV_THROW noexcept
47# else
48# define EV_THROW throw ()
49# endif
45#else 50#else
46# define EV_CPP(x) 51# define EV_CPP(x)
47#endif
48
49#define EV_THROW EV_CPP(throw())
50
51/* apple's proprietary clang fork errors out with exception specifications */
52/* in all sorts of places, so let's not even bother with them */
53/* users are strongly advised to install clang or gcc */
54#if __APPLE__ && __clang__
55# undef EV_THROW
56# define EV_THROW 52# define EV_THROW
57#endif 53#endif
58 54
59EV_CPP(extern "C" {) 55EV_CPP(extern "C" {)
60 56
153#endif 149#endif
154 150
155/*****************************************************************************/ 151/*****************************************************************************/
156 152
157typedef double ev_tstamp; 153typedef double ev_tstamp;
154
155#include <string.h> /* for memmove */
158 156
159#ifndef EV_ATOMIC_T 157#ifndef EV_ATOMIC_T
160# include <signal.h> 158# include <signal.h>
161# define EV_ATOMIC_T sig_atomic_t volatile 159# define EV_ATOMIC_T sig_atomic_t volatile
162#endif 160#endif
211#endif 209#endif
212 210
213/*****************************************************************************/ 211/*****************************************************************************/
214 212
215#define EV_VERSION_MAJOR 4 213#define EV_VERSION_MAJOR 4
216#define EV_VERSION_MINOR 18 214#define EV_VERSION_MINOR 22
217 215
218/* eventmask, revents, events... */ 216/* eventmask, revents, events... */
219enum { 217enum {
220 EV_UNDEF = (int)0xFFFFFFFF, /* guaranteed to be invalid */ 218 EV_UNDEF = (int)0xFFFFFFFF, /* guaranteed to be invalid */
221 EV_NONE = 0x00, /* no events */ 219 EV_NONE = 0x00, /* no events */
666/* advanced stuff for threading etc. support, see docs */ 664/* advanced stuff for threading etc. support, see docs */
667EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW; 665EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW;
668EV_API_DECL void *ev_userdata (EV_P) EV_THROW; 666EV_API_DECL void *ev_userdata (EV_P) EV_THROW;
669typedef void (*ev_loop_callback)(EV_P); 667typedef void (*ev_loop_callback)(EV_P);
670EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW; 668EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW;
671EV_API_DECL void ev_set_loop_release_cb (EV_P_ ev_loop_callback EV_THROW release, ev_loop_callback EV_THROW acquire) EV_THROW; 669/* C++ doesn't allow the use of the ev_loop_callback typedef here, so we need to spell it out */
670EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW;
672 671
673EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */ 672EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */
674EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */ 673EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */
675 674
676/* 675/*
720#define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0) 719#define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0)
721 720
722#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ 721#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
723#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ 722#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
724 723
725#define ev_cb(ev) (ev)->cb /* rw */ 724#define ev_cb_(ev) (ev)->cb /* rw */
725#define ev_cb(ev) (memmove (&ev_cb_ (ev), &((ev_watcher *)(ev))->cb, sizeof (ev_cb_ (ev))), (ev)->cb)
726 726
727#if EV_MINPRI == EV_MAXPRI 727#if EV_MINPRI == EV_MAXPRI
728# define ev_priority(ev) ((ev), EV_MINPRI) 728# define ev_priority(ev) ((ev), EV_MINPRI)
729# define ev_set_priority(ev,pri) ((ev), (pri)) 729# define ev_set_priority(ev,pri) ((ev), (pri))
730#else 730#else
733#endif 733#endif
734 734
735#define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at) 735#define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at)
736 736
737#ifndef ev_set_cb 737#ifndef ev_set_cb
738# define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) 738# define ev_set_cb(ev,cb_) (ev_cb_ (ev) = (cb_), memmove (&((ev_watcher *)(ev))->cb, &ev_cb_ (ev), sizeof (ev_cb_ (ev))))
739#endif 739#endif
740 740
741/* stopping (enabling, adding) a watcher does nothing if it is already running */ 741/* stopping (enabling, adding) a watcher does nothing if it is already running */
742/* stopping (disabling, deleting) a watcher does nothing unless it's already running */ 742/* stopping (disabling, deleting) a watcher does nothing unless it's already running */
743#if EV_PROTOTYPES 743#if EV_PROTOTYPES

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines