6 #ifndef ABTD_FCONTEXT_H_INCLUDED
7 #define ABTD_FCONTEXT_H_INCLUDED
16 return !!p_ftx->
dummy;
24 #if defined(ABT_C_HAVE_VISIBILITY)
25 #define ABT_API_PRIVATE __attribute__((visibility("hidden")))
27 #define ABT_API_PRIVATE
34 void (*f_thread)(
fcontext_t *),
void *p_stacktop,
56 struct ABTD_ythread_context {
60 ABTD_ythread_context_atomic_ptr
64 static inline ABTD_ythread_context *
67 return (ABTD_ythread_context *)(((
char *)p_fctx) -
68 offsetof(ABTD_ythread_context, ctx));
71 static void ABTD_ythread_context_func_wrapper(
fcontext_t *p_fctx)
74 ABTD_ythread_func_wrapper(p_ctx);
80 static inline void ABTD_ythread_context_init(ABTD_ythread_context *p_ctx,
81 void *p_stacktop,
size_t stacksize)
84 p_ctx->p_stacktop = p_stacktop;
85 p_ctx->stacksize = stacksize;
86 ABTD_atomic_relaxed_store_ythread_context_ptr(&p_ctx->p_link, NULL);
89 static inline void ABTD_ythread_context_init_lazy(ABTD_ythread_context *p_ctx,
93 p_ctx->p_stacktop = NULL;
94 p_ctx->stacksize = stacksize;
95 ABTD_atomic_relaxed_store_ythread_context_ptr(&p_ctx->p_link, NULL);
99 ABTD_ythread_context_lazy_set_stack(ABTD_ythread_context *p_ctx,
102 p_ctx->p_stacktop = p_stacktop;
106 ABTD_ythread_context_lazy_unset_stack(ABTD_ythread_context *p_ctx)
108 p_ctx->p_stacktop = NULL;
111 static inline void ABTD_ythread_context_reinit(ABTD_ythread_context *p_ctx)
114 ABTD_atomic_relaxed_store_ythread_context_ptr(&p_ctx->p_link, NULL);
118 ABTD_ythread_context_get_stacktop(ABTD_ythread_context *p_ctx)
120 return p_ctx->p_stacktop;
124 ABTD_ythread_context_has_stack(
const ABTD_ythread_context *p_ctx)
130 ABTD_ythread_context_get_stacksize(ABTD_ythread_context *p_ctx)
132 return p_ctx->stacksize;
136 ABTD_ythread_context_is_started(
const ABTD_ythread_context *p_ctx)
141 static inline void ABTD_ythread_context_switch(ABTD_ythread_context *p_old,
142 ABTD_ythread_context *p_new)
150 ABTD_ythread_context_start_and_switch(ABTD_ythread_context *p_old,
151 ABTD_ythread_context *p_new)
156 p_new->p_stacktop, &p_old->ctx);
160 ABTD_ythread_context_jump(ABTD_ythread_context *p_new)
169 ABTD_ythread_context_start_and_jump(ABTD_ythread_context *p_new)
179 ABTD_ythread_context_switch_with_call(ABTD_ythread_context *p_old,
180 ABTD_ythread_context *p_new,
181 void (*f_cb)(
void *),
void *cb_arg)
189 static inline void ABTD_ythread_context_start_and_switch_with_call(
190 ABTD_ythread_context *p_old, ABTD_ythread_context *p_new,
191 void (*f_cb)(
void *),
void *cb_arg)
196 ABTD_ythread_context_func_wrapper,
197 p_new->p_stacktop, &p_old->ctx);
201 ABTD_ythread_context_jump_with_call(ABTD_ythread_context *p_new,
202 void (*f_cb)(
void *),
void *cb_arg)
210 ABTU_noreturn static inline void ABTD_ythread_context_start_and_jump_with_call(
211 ABTD_ythread_context *p_new,
void (*f_cb)(
void *),
void *cb_arg)
216 ABTD_ythread_context_func_wrapper,
222 ABTD_ythread_context_peek(ABTD_ythread_context *p_target_ctx,
223 void (*f_peek)(
void *),
void *arg)