ARGOBOTS  1227c643f7a7f974f1f1778a9ffebd29d7dafecf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
abtd_fcontext.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #ifndef ABTD_FCONTEXT_H_INCLUDED
7 #define ABTD_FCONTEXT_H_INCLUDED
8 
9 typedef void *fcontext_t;
10 
11 #if defined(ABT_C_HAVE_VISIBILITY)
12 #define ABT_API_PRIVATE __attribute__((visibility("hidden")))
13 #else
14 #define ABT_API_PRIVATE
15 #endif
16 
17 fcontext_t make_fcontext(void *sp, size_t size,
18  void (*thread_func)(void *)) ABT_API_PRIVATE;
19 void *jump_fcontext(fcontext_t *old, fcontext_t new, void *arg) ABT_API_PRIVATE;
20 void *take_fcontext(fcontext_t *old, fcontext_t new, void *arg) ABT_API_PRIVATE;
21 #if ABT_CONFIG_THREAD_TYPE == ABT_THREAD_TYPE_DYNAMIC_PROMOTION
22 void init_and_call_fcontext(void *p_arg, void (*f_thread)(void *),
23  void *p_stacktop, fcontext_t *old);
24 #endif
25 
26 static inline void ABTD_ythread_context_make(ABTD_ythread_context *p_ctx,
27  void *sp, size_t size,
28  void (*thread_func)(void *))
29 {
30  p_ctx->p_ctx = make_fcontext(sp, size, thread_func);
31 }
32 
33 static inline void ABTD_ythread_context_jump(ABTD_ythread_context *p_old,
34  ABTD_ythread_context *p_new,
35  void *arg)
36 {
37  jump_fcontext(&p_old->p_ctx, p_new->p_ctx, arg);
38 }
39 
40 ABTU_noreturn static inline void
41 ABTD_ythread_context_take(ABTD_ythread_context *p_old,
42  ABTD_ythread_context *p_new, void *arg)
43 {
44  take_fcontext(&p_old->p_ctx, p_new->p_ctx, arg);
46 }
47 
48 #if ABT_CONFIG_THREAD_TYPE == ABT_THREAD_TYPE_DYNAMIC_PROMOTION
49 static inline void
50 ABTD_ythread_context_init_and_call(ABTD_ythread_context *p_ctx, void *sp,
51  void (*thread_func)(void *), void *arg)
52 {
53  init_and_call_fcontext(arg, thread_func, sp, &p_ctx->p_ctx);
54 }
55 #endif
56 
57 #endif /* ABTD_FCONTEXT_H_INCLUDED */
#define ABTU_unreachable()
Definition: abtu.h:25
void init_and_call_fcontext(void *p_arg, void(*f_thread)(void *), void *p_stacktop, fcontext_t *old)
void * jump_fcontext(fcontext_t *old, fcontext_t new, void *arg) ABT_API_PRIVATE
void * take_fcontext(fcontext_t *old, fcontext_t new, void *arg) ABT_API_PRIVATE
#define ABT_API_PRIVATE
Definition: abtd_fcontext.h:14
fcontext_t make_fcontext(void *sp, size_t size, void(*thread_func)(void *)) ABT_API_PRIVATE
#define ABTU_noreturn
Definition: abtu.h:31
void * fcontext_t
Definition: abtd_fcontext.h:9