diff --git a/.github/workflows/.aarch64.yml b/.github/workflows/.aarch64.yml index b67bf39..63ac2d6 100644 --- a/.github/workflows/.aarch64.yml +++ b/.github/workflows/.aarch64.yml @@ -13,7 +13,7 @@ jobs: name: Build on aarch64 steps: - uses: actions/checkout@v2.1.0 - - uses: uraimo/run-on-arch-action@v2.0.9 + - uses: uraimo/run-on-arch-action@v2.1.1 name: Build artifact id: build with: diff --git a/.github/workflows/.armv6.yml b/.github/workflows/.armv6.yml index 775e19b..ed6af17 100644 --- a/.github/workflows/.armv6.yml +++ b/.github/workflows/.armv6.yml @@ -13,7 +13,7 @@ jobs: name: Build on armv6 steps: - uses: actions/checkout@v2.1.0 - - uses: uraimo/run-on-arch-action@v2.0.9 + - uses: uraimo/run-on-arch-action@v2.1.1 name: Build artifact id: build with: @@ -31,4 +31,4 @@ jobs: apk update apk add git build-base gcc make valgrind cmake mkdir build && cd build - cmake .. && make -j && make check + cmake .. -DSC_USE_WRAP=OFF && make -j && make check diff --git a/.github/workflows/.armv7.yml b/.github/workflows/.armv7.yml index 2fc7910..decd5bd 100644 --- a/.github/workflows/.armv7.yml +++ b/.github/workflows/.armv7.yml @@ -13,7 +13,7 @@ jobs: name: Build on armv7 steps: - uses: actions/checkout@v2.1.0 - - uses: uraimo/run-on-arch-action@v2.0.9 + - uses: uraimo/run-on-arch-action@v2.1.1 name: Build artifact id: build with: diff --git a/.github/workflows/.ppc64le.yml b/.github/workflows/.ppc64le.yml index 804c8c8..e8a857c 100644 --- a/.github/workflows/.ppc64le.yml +++ b/.github/workflows/.ppc64le.yml @@ -13,7 +13,7 @@ jobs: name: Build on ppc64le steps: - uses: actions/checkout@v2.1.0 - - uses: uraimo/run-on-arch-action@v2.0.9 + - uses: uraimo/run-on-arch-action@v2.1.1 name: Build artifact id: build with: diff --git a/.github/workflows/.s390x.yml b/.github/workflows/.s390x.yml index 20db0d4..fd18b29 100644 --- a/.github/workflows/.s390x.yml +++ b/.github/workflows/.s390x.yml @@ -13,7 +13,7 @@ jobs: name: Build on s390x steps: - uses: actions/checkout@v2.1.0 - - uses: uraimo/run-on-arch-action@v2.0.9 + - uses: uraimo/run-on-arch-action@v2.1.1 name: Build artifact id: build with: diff --git a/CMakeLists.txt b/CMakeLists.txt index cf9a5ba..c33fea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,11 @@ if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug" AND NOT ${CMAKE_BUILD_TYPE} MATCHES message(STATUS "Not building tests, SC tests are supported in Debug build only.") endif () +option(SC_USE_WRAP "Use --wrap to test libc function failures" ON) +if (NOT SC_USE_WRAP) + message(STATUS "Turned off --wrap.") +endif() + add_subdirectory(array) add_subdirectory(buffer) add_subdirectory(condition) diff --git a/array/CMakeLists.txt b/array/CMakeLists.txt index 9ecfe95..c3cd1b7 100644 --- a/array/CMakeLists.txt +++ b/array/CMakeLists.txt @@ -42,7 +42,7 @@ if (SC_BUILD_TEST) message(STATUS "Compiler is ${CMAKE_C_COMPILER_ID}") - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") message(STATUS "Defined SC_HAVE_WRAP") diff --git a/buffer/CMakeLists.txt b/buffer/CMakeLists.txt index b4a132a..3c439b8 100644 --- a/buffer/CMakeLists.txt +++ b/buffer/CMakeLists.txt @@ -41,9 +41,10 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_BUF_MAX=1400000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + message(STATUS "Defined SC_HAVE_WRAP") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP) target_compile_options(${PROJECT_NAME}_test PRIVATE -fno-builtin) target_link_options(${PROJECT_NAME}_test PRIVATE diff --git a/buffer/sc_buf.c b/buffer/sc_buf.c index 49a432c..5e86f1a 100644 --- a/buffer/sc_buf.c +++ b/buffer/sc_buf.c @@ -34,7 +34,7 @@ #include #ifndef SC_BUF_MAX -#define SC_BUF_MAX UINT64_MAX +#define SC_BUF_MAX UINT64_MAX-4096 #endif #define NULL_LEN SC_BUF_MAX @@ -686,21 +686,21 @@ void sc_buf_put_double(struct sc_buf *b, double val) void sc_buf_put_str(struct sc_buf *b, const char *str) { - size_t sz; + uint64_t sz; if (str == NULL) { sc_buf_put_64(b, NULL_LEN); return; } - sz = strlen(str); + sz = (uint64_t) strlen(str); if (sz >= SC_BUF_MAX) { b->err |= SC_BUF_CORRUPT; return; } - sc_buf_put_64(b, (uint64_t) sz); - sc_buf_put_raw(b, str, (uint64_t) sz + sc_buf_8_len('\0')); + sc_buf_put_64(b, sz); + sc_buf_put_raw(b, str, sz + sc_buf_8_len('\0')); } void sc_buf_put_str_len(struct sc_buf *b, const char *str, uint64_t len) diff --git a/condition/CMakeLists.txt b/condition/CMakeLists.txt index c3fd173..e2f6e8f 100644 --- a/condition/CMakeLists.txt +++ b/condition/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_SIZE_MAX=140000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP) diff --git a/heap/CMakeLists.txt b/heap/CMakeLists.txt index 6ae93d0..28a8816 100644 --- a/heap/CMakeLists.txt +++ b/heap/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HEAP_MAX=140000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP) diff --git a/heap/README.md b/heap/README.md index d1d542f..245b759 100644 --- a/heap/README.md +++ b/heap/README.md @@ -37,7 +37,8 @@ int main(int argc, char *argv[]) } while ((elem = sc_heap_pop(&heap)) != NULL) { - printf("key = %d, data = %s \n", (int) elem->key, elem->data); + printf("key = %d, data = %s \n", + (int) elem->key, (char*) elem->data); } printf("---------------- \n"); @@ -48,7 +49,8 @@ int main(int argc, char *argv[]) } while ((elem = sc_heap_pop(&heap)) != NULL) { - printf("key = %d, data = %s \n", (int) elem->key, elem->data); + printf("key = %d, data = %s \n", + (int) elem->key, (char*) elem->data); } sc_heap_term(&heap); diff --git a/heap/heap_example.c b/heap/heap_example.c index bb09afd..e709add 100644 --- a/heap/heap_example.c +++ b/heap/heap_example.c @@ -26,7 +26,8 @@ int main() } while ((elem = sc_heap_pop(&heap)) != NULL) { - printf("key = %d, data = %s \n", (int) elem->key, elem->data); + printf("key = %d, data = %s \n", + (int) elem->key, (char*) elem->data); } printf("---------------- \n"); @@ -37,7 +38,8 @@ int main() } while ((elem = sc_heap_pop(&heap)) != NULL) { - printf("key = %d, data = %s \n", (int) elem->key, elem->data); + printf("key = %d, data = %s \n", + (int) elem->key, (char*) elem->data); } sc_heap_term(&heap); diff --git a/heap/heap_test.c b/heap/heap_test.c index df4dade..8b2b577 100644 --- a/heap/heap_test.c +++ b/heap/heap_test.c @@ -30,7 +30,8 @@ int example(void) } while ((elem = sc_heap_pop(&heap)) != NULL) { - printf("key = %d, data = %s \n", (int) elem->key, elem->data); + printf("key = %d, data = %s \n", + (int) elem->key, (char*) elem->data); } printf("---------------- \n"); @@ -41,7 +42,8 @@ int example(void) } while ((elem = sc_heap_pop(&heap)) != NULL) { - printf("key = %d, data = %s \n", (int) elem->key, elem->data); + printf("key = %d, data = %s \n", + (int) elem->key, (char*) elem->data); } sc_heap_term(&heap); diff --git a/ini/CMakeLists.txt b/ini/CMakeLists.txt index efaac65..8cff57f 100644 --- a/ini/CMakeLists.txt +++ b/ini/CMakeLists.txt @@ -39,7 +39,7 @@ if (SC_BUILD_TEST) add_executable(${PROJECT_NAME}_test ini_test.c sc_ini.c) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP) diff --git a/logger/CMakeLists.txt b/logger/CMakeLists.txt index be63e9d..b498d2a 100644 --- a/logger/CMakeLists.txt +++ b/logger/CMakeLists.txt @@ -39,10 +39,10 @@ if (SC_BUILD_TEST) add_executable(${PROJECT_NAME}_test log_test.c sc_log.c) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - + message(STATUS "Defined SC_HAVE_WRAP") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP) target_compile_options(${PROJECT_NAME}_test PRIVATE -fno-builtin) target_link_options(${PROJECT_NAME}_test PRIVATE diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index b213925..bbcdc4d 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_MAP_MAX=140000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/memory-map/CMakeLists.txt b/memory-map/CMakeLists.txt index 66f6694..8595d9d 100644 --- a/memory-map/CMakeLists.txt +++ b/memory-map/CMakeLists.txt @@ -39,10 +39,10 @@ if (SC_BUILD_TEST) add_executable(${PROJECT_NAME}_test mmap_test.c sc_mmap.c) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - + message(STATUS "Defined SC_HAVE_WRAP") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP) target_compile_options(${PROJECT_NAME}_test PRIVATE -fno-builtin) target_link_options(${PROJECT_NAME}_test PRIVATE diff --git a/mutex/CMakeLists.txt b/mutex/CMakeLists.txt index b4bbc6a..de74304 100644 --- a/mutex/CMakeLists.txt +++ b/mutex/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_SIZE_MAX=1400000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/option/CMakeLists.txt b/option/CMakeLists.txt index f253960..81cf973 100644 --- a/option/CMakeLists.txt +++ b/option/CMakeLists.txt @@ -42,7 +42,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_SIZE_MAX=1400000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/queue/CMakeLists.txt b/queue/CMakeLists.txt index 29838ed..024b263 100644 --- a/queue/CMakeLists.txt +++ b/queue/CMakeLists.txt @@ -42,7 +42,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_QUEUE_MAX=1400000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/sc/CMakeLists.txt b/sc/CMakeLists.txt index ac3c645..2069930 100644 --- a/sc/CMakeLists.txt +++ b/sc/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_SIZE_MAX=1400000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/signal/CMakeLists.txt b/signal/CMakeLists.txt index f4a88da..525e6d5 100644 --- a/signal/CMakeLists.txt +++ b/signal/CMakeLists.txt @@ -61,7 +61,7 @@ if (SC_BUILD_TEST) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_BACKTRACE") endif () - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/socket/CMakeLists.txt b/socket/CMakeLists.txt index b5e1722..ce495b5 100644 --- a/socket/CMakeLists.txt +++ b/socket/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_SIZE_MAX=300 -Dsc_fcntl=test_fcntl) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/string/CMakeLists.txt b/string/CMakeLists.txt index 6ce02e9..649053e 100644 --- a/string/CMakeLists.txt +++ b/string/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_STR_MAX=4000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/thread/CMakeLists.txt b/thread/CMakeLists.txt index 49f23a8..ac0a79c 100644 --- a/thread/CMakeLists.txt +++ b/thread/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_SIZE_MAX=4000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/time/CMakeLists.txt b/time/CMakeLists.txt index 73b52cc..c277ae5 100644 --- a/time/CMakeLists.txt +++ b/time/CMakeLists.txt @@ -51,10 +51,10 @@ if (SC_BUILD_TEST) endif () endif () - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - + message(STATUS "Defined SC_HAVE_WRAP") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP) target_compile_options(${PROJECT_NAME}_test PRIVATE -fno-builtin) target_link_options(${PROJECT_NAME}_test PRIVATE diff --git a/timer/CMakeLists.txt b/timer/CMakeLists.txt index 002ef4a..07d78e5 100644 --- a/timer/CMakeLists.txt +++ b/timer/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_TIMER_MAX=4000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/uri/CMakeLists.txt b/uri/CMakeLists.txt index b86e466..9920ac1 100644 --- a/uri/CMakeLists.txt +++ b/uri/CMakeLists.txt @@ -41,7 +41,7 @@ if (SC_BUILD_TEST) target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_SIZE_MAX=140000ul) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND SC_USE_WRAP) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") target_compile_options(${PROJECT_NAME}_test PRIVATE -DSC_HAVE_WRAP)