From 547a273e4edd84b2a2e2d69b5698a7b88374578c Mon Sep 17 00:00:00 2001 From: bernie Date: Sun, 10 Aug 2008 17:15:34 +0000 Subject: [PATCH] ASSERT_IRQ_CONTEXT(), ASSERT_USER_CONTEXT(), ASSERT_IRQ_ENABLED(), ASSERT_IRQ_DISABLED(): New macros git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1601 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/irq.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 290b73d7..5fddfdc9 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -232,6 +232,27 @@ #define IRQ_EXIT() /* NOP */ #endif +#ifdef IRQ_RUNNING + /// Ensure callee is running within an interrupt + #define ASSERT_IRQ_CONTEXT() ASSERT(IRQ_RUNNING()) + + /// Ensure callee is not running within an interrupt + #define ASSERT_USER_CONTEXT() ASSERT(!IRQ_RUNNING()) +#else + #define ASSERT_USER_CONTEXT() do {} while(0) + #define ASSERT_IRQ_CONTEXT() do {} while(0) +#endif + +#ifdef IRQ_ENABLED + /// Ensure interrupts are enabled + #define ASSERT_IRQ_ENABLED() ASSERT(IRQ_ENABLED()) + + /// Ensure interrupts are not enabled + #define ASSERT_IRQ_DISABLED() ASSERT(IRQ_ENABLED()) +#else + #define ASSERT_IRQ_ENABLED() do {} while(0) + #define ASSERT_IRQ_DISABLED() do {} while(0) +#endif /** * Execute \a CODE atomically with respect to interrupts. -- 2.25.1