Xenomai 3.3.2
Loading...
Searching...
No Matches
assert.h
1/*
2 * Copyright (C) 2006 Philippe Gerum <rpm@xenomai.org>.
3 *
4 * Xenomai is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
8 *
9 * Xenomai is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Xenomai; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
18 */
19#ifndef _COBALT_KERNEL_ASSERT_H
20#define _COBALT_KERNEL_ASSERT_H
21
22#include <linux/kconfig.h>
23
24#define XENO_INFO KERN_INFO "[Xenomai] "
25#define XENO_WARNING KERN_WARNING "[Xenomai] "
26#define XENO_ERR KERN_ERR "[Xenomai] "
27
28#define XENO_DEBUG(__subsys) \
29 IS_ENABLED(CONFIG_XENO_OPT_DEBUG_##__subsys)
30#define XENO_ASSERT(__subsys, __cond) \
31 (!WARN_ON(XENO_DEBUG(__subsys) && !(__cond)))
32#define XENO_BUG(__subsys) \
33 BUG_ON(XENO_DEBUG(__subsys))
34#define XENO_BUG_ON(__subsys, __cond) \
35 BUG_ON(XENO_DEBUG(__subsys) && (__cond))
36#define XENO_WARN(__subsys, __cond, __fmt...) \
37 WARN(XENO_DEBUG(__subsys) && (__cond), __fmt)
38#define XENO_WARN_ON(__subsys, __cond) \
39 WARN_ON(XENO_DEBUG(__subsys) && (__cond))
40#define XENO_WARN_ON_ONCE(__subsys, __cond) \
41 WARN_ON_ONCE(XENO_DEBUG(__subsys) && (__cond))
42#ifdef CONFIG_SMP
43#define XENO_BUG_ON_SMP(__subsys, __cond) \
44 XENO_BUG_ON(__subsys, __cond)
45#define XENO_WARN_ON_SMP(__subsys, __cond) \
46 XENO_WARN_ON(__subsys, __cond)
47#define XENO_WARN_ON_ONCE_SMP(__subsys, __cond) \
48 XENO_WARN_ON_ONCE(__subsys, __cond)
49#else
50#define XENO_BUG_ON_SMP(__subsys, __cond) \
51 do { } while (0)
52#define XENO_WARN_ON_SMP(__subsys, __cond) \
53 do { } while (0)
54#define XENO_WARN_ON_ONCE_SMP(__subsys, __cond) \
55 do { } while (0)
56#endif
57
58#define primary_mode_only() XENO_BUG_ON(CONTEXT, is_secondary_domain())
59#define secondary_mode_only() XENO_BUG_ON(CONTEXT, !is_secondary_domain())
60#define interrupt_only() XENO_BUG_ON(CONTEXT, !xnsched_interrupt_p())
61#define realtime_cpu_only() XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(raw_smp_processor_id()))
62#define thread_only() XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
63#define irqoff_only() XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
64#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
65#define atomic_only() XENO_BUG_ON(CONTEXT, (xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0)
66#define preemptible_only() XENO_BUG_ON(CONTEXT, xnlock_is_owner(&nklock) || hard_irqs_disabled())
67#else
68#define atomic_only() XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
69#define preemptible_only() XENO_BUG_ON(CONTEXT, hard_irqs_disabled() != 0)
70#endif
71
72#endif /* !_COBALT_KERNEL_ASSERT_H */