#ifndef _MACRO_H
#define _MACRO_H

#ifdef __cplusplus
extern "C"
{
#endif

#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)

#ifdef STELLAR_GIT_VERSION
    static __attribute__((__used__)) const char *__stellar_version = STELLAR_GIT_VERSION;
#else
    static __attribute__((__used__)) const char *__stellar_version = "Unknown";
#endif

#ifdef __cplusplus
}
#endif

#endif
