39 lines
706 B
C++
39 lines
706 B
C++
#ifndef SOCKS_COMPILER_H_
|
|
#define SOCKS_COMPILER_H_
|
|
|
|
#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;
|
|
}
|
|
#else
|
|
|
|
#define READ_ONCE(p) (*((const volatile typeof(p) *)&(p)))
|
|
#define WRITE_ONCE(p, v) *(volatile typeof(p) *)&(p) = (v)
|
|
|
|
#endif
|
|
|
|
#undef __used
|
|
#define __used __attribute__((__used__))
|
|
|
|
#undef __noreturn
|
|
#define __noreturn __attribute__((__noreturn__))
|
|
|
|
#undef __packed
|
|
#define __packed __attribute__((__packed__))
|
|
|
|
#undef __section
|
|
#define __section(name) __attribute__((__section__(name)))
|
|
|
|
#undef __aligned
|
|
#define __aligned(x) __attribute__((__aligned__(x)))
|
|
|
|
#endif
|