From 796bd456636a4819cc4732e30be959d68afa6fae Mon Sep 17 00:00:00 2001 From: tezc Date: Tue, 27 Apr 2021 21:13:23 +0300 Subject: [PATCH] more 32 bit tests, doc fix --- .github/workflows/.ubuntu.yml | 28 ++++++++++++++++++++++++++++ array/CMakeLists.txt | 3 +-- buffer/buf_test.c | 2 +- crc32/CMakeLists.txt | 14 ++++++++------ map/CMakeLists.txt | 2 -- socket/sc_sock.h | 13 +++++++------ 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/.github/workflows/.ubuntu.yml b/.github/workflows/.ubuntu.yml index 945ee0c..67a56d0 100644 --- a/.github/workflows/.ubuntu.yml +++ b/.github/workflows/.ubuntu.yml @@ -63,4 +63,32 @@ jobs: mkdir build-debug && cd build-debug cmake .. -DSC_CLANG_TIDY=1 make -j + make check + ubuntu-32bit-address: + runs-on: ubuntu-latest + name: Clang Tidy + steps: + - uses: actions/checkout@v2.1.0 + - name: build + env: + CC: clang + run: | + sudo apt-get install cmake clang-tidy + mkdir build-debug && cd build-debug + cmake .. -DCMAKE_C_FLAGS=-m32 -DSANITIZER=address + make -j + make check + ubuntu-32bit-undefined: + runs-on: ubuntu-latest + name: Clang Tidy + steps: + - uses: actions/checkout@v2.1.0 + - name: build + env: + CC: clang + run: | + sudo apt-get install cmake clang-tidy + mkdir build-debug && cd build-debug + cmake .. -DCMAKE_C_FLAGS=-m32 -DSANITIZER=undefined + make -j make check \ No newline at end of file diff --git a/array/CMakeLists.txt b/array/CMakeLists.txt index f64ccf3..9ecfe95 100644 --- a/array/CMakeLists.txt +++ b/array/CMakeLists.txt @@ -5,8 +5,7 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) -add_library(sc_array SHARED - sc_array.h) +add_library(sc_array SHARED sc_array.h) set_target_properties(sc_array PROPERTIES LINKER_LANGUAGE C) diff --git a/buffer/buf_test.c b/buffer/buf_test.c index f8bd6ea..ae0ca8f 100644 --- a/buffer/buf_test.c +++ b/buffer/buf_test.c @@ -525,7 +525,7 @@ void fail_test() sc_buf_term(&buf); sc_buf_init(&buf, 0); - sc_buf_peek_data(&buf, 100, (unsigned char *) &p, 8); + sc_buf_peek_data(&buf, 100, (unsigned char *) &p, sizeof(p)); assert(sc_buf_valid(&buf) == false); sc_buf_term(&buf); diff --git a/crc32/CMakeLists.txt b/crc32/CMakeLists.txt index effa75a..c4074e6 100644 --- a/crc32/CMakeLists.txt +++ b/crc32/CMakeLists.txt @@ -24,7 +24,7 @@ if (SC_BUILD_TEST) include(CTest) include(CheckCCompilerFlag) - include (TestBigEndian) + include(TestBigEndian) if (SC_CLANG_TIDY) message(STATUS "Enabled CLANG_TIDY") @@ -43,9 +43,11 @@ if (SC_BUILD_TEST) # detect x86 check_c_compiler_flag(-msse4.2 HAVE_CRC32_HARDWARE) if (${HAVE_CRC32_HARDWARE}) - message(STATUS "CPU have -msse4.2, defined HAVE_CRC32C") - target_compile_options(${PROJECT_NAME}_test PRIVATE -msse4.2) - target_compile_definitions(${PROJECT_NAME}_test PRIVATE -DHAVE_CRC32C) + if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + message(STATUS "CPU have -msse4.2, defined HAVE_CRC32C") + target_compile_options(${PROJECT_NAME}_test PRIVATE -msse4.2) + target_compile_definitions(${PROJECT_NAME}_test PRIVATE -DHAVE_CRC32C) + endif () endif () # detect aarch64 @@ -53,14 +55,14 @@ if (SC_BUILD_TEST) message(STATUS "CPU = aarch64, defined HAVE_CRC32C, -march=armv8.1-a") target_compile_definitions(${PROJECT_NAME}_test PRIVATE -DHAVE_CRC32C) target_compile_options(${PROJECT_NAME}_test PRIVATE -march=armv8.1-a) - endif() + endif () # detect software version endianness test_big_endian(HAVE_BIG_ENDIAN) if (${HAVE_BIG_ENDIAN}) message(STATUS "System is BIG ENDIAN") target_compile_definitions(${PROJECT_NAME}_test PRIVATE -DHAVE_BIG_ENDIAN) - else() + else () message(STATUS "System is LITTLE ENDIAN") endif () diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index 2be5883..b213925 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -10,8 +10,6 @@ add_library( sc_map.c sc_map.h) -add_executable(test_map sc_map.h sc_map.c map_example.c) - target_include_directories(sc_map PUBLIC ${CMAKE_CURRENT_LIST_DIR}) if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") diff --git a/socket/sc_sock.h b/socket/sc_sock.h index c440d09..b1e902d 100644 --- a/socket/sc_sock.h +++ b/socket/sc_sock.h @@ -144,8 +144,9 @@ int sc_sock_accept(struct sc_sock *s, struct sc_sock *in); * @param dst_port destination port * @param src_addr source addr (outgoing addr) * @param src_port source port (outgoing port) - * @return '0' on success, negative number on failure. - * call sc_sock_error() for error string. + * @return '0' on success + * negative value if it is non-blocking, errno will be EAGAIN + * negative value on error, call sc_sock_error() error text. */ int sc_sock_connect(struct sc_sock *s, const char *dst_addr, const char *dst_port, const char *src_addr, @@ -195,8 +196,8 @@ int sc_sock_finish_connect(struct sc_sock *s); * @param len len * @param flags normally should be zero, otherwise flags are passed to send(). * @return - on success, returns sent byte count. - * - SC_SOCK_WANT_WRITE on EAGAIN. - * - SC_SOCK_ERROR on error + * - negative value if it fails with errno = EAGAIN. + * - negative value on error */ int sc_sock_send(struct sc_sock *s, char *buf, int len, int flags); @@ -206,8 +207,8 @@ int sc_sock_send(struct sc_sock *s, char *buf, int len, int flags); * @param len len * @param flags normally should be zero, otherwise flags are passed to recv(). * @return - on success, returns bytes received. - * - SC_SOCK_WANT_READ on EAGAIN. - * - SC_SOCK_ERROR on error + * - negative value if it fails with errno = EAGAIN. + * - negative value on error */ int sc_sock_recv(struct sc_sock *s, char *buf, int len, int flags);