libkoishi
Decently portable C11 coroutine library
koishi.h File Reference
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  koishi_coroutine_t
 A coroutine instance. More...
 

Macros

#define KOISHI_API
 Annotates all publicly visible API functions. More...
 
#define KOISHI_NORETURN
 Annotates API functions that don't return to their callers. More...
 

Typedefs

typedef void *(* koishi_entrypoint_t) (void *data)
 A coroutine entry point. More...
 

Enumerations

enum  koishi_state {
  KOISHI_SUSPENDED ,
  KOISHI_RUNNING ,
  KOISHI_DEAD ,
  KOISHI_IDLE
}
 State of a koishi_coroutine_t instance. More...
 

Functions

KOISHI_API void koishi_init (koishi_coroutine_t *co, size_t min_stack_size, koishi_entrypoint_t entry_point)
 Initialize a koishi_coroutine_t structure. More...
 
KOISHI_API void koishi_recycle (koishi_coroutine_t *co, koishi_entrypoint_t entry_point)
 Recycle a previously initialized coroutine. More...
 
KOISHI_API void koishi_deinit (koishi_coroutine_t *co)
 Deinitialize a koishi_coroutine_t structure. More...
 
KOISHI_API void * koishi_resume (koishi_coroutine_t *co, void *arg)
 Resume a suspended coroutine. More...
 
KOISHI_API void * koishi_yield (void *arg)
 Suspend the currently running coroutine. More...
 
KOISHI_API KOISHI_NORETURN void koishi_die (void *arg)
 Return from the currently running coroutine. More...
 
KOISHI_API void koishi_kill (koishi_coroutine_t *co, void *arg)
 Stop a coroutine. More...
 
KOISHI_API int koishi_state (koishi_coroutine_t *co)
 Query the state of a coroutine. More...
 
KOISHI_API koishi_coroutine_tkoishi_active (void)
 Query the currently running coroutine context. More...
 
KOISHI_API void * koishi_get_stack (koishi_coroutine_t *co, size_t *stack_size)
 Query the coroutine's stack region. More...
 
KOISHI_API size_t koishi_util_page_size (void)
 Query the system's page size. More...
 
KOISHI_API size_t koishi_util_real_stack_size (size_t min_size)
 Query the real stack size for a given minimum. More...
 

Macro Definition Documentation

◆ KOISHI_API

#define KOISHI_API

Annotates all publicly visible API functions.

Definition at line 20 of file koishi.h.

◆ KOISHI_NORETURN

#define KOISHI_NORETURN

Annotates API functions that don't return to their callers.

Definition at line 34 of file koishi.h.