perf: Optimize ATOMIC_READ
This commit is contained in:
@@ -22,7 +22,8 @@ extern "C"
|
||||
|
||||
#define ATOMIC_INC(x) __atomic_fetch_add(x, 1, __ATOMIC_RELAXED)
|
||||
#define ATOMIC_DEC(x) __atomic_fetch_sub(x, 1, __ATOMIC_RELAXED)
|
||||
#define ATOMIC_READ(x) __atomic_fetch_add(x, 0, __ATOMIC_RELAXED)
|
||||
//#define ATOMIC_READ(x) __atomic_fetch_add(x, 0, __ATOMIC_RELAXED)
|
||||
#define ATOMIC_READ(x) __atomic_load_n(x, __ATOMIC_RELAXED)
|
||||
#define ATOMIC_ZERO(x) __atomic_fetch_and(x, 0, __ATOMIC_RELAXED)
|
||||
#define ATOMIC_ADD(x, y) __atomic_fetch_add(x, y, __ATOMIC_RELAXED)
|
||||
#define ATOMIC_SET(x, y) __atomic_store_n(x, y, __ATOMIC_RELAXED)
|
||||
|
||||
@@ -41,7 +41,7 @@ void timestamp_update(struct timestamp *ts)
|
||||
clock_gettime(CLOCK_MONOTONIC, &temp);
|
||||
uint64_t current_timestamp_ms = temp.tv_sec * 1000 + temp.tv_nsec / 1000000;
|
||||
|
||||
__atomic_store_n(&ts->timestamp_ms, current_timestamp_ms, __ATOMIC_RELEASE);
|
||||
ATOMIC_SET(&ts->timestamp_ms, current_timestamp_ms);
|
||||
}
|
||||
|
||||
uint64_t timestamp_update_interval_ms(struct timestamp *ts)
|
||||
@@ -51,5 +51,5 @@ uint64_t timestamp_update_interval_ms(struct timestamp *ts)
|
||||
|
||||
uint64_t timestamp_get_msec(struct timestamp *ts)
|
||||
{
|
||||
return __atomic_load_n(&ts->timestamp_ms, __ATOMIC_ACQUIRE);
|
||||
return ATOMIC_READ(&ts->timestamp_ms);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user