kernel: C++ read_once() and write_once() functions
This commit is contained in:
@@ -4,6 +4,20 @@
|
||||
#define READ_ONCE(t, p) (*((const volatile t *)&(p)))
|
||||
#define WRITE_ONCE(t, p, v) *(volatile t *)&(p) = (v)
|
||||
|
||||
#ifdef __cplusplus
|
||||
template <typename T>
|
||||
T read_once(const volatile T *ptr)
|
||||
{
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void write_once(volatile T *ptr, T value)
|
||||
{
|
||||
*ptr = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef __used
|
||||
#define __used __attribute__((used))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user