| | |
| | | |
| | | # control where the static and shared libraries are built so that on windows |
| | | # we don't need to tinker with the path to run the executable |
| | | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") |
| | | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") |
| | | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
| | | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
| | | # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") |
| | | |
| | | #option(BUILD_SHARED_LIBS "Build using shared libraries" ON) |
| | |
| | | # to the source code |
| | | configure_file(bus_config.h.in bus_config.h) |
| | | |
| | | add_library(shm_queue |
| | | ./logger_factory.cpp |
| | | |
| | | list(APPEND _SOURCES_ |
| | | ./logger_factory.cpp |
| | | ./socket/bus_server_socket.cpp |
| | | ./socket/bus_server_socket_wrapper.cpp |
| | | ./socket/shm_stream_mod_socket.cpp |
| | |
| | | ./shm/shm_mm_wrapper.cpp |
| | | ./shm/mm.cpp |
| | | ./shm/hashtable.cpp |
| | | ) |
| | | |
| | | ) |
| | | |
| | | target_include_directories(shm_queue PUBLIC |
| | | ${EXTRA_INCLUDES} |
| | | ) |
| | | add_library(shm_queue ${_SOURCES_}) |
| | | |
| | | target_include_directories(shm_queue PUBLIC ${EXTRA_INCLUDES} ) |
| | | |
| | | target_include_directories(shm_queue PUBLIC |
| | | ${PROJECT_BINARY_DIR}/src |
| | |
| | | # install rules |
| | | install(TARGETS shm_queue DESTINATION lib) |
| | | install(FILES |
| | | ./socket/socket_def.h |
| | | ./socket/bus_server_socket.h |
| | | ./socket/shm_socket.h |
| | | ./socket/shm_stream_mod_socket.h |
| | | ./socket/shm_mod_socket.h |
| | | ./socket/bus_server_socket_wrapper.h |
| | | ./psem.h |
| | | ./key_def.h |
| | | ./time_util.h |
| | | ./futex_sem.h |
| | | ./bus_error.h |
| | | ./bus_def.h |
| | | ./logger_factory.h |
| | | ./queue/linked_lock_free_queue.h |
| | | ./queue/array_lock_free_queue.h |
| | | ./queue/shm_queue.h |
| | | ./queue/array_lock_free_sem_queue.h |
| | | ./queue/lock_free_queue.h |
| | | ./svsem.h |
| | | ./net/net_conn_pool.h |
| | | ./net/net_mod_socket.h |
| | | ./net/net_mod_server_socket_wrapper.h |
| | | ./net/net_mod_socket_io.h |
| | | ./net/net_mod_server_socket.h |
| | | ./net/net_mod_socket_wrapper.h |
| | | ./shm/hashtable.h |
| | | ./shm/mem_pool.h |
| | | ./shm/mm.h |
| | | ./shm/shm_mm_wrapper.h |
| | | ./shm/shm_allocator.h |
| | | |
| | | |
| | | ./socket/socket_def.h |
| | | ./socket/bus_server_socket.h |
| | | ./socket/shm_socket.h |
| | | ./socket/shm_stream_mod_socket.h |
| | | ./socket/shm_mod_socket.h |
| | | ./socket/bus_server_socket_wrapper.h |
| | | ./psem.h |
| | | ./key_def.h |
| | | ./time_util.h |
| | | ./futex_sem.h |
| | | ./bus_error.h |
| | | ./bus_def.h |
| | | ./logger_factory.h |
| | | ./queue/linked_lock_free_queue.h |
| | | ./queue/array_lock_free_queue.h |
| | | ./queue/shm_queue.h |
| | | ./queue/array_lock_free_sem_queue.h |
| | | ./queue/lock_free_queue.h |
| | | ./svsem.h |
| | | ./net/net_conn_pool.h |
| | | ./net/net_mod_socket.h |
| | | ./net/net_mod_server_socket_wrapper.h |
| | | ./net/net_mod_socket_io.h |
| | | ./net/net_mod_server_socket.h |
| | | ./net/net_mod_socket_wrapper.h |
| | | ./shm/hashtable.h |
| | | ./shm/mem_pool.h |
| | | ./shm/mm.h |
| | | ./shm/shm_mm_wrapper.h |
| | | ./shm/shm_allocator.h |
| | | |
| | | DESTINATION include) |
| | | |
| | |
| | | return logger; |
| | | } |
| | | |
| | | void LoggerFactory::error(int s) { |
| | | Logger* logger = LoggerFactory::getLogger(); |
| | | if(s == EBUS_TIMEOUT) { |
| | | logger->error("shm_recvfrom failed, %s", bus_strerror(EBUS_TIMEOUT)); |
| | | |
| | | } else { |
| | | logger->error(s, "shm_recvfrom failed!"); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | public: |
| | | |
| | | static Logger* getLogger(); |
| | | static void error(int s); |
| | | }; |
| | | |
| | | #endif |
| | |
| | | #include "hashtable.h" |
| | | #include "logger_factory.h" |
| | | #include <map> |
| | | #include <cassert> |
| | | #include "bus_error.h" |
| | | |
| | | static Logger *logger = LoggerFactory::getLogger(); |
| | |
| | | |
| | | if ((rv = shm_sendto(tmp_socket, send_buf, send_size, send_key, timeout, flags)) == 0) { |
| | | rv = shm_recvfrom(tmp_socket, recv_buf, recv_size, &recv_key, timeout, flags); |
| | | printf("======send key =%d , recv key=%d\n", send_key, recv_key); |
| | | assert( send_key == recv_key); |
| | | if(send_key != recv_key) |
| | | err_exit(0, "send key need to equal to recv key! send key =%d , recv key=%d", send_key, recv_key); |
| | | return rv; |
| | | } else { |
| | | return rv; |
| | |
| | | |
| | | if ((rv = shm_sendto(tmp_socket, send_buf, send_size, send_key, timeout, flags)) == 0) { |
| | | rv = shm_recvfrom(tmp_socket, recv_buf, recv_size, &recv_key, timeout, flags); |
| | | printf("======send key =%d , recv key=%d\n", send_key, recv_key); |
| | | |
| | | if(rv != 0) { |
| | | printf("_shm_sendandrecv_alloc_new shm_recvfrom : %s\n", bus_strerror(rv)); |
| | | } |
| | | else if(rv == 0 ) { |
| | | assert( send_key == recv_key); |
| | | if(send_key != recv_key) { |
| | | err_exit(0, "send key need to equal to recv key! send key =%d , recv key=%d", send_key, recv_key); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | shm_close_socket(tmp_socket); |
| | |
| | | int shm_sendandrecv(shm_socket_t *socket, const void *send_buf, |
| | | const int send_size, const int send_key, void **recv_buf, |
| | | int *recv_size, const struct timespec *timeout, int flags) { |
| | | return _shm_sendandrecv_thread_local(socket, send_buf, send_size, send_key,recv_buf, recv_size, timeout, flags); |
| | | return _shm_sendandrecv_alloc_new(socket, send_buf, send_size, send_key,recv_buf, recv_size, timeout, flags); |
| | | } |
| | | |
| | | |
| | |
| | | ${EXTRA_INCLUDES} |
| | | ) |
| | | |
| | | add_executable(test_assert test_assert.cpp ) |
| | | target_link_libraries(test_assert PRIVATE ${EXTRA_LIBS} ) |
| | | target_include_directories(test_assert PRIVATE |
| | | "${PROJECT_BINARY_DIR}" |
| | | ${EXTRA_INCLUDES} |
| | | ) |
| | | |
| | | |
| | | |
| | | |
| | | |
New file |
| | |
| | | |
| | | #include <iostream> |
| | | // uncomment to disable assert() |
| | | // #define NDEBUG |
| | | #include <cassert> |
| | | |
| | | // Use (void) to silent unused warnings. |
| | | #define assertm(exp, msg) assert(((void)msg, exp)) |
| | | |
| | | int main() |
| | | { |
| | | assert(2+2==4); |
| | | std::cout << "Execution continues past the first assert\n"; |
| | | // assertm(2+2==5, "There are five lights"); |
| | | // std::cout << "Execution continues past the second assert\n"; |
| | | assert((2*2==4) && "Yet another way to add assert message"); |
| | | assert(("There are five lights", 2 + 2 == 5)); |
| | | } |