From: bernie Date: Mon, 6 Sep 2004 21:48:27 +0000 (+0000) Subject: ATOMIC(): New macro. X-Git-Tag: 1.0.0~1053 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=75021d741d1a55013d98e8e67748009d87835341;p=bertos.git ATOMIC(): New macro. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@188 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/cpu.h b/cpu.h index 4b762449..562d8619 100755 --- a/cpu.h +++ b/cpu.h @@ -17,6 +17,9 @@ /*#* *#* $Log$ + *#* Revision 1.17 2004/09/06 21:48:27 bernie + *#* ATOMIC(): New macro. + *#* *#* Revision 1.16 2004/08/29 21:58:33 bernie *#* Rename BITS_PER_XYZ macros; Add sanity checks. *#* @@ -154,6 +157,19 @@ #endif +/*! + * Execute \a CODE atomically with respect to interrupts. + * + * \see ENABLE_IRQSAVE DISABLE_IRQRESTORE + */ +#define ATOMIC(CODE) \ + do { \ + cpuflags_t __flags; \ + DISABLE_IRQSAVE(__flags); \ + CODE; \ + ENABLE_IRQRESTORE(__flags); \ + } while (0) + //! Default for macro not defined in the right arch section #ifndef CPU_REG_INIT_VALUE