add guint32_before and after
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 14 Sep 2005 16:40:20 +0000 (16:40 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 14 Sep 2005 16:40:20 +0000 (16:40 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1182 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/compiler.h

index cef7a476d67f85f6a1e1334ce038c413eca040b3..1ab188f871a4e21ba5fd370c7b39e7c4ed4b7df2 100644 (file)
 #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)
+
+
 #endif //COMPILER_H
This page took 0.02444 seconds and 4 git commands to generate.