From: Mathieu Desnoyers Date: Tue, 17 Jul 2012 05:49:45 +0000 (-0400) Subject: Fix: filter: remove dependency on UST bug.h X-Git-Tag: v2.1.0-rc1~83 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8564ccbd529ed367de6a0c86f428dda64e14cf5d;p=lttng-tools.git Fix: filter: remove dependency on UST bug.h Fixes #308 Signed-off-by: Mathieu Desnoyers --- diff --git a/src/lib/lttng-ctl/Makefile.am b/src/lib/lttng-ctl/Makefile.am index bb5561e79..c5e4af651 100644 --- a/src/lib/lttng-ctl/Makefile.am +++ b/src/lib/lttng-ctl/Makefile.am @@ -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 \ diff --git a/src/lib/lttng-ctl/align.h b/src/lib/lttng-ctl/align.h index 813bade92..fe3267354 100644 --- a/src/lib/lttng-ctl/align.h +++ b/src/lib/lttng-ctl/align.h @@ -17,7 +17,7 @@ * all copies or substantial portions of the Software. */ -#include +#include "bug.h" #include #include diff --git a/src/lib/lttng-ctl/bug.h b/src/lib/lttng-ctl/bug.h new file mode 100644 index 000000000..9368c0897 --- /dev/null +++ b/src/lib/lttng-ctl/bug.h @@ -0,0 +1,54 @@ +#ifndef _LTTNG_BUG_H +#define _LTTNG_BUG_H + +/* + * lttng/bug.h + * + * (C) Copyright 2010-2011 - Mathieu Desnoyers + * + * 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 +#include +#include + +#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