diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-11-24 11:36:24 +0200 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-11-24 13:26:52 +0200 |
commit | 3ea1a77fb5419ffd2f9c997977b383b5faf75423 (patch) | |
tree | 6f848510e07e11ca0ce34939bcb7944dfa49a4f5 /include/libtf/defines.h | |
parent | e4e54c2ec744e884f6f55c135bea78e815d28d6c (diff) | |
download | libtf-3ea1a77fb5419ffd2f9c997977b383b5faf75423.tar.bz2 libtf-3ea1a77fb5419ffd2f9c997977b383b5faf75423.tar.xz |
libtf: implement timeouts
internally put sleepers to d-ary heap based priority queue. the
heap value is compared with overflow.
Diffstat (limited to 'include/libtf/defines.h')
-rw-r--r-- | include/libtf/defines.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/libtf/defines.h b/include/libtf/defines.h index 7e35ff7..b1d2aa9 100644 --- a/include/libtf/defines.h +++ b/include/libtf/defines.h @@ -54,7 +54,7 @@ #define attribute_never_inline __attribute__((noinline)) #define attribute_weak_function __attribute__((weak)) -#define TF_BUG_ON(cond) if (cond) { \ +#define TF_BUG_ON(cond) if (unlikely(cond)) { \ fprintf(stderr, "BUG: failure at %s:%d/%s(): %s!\n", \ __FILE__, __LINE__, __func__, #cond); \ abort(); \ @@ -64,4 +64,18 @@ #define TF_EMPTY_ARRAY 0 +#ifndef TF_STACK_SIZE +#define TF_STACK_SIZE 4096 +#endif + +/* Monotonic time */ +typedef uint32_t tf_mtime_t; +typedef int32_t tf_mtime_diff_t; + +static inline +tf_mtime_diff_t tf_mtime_diff(tf_mtime_t a, tf_mtime_t b) +{ + return (tf_mtime_diff_t)(a - b); +} + #endif |