Initial port of the state system to the LTTng 2.0 trace format
[lttv.git] / lttv / lttv / compiler.h
diff --git a/lttv/lttv/compiler.h b/lttv/lttv/compiler.h
new file mode 100644 (file)
index 0000000..d621a8c
--- /dev/null
@@ -0,0 +1,61 @@
+/* This file is part of the Linux Trace Toolkit trace reading library
+ * Copyright (C) 2003-2004 Mathieu Desnoyers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License Version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef COMPILER_H
+#define COMPILER_H
+
+/* Fast prediction if likely branches */
+#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")))
+
+#ifndef max
+#define max(a,b) ((a)>(b)?(a):(b))
+#endif
+
+#ifndef min
+#define min(a,b) ((a)<(b)?(a):(b))
+#endif
+
+#endif //COMPILER_H
This page took 0.022946 seconds and 4 git commands to generate.