refactor: move macro to utils.h
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
add_library(id_generator id_generator.cpp)
|
add_library(id_generator id_generator.cpp)
|
||||||
target_include_directories(id_generator PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(id_generator PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
target_include_directories(id_generator PUBLIC ${CMAKE_SOURCE_DIR}/src/utils)
|
||||||
target_include_directories(id_generator PUBLIC ${CMAKE_SOURCE_DIR}/include/stellar)
|
target_include_directories(id_generator PUBLIC ${CMAKE_SOURCE_DIR}/include/stellar)
|
||||||
target_include_directories(id_generator PUBLIC ${CMAKE_SOURCE_DIR}/src/stellar)
|
target_link_libraries(id_generator stellar_core)
|
||||||
target_link_libraries(id_generator PRIVATE stellar_core log)
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "macro.h"
|
#include "utils.h"
|
||||||
#include "stellar.h"
|
#include "stellar.h"
|
||||||
#include "id_generator.h"
|
#include "id_generator.h"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "tuple.h"
|
#include "tuple.h"
|
||||||
#include "macro.h"
|
#include "utils.h"
|
||||||
#include "dumpfile_io.h"
|
#include "dumpfile_io.h"
|
||||||
#include "packet_def.h"
|
#include "packet_def.h"
|
||||||
#include "packet_ldbc.h"
|
#include "packet_ldbc.h"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "macro.h"
|
#include "utils.h"
|
||||||
#include "lock_free_queue.h"
|
#include "lock_free_queue.h"
|
||||||
|
|
||||||
#define LOCK_FREE_QUEUE_LOG_ERROR(format, ...) LOG_ERROR("lock free queue", format, ##__VA_ARGS__)
|
#define LOCK_FREE_QUEUE_LOG_ERROR(format, ...) LOG_ERROR("lock free queue", format, ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ extern "C"
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "macro.h"
|
#include "utils.h"
|
||||||
|
|
||||||
struct __attribute__((aligned(64))) packet_io_stat
|
struct __attribute__((aligned(64))) packet_io_stat
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ add_library(session_manager
|
|||||||
target_include_directories(session_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(session_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/src/stellar)
|
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/src/stellar)
|
||||||
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
||||||
|
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/src/utils)
|
||||||
target_link_libraries(session_manager timeout id_generator duplicated_packet_filter evicted_session_filter log tcp_reassembly)
|
target_link_libraries(session_manager timeout id_generator duplicated_packet_filter evicted_session_filter log tcp_reassembly)
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "macro.h"
|
#include "utils.h"
|
||||||
#include "tcp_utils.h"
|
#include "tcp_utils.h"
|
||||||
#include "udp_utils.h"
|
#include "udp_utils.h"
|
||||||
#include "packet_layer.h"
|
#include "packet_layer.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "macro.h"
|
#include "utils.h"
|
||||||
#include "ip4_utils.h"
|
#include "ip4_utils.h"
|
||||||
#include "packet_def.h"
|
#include "packet_def.h"
|
||||||
#include "packet_parse.h"
|
#include "packet_parse.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "macro.h"
|
#include "utils.h"
|
||||||
#include "ip4_utils.h"
|
#include "ip4_utils.h"
|
||||||
#include "packet_def.h"
|
#include "packet_def.h"
|
||||||
#include "packet_parse.h"
|
#include "packet_parse.h"
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#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
|
|
||||||
@@ -26,6 +26,12 @@
|
|||||||
#define STELLAR_LOG_ERROR(format, ...) LOG_ERROR("stellar", format, ##__VA_ARGS__)
|
#define STELLAR_LOG_ERROR(format, ...) LOG_ERROR("stellar", format, ##__VA_ARGS__)
|
||||||
#define STELLAR_LOG_DEBUG(format, ...) LOG_DEBUG("stellar", format, ##__VA_ARGS__)
|
#define STELLAR_LOG_DEBUG(format, ...) LOG_DEBUG("stellar", format, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef STELLAR_GIT_VERSION
|
||||||
|
static __attribute__((__used__)) const char *version = STELLAR_GIT_VERSION;
|
||||||
|
#else
|
||||||
|
static __attribute__((__used__)) const char *version = "Unknown";
|
||||||
|
#endif
|
||||||
|
|
||||||
struct schedule_data
|
struct schedule_data
|
||||||
{
|
{
|
||||||
uint64_t last_free_expired_session_timestamp;
|
uint64_t last_free_expired_session_timestamp;
|
||||||
@@ -493,7 +499,7 @@ int stellar_run(int argc __attribute__((unused)), char **argv __attribute__((unu
|
|||||||
STELLAR_LOG_ERROR("unable to init log");
|
STELLAR_LOG_ERROR("unable to init log");
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
STELLAR_LOG_STATE("start stellar (version: %s)\n %s", __stellar_version, logo_str);
|
STELLAR_LOG_STATE("start stellar (version: %s)\n %s", version, logo_str);
|
||||||
STELLAR_LOG_STATE("log config file : %s", log_config_file);
|
STELLAR_LOG_STATE("log config file : %s", log_config_file);
|
||||||
STELLAR_LOG_STATE("main config file : %s", main_config_file);
|
STELLAR_LOG_STATE("main config file : %s", main_config_file);
|
||||||
STELLAR_LOG_STATE("plugin config file : %s", plugin_config_file);
|
STELLAR_LOG_STATE("plugin config file : %s", plugin_config_file);
|
||||||
|
|||||||
@@ -9,6 +9,20 @@ extern "C"
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.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.
|
* The maximum number of seconds that can be stored in the time_t value is 2147483647 –- a little over 68 years.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user