ARGOBOTS  1227c643f7a7f974f1f1778a9ffebd29d7dafecf
 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  int abt_errno = ABT_SUCCESS;
29  ABTI_mutex_attr *p_newattr;
30 
31  abt_errno = ABTU_malloc(sizeof(ABTI_mutex_attr), (void **)&p_newattr);
32  ABTI_CHECK_ERROR(abt_errno);
33 
34  /* Default values */
35  p_newattr->attrs = ABTI_MUTEX_ATTR_NONE;
36  p_newattr->nesting_cnt = 0;
37  p_newattr->owner_id = 0;
38  p_newattr->max_handovers = gp_ABTI_global->mutex_max_handovers;
39  p_newattr->max_wakeups = gp_ABTI_global->mutex_max_wakeups;
40 
41  /* Return value */
42  *newattr = ABTI_mutex_attr_get_handle(p_newattr);
43 
44 fn_exit:
45  return abt_errno;
46 
47 fn_fail:
48  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
49  goto fn_exit;
50 }
51 
65 {
66  int abt_errno = ABT_SUCCESS;
67  ABT_mutex_attr h_attr = *attr;
68  ABTI_mutex_attr *p_attr = ABTI_mutex_attr_get_ptr(h_attr);
69  ABTI_CHECK_NULL_MUTEX_ATTR_PTR(p_attr);
70 
71  /* Free the memory */
72  ABTU_free(p_attr);
73 
74  /* Return value */
75  *attr = ABT_MUTEX_ATTR_NULL;
76 
77 fn_exit:
78  return abt_errno;
79 
80 fn_fail:
81  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
82  goto fn_exit;
83 }
84 
99 {
100  int abt_errno = ABT_SUCCESS;
101  ABTI_mutex_attr *p_attr = ABTI_mutex_attr_get_ptr(attr);
102  ABTI_CHECK_NULL_MUTEX_ATTR_PTR(p_attr);
103 
104  /* Set the value */
105  if (recursive == ABT_TRUE) {
106  p_attr->attrs |= ABTI_MUTEX_ATTR_RECURSIVE;
107  } else {
108  p_attr->attrs &= ~ABTI_MUTEX_ATTR_RECURSIVE;
109  }
110 
111 fn_exit:
112  return abt_errno;
113 
114 fn_fail:
115  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
116  goto fn_exit;
117 }
#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:142
#define HANDLE_ERROR_FUNC_WITH_CODE(n)
Definition: abti_error.h:353
ABTI_global * gp_ABTI_global
Definition: global.c:14
#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:98
int ABT_mutex_attr_free(ABT_mutex_attr *attr) ABT_API_PUBLIC
Free the mutex attribute object.
Definition: mutex_attr.c:64
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:135