Skip to content

Commit

Permalink
Merge pull request #3 from hylo-lang/c_compilation
Browse files Browse the repository at this point in the history
Fix C compilation.
  • Loading branch information
lucteo authored Dec 18, 2023
2 parents f4abea1 + 6e28ee4 commit 219d7af
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
15 changes: 8 additions & 7 deletions include/context_core_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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.
///
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# The source files for the tests
set(sourceFiles
"test_context.cpp"
"test_c_compilation.c"
)

find_package(Catch2 REQUIRED CONFIG)
Expand Down
3 changes: 3 additions & 0 deletions test/test_c_compilation.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "context_core_api.h"

// Just test the C compilation
4 changes: 2 additions & 2 deletions test/test_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 219d7af

Please sign in to comment.