From 8f58e5a3ec0e4a15fc8ae0911cc864f5dbf86c6e Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Fri, 18 Aug 2017 15:56:55 +0200 Subject: build: Revise the build system This revises the build system to have configuration per system component. System settings can now be set using cmake. The standard compliance defines were removed from configuration header and are set in the sources where needed. Also some small code refactors, such as moving the data for shims out of the ipcp structure to the respective shims were performed. --- src/ipcpd/local/CMakeLists.txt | 2 +- src/ipcpd/local/main.c | 34 ++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) (limited to 'src/ipcpd/local') diff --git a/src/ipcpd/local/CMakeLists.txt b/src/ipcpd/local/CMakeLists.txt index 824b4ca6..925092bd 100644 --- a/src/ipcpd/local/CMakeLists.txt +++ b/src/ipcpd/local/CMakeLists.txt @@ -12,7 +12,7 @@ include_directories(${CURRENT_BINARY_PARENT_DIR}) include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_BINARY_DIR}/include) -set(IPCP_LOCAL_TARGET ipcpd-local CACHE STRING "IPCP_LOCAL") +set(IPCP_LOCAL_TARGET ipcpd-local CACHE INTERNAL "") set(SHIM_LOCAL_SOURCES # Add source files here diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 241a47eb..37d23fc3 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -20,9 +20,12 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ +#define _POSIX_C_SOURCE 200112L + +#include "config.h" + #define OUROBOROS_PREFIX "ipcpd-local" -#include #include #include #include @@ -33,6 +36,7 @@ #include #include "ipcp.h" +#include "shim-data.h" #include #include @@ -44,18 +48,20 @@ #define THIS_TYPE IPCP_LOCAL struct { - int in_out[IRMD_MAX_FLOWS]; - flow_set_t * flows; - fqueue_t * fq; + struct shim_data * shim_data; - pthread_rwlock_t lock; - pthread_t sduloop; + int in_out[SYS_MAX_FLOWS]; + flow_set_t * flows; + fqueue_t * fq; + + pthread_rwlock_t lock; + pthread_t sduloop; } local_data; static int local_data_init(void) { int i; - for (i = 0; i < IRMD_MAX_FLOWS; ++i) + for (i = 0; i < SYS_MAX_FLOWS; ++i) local_data.in_out[i] = -1; local_data.flows = flow_set_create(); @@ -68,12 +74,20 @@ static int local_data_init(void) return -ENOMEM; } + local_data.shim_data = shim_data_create(); + if (local_data.shim_data == NULL) { + fqueue_destroy(local_data.fq); + flow_set_destroy(local_data.flows); + return -ENOMEM; + } + pthread_rwlock_init(&local_data.lock, NULL); return 0; } static void local_data_fini(void){ + shim_data_destroy(local_data.shim_data); flow_set_destroy(local_data.flows); fqueue_destroy(local_data.fq); pthread_rwlock_destroy(&local_data.lock); @@ -142,7 +156,7 @@ static int ipcp_local_reg(const uint8_t * hash) return -ENOMEM; } - if (shim_data_reg_add_entry(ipcpi.shim_data, hash_dup)) { + if (shim_data_reg_add_entry(local_data.shim_data, hash_dup)) { log_dbg("Failed to add " HASH_FMT " to local registry.", HASH_VAL(hash)); free(hash_dup); @@ -156,7 +170,7 @@ static int ipcp_local_reg(const uint8_t * hash) static int ipcp_local_unreg(const uint8_t * hash) { - shim_data_reg_del_entry(ipcpi.shim_data, hash); + shim_data_reg_del_entry(local_data.shim_data, hash); log_info("Unregistered " HASH_FMT ".", HASH_VAL(hash)); @@ -167,7 +181,7 @@ static int ipcp_local_query(const uint8_t * hash) { int ret; - ret = (shim_data_reg_has(ipcpi.shim_data, hash) ? 0 : -1); + ret = (shim_data_reg_has(local_data.shim_data, hash) ? 0 : -1); return ret; } -- cgit v1.2.3