-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patharch_dd.h
More file actions
33 lines (23 loc) · 815 Bytes
/
arch_dd.h
File metadata and controls
33 lines (23 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef _ARCH_DD_H
#define _ARCH_DD_H
#include "arch.h"
#define COMMA ,
#include <stddef.h>
constexpr int DEFAULT_CACHE_LINE_SIZE = 64;
static inline long long atomicInc(volatile long long &var,
long long increment = 1) {
return __sync_fetch_and_add(&var, increment);
}
static inline u64 loadAcquire(volatile u64 &var) {
return __atomic_load_n(&var, __ATOMIC_ACQUIRE);
}
static inline size_t loadAcquire(volatile size_t &var) {
return __atomic_load_n(&var, __ATOMIC_ACQUIRE);
}
static inline void storeRelease(volatile long long &var, long long value) {
return __atomic_store_n(&var, value, __ATOMIC_RELEASE);
}
static inline void storeRelease(volatile size_t &var, size_t value) {
return __atomic_store_n(&var, value, __ATOMIC_RELEASE);
}
#endif // _ARCH_DD_H