ARGOBOTS  dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
mutex_attr.c
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 #include "abti.h"
7 
40 {
42  ABTI_UB_ASSERT(newattr);
43 
44  ABTI_mutex_attr *p_newattr;
45 
46  int abt_errno = ABTU_malloc(sizeof(ABTI_mutex_attr), (void **)&p_newattr);
47  ABTI_CHECK_ERROR(abt_errno);
48 
49  /* Default values */
50  p_newattr->attrs = ABTI_MUTEX_ATTR_NONE;
51 
52  /* Return value */
53  *newattr = ABTI_mutex_attr_get_handle(p_newattr);
54  return ABT_SUCCESS;
55 }
56 
80 {
82  ABTI_UB_ASSERT(attr);
83 
84  ABT_mutex_attr h_attr = *attr;
85  ABTI_mutex_attr *p_attr = ABTI_mutex_attr_get_ptr(h_attr);
87 
88  /* Free the memory */
89  ABTU_free(p_attr);
90  /* Return value */
91  *attr = ABT_MUTEX_ATTR_NULL;
92  return ABT_SUCCESS;
93 }
94 
121 {
123  ABTI_UB_ASSERT_BOOL(recursive);
124 
127 
128  /* Set the value */
129  if (recursive == ABT_TRUE) {
130  p_attr->attrs |= ABTI_MUTEX_ATTR_RECURSIVE;
131  } else {
132  p_attr->attrs &= ~ABTI_MUTEX_ATTR_RECURSIVE;
133  }
134  return ABT_SUCCESS;
135 }
136 
163 {
165  ABTI_UB_ASSERT(recursive);
166 
169 
170  /* Get the value */
171  if (p_attr->attrs & ABTI_MUTEX_ATTR_RECURSIVE) {
172  *recursive = ABT_TRUE;
173  } else {
174  *recursive = ABT_FALSE;
175  }
176  return ABT_SUCCESS;
177 }
ABT_bool
int ABT_bool
Boolean type.
Definition: abt.h:1043
ABTI_mutex_attr::attrs
int attrs
Definition: abti.h:198
ABTI_CHECK_ERROR
#define ABTI_CHECK_ERROR(abt_errno)
Definition: abti_error.h:136
ABTI_MUTEX_ATTR_RECURSIVE
#define ABTI_MUTEX_ATTR_RECURSIVE
Definition: abti.h:125
ABTI_mutex_attr_get_handle
static ABT_mutex_attr ABTI_mutex_attr_get_handle(ABTI_mutex_attr *p_attr)
Definition: abti_mutex_attr.h:26
ABTI_mutex_attr_get_ptr
static ABTI_mutex_attr * ABTI_mutex_attr_get_ptr(ABT_mutex_attr attr)
Definition: abti_mutex_attr.h:11
abti.h
ABT_mutex_attr
struct ABT_mutex_attr_opaque * ABT_mutex_attr
Mutex attribute handle type.
Definition: abt.h:994
ABTU_malloc
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
Definition: abtu.h:235
ABTI_CHECK_NULL_MUTEX_ATTR_PTR
#define ABTI_CHECK_NULL_MUTEX_ATTR_PTR(p)
Definition: abti_error.h:283
ABT_mutex_attr_free
int ABT_mutex_attr_free(ABT_mutex_attr *attr)
Free a mutex attribute.
Definition: mutex_attr.c:79
ABT_mutex_attr_set_recursive
int ABT_mutex_attr_set_recursive(ABT_mutex_attr attr, ABT_bool recursive)
Set a recursive property in a mutex attribute.
Definition: mutex_attr.c:120
ABTI_initialized
ABT_bool ABTI_initialized(void)
Definition: global.c:187
ABT_SUCCESS
#define ABT_SUCCESS
Error code: the routine returns successfully.
Definition: abt.h:92
ABT_mutex_attr_get_recursive
int ABT_mutex_attr_get_recursive(ABT_mutex_attr attr, ABT_bool *recursive)
Get a recursive property in a mutex attribute.
Definition: mutex_attr.c:162
ABT_TRUE
#define ABT_TRUE
True constant for ABT_bool.
Definition: abt.h:784
ABT_FALSE
#define ABT_FALSE
False constant for ABT_bool.
Definition: abt.h:786
ABTI_MUTEX_ATTR_NONE
#define ABTI_MUTEX_ATTR_NONE
Definition: abti.h:123
ABTI_mutex_attr
Definition: abti.h:197
ABTI_UB_ASSERT
#define ABTI_UB_ASSERT(cond)
Definition: abti_error.h:19
ABTU_free
static void ABTU_free(void *ptr)
Definition: abtu.h:228
ABT_MUTEX_ATTR_NULL
#define ABT_MUTEX_ATTR_NULL
Definition: abt.h:1110
ABT_mutex_attr_create
int ABT_mutex_attr_create(ABT_mutex_attr *newattr)
Create a new mutex attribute.
Definition: mutex_attr.c:39
ABTI_UB_ASSERT_BOOL
#define ABTI_UB_ASSERT_BOOL(bool_val)
Definition: abti_error.h:26