2 * Copyright 2007, Ryan Leavengood, leavengood@gmail.com.
3 * All rights reserved. Distributed under the terms of the MIT License.
8 #include "pthread_private.h"
14 pthread_condattr_init(pthread_condattr_t
*_condAttr
)
16 pthread_condattr
*attr
;
18 if (_condAttr
== NULL
)
21 attr
= (pthread_condattr
*)malloc(sizeof(pthread_condattr
));
25 attr
->process_shared
= false;
26 attr
->clock_id
= CLOCK_REALTIME
;
34 pthread_condattr_destroy(pthread_condattr_t
*_condAttr
)
36 pthread_condattr
*attr
;
38 if (_condAttr
== NULL
|| (attr
= *_condAttr
) == NULL
)
49 pthread_condattr_getpshared(const pthread_condattr_t
*_condAttr
, int *_processShared
)
51 pthread_condattr
*attr
;
53 if (_condAttr
== NULL
|| (attr
= *_condAttr
) == NULL
|| _processShared
== NULL
)
56 *_processShared
= attr
->process_shared
? PTHREAD_PROCESS_SHARED
: PTHREAD_PROCESS_PRIVATE
;
62 pthread_condattr_setpshared(pthread_condattr_t
*_condAttr
, int processShared
)
64 pthread_condattr
*attr
;
66 if (_condAttr
== NULL
|| (attr
= *_condAttr
) == NULL
67 || processShared
< PTHREAD_PROCESS_PRIVATE
68 || processShared
> PTHREAD_PROCESS_SHARED
)
71 attr
->process_shared
= processShared
== PTHREAD_PROCESS_SHARED
? true : false;
77 pthread_condattr_getclock(const pthread_condattr_t
*_condAttr
, clockid_t
*_clockID
)
79 pthread_condattr
*attr
;
81 if (_condAttr
== NULL
|| (attr
= *_condAttr
) == NULL
|| _clockID
== NULL
)
84 *_clockID
= attr
->clock_id
;
90 pthread_condattr_setclock(pthread_condattr_t
*_condAttr
, clockid_t clockID
)
92 pthread_condattr
*attr
;
94 if (_condAttr
== NULL
|| (attr
= *_condAttr
) == NULL
95 || (clockID
!= CLOCK_REALTIME
&& clockID
!= CLOCK_MONOTONIC
))
98 attr
->clock_id
= clockID
;