Permalink
Browse files

Add CLI_SEI_BUG_MEMORY_BARRIER() macro that inserts a memory barrier …

…for older versions of avr-libc that do not include a memory barrier as part of the definition of SEI() and CLI().
  • Loading branch information...
madscifi authored and triffid committed May 9, 2011
1 parent 4420652 commit b6b5ced7be406c52fc140fc1061a7aaa153834d2
Showing with 14 additions and 1 deletion.
  1. +14 −1 memory_barrier.h
View
@@ -15,4 +15,17 @@
#define MEMORY_BARRIER() __asm volatile( "" ::: "memory" )
-#endif
+// There is a bug in the CLI/SEI functions in older versions of
+// avr-libc - they should be defined to include a memory barrier.
+// This macro is used to define the barrier in the code so that
+// it will be easy to remove once the bug has become ancient history.
+// At the moment the bug is included in most of the distributed
+// compilers.
+
+#if __AVR_LIBC_VERSION__ < 10700UL
+ #define CLI_SEI_BUG_MEMORY_BARRIER() MEMORY_BARRIER()
+#else
+ #define CLI_SEI_BUG_MEMORY_BARRIER()
+#endif
+
+#endif

0 comments on commit b6b5ced

Please sign in to comment.