diff options
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | ev.c | 20 |
2 files changed, 20 insertions, 2 deletions
@@ -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. @@ -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> |