2 * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
8 #include "pthread_private.h"
14 pthread_mutexattr_init(pthread_mutexattr_t
*_mutexAttr
)
16 pthread_mutexattr
*attr
;
18 if (_mutexAttr
== NULL
)
21 attr
= (pthread_mutexattr
*)malloc(sizeof(pthread_mutexattr
));
25 attr
->type
= PTHREAD_MUTEX_DEFAULT
;
26 attr
->process_shared
= false;
34 pthread_mutexattr_destroy(pthread_mutexattr_t
*_mutexAttr
)
36 pthread_mutexattr
*attr
;
38 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
)
49 pthread_mutexattr_gettype(const pthread_mutexattr_t
*_mutexAttr
, int *_type
)
51 pthread_mutexattr
*attr
;
53 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
|| _type
== NULL
)
62 pthread_mutexattr_settype(pthread_mutexattr_t
*_mutexAttr
, int type
)
64 pthread_mutexattr
*attr
;
66 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
67 || type
< PTHREAD_MUTEX_DEFAULT
68 || type
> PTHREAD_MUTEX_RECURSIVE
)
77 pthread_mutexattr_getpshared(const pthread_mutexattr_t
*_mutexAttr
,
80 pthread_mutexattr
*attr
;
82 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
83 || _processShared
== NULL
) {
87 *_processShared
= attr
->process_shared
? PTHREAD_PROCESS_SHARED
88 : PTHREAD_PROCESS_PRIVATE
;
94 pthread_mutexattr_setpshared(pthread_mutexattr_t
*_mutexAttr
,
97 pthread_mutexattr
*attr
;
99 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
100 || processShared
< PTHREAD_PROCESS_PRIVATE
101 || processShared
> PTHREAD_PROCESS_SHARED
) {
105 attr
->process_shared
= processShared
== PTHREAD_PROCESS_SHARED
;
111 pthread_mutexattr_getprioceiling(const pthread_mutexattr_t
*_mutexAttr
,
112 int *_priorityCeiling
)
114 pthread_mutexattr
*attr
;
116 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
117 || _priorityCeiling
== NULL
) {
121 *_priorityCeiling
= 0;
129 pthread_mutexattr_setprioceiling(pthread_mutexattr_t
*_mutexAttr
,
132 pthread_mutexattr
*attr
;
134 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
)
138 return B_NOT_ALLOWED
;
143 pthread_mutexattr_getprotocol(const pthread_mutexattr_t
*_mutexAttr
,
146 pthread_mutexattr
*attr
;
148 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
149 || _protocol
== NULL
) {
161 pthread_mutexattr_setprotocol(pthread_mutexattr_t
*_mutexAttr
, int protocol
)
163 pthread_mutexattr
*attr
;
165 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
)
169 return B_NOT_ALLOWED
;