Fix: filter: remove dependency on UST bug.h
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 17 Jul 2012 05:49:45 +0000 (01:49 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 17 Jul 2012 05:49:45 +0000 (01:49 -0400)
Fixes #308

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/lib/lttng-ctl/Makefile.am
src/lib/lttng-ctl/align.h
src/lib/lttng-ctl/bug.h [new file with mode: 0644]

index bb5561e792cb76dea2d3622a1539c311b61e37dc..c5e4af651c2642561ff48ef5838d6a988705bfd9 100644 (file)
@@ -13,6 +13,7 @@ liblttng_ctl_la_SOURCES = lttng-ctl.c \
        filter-visitor-ir-check-binary-op-nesting.c \
        filter-visitor-generate-bytecode.c \
        align.h \
+       bug.h \
        filter-ast.h \
        filter-bytecode.h \
        filter-ir.h \
index 813bade92552be49f7b130fbc7c86a9230c133ba..fe3267354aad3980a4ba55e28b35cd99bfb1b5b3 100644 (file)
@@ -17,7 +17,7 @@
  * all copies or substantial portions of the Software.
  */
 
-#include <lttng/bug.h>
+#include "bug.h"
 #include <unistd.h>
 #include <limits.h>
 
diff --git a/src/lib/lttng-ctl/bug.h b/src/lib/lttng-ctl/bug.h
new file mode 100644 (file)
index 0000000..9368c08
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef _LTTNG_BUG_H
+#define _LTTNG_BUG_H
+
+/*
+ * lttng/bug.h
+ *
+ * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <urcu/compiler.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LTTNG_BUG_ON(condition)                                                \
+       do {                                                            \
+               if (caa_unlikely(condition)) {                          \
+                       fprintf(stderr,                                 \
+                               "LTTng BUG in file %s, line %d.\n",     \
+                               __FILE__, __LINE__);                    \
+                       exit(EXIT_FAILURE);                             \
+               }                                                       \
+       } while (0)
+
+#define LTTNG_BUILD_BUG_ON(condition)                                  \
+       ((void) sizeof(char[-!!(condition)]))
+
+/**
+ * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
+ * @condition: the condition which should be false.
+ *
+ * If the condition is a constant and true, the compiler will generate a build
+ * error. If the condition is not constant, a BUG will be triggered at runtime
+ * if the condition is ever true. If the condition is constant and false, no
+ * code is emitted.
+ */
+#define LTTNG_BUILD_RUNTIME_BUG_ON(condition)                  \
+       do {                                                    \
+               if (__builtin_constant_p(condition))            \
+                       LTTNG_BUILD_BUG_ON(condition);          \
+               else                                            \
+                       LTTNG_BUG_ON(condition);                \
+       } while (0)
+
+#endif
This page took 0.026539 seconds and 4 git commands to generate.