ARGOBOTS  c6511494322293e01714f56f341b8d2b22c1e3c1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
abti_thread.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 ABTI_THREAD_H_INCLUDED
7 #define ABTI_THREAD_H_INCLUDED
8 
9 static inline ABTI_thread *ABTI_thread_get_ptr(ABT_thread thread)
10 {
11 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
12  ABTI_thread *p_thread;
13  if (thread == ABT_THREAD_NULL) {
14  p_thread = NULL;
15  } else {
16  p_thread = (ABTI_thread *)thread;
17  }
18  return p_thread;
19 #else
20  return (ABTI_thread *)thread;
21 #endif
22 }
23 
24 static inline ABT_thread ABTI_thread_get_handle(ABTI_thread *p_thread)
25 {
26 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
27  ABT_thread h_thread;
28  if (p_thread == NULL) {
29  h_thread = ABT_THREAD_NULL;
30  } else {
31  h_thread = (ABT_thread)p_thread;
32  }
33  return h_thread;
34 #else
35  return (ABT_thread)p_thread;
36 #endif
37 }
38 
39 /* Inlined functions for User-level Thread (ULT) */
40 
41 static inline ABT_unit_type ABTI_thread_type_get_type(ABTI_thread_type type)
42 {
43  if (type & ABTI_THREAD_TYPE_YIELDABLE) {
44  return ABT_UNIT_TYPE_THREAD;
45  } else if (type == ABTI_THREAD_TYPE_EXT) {
46  return ABT_UNIT_TYPE_EXT;
47  } else {
48  return ABT_UNIT_TYPE_TASK;
49  }
50 }
51 
52 static inline ABTI_ythread *ABTI_thread_get_ythread(ABTI_thread *p_thread)
53 {
54  ABTI_STATIC_ASSERT(offsetof(ABTI_ythread, thread) == 0);
55  return (ABTI_ythread *)p_thread;
56 }
57 
58 static inline ABTI_ythread *
59 ABTI_thread_get_ythread_or_null(ABTI_thread *p_thread)
60 {
61  if (p_thread->type & ABTI_THREAD_TYPE_YIELDABLE) {
62  return ABTI_thread_get_ythread(p_thread);
63  } else {
64  return NULL;
65  }
66 }
67 
68 static inline void ABTI_thread_set_request(ABTI_thread *p_thread, uint32_t req)
69 {
70  ABTD_atomic_fetch_or_uint32(&p_thread->request, req);
71 }
72 
73 static inline void ABTI_thread_unset_request(ABTI_thread *p_thread,
74  uint32_t req)
75 {
76  ABTD_atomic_fetch_and_uint32(&p_thread->request, ~req);
77 }
78 
79 #endif /* ABTI_THREAD_H_INCLUDED */
struct ABT_thread_opaque * ABT_thread
Definition: abt.h:343
ABT_unit_type
Definition: abt.h:169
#define ABT_THREAD_NULL
Definition: abt.h:416