diff options
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | source/kit/CMakeLists.txt | 5 | ||||
-rw-r--r-- | source/kit/async_function.h | 12 | ||||
-rw-r--r-- | source/kit/lower_bound.c | 1 | ||||
-rw-r--r-- | source/kit/thread.posix.c | 11 | ||||
-rw-r--r-- | source/kit/thread.win32.c | 11 | ||||
-rw-r--r-- | source/test/unittests/async_function.test.c | 22 |
7 files changed, 35 insertions, 37 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 33b42fe..770e79d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,16 +7,10 @@ if(NOT DEFINED CMAKE_BUILD_PARALLEL_LEVEL) endif() option(KIT_ENABLE_TESTING "Enable testing" ON) -option(KIT_FORCE_ANSI_C "Force ANSI C" ${KIT_ENABLE_TESTING}) option(KIT_DISABLE_SYSTEM_MALLOC "Disable system memory allocator" OFF) option(KIT_DISABLE_SYSTEM_THREADS "Disable system threads" OFF) -if(KIT_FORCE_ANSI_C) - set(CMAKE_C_STANDARD 90) - set(CMAKE_C_EXTENSIONS OFF) -endif() - project( kit VERSION 0.1.1 @@ -32,6 +26,10 @@ if(WIN32) target_link_libraries(kit PUBLIC Shlwapi) endif() +if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(kit PUBLIC -pedantic -Wall -Werror) +endif() + include(CheckCSourceRuns) check_c_source_runs( diff --git a/source/kit/CMakeLists.txt b/source/kit/CMakeLists.txt index 101e2a8..4113668 100644 --- a/source/kit/CMakeLists.txt +++ b/source/kit/CMakeLists.txt @@ -3,9 +3,8 @@ target_sources( PRIVATE input_buffer.c bigint.c status.c secure_random.c thread.posix.c atomic.win32.c condition_variable.c thread.win32.c - move_back.c input_stream.c lower_bound.c file.c string_ref.c - async_function.c allocator.c array_ref.c dynamic_array.c mutex.c - mersenne_twister_64.c + move_back.c input_stream.c file.c string_ref.c async_function.c + allocator.c array_ref.c dynamic_array.c mutex.c mersenne_twister_64.c PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/mutex.h> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/status.h> diff --git a/source/kit/async_function.h b/source/kit/async_function.h index 73e3fee..1791291 100644 --- a/source/kit/async_function.h +++ b/source/kit/async_function.h @@ -190,12 +190,12 @@ typedef struct { ((promise_)._state_machine(&(promise_), kit_af_request_join), \ (promise_).return_value) -#define KIT_AF_JOIN_N(promises_, size_) \ - do { \ - int kit_af_index_; \ - for (kit_af_index_ = 0; kit_af_index_ < (size_); \ - kit_af_index_++) \ - KIT_AF_JOIN((promises_)[kit_af_index_]); \ +#define KIT_AF_JOIN_N(promises_, size_) \ + do { \ + int kit_af_index_; \ + for (kit_af_index_ = 0; kit_af_index_ < (size_); \ + kit_af_index_++) \ + (void) KIT_AF_JOIN((promises_)[kit_af_index_]); \ } while (0) #define KIT_AF_RESUME_AND_JOIN(promise_) \ diff --git a/source/kit/lower_bound.c b/source/kit/lower_bound.c deleted file mode 100644 index 0ae8489..0000000 --- a/source/kit/lower_bound.c +++ /dev/null @@ -1 +0,0 @@ -#include "lower_bound.h" diff --git a/source/kit/thread.posix.c b/source/kit/thread.posix.c index 12bdd05..192dca4 100644 --- a/source/kit/thread.posix.c +++ b/source/kit/thread.posix.c @@ -1,11 +1,12 @@ +#include "thread.h" + +#include "allocator.h" +#include "condition_variable.h" +#include "mutex.h" + #ifndef KIT_DISABLE_SYSTEM_THREADS # if !defined(_WIN32) || defined(__CYGWIN__) -# include "allocator.h" -# include "condition_variable.h" -# include "mutex.h" -# include "thread.h" - # include <assert.h> # include <errno.h> # include <limits.h> diff --git a/source/kit/thread.win32.c b/source/kit/thread.win32.c index e483c4e..94f6e89 100644 --- a/source/kit/thread.win32.c +++ b/source/kit/thread.win32.c @@ -1,3 +1,9 @@ +#include "thread.h" + +#include "allocator.h" +#include "condition_variable.h" +#include "mutex.h" + #ifndef KIT_DISABLE_SYSTEM_THREADS # if defined(_WIN32) && !defined(__CYGWIN__) @@ -8,11 +14,6 @@ # include <stdbool.h> # include <stdlib.h> -# include "allocator.h" -# include "condition_variable.h" -# include "mutex.h" -# include "thread.h" - # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif diff --git a/source/test/unittests/async_function.test.c b/source/test/unittests/async_function.test.c index 320f323..6ec8825 100644 --- a/source/test/unittests/async_function.test.c +++ b/source/test/unittests/async_function.test.c @@ -142,29 +142,29 @@ TEST("coroutine generator") { TEST("coroutine status finished") { AF_CREATE(promise, test_bar); REQUIRE(!AF_FINISHED(promise)); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(!AF_FINISHED(promise)); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(AF_FINISHED(promise)); } TEST("coroutine task") { AF_CREATE(promise, test_task); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(!AF_FINISHED(promise)); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(!AF_FINISHED(promise)); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(AF_FINISHED(promise)); } TEST("coroutine nested task") { AF_CREATE(promise, test_nest_task); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(!AF_FINISHED(promise)); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(!AF_FINISHED(promise)); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(AF_FINISHED(promise)); } @@ -174,7 +174,7 @@ TEST("coroutine nested generator") { REQUIRE(AF_RESUME_AND_JOIN(promise) == 2); REQUIRE(AF_RESUME_AND_JOIN(promise) == 3); REQUIRE(!AF_FINISHED(promise)); - AF_RESUME_AND_JOIN(promise); + (void) AF_RESUME_AND_JOIN(promise); REQUIRE(AF_FINISHED(promise)); } @@ -198,7 +198,7 @@ TEST("coroutine custom execution context lazy") { AF_RESUME(promise); REQUIRE(promise.return_value == 0); REQUIRE(!AF_FINISHED(promise)); - AF_JOIN(promise); + (void) AF_JOIN(promise); REQUIRE(promise.return_value == 42); REQUIRE(AF_FINISHED(promise)); } @@ -210,7 +210,7 @@ TEST("coroutine custom execution context immediate") { AF_RESUME(promise); REQUIRE(promise.return_value == 42); REQUIRE(AF_FINISHED(promise)); - AF_JOIN(promise); + (void) AF_JOIN(promise); REQUIRE(promise.return_value == 42); REQUIRE(AF_FINISHED(promise)); } |