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(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(pthread_mutexattr_t
*_mutexAttr
, int *_processShared
)
79 pthread_mutexattr
*attr
;
81 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
|| _processShared
== NULL
)
84 *_processShared
= attr
->process_shared
? PTHREAD_PROCESS_SHARED
: PTHREAD_PROCESS_PRIVATE
;
90 pthread_mutexattr_setpshared(pthread_mutexattr_t
*_mutexAttr
, int processShared
)
92 pthread_mutexattr
*attr
;
94 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
95 || processShared
< PTHREAD_PROCESS_PRIVATE
96 || processShared
> PTHREAD_PROCESS_SHARED
)
99 attr
->process_shared
= processShared
== PTHREAD_PROCESS_SHARED
? true : false;
105 pthread_mutexattr_getprioceiling(pthread_mutexattr_t
*_mutexAttr
, int *_priorityCeiling
)
107 pthread_mutexattr
*attr
;
109 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
|| _priorityCeiling
== NULL
)
112 *_priorityCeiling
= 0;
120 pthread_mutexattr_setprioceiling(pthread_mutexattr_t
*_mutexAttr
, int priorityCeiling
)
122 pthread_mutexattr
*attr
;
124 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
)
128 return B_NOT_ALLOWED
;
133 pthread_mutexattr_getprotocol(pthread_mutexattr_t
*_mutexAttr
, int *_protocol
)
135 pthread_mutexattr
*attr
;
137 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
|| _protocol
== NULL
)
148 pthread_mutexattr_setprotocol(pthread_mutexattr_t
*_mutexAttr
, int protocol
)
150 pthread_mutexattr
*attr
;
152 if (_mutexAttr
== NULL
|| (attr
= *_mutexAttr
) == NULL
)
156 return B_NOT_ALLOWED
;