From 7a6db77f598f0f4723b3f6048e372daa92ec2430 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 15 Dec 2012 16:06:59 +0100 Subject: digital/ucoolib/ucoolib/utils: add fifo low level container --- digital/ucoolib/ucoolib/common.hh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'digital/ucoolib/ucoolib/common.hh') diff --git a/digital/ucoolib/ucoolib/common.hh b/digital/ucoolib/ucoolib/common.hh index 1f6d75ae..83763899 100644 --- a/digital/ucoolib/ucoolib/common.hh +++ b/digital/ucoolib/ucoolib/common.hh @@ -27,6 +27,9 @@ namespace ucoo { +/// Integer which is read and written atomically. +typedef int int_atomic_t; + /// Compiler barrier. Prevents the compiler from moving the memory accesses /// from one side of it to the other side. extern inline void @@ -35,6 +38,14 @@ barrier () __asm__ __volatile__("": : : "memory"); } +/// Ensure a single access is done, avoid compiler optimisations. +template +extern inline volatile T & +access_once (T &x) +{ + return *static_cast (&x); +} + /// Stop, abruptly. void halt () __attribute__ ((noreturn)); -- cgit v1.2.3