X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fcompiler.h;h=2b496a88b70824b065461db08da1f2ca699161d5;hb=3de8060d28ffe56a57855df01849cac2e93dafd0;hp=cef7a476d67f85f6a1e1334ce038c413eca040b3;hpb=1d1df11d0582bef07ef2b33e8e82a75b08f32be4;p=lttv.git diff --git a/ltt/branches/poly/ltt/compiler.h b/ltt/branches/poly/ltt/compiler.h index cef7a476..2b496a88 100644 --- a/ltt/branches/poly/ltt/compiler.h +++ b/ltt/branches/poly/ltt/compiler.h @@ -23,4 +23,31 @@ #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) + +/* + * Check at compile time that something is of a particular type. + * Always evaluates to 1 so you may use it easily in comparisons. + */ +#define typecheck(type,x) \ +({ type __dummy; \ + typeof(x) __dummy2; \ + (void)(&__dummy == &__dummy2); \ + 1; \ +}) + +/* Deal with 32 wrap correctly */ +#define guint32_after(a,b) \ + (typecheck(guint32, a) && \ + typecheck(guint32, b) && \ + ((gint32)(b) - (gint32)(a) < 0)) +#define guint32_before(a,b) guint32_after(b,a) + +#define guint32_after_eq(a,b) \ + (typecheck(guint32, a) && \ + typecheck(guint32, b) && \ + ((gint32)(b) - (gint32)(a) <= 0)) +#define guint32_before_eq(a,b) guint32_after_eq(b,a) + +#define __EXPORT __attribute__ ((visibility ("default"))) + #endif //COMPILER_H