sessiond: trigger: run trigger actions through an action executor
[lttng-tools.git] / src / common / bug.h
CommitLineData
8564ccbd 1/*
ab5be9fa 2 * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8564ccbd 3 *
ab5be9fa 4 * SPDX-License-Identifier: MIT
8564ccbd 5 *
8564ccbd
MD
6 */
7
ab5be9fa
MJ
8#ifndef _LTTNG_BUG_H
9#define _LTTNG_BUG_H
10
8564ccbd
MD
11#include <urcu/compiler.h>
12#include <stdio.h>
13#include <stdlib.h>
14
15#define LTTNG_BUG_ON(condition) \
16 do { \
17 if (caa_unlikely(condition)) { \
18 fprintf(stderr, \
19 "LTTng BUG in file %s, line %d.\n", \
20 __FILE__, __LINE__); \
21 exit(EXIT_FAILURE); \
22 } \
23 } while (0)
24
25#define LTTNG_BUILD_BUG_ON(condition) \
26 ((void) sizeof(char[-!!(condition)]))
27
28/**
29 * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
30 * @condition: the condition which should be false.
31 *
32 * If the condition is a constant and true, the compiler will generate a build
33 * error. If the condition is not constant, a BUG will be triggered at runtime
34 * if the condition is ever true. If the condition is constant and false, no
35 * code is emitted.
36 */
37#define LTTNG_BUILD_RUNTIME_BUG_ON(condition) \
38 do { \
39 if (__builtin_constant_p(condition)) \
40 LTTNG_BUILD_BUG_ON(condition); \
41 else \
42 LTTNG_BUG_ON(condition); \
43 } while (0)
44
45#endif
This page took 0.068366 seconds and 5 git commands to generate.