compiling

This commit is contained in:
quackerd 2023-03-12 02:59:49 +01:00
parent 0b4a609064
commit 3889536160
4 changed files with 22 additions and 28 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10.0) cmake_minimum_required(VERSION 3.18.0)
project(ppd) project(ppd)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
@ -10,34 +10,30 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/msg/msg.pb.cc
set(CMAKE_EXPORT_COMPILE_COMMANDS True) set(CMAKE_EXPORT_COMPILE_COMMANDS True)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(OpenSSL REQUIRED)
pkg_check_modules(bsock REQUIRED bsock) pkg_check_modules(bsock REQUIRED bsock)
set(CFLAGS -Wall -Wextra -Werror -std=c++17 -O3 -g)
# if (${ENABLE_FSTACK} MATCHES "y") add_library(common OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/common/io.cc)
# pkg_check_modules(dpdk REQUIRED libdpdk) target_link_directories(common PRIVATE ${bsock_LIBRARY_DIRS})
# pkg_check_modules(bsdtopo REQUIRED bsdtopo) target_link_libraries(common ${bsock_LIBRARIES})
# pkg_check_modules(ssl REQUIRED libssl) target_compile_options(common PRIVATE ${CFLAGS})
# include_directories(${dpdk_INCLUDE_DIRS}) target_include_directories(common PRIVATE ${bsock_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
# include_directories(${ssl_INCLUDE_DIRS})
# include_directories(${bsdtopo_INCLUDE_DIRS})
# endif()
set(CFLAGS -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable -std=c++17 -O2 -g)
add_executable(dsmbr ${CMAKE_CURRENT_SOURCE_DIR}/dsmbr/dsmbr.cc add_executable(dsmbr ${CMAKE_CURRENT_SOURCE_DIR}/dsmbr/dsmbr.cc
${CMAKE_CURRENT_SOURCE_DIR}/common/io.cc
${CMAKE_CURRENT_SOURCE_DIR}/dsmbr/dmsg.cc ${CMAKE_CURRENT_SOURCE_DIR}/dsmbr/dmsg.cc
${CMAKE_CURRENT_SOURCE_DIR}/dsmbr/generator.cc) ${CMAKE_CURRENT_SOURCE_DIR}/dsmbr/generator.cc)
target_link_libraries(dsmbr pthread bsock) target_link_libraries(dsmbr common pthread OpenSSL::SSL ${bsock_LIBRARIES})
target_compile_options(dsmbr PRIVATE ${CFLAGS} ${bsock_CFLAGS}) target_link_directories(dsmbr PRIVATE ${bsock_LIBRARY_DIRS})
target_include_directories(dsmbr PRIVATE ${bsock_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include) target_compile_options(dsmbr PRIVATE ${CFLAGS})
target_include_directories(dsmbr PRIVATE ${bsock_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_executable(ppd ${CMAKE_CURRENT_SOURCE_DIR}/ppd/ppd.cc add_executable(ppd ${CMAKE_CURRENT_SOURCE_DIR}/ppd/ppd.cc)
${CMAKE_CURRENT_SOURCE_DIR}/common/io.cc) target_link_libraries(ppd pthread common OpenSSL::SSL ${bsock_LIBRARIES})
target_link_libraries(ppd pthread bsock) target_link_directories(ppd PRIVATE ${bsock_LIBRARY_DIRS})
target_compile_options(ppd PRIVATE ${CFLAGS} ${bsock_CFLAGS}) target_compile_options(ppd PRIVATE ${CFLAGS})
target_include_directories(ppd PRIVATE ${bsock_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(ppd PRIVATE ${bsock_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
# if (${ENABLE_FSTACK} MATCHES "y") # if (${ENABLE_FSTACK} MATCHES "y")
# add_executable(ppd_ff ${CMAKE_CURRENT_SOURCE_DIR}/ppd_ff/ppd.cc # add_executable(ppd_ff ${CMAKE_CURRENT_SOURCE_DIR}/ppd_ff/ppd.cc

View File

@ -103,8 +103,8 @@ struct dsmbr_options {
char output_file[128]; char output_file[128];
cpuset_t cpuset; cpuset_t cpuset;
char module_path[128]; char module_path[128];
char mod_argk[MAX_MOD_ARGS][64]; char mod_argk[MAX_MOD_ARGS][MAX_MOD_ARG_LEN];
char mod_argv[MAX_MOD_ARGS][64]; char mod_argv[MAX_MOD_ARGS][MAX_MOD_ARG_LEN];
int mod_argc; int mod_argc;
int enable_tls; int enable_tls;
int master_mode; int master_mode;
@ -220,7 +220,6 @@ static struct dsmbr_conn *
dsmbr_conn_create(void *thrd_ctx) dsmbr_conn_create(void *thrd_ctx)
{ {
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
SSL *ssl = nullptr;
server_addr.sin_family = AF_INET; server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(options.server_port); server_addr.sin_port = htons(options.server_port);
@ -350,7 +349,6 @@ dsmbr_worker_main(void *ctx)
V("Thread %d starting...\n", tinfo->tid); V("Thread %d starting...\n", tinfo->tid);
while (true) { while (true) {
int ret = 0; int ret = 0;
struct kevent kev;
if (options.state.load(std::memory_order_relaxed) == STATE_STOP) { if (options.state.load(std::memory_order_relaxed) == STATE_STOP) {
break; break;

View File

@ -49,7 +49,7 @@ Generator* createGenerator(std::string str) {
if (t_ptr == NULL) // || a_ptr == NULL) if (t_ptr == NULL) // || a_ptr == NULL)
DIE("strtok(.., \":\") failed to parse %s", str.c_str()); DIE("strtok(.., \":\") failed to parse %s", str.c_str());
char t = t_ptr[0]; // char t = t_ptr[0];
saveptr = NULL; saveptr = NULL;
char *s1 = strtok_r(a_ptr, ",", &saveptr); char *s1 = strtok_r(a_ptr, ",", &saveptr);

View File

@ -51,7 +51,7 @@ public:
virtual ~Generator() {} virtual ~Generator() {}
virtual double generate(double U = -1.0) = 0; virtual double generate(double U = -1.0) = 0;
virtual void set_lambda(double lambda) {DIE("set_lambda() not implemented");} virtual void set_lambda(__attribute__((unused)) double lambda) { DIE("set_lambda() not implemented");}
protected: protected:
std::string type; std::string type;
}; };
@ -59,7 +59,7 @@ protected:
class Fixed : public Generator { class Fixed : public Generator {
public: public:
Fixed(double _value = 1.0) : value(_value) { D("Fixed(%f)", value); } Fixed(double _value = 1.0) : value(_value) { D("Fixed(%f)", value); }
virtual double generate(double U = -1.0) { return value; } virtual double generate(__attribute__((unused)) double U = -1.0) { return value; }
virtual void set_lambda(double lambda) { virtual void set_lambda(double lambda) {
if (lambda > 0.0) value = 1.0 / lambda; if (lambda > 0.0) value = 1.0 / lambda;
else value = 0.0; else value = 0.0;