Ruby
3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
wasm
fiber.h
1
#ifndef RB_WASM_SUPPORT_FIBER_H
2
#define RB_WASM_SUPPORT_FIBER_H
3
4
#include <
stdbool.h
>
5
6
#ifndef WASM_FIBER_STACK_BUFFER_SIZE
7
# define WASM_FIBER_STACK_BUFFER_SIZE 6144
8
#endif
9
10
struct
__rb_wasm_asyncify_fiber_ctx
{
11
void
* top;
12
void
* end;
13
char
buffer[WASM_FIBER_STACK_BUFFER_SIZE];
14
};
15
16
// Fiber execution context needed to perform context switch
17
typedef
struct
{
18
// Fiber entry point called when the fiber started for the first time.
19
// NULL if the entry point is main
20
void (*entry_point)(
void
*,
void
*);
21
// Opaque argument pointers passed to the entry point function
22
void
*arg0, *arg1;
23
24
// Internal asyncify buffer space
25
struct
__rb_wasm_asyncify_fiber_ctx
asyncify_buf
;
26
27
bool
is_rewinding;
28
bool
is_started;
29
}
rb_wasm_fiber_context
;
30
31
// Initialize a given fiber context to be ready to pass to `rb_wasm_swapcontext`
32
void
rb_wasm_init_context(
rb_wasm_fiber_context
*fcp,
void
(*func)(
void
*,
void
*),
void
*arg0,
void
*arg1);
33
34
// Swap the execution control with `target_fiber` and save the current context in `old_fiber`
35
// NOTE: `old_fiber` must be the current executing fiber context
36
void
rb_wasm_swapcontext(
rb_wasm_fiber_context
*old_fiber,
rb_wasm_fiber_context
*target_fiber);
37
38
// Returns the Asyncify buffer of next fiber if unwound for fiber context switch.
39
// Used by the top level Asyncify handling in wasm/runtime.c
40
void
*rb_wasm_handle_fiber_unwind(
void
(**new_fiber_entry)(
void
*,
void
*),
41
void
**arg0,
void
**arg1,
bool
*is_new_fiber_started);
42
43
#endif
stdbool.h
C99 shim for <stdbool.h>
__rb_wasm_asyncify_fiber_ctx
Definition:
fiber.h:10
asyncify_buf
Definition:
machine.c:9
rb_wasm_fiber_context
Definition:
fiber.h:17
Generated by
1.9.1