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;
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);
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;
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 }
uint32_t max_handovers
Definition: abti.h:157
#define ABT_MUTEX_ATTR_NULL
Definition: abt.h:420
struct ABT_mutex_attr_opaque * ABT_mutex_attr
Definition: abt.h:359
uint32_t max_wakeups
Definition: abti.h:158
uint32_t attrs
Definition: abti.h:154
uint32_t nesting_cnt
Definition: abti.h:155
int ABT_bool
Definition: abt.h:373
#define ABTI_CHECK_NULL_MUTEX_ATTR_PTR(p)
Definition: abti_error.h:245
static ABT_mutex_attr ABTI_mutex_attr_get_handle(ABTI_mutex_attr *p_attr)
uint32_t mutex_max_handovers
Definition: abti.h:188
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
Definition: abtu.h:142
ABTI_thread_id owner_id
Definition: abti.h:156
uint32_t mutex_max_wakeups
Definition: abti.h:189
#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
#define ABTI_CHECK_ERROR(abt_errno)
Definition: abti_error.h:86
static void ABTU_free(void *ptr)
Definition: abtu.h:135
static ABTI_mutex_attr * ABTI_mutex_attr_get_ptr(ABT_mutex_attr attr)