libcopp  2.2.0
fcontext_test.cpp
Go to the documentation of this file.
1 // Copyright 2023 owent
2 
3 #include <libcopp/utils/config/libcopp_build_features.h>
4 
5 #include <cstdio>
6 #include <cstring>
7 #include <iostream>
8 
9 #if defined(LIBCOPP_MACRO_USE_VALGRIND)
10 # include <valgrind/valgrind.h>
11 #endif
12 
13 #include "frame/test_macros.h"
14 #include "libcopp/fcontext/all.hpp"
15 
17 char test_core_fcontext_stack_a[128 * 1024] = {0};
18 char test_core_fcontext_stack_b[128 * 1024] = {0};
20 
21 void test_core_fcontext_func_a(LIBCOPP_COPP_NAMESPACE_ID::fcontext::transfer_t src) {
23 
24  copp::fcontext::fcontext_t* fc = reinterpret_cast<copp::fcontext::fcontext_t*>(src.data);
25 
29 
31  fc = reinterpret_cast<copp::fcontext::fcontext_t*>(src.data);
33  test_core_fcontext_b_func = src.fctx;
34 
37 
39 }
40 
41 void test_core_fcontext_func_b(LIBCOPP_COPP_NAMESPACE_ID::fcontext::transfer_t src) {
44 
45  copp::fcontext::fcontext_t* fc = reinterpret_cast<copp::fcontext::fcontext_t*>(src.data);
47 
48  test_core_fcontext_a_func = src.fctx;
50 }
51 
53 #if defined(LIBCOPP_MACRO_USE_VALGRIND)
54  unsigned valgrind_stack_id_a = VALGRIND_STACK_REGISTER(
56  unsigned valgrind_stack_id_b = VALGRIND_STACK_REGISTER(
58 #endif
61 
68 
70 
73 
74 #if defined(LIBCOPP_MACRO_USE_VALGRIND)
75  VALGRIND_STACK_DEREGISTER(valgrind_stack_id_a);
76  VALGRIND_STACK_DEREGISTER(valgrind_stack_id_b);
77 #endif
78 }
char test_core_fcontext_stack_b[128 *1024]
CASE_TEST(core, fcontext)
int g_test_core_fcontext_status
copp::fcontext::fcontext_t test_core_fcontext_a_func
char test_core_fcontext_stack_a[128 *1024]
copp::fcontext::fcontext_t test_core_fcontext_main_func
void test_core_fcontext_func_b(LIBCOPP_COPP_NAMESPACE_ID::fcontext::transfer_t src)
copp::fcontext::fcontext_t test_core_fcontext_b_func
void test_core_fcontext_func_a(LIBCOPP_COPP_NAMESPACE_ID::fcontext::transfer_t src)
COPP_BOOST_CONTEXT_DECL fcontext_t COPP_BOOST_CONTEXT_CALLDECL copp_make_fcontext_v2(void *sp, std::size_t size, void(*fn)(transfer_t))
COPP_BOOST_CONTEXT_DECL transfer_t COPP_BOOST_CONTEXT_CALLDECL copp_jump_fcontext_v2(fcontext_t const to, void *vp)
void * fcontext_t
Definition: fcontext.hpp:27
#define CASE_EXPECT_EQ(l, r)
Definition: test_macros.h:96