From 5eced9fa401e05226309ec9682df4310b18683c3 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期三, 30 十二月 2020 11:57:49 +0800 Subject: [PATCH] update --- test_socket/dgram_mod_bus.cpp | 0 src/socket/net_conn_pool.cpp | 0 test_queue/test_timeout.cpp | 0 src/shm/shm_mm_wrapper.cpp | 0 test_queue/test_lockfree_queue.cpp | 0 CMakeLists.txt | 41 +++++++++++++ test/strtok.cpp | 0 test_net_socket/test_bus_stop.cpp | 0 demo/dgram_mod_survey.cpp | 0 demo/dgram_mod_bus.cpp | 0 src/logger_factory.cpp | 0 test_queue/multiple_queue_consumer.cpp | 0 test_queue/test_lostdata.cpp | 0 test/protocle_parse.cpp | 0 src/socket/shm_mod_socket.cpp | 0 src/shm/hashtable.cpp | 0 test_net_socket/heart_beat.cpp | 0 test_socket/test_open_close.cpp | 0 src/socket/bus_server_socket_wrapper.cpp | 0 src/socket/net_mod_socket_io.cpp | 0 test_net_socket/test_net_mod_socket.cpp | 0 src/shm/mm.cpp | 0 demo/stream_mod_pub_sub.cpp | 0 src/socket/shm_socket.cpp | 0 test_queue/single_productor.cpp | 0 test_queue/single_consumer.cpp | 0 Make.common.inc | 14 ++-- test/test.cpp | 0 test_socket/survey.cpp | 0 test_queue/test_queue.cpp | 0 src/Makefile | 8 +- test_net_socket/is_seqnum_sv.cpp | 0 src/socket/net_mod_socket.cpp | 0 test_queue/multiple_queue_productor.cpp | 0 test_socket/stream_mod_pub_sub.cpp | 0 .gitignore | 1 test_socket/stream_mod_req_rep.cpp | 0 test_socket/dgram_socket_test.cpp | 0 test_socket/client.cpp | 0 demo/queue.cpp | 0 include/usgcommon/usg_common.h | 2 test/test_vector.cpp | 0 src/socket/net_mod_server_socket_wrapper.cpp | 0 demo/dgram_mod_req_rep.cpp | 0 test_net_socket/is_seqnum_cl.cpp | 0 test_queue/test_queue_wrapper.cpp | 0 test/is_little_endian.cpp | 0 src/BusConfig.h.in | 4 + test_socket/stream_socket_test.cpp | 0 test/lambda.cpp | 0 src/socket/net_mod_server_socket.cpp | 0 src/queue/shm_queue_wrapper.cpp | 0 src/socket/shm_stream_mod_socket.cpp | 0 test_nng/test_nng.cpp | 0 build.sh | 14 ++++ test/test_set.cpp | 0 src/bus_error.cpp | 0 test_socket/dgram_mod_req_rep.cpp | 0 demo/stream_mod_req_rep.cpp | 0 test/test2.cpp | 0 src/socket/bus_server_socket.cpp | 0 src/socket/net_mod_socket_wrapper.cpp | 0 src/CMakeLists.txt | 85 ++++++++++++++++++++++++++++ test_socket/test_timeout.cpp | 0 test/test_type.cpp | 0 chsuffix.sh | 7 ++ test_socket/server.cpp | 0 test_nng/client.cpp | 0 68 files changed, 163 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 533c2f0..1f1e670 100644 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,4 @@ build/ *.tmp -*.txt core diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c4a8bee --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.5) + +# set the project name and version +project(B_BUS VERSION 3.0) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + + + +# add the MathFunctions library +# if(USE_MYMATH) +# add_subdirectory(MathFunctions) +# list(APPEND EXTRA_LIBS MathFunctions) +# endif() + +# list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/include/usgcommon") +# list(APPEND EXTRA_LIBS lib/usgcommon) + +add_subdirectory(${PROJECT_SOURCE_DIR}/src) +# list(APPEND EXTRA_LIBS shm_queue) + + +# target_link_libraries(B_BUS PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find BusConfig.h +# target_include_directories(B_BUS PUBLIC +# "${PROJECT_BINARY_DIR}" +# ${EXTRA_INCLUDES} +# ) + +# add the executable +# add_executable(B_BUS B_BUS.cxx) +# add the install targets +# install(TARGETS B_BUS DESTINATION bin) +# install(FILES "${PROJECT_BINARY_DIR}/BusConfig.h" +# DESTINATION include +# ) + diff --git a/Make.common.inc b/Make.common.inc index d6b5f9f..fa0d30f 100644 --- a/Make.common.inc +++ b/Make.common.inc @@ -9,24 +9,24 @@ -$(DEST)/%.d: %.c +$(DEST)/%.d: %.cpp @echo generating dependences of $< ... @test -d $(DEST)/$(shell dirname $<) || mkdir -p $(DEST)/$(shell dirname $<); \ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,$(DEST)/\1 $(DEST)/\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ -$(DEST)/%.o: %.c - $(CC) ${CPPFLAGS} $(CFLAGS) -c $(filter %.c, $^) -o $@ +$(DEST)/%.o: %.cpp + $(CC) ${CPPFLAGS} $(CFLAGS) -c $(filter %.cpp, $^) -o $@ -$(DEST)/%/%.o: %.c - $(CC) ${CPPFLAGS} $(CFLAGS) -c $(filter %.c, $^) -o $@ +$(DEST)/%/%.o: %.cpp + $(CC) ${CPPFLAGS} $(CFLAGS) -c $(filter %.cpp, $^) -o $@ ${DEST}/%: %.o $(CC) $(LDFLAGS) $(filter %.o, $^) -o $@ $(LDLIBS) -${DEST}/%: %.c - $(CC) ${CPPFLAGS} $(CFLAGS) $(LDFLAGS) $(filter %.c, $^) -o $@ $(LDLIBS) +${DEST}/%: %.cpp + $(CC) ${CPPFLAGS} $(CFLAGS) $(LDFLAGS) $(filter %.cpp, $^) -o $@ $(LDLIBS) gdb: gdb -n -x .gdbinit diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..f8f00de --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +rm -rf build +mkdir build +cd build +# cmake ../Step2 +# cmake ../Step4 -DSUPPORT_RDMA=OFF + +cmake -DCMAKE_INSTALL_PREFIX=/home/wzq/tmp2 -DSUPPORT_RDMA=OFF .. + +cmake --build . + +cmake --build . --target install + \ No newline at end of file diff --git a/chsuffix.sh b/chsuffix.sh new file mode 100644 index 0000000..be83dee --- /dev/null +++ b/chsuffix.sh @@ -0,0 +1,7 @@ +for file in $(find . -name "*.c") +do + filename=${file%.c} + echo $filename.cpp + mv $file $filename.cpp +done + diff --git a/demo/dgram_mod_bus.c b/demo/dgram_mod_bus.cpp similarity index 100% rename from demo/dgram_mod_bus.c rename to demo/dgram_mod_bus.cpp diff --git a/demo/dgram_mod_req_rep.c b/demo/dgram_mod_req_rep.cpp similarity index 100% rename from demo/dgram_mod_req_rep.c rename to demo/dgram_mod_req_rep.cpp diff --git a/demo/dgram_mod_survey.c b/demo/dgram_mod_survey.cpp similarity index 100% rename from demo/dgram_mod_survey.c rename to demo/dgram_mod_survey.cpp diff --git a/demo/queue.c b/demo/queue.cpp similarity index 100% rename from demo/queue.c rename to demo/queue.cpp diff --git a/demo/stream_mod_pub_sub.c b/demo/stream_mod_pub_sub.cpp similarity index 100% rename from demo/stream_mod_pub_sub.c rename to demo/stream_mod_pub_sub.cpp diff --git a/demo/stream_mod_req_rep.c b/demo/stream_mod_req_rep.cpp similarity index 100% rename from demo/stream_mod_req_rep.c rename to demo/stream_mod_req_rep.cpp diff --git a/include/usgcommon/usg_common.h b/include/usgcommon/usg_common.h index 08d4885..ba90002 100644 --- a/include/usgcommon/usg_common.h +++ b/include/usgcommon/usg_common.h @@ -101,7 +101,7 @@ /** * @ seperator 鍒嗗壊绗� */ -char * str_join( const char *seperator, const char *first...); +char * str_join( const char *seperator, const char *first, ...); /** * 鎶婂瓧绗︿覆浠delim鍒嗗壊涓烘暟缁勶紝鏁扮粍鐨勫湴鍧�瀛樻斁鍦ˊarr_addr */ diff --git a/src/BusConfig.h.in b/src/BusConfig.h.in new file mode 100644 index 0000000..3227ca3 --- /dev/null +++ b/src/BusConfig.h.in @@ -0,0 +1,4 @@ +// the configured options and settings for Tutorial +#define B_BUS_VERSION_MAJOR @B_BUS_VERSION_MAJOR@ +#define B_BUS_VERSION_MINOR @B_BUS_VERSION_MINOR@ +#cmakedefine SUPPORT_RDMA \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..86714bb --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,85 @@ + + +# should we use our own math functions +option(SUPPORT_RDMA "If support rdma" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file(BusConfig.h.in BusConfig.h) + +add_library(shm_queue + logger_factory.cpp + socket/bus_server_socket.cpp + socket/bus_server_socket_wrapper.cpp + socket/shm_stream_mod_socket.cpp + socket/shm_socket.cpp + socket/net_conn_pool.cpp + socket/shm_mod_socket.cpp + socket/net_mod_server_socket_wrapper.cpp + socket/net_mod_socket_wrapper.cpp + socket/net_mod_socket.cpp + socket/net_mod_socket_io.cpp + socket/net_mod_server_socket.cpp + bus_error.cpp + queue/shm_queue_wrapper.cpp + shm/shm_mm_wrapper.cpp + shm/mm.cpp + shm/hashtable.cpp + + ) + +target_include_directories(shm_queue PUBLIC + "${PROJECT_BINARY_DIR}" + "${PROJECT_SOURCE_DIR}/include/usgcommon" + ) + +target_include_directories(shm_queue PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/shm + ${CMAKE_CURRENT_SOURCE_DIR}/queue + ${CMAKE_CURRENT_SOURCE_DIR}/socket + ) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(shm_queue INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/shm + ${CMAKE_CURRENT_SOURCE_DIR}/queue + ${CMAKE_CURRENT_SOURCE_DIR}/socket + ) + +# install rules +install(TARGETS shm_queue DESTINATION lib) +install(FILES + socket/socket_def.h + socket/net_conn_pool.h + socket/bus_server_socket.h + socket/shm_socket.h + socket/net_mod_socket.h + socket/shm_stream_mod_socket.h + socket/net_mod_server_socket_wrapper.h + socket/net_mod_socket_io.h + socket/net_mod_server_socket.h + socket/shm_mod_socket.h + socket/net_mod_socket_wrapper.h + socket/bus_server_socket_wrapper.h + key_def.h + bus_error.h + logger_factory.h + queue/linked_lock_free_queue.h + queue/array_lock_free_queue2.h + queue/array_lock_free_queue.h + queue/shm_queue.h + queue/shm_queue_wrapper.h + queue/lock_free_queue.h + shm/hashtable.h + shm/mem_pool.h + shm/mm.h + shm/shm_allocator.h + shm/shm_mm_wraper.h + DESTINATION include) + +install(FILES "${PROJECT_BINARY_DIR}/src/BusConfig.h" + DESTINATION include +) diff --git a/src/Makefile b/src/Makefile index 89b9f59..b126aa1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,9 +18,9 @@ INCLUDES += -I./shm -I./queue -I./socket -I$(ROOT)/include/usgcommon -SOURCES := $(wildcard *.c ./**/*.c) -OBJS = $(patsubst %.c, $(DEST)/%.o, $(SOURCES)) -DEPENDENCES = $(patsubst %.c, $(DEST)/%.d, $(SOURCES)) +SOURCES := $(wildcard *.cpp ./**/*.cpp) +OBJS = $(patsubst %.cpp, $(DEST)/%.o, $(SOURCES)) +DEPENDENCES = $(patsubst %.cpp, $(DEST)/%.d, $(SOURCES)) # MYLIBS = $(LIBCOMMON) $(DLIBCOMMON) @@ -64,7 +64,7 @@ -# 浣跨敤鏂瑰紡锛� g++ test1.c -lcommon +# 浣跨敤鏂瑰紡锛� g++ test1.cpp -lcommon .PHONY: install install: $(MYLIBS) @echo '>>>>>>' installing $^ ... diff --git a/src/bus_error.c b/src/bus_error.cpp similarity index 100% rename from src/bus_error.c rename to src/bus_error.cpp diff --git a/src/logger_factory.c b/src/logger_factory.cpp similarity index 100% rename from src/logger_factory.c rename to src/logger_factory.cpp diff --git a/src/queue/shm_queue_wrapper.c b/src/queue/shm_queue_wrapper.cpp similarity index 100% rename from src/queue/shm_queue_wrapper.c rename to src/queue/shm_queue_wrapper.cpp diff --git a/src/shm/hashtable.c b/src/shm/hashtable.cpp similarity index 100% rename from src/shm/hashtable.c rename to src/shm/hashtable.cpp diff --git a/src/shm/mm.c b/src/shm/mm.cpp similarity index 100% rename from src/shm/mm.c rename to src/shm/mm.cpp diff --git a/src/shm/shm_mm_wrapper.c b/src/shm/shm_mm_wrapper.cpp similarity index 100% rename from src/shm/shm_mm_wrapper.c rename to src/shm/shm_mm_wrapper.cpp diff --git a/src/socket/bus_server_socket.c b/src/socket/bus_server_socket.cpp similarity index 100% rename from src/socket/bus_server_socket.c rename to src/socket/bus_server_socket.cpp diff --git a/src/socket/bus_server_socket_wrapper.c b/src/socket/bus_server_socket_wrapper.cpp similarity index 100% rename from src/socket/bus_server_socket_wrapper.c rename to src/socket/bus_server_socket_wrapper.cpp diff --git a/src/socket/net_conn_pool.c b/src/socket/net_conn_pool.cpp similarity index 100% rename from src/socket/net_conn_pool.c rename to src/socket/net_conn_pool.cpp diff --git a/src/socket/net_mod_server_socket.c b/src/socket/net_mod_server_socket.cpp similarity index 100% rename from src/socket/net_mod_server_socket.c rename to src/socket/net_mod_server_socket.cpp diff --git a/src/socket/net_mod_server_socket_wrapper.c b/src/socket/net_mod_server_socket_wrapper.cpp similarity index 100% rename from src/socket/net_mod_server_socket_wrapper.c rename to src/socket/net_mod_server_socket_wrapper.cpp diff --git a/src/socket/net_mod_socket.c b/src/socket/net_mod_socket.cpp similarity index 100% rename from src/socket/net_mod_socket.c rename to src/socket/net_mod_socket.cpp diff --git a/src/socket/net_mod_socket_io.c b/src/socket/net_mod_socket_io.cpp similarity index 100% rename from src/socket/net_mod_socket_io.c rename to src/socket/net_mod_socket_io.cpp diff --git a/src/socket/net_mod_socket_wrapper.c b/src/socket/net_mod_socket_wrapper.cpp similarity index 100% rename from src/socket/net_mod_socket_wrapper.c rename to src/socket/net_mod_socket_wrapper.cpp diff --git a/src/socket/shm_mod_socket.c b/src/socket/shm_mod_socket.cpp similarity index 100% rename from src/socket/shm_mod_socket.c rename to src/socket/shm_mod_socket.cpp diff --git a/src/socket/shm_socket.c b/src/socket/shm_socket.cpp similarity index 100% rename from src/socket/shm_socket.c rename to src/socket/shm_socket.cpp diff --git a/src/socket/shm_stream_mod_socket.c b/src/socket/shm_stream_mod_socket.cpp similarity index 100% rename from src/socket/shm_stream_mod_socket.c rename to src/socket/shm_stream_mod_socket.cpp diff --git a/test/is_little_endian.c b/test/is_little_endian.cpp similarity index 100% rename from test/is_little_endian.c rename to test/is_little_endian.cpp diff --git a/test/lambda.c b/test/lambda.cpp similarity index 100% rename from test/lambda.c rename to test/lambda.cpp diff --git a/test/protocle_parse.c b/test/protocle_parse.cpp similarity index 100% rename from test/protocle_parse.c rename to test/protocle_parse.cpp diff --git a/test/strtok.c b/test/strtok.cpp similarity index 100% rename from test/strtok.c rename to test/strtok.cpp diff --git a/test/test.c b/test/test.cpp similarity index 100% rename from test/test.c rename to test/test.cpp diff --git a/test/test2.c b/test/test2.cpp similarity index 100% rename from test/test2.c rename to test/test2.cpp diff --git a/test/test_set.c b/test/test_set.cpp similarity index 100% rename from test/test_set.c rename to test/test_set.cpp diff --git a/test/test_type.c b/test/test_type.cpp similarity index 100% rename from test/test_type.c rename to test/test_type.cpp diff --git a/test/test_vector.c b/test/test_vector.cpp similarity index 100% rename from test/test_vector.c rename to test/test_vector.cpp diff --git a/test_net_socket/heart_beat.c b/test_net_socket/heart_beat.cpp similarity index 100% rename from test_net_socket/heart_beat.c rename to test_net_socket/heart_beat.cpp diff --git a/test_net_socket/is_seqnum_cl.c b/test_net_socket/is_seqnum_cl.cpp similarity index 100% rename from test_net_socket/is_seqnum_cl.c rename to test_net_socket/is_seqnum_cl.cpp diff --git a/test_net_socket/is_seqnum_sv.c b/test_net_socket/is_seqnum_sv.cpp similarity index 100% rename from test_net_socket/is_seqnum_sv.c rename to test_net_socket/is_seqnum_sv.cpp diff --git a/test_net_socket/test_bus_stop.c b/test_net_socket/test_bus_stop.cpp similarity index 100% rename from test_net_socket/test_bus_stop.c rename to test_net_socket/test_bus_stop.cpp diff --git a/test_net_socket/test_net_mod_socket.c b/test_net_socket/test_net_mod_socket.cpp similarity index 100% rename from test_net_socket/test_net_mod_socket.c rename to test_net_socket/test_net_mod_socket.cpp diff --git a/test_nng/client.c b/test_nng/client.cpp similarity index 100% rename from test_nng/client.c rename to test_nng/client.cpp diff --git a/test_nng/test_nng.c b/test_nng/test_nng.cpp similarity index 100% rename from test_nng/test_nng.c rename to test_nng/test_nng.cpp diff --git a/test_queue/multiple_queue_consumer.c b/test_queue/multiple_queue_consumer.cpp similarity index 100% rename from test_queue/multiple_queue_consumer.c rename to test_queue/multiple_queue_consumer.cpp diff --git a/test_queue/multiple_queue_productor.c b/test_queue/multiple_queue_productor.cpp similarity index 100% rename from test_queue/multiple_queue_productor.c rename to test_queue/multiple_queue_productor.cpp diff --git a/test_queue/single_consumer.c b/test_queue/single_consumer.cpp similarity index 100% rename from test_queue/single_consumer.c rename to test_queue/single_consumer.cpp diff --git a/test_queue/single_productor.c b/test_queue/single_productor.cpp similarity index 100% rename from test_queue/single_productor.c rename to test_queue/single_productor.cpp diff --git a/test_queue/test_lockfree_queue.c b/test_queue/test_lockfree_queue.cpp similarity index 100% rename from test_queue/test_lockfree_queue.c rename to test_queue/test_lockfree_queue.cpp diff --git a/test_queue/test_lostdata.c b/test_queue/test_lostdata.cpp similarity index 100% rename from test_queue/test_lostdata.c rename to test_queue/test_lostdata.cpp diff --git a/test_queue/test_queue.c b/test_queue/test_queue.cpp similarity index 100% rename from test_queue/test_queue.c rename to test_queue/test_queue.cpp diff --git a/test_queue/test_queue_wrapper.c b/test_queue/test_queue_wrapper.cpp similarity index 100% rename from test_queue/test_queue_wrapper.c rename to test_queue/test_queue_wrapper.cpp diff --git a/test_queue/test_timeout.c b/test_queue/test_timeout.cpp similarity index 100% rename from test_queue/test_timeout.c rename to test_queue/test_timeout.cpp diff --git a/test_socket/client.c b/test_socket/client.cpp similarity index 100% rename from test_socket/client.c rename to test_socket/client.cpp diff --git a/test_socket/dgram_mod_bus.c b/test_socket/dgram_mod_bus.cpp similarity index 100% rename from test_socket/dgram_mod_bus.c rename to test_socket/dgram_mod_bus.cpp diff --git a/test_socket/dgram_mod_req_rep.c b/test_socket/dgram_mod_req_rep.cpp similarity index 100% rename from test_socket/dgram_mod_req_rep.c rename to test_socket/dgram_mod_req_rep.cpp diff --git a/test_socket/dgram_socket_test.c b/test_socket/dgram_socket_test.cpp similarity index 100% rename from test_socket/dgram_socket_test.c rename to test_socket/dgram_socket_test.cpp diff --git a/test_socket/server.c b/test_socket/server.cpp similarity index 100% rename from test_socket/server.c rename to test_socket/server.cpp diff --git a/test_socket/stream_mod_pub_sub.c b/test_socket/stream_mod_pub_sub.cpp similarity index 100% rename from test_socket/stream_mod_pub_sub.c rename to test_socket/stream_mod_pub_sub.cpp diff --git a/test_socket/stream_mod_req_rep.c b/test_socket/stream_mod_req_rep.cpp similarity index 100% rename from test_socket/stream_mod_req_rep.c rename to test_socket/stream_mod_req_rep.cpp diff --git a/test_socket/stream_socket_test.c b/test_socket/stream_socket_test.cpp similarity index 100% rename from test_socket/stream_socket_test.c rename to test_socket/stream_socket_test.cpp diff --git a/test_socket/survey.c b/test_socket/survey.cpp similarity index 100% rename from test_socket/survey.c rename to test_socket/survey.cpp diff --git a/test_socket/test_open_close.c b/test_socket/test_open_close.cpp similarity index 100% rename from test_socket/test_open_close.c rename to test_socket/test_open_close.cpp diff --git a/test_socket/test_timeout.c b/test_socket/test_timeout.cpp similarity index 100% rename from test_socket/test_timeout.c rename to test_socket/test_timeout.cpp -- Gitblit v1.8.0