ARGOBOTS  c6511494322293e01714f56f341b8d2b22c1e3c1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 
27 {
28  ABTI_mutex_attr *p_newattr;
29 
30  int abt_errno = ABTU_malloc(sizeof(ABTI_mutex_attr), (void **)&p_newattr);
31  ABTI_CHECK_ERROR(abt_errno);
32 
33  /* Default values */
34  p_newattr->attrs = ABTI_MUTEX_ATTR_NONE;
35  p_newattr->nesting_cnt = 0;
36  p_newattr->owner_id = 0;
37  p_newattr->max_handovers = gp_ABTI_global->mutex_max_handovers;
38  p_newattr->max_wakeups = gp_ABTI_global->mutex_max_wakeups;
39 
40  /* Return value */
41  *newattr = ABTI_mutex_attr_get_handle(p_newattr);
42  return ABT_SUCCESS;
43 }
44 
58 {
59  ABT_mutex_attr h_attr = *attr;
60  ABTI_mutex_attr *p_attr = ABTI_mutex_attr_get_ptr(h_attr);
61  ABTI_CHECK_NULL_MUTEX_ATTR_PTR(p_attr);
62 
63  /* Free the memory */
64  ABTU_free(p_attr);
65  /* Return value */
66  *attr = ABT_MUTEX_ATTR_NULL;
67  return ABT_SUCCESS;
68 }
69 
84 {
85  ABTI_mutex_attr *p_attr = ABTI_mutex_attr_get_ptr(attr);
86  ABTI_CHECK_NULL_MUTEX_ATTR_PTR(p_attr);
87 
88  /* Set the value */
89  if (recursive == ABT_TRUE) {
90  p_attr->attrs |= ABTI_MUTEX_ATTR_RECURSIVE;
91  } else {
92  p_attr->attrs &= ~ABTI_MUTEX_ATTR_RECURSIVE;
93  }
94  return ABT_SUCCESS;
95 }
#define ABT_MUTEX_ATTR_NULL
Definition: abt.h:420
struct ABT_mutex_attr_opaque * ABT_mutex_attr
Definition: abt.h:359
int ABT_bool
Definition: abt.h:373
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
Definition: abtu.h:129
ABTI_global * gp_ABTI_global
Definition: global.c:18
#define ABT_SUCCESS
Definition: abt.h:64
#define ABT_TRUE
Definition: abt.h:284
int ABT_mutex_attr_set_recursive(ABT_mutex_attr attr, ABT_bool recursive) ABT_API_PUBLIC
Set the recursive property in the attribute object.
Definition: mutex_attr.c:83
int ABT_mutex_attr_free(ABT_mutex_attr *attr) ABT_API_PUBLIC
Free the mutex attribute object.
Definition: mutex_attr.c:57
int ABT_mutex_attr_create(ABT_mutex_attr *newattr) ABT_API_PUBLIC
Create a new mutex attribute object.
Definition: mutex_attr.c:26
static void ABTU_free(void *ptr)
Definition: abtu.h:122