summaryrefslogtreecommitdiff
path: root/digital/ucoolib/ucoolib/common.hh
diff options
context:
space:
mode:
authorNicolas Schodet2012-12-15 16:06:59 +0100
committerNicolas Schodet2012-12-23 23:04:00 +0100
commit7a6db77f598f0f4723b3f6048e372daa92ec2430 (patch)
treefa337c41ecd63d78b9686f4b10c83aed9f25197a /digital/ucoolib/ucoolib/common.hh
parent87e67c28d9bbc17517481d6c90c0af40b5638b81 (diff)
digital/ucoolib/ucoolib/utils: add fifo low level container
Diffstat (limited to 'digital/ucoolib/ucoolib/common.hh')
-rw-r--r--digital/ucoolib/ucoolib/common.hh11
1 files changed, 11 insertions, 0 deletions
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<typename T>
+extern inline volatile T &
+access_once (T &x)
+{
+ return *static_cast<volatile T *> (&x);
+}
+
/// Stop, abruptly.
void
halt () __attribute__ ((noreturn));