ARGOBOTS  1227c643f7a7f974f1f1778a9ffebd29d7dafecf
 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 
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 
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 
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 
53 {
54  ABTI_STATIC_ASSERT(offsetof(ABTI_ythread, thread) == 0);
55  return (ABTI_ythread *)p_thread;
56 }
57 
58 static inline ABTI_ythread *
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 */
static ABTI_ythread * ABTI_thread_get_ythread_or_null(ABTI_thread *p_thread)
Definition: abti_thread.h:59
ABTD_atomic_uint32 request
Definition: abti.h:323
ABTI_thread_type type
Definition: abti.h:316
static void ABTI_thread_unset_request(ABTI_thread *p_thread, uint32_t req)
Definition: abti_thread.h:73
static ABTI_thread * ABTI_thread_get_ptr(ABT_thread thread)
Definition: abti_thread.h:9
static void ABTI_thread_set_request(ABTI_thread *p_thread, uint32_t req)
Definition: abti_thread.h:68
static uint32_t ABTD_atomic_fetch_or_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:538
struct ABT_thread_opaque * ABT_thread
Definition: abt.h:343
static uint32_t ABTD_atomic_fetch_and_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:489
uint32_t ABTI_thread_type
Definition: abti.h:115
ABT_unit_type
Definition: abt.h:169
#define ABTI_THREAD_TYPE_YIELDABLE
Definition: abti.h:77
static ABT_unit_type ABTI_thread_type_get_type(ABTI_thread_type type)
Definition: abti_thread.h:41
#define ABT_THREAD_NULL
Definition: abt.h:416
static ABTI_ythread * ABTI_thread_get_ythread(ABTI_thread *p_thread)
Definition: abti_thread.h:52
#define ABTI_THREAD_TYPE_EXT
Definition: abti.h:72
#define ABTI_STATIC_ASSERT(cond)
Definition: abti_error.h:19
static ABT_thread ABTI_thread_get_handle(ABTI_thread *p_thread)
Definition: abti_thread.h:24