refactor: move macro to utils.h

This commit is contained in:
luwenpeng
2024-08-16 10:43:00 +08:00
parent bfa5564558
commit 6fbce43afc
12 changed files with 31 additions and 40 deletions

View File

@@ -9,6 +9,20 @@ extern "C"
#include <stdio.h>
#include <time.h>
#define RX_BURST_MAX 32
#define MAX_THREAD_NUM 256 // limit by id_generator
#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_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)
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define likely(expr) __builtin_expect((expr), 1)
#define unlikely(expr) __builtin_expect((expr), 0)
/*
* The maximum number of seconds that can be stored in the time_t value is 2147483647 - a little over 68 years.
*