L4Re - L4 Runtime Environment
utils
1 #pragma once
2 
3 namespace cxx {
4 
5 template< typename T >
6 T access_once(T const *a)
7 {
8 #if 1
9  __asm__ __volatile__ ( "" : "=m"(*const_cast<T*>(a)));
10  T tmp = *a;
11  __asm__ __volatile__ ( "" : "=m"(*const_cast<T*>(a)));
12  return tmp;
13 #else
14  return *static_cast<T const volatile *>(a);
15 #endif
16 }
17 
18 template< typename T >
19 void write_now(T *a, T const &val)
20 {
21  __asm__ __volatile__ ( "" : "=m"(*a));
22  *a = val;
23  __asm__ __volatile__ ( "" : : "m"(*a));
24 }
25 
26 
27 }
28 
Our C++ library.
Definition: arith:22