summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2011-09-25 21:27:35 +0000
committerroot <root>2011-09-25 21:27:35 +0000
commit8a570a6407f41e258b29db53fa6a5d4f485e8723 (patch)
treea6c596247027c0e38445bada9671ae7077527e75
parentd64e35cce4274203770aa217d982a956e8e34c89 (diff)
*** empty log message ***
-rw-r--r--Changes2
-rw-r--r--ev.c20
2 files changed, 20 insertions, 2 deletions
diff --git a/Changes b/Changes
index e2df754..baf554b 100644
--- a/Changes
+++ b/Changes
@@ -4,6 +4,8 @@ TODO: ev_loop_wakeup
TODO: EV_NO_THREADS/NO_SMP and/or EV_USE_PTHREADS or so. also document.
TODO: #define EV_API_DECL static? ev_default_loop_ptr?
+TODO: EV_STANDALONE == NO_HASSEL (do not use clock_gettime in ev_standalone)
+TODO: memory fences for clang
4.10
- fix a race where the workaround against the epoll fork bugs
caused signals to not be handled anymore.
diff --git a/ev.c b/ev.c
index c27aca1..2b4a1ae 100644
--- a/ev.c
+++ b/ev.c
@@ -543,7 +543,7 @@ struct signalfd_siginfo
#endif
#ifndef ECB_MEMORY_FENCE
- #if ECB_GCC_VERSION(2,5)
+ #if ECB_GCC_VERSION(2,5) || defined(__INTEL_COMPILER) || defined(__clang__)
#if __i386__
#define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory")
#define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */
@@ -565,7 +565,7 @@ struct signalfd_siginfo
#endif
#ifndef ECB_MEMORY_FENCE
- #if ECB_GCC_VERSION(4,4) || defined(__INTEL_COMPILER)
+ #if ECB_GCC_VERSION(4,4) || defined(__INTEL_COMPILER) || defined(__clang__)
#define ECB_MEMORY_FENCE __sync_synchronize ()
/*#define ECB_MEMORY_FENCE_ACQUIRE ({ char dummy = 0; __sync_lock_test_and_set (&dummy, 1); }) */
/*#define ECB_MEMORY_FENCE_RELEASE ({ char dummy = 1; __sync_lock_release (&dummy ); }) */
@@ -845,6 +845,22 @@ ecb_function_ ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper ()
#define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n)))
#endif
+#if __cplusplus
+ template<typename T>
+ static inline T ecb_div_rd (T val, T div)
+ {
+ return val < 0 ? - ((-val + div - 1) / div) : (val ) / div;
+ }
+ template<typename T>
+ static inline T ecb_div_ru (T val, T div)
+ {
+ return val < 0 ? - ((-val ) / div) : (val + div - 1) / div;
+ }
+#else
+ #define ecb_div_rd(val,div) ((val) < 0 ? - ((-(val) + (div) - 1) / (div)) : ((val) ) / (div))
+ #define ecb_div_ru(val,div) ((val) < 0 ? - ((-(val) ) / (div)) : ((val) + (div) - 1) / (div))
+#endif
+
#if ecb_cplusplus_does_not_suck
/* does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) */
template<typename T, int N>