diff --git a/CMakeLists.txt b/CMakeLists.txt index ea91553..09b7174 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.24) -project(context_core_api CXX) +project(context_core_api CXX C) find_package(Boost COMPONENTS context CONFIG REQUIRED) diff --git a/include/context_core_api.h b/include/context_core_api.h index 6acf106..5233119 100644 --- a/include/context_core_api.h +++ b/include/context_core_api.h @@ -54,8 +54,9 @@ struct context_core_api_transfer_t { /// - return `suspended_ctx` /// /// @sa context_core_api_fcontext_t, context_core_api_jump_fcontext -context_core_api_fcontext_t context_core_api_make_fcontext(void* sp, size_t size, - void (*fn)(context_core_api_transfer_t)); +context_core_api_fcontext_t +context_core_api_make_fcontext(void* sp, size_t size, + void (*fn)(struct context_core_api_transfer_t)); /// @brief Jump to the given context. /// @@ -79,8 +80,8 @@ context_core_api_fcontext_t context_core_api_make_fcontext(void* sp, size_t size /// data will be returned at the point of resumption. /// /// @sa context_core_api_fcontext_t, context_core_api_make_fcontext, context_core_api_ontop_fcontext -context_core_api_transfer_t context_core_api_jump_fcontext(context_core_api_fcontext_t const to, - void* vp); +struct context_core_api_transfer_t +context_core_api_jump_fcontext(context_core_api_fcontext_t const to, void* vp); /// @brief Execute the content of a given function on top of a given context. /// @@ -108,9 +109,9 @@ context_core_api_transfer_t context_core_api_jump_fcontext(context_core_api_fcon /// It is expected that the context of the current resumption point will be eventually resumed. /// /// @sa context_core_api_jump_fcontext, context_core_api_make_fcontext -context_core_api_transfer_t -context_core_api_ontop_fcontext(context_core_api_fcontext_t const to, void* vp, - context_core_api_transfer_t (*fn)(context_core_api_transfer_t)); +struct context_core_api_transfer_t context_core_api_ontop_fcontext( + context_core_api_fcontext_t const to, void* vp, + struct context_core_api_transfer_t (*fn)(struct context_core_api_transfer_t)); #ifdef __cplusplus } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 75f1857..cc8f10e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,7 @@ # The source files for the tests set(sourceFiles "test_context.cpp" +"test_c_compilation.c" ) find_package(Catch2 REQUIRED CONFIG) diff --git a/test/test_c_compilation.c b/test/test_c_compilation.c new file mode 100644 index 0000000..7174773 --- /dev/null +++ b/test/test_c_compilation.c @@ -0,0 +1,3 @@ +#include "context_core_api.h" + +// Just test the C compilation \ No newline at end of file diff --git a/test/test_context.cpp b/test/test_context.cpp index 00edc79..86f976c 100644 --- a/test/test_context.cpp +++ b/test/test_context.cpp @@ -25,7 +25,7 @@ TEST_CASE("Can create fcontexts, without crashing", "[context_core_api_make_fcon }; // Act - (void) context_core_api_make_fcontext(stack.end(), stack.size(), &t::context_fun); + (void)context_core_api_make_fcontext(stack.end(), stack.size(), &t::context_fun); // Assert: if we are here, we didn't crash REQUIRE(true); @@ -64,7 +64,7 @@ TEST_CASE("Function passed to context_core_api_make_fcontext is executed", // Act auto ctx = context_core_api_make_fcontext(stack.end(), stack.size(), &t::context_fun); - (void) context_core_api_jump_fcontext(ctx, &called); + (void)context_core_api_jump_fcontext(ctx, &called); // Assert REQUIRE(called);