ARGOBOTS  be4fa269aff5d27d176eaaf43a9acaa10a66c79d
abtd_context.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_CONTEXT_H_INCLUDED
7 #define ABTD_CONTEXT_H_INCLUDED
8 
9 #include "abt_config.h"
10 
11 #ifndef ABT_CONFIG_USE_FCONTEXT
12 #ifndef _XOPEN_SOURCE
13 #define _XOPEN_SOURCE
14 #endif
15 #include <ucontext.h>
16 #endif
17 
18 #ifdef ABT_CONFIG_ENABLE_STACK_UNWIND
19 /* Peek context is needed only for stack unwinding. */
20 #define ABT_CONFIG_ENABLE_PEEK_CONTEXT
21 #endif
22 
23 typedef struct ABTD_ythread_context ABTD_ythread_context;
24 
25 typedef struct ABTD_ythread_context_atomic_ptr {
26  ABTD_atomic_ptr val;
27 } ABTD_ythread_context_atomic_ptr;
28 
29 static inline ABTD_ythread_context *
30 ABTD_atomic_relaxed_load_ythread_context_ptr(
31  const ABTD_ythread_context_atomic_ptr *ptr)
32 {
33  return (ABTD_ythread_context *)ABTD_atomic_relaxed_load_ptr(&ptr->val);
34 }
35 
36 static inline ABTD_ythread_context *
37 ABTD_atomic_acquire_load_ythread_context_ptr(
38  const ABTD_ythread_context_atomic_ptr *ptr)
39 {
40  return (ABTD_ythread_context *)ABTD_atomic_acquire_load_ptr(&ptr->val);
41 }
42 
43 static inline void ABTD_atomic_relaxed_store_ythread_context_ptr(
44  ABTD_ythread_context_atomic_ptr *ptr, ABTD_ythread_context *p_ctx)
45 {
46  ABTD_atomic_relaxed_store_ptr(&ptr->val, (void *)p_ctx);
47 }
48 
49 static inline void ABTD_atomic_release_store_ythread_context_ptr(
50  ABTD_ythread_context_atomic_ptr *ptr, ABTD_ythread_context *p_ctx)
51 {
52  ABTD_atomic_release_store_ptr(&ptr->val, (void *)p_ctx);
53 }
54 
55 struct ABTD_ythread_context;
56 
57 static void ABTD_ythread_context_make(ABTD_ythread_context *p_ctx, void *sp,
58  size_t size, void (*thread_func)(void *));
59 static void ABTD_ythread_context_jump(ABTD_ythread_context *p_old,
60  ABTD_ythread_context *p_new, void *arg);
61 ABTU_noreturn static void ABTD_ythread_context_take(ABTD_ythread_context *p_old,
62  ABTD_ythread_context *p_new,
63  void *arg);
64 #if ABT_CONFIG_THREAD_TYPE == ABT_THREAD_TYPE_DYNAMIC_PROMOTION
65 static void ABTD_ythread_context_init_and_call(ABTD_ythread_context *p_ctx,
66  void *sp,
67  void (*thread_func)(void *),
68  void *arg);
69 #endif
70 #ifdef ABT_CONFIG_ENABLE_PEEK_CONTEXT
71 static inline void ABTD_ythread_context_peek(ABTD_ythread_context *p_ctx,
72  void (*peek_func)(void *),
73  void *arg);
74 #endif
75 
76 void ABTD_ythread_print_context(ABTI_ythread *p_ythread, FILE *p_os,
77  int indent);
78 
79 #ifdef ABT_CONFIG_USE_FCONTEXT
80 #include "abtd_fcontext.h"
81 #else
82 #include "abtd_ucontext.h"
83 #endif
84 
85 #endif /* ABTD_CONTEXT_H_INCLUDED */
ABTU_noreturn
#define ABTU_noreturn
Definition: abtu.h:116
abtd_fcontext.h
abt_config.h
abtd_ucontext.h