ARGOBOTS  1.1
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 {
41  ABTI_mutex_attr *p_newattr;
42 
43  int abt_errno = ABTU_malloc(sizeof(ABTI_mutex_attr), (void **)&p_newattr);
44  ABTI_CHECK_ERROR(abt_errno);
45 
46  /* Default values */
47  p_newattr->attrs = ABTI_MUTEX_ATTR_NONE;
48 
49  /* Return value */
50  *newattr = ABTI_mutex_attr_get_handle(p_newattr);
51  return ABT_SUCCESS;
52 }
53 
77 {
78  ABT_mutex_attr h_attr = *attr;
79  ABTI_mutex_attr *p_attr = ABTI_mutex_attr_get_ptr(h_attr);
81 
82  /* Free the memory */
83  ABTU_free(p_attr);
84  /* Return value */
85  *attr = ABT_MUTEX_ATTR_NULL;
86  return ABT_SUCCESS;
87 }
88 
115 {
118 
119  /* Set the value */
120  if (recursive == ABT_TRUE) {
121  p_attr->attrs |= ABTI_MUTEX_ATTR_RECURSIVE;
122  } else {
123  p_attr->attrs &= ~ABTI_MUTEX_ATTR_RECURSIVE;
124  }
125  return ABT_SUCCESS;
126 }
127 
154 {
157 
158  /* Get the value */
159  if (p_attr->attrs & ABTI_MUTEX_ATTR_RECURSIVE) {
160  *recursive = ABT_TRUE;
161  } else {
162  *recursive = ABT_FALSE;
163  }
164  return ABT_SUCCESS;
165 }
ABT_bool
int ABT_bool
Boolean type.
Definition: abt.h:1001
ABTI_mutex_attr::attrs
int attrs
Definition: abti.h:171
ABTI_CHECK_ERROR
#define ABTI_CHECK_ERROR(abt_errno)
Definition: abti_error.h:120
ABTI_MUTEX_ATTR_RECURSIVE
#define ABTI_MUTEX_ATTR_RECURSIVE
Definition: abti.h:103
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:952
ABTU_malloc
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
Definition: abtu.h:262
ABTI_CHECK_NULL_MUTEX_ATTR_PTR
#define ABTI_CHECK_NULL_MUTEX_ATTR_PTR(p)
Definition: abti_error.h:249
ABT_mutex_attr_free
int ABT_mutex_attr_free(ABT_mutex_attr *attr)
Free a mutex attribute.
Definition: mutex_attr.c:76
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:114
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:153
ABT_TRUE
#define ABT_TRUE
True constant for ABT_bool.
Definition: abt.h:748
ABT_FALSE
#define ABT_FALSE
False constant for ABT_bool.
Definition: abt.h:750
ABTI_MUTEX_ATTR_NONE
#define ABTI_MUTEX_ATTR_NONE
Definition: abti.h:101
ABTI_mutex_attr
Definition: abti.h:170
ABTU_free
static void ABTU_free(void *ptr)
Definition: abtu.h:217
ABT_MUTEX_ATTR_NULL
#define ABT_MUTEX_ATTR_NULL
Definition: abt.h:1067
ABT_mutex_attr_create
int ABT_mutex_attr_create(ABT_mutex_attr *newattr)
Create a new mutex attribute.
Definition: mutex_attr.c:39