Sanitize for C++.
[bertos.git] / cpu.h
diff --git a/cpu.h b/cpu.h
index 4b762449c9adc67a295d5fcb8aef9b03f0aff382..562d8619aa3800134c56cbfb4249a39ebb51ad7e 100755 (executable)
--- 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.
  *#*
 
 #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