ARGOBOTS
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_thread_context_make(ABTD_thread_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_thread_context_jump(ABTD_thread_context *p_old,
34  ABTD_thread_context *p_new,
35  void *arg)
36 {
37  jump_fcontext(&p_old->p_ctx, p_new->p_ctx, arg);
38 }
39 
40 static inline void ABTD_thread_context_take(ABTD_thread_context *p_old,
41  ABTD_thread_context *p_new,
42  void *arg)
43 {
44  take_fcontext(&p_old->p_ctx, p_new->p_ctx, arg);
45 }
46 
47 #if ABT_CONFIG_THREAD_TYPE == ABT_THREAD_TYPE_DYNAMIC_PROMOTION
48 static inline void
49 ABTD_thread_context_init_and_call(ABTD_thread_context *p_ctx, void *sp,
50  void (*thread_func)(void *), void *arg)
51 {
52  init_and_call_fcontext(arg, thread_func, sp, &p_ctx->p_ctx);
53 }
54 #endif
55 
56 #endif /* ABTD_FCONTEXT_H_INCLUDED */
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
void * fcontext_t
Definition: abtd_fcontext.h:9