move is_aligned() helper function into bertos/cfg/macros.h
[bertos.git] / bertos / cfg / compiler.h
index 0121b96367fe067cc98ba9a92004356c05ef56a5..c2e814e522e0be69086eb447ef7442d81ced9d51 100644 (file)
@@ -603,4 +603,11 @@ typedef unsigned char sigmask_t; /**< Type for signal masks. */
                        do { (void)(&(var) == (type *)0); } while(0)
 #endif
 
+/**
+ * Prevent the compiler from optimizing access to the variable \a x, enforcing
+ * a refetch from memory. This also forbid from reordering successing instances
+ * of ACCESS_SAFE().
+ */
+#define ACCESS_SAFE(x) (*(volatile typeof(x) *)&(x))
+
 #endif /* BERTOS_COMPILER_H */