@@ -19,6 +19,7 @@ fn main() {
1919 check_rwlock_write ( ) ;
2020 check_rwlock_read_no_deadlock ( ) ;
2121 check_cond ( ) ;
22+ check_condattr ( ) ;
2223}
2324
2425fn test_mutex_libc_init_recursive ( ) {
@@ -261,6 +262,31 @@ fn check_cond() {
261262 }
262263}
263264
265+ fn check_condattr ( ) {
266+ unsafe {
267+ // Just smoke-testing that these functions can be called.
268+ let mut attr: MaybeUninit < libc:: pthread_condattr_t > = MaybeUninit :: uninit ( ) ;
269+ assert_eq ! ( libc:: pthread_condattr_init( attr. as_mut_ptr( ) ) , 0 ) ;
270+
271+ #[ cfg( not( target_os = "macos" ) ) ] // setclock-getclock do not exist on macOS
272+ {
273+ let clock_id = libc:: CLOCK_MONOTONIC ;
274+ assert_eq ! ( libc:: pthread_condattr_setclock( attr. as_mut_ptr( ) , clock_id) , 0 ) ;
275+ let mut check_clock_id = MaybeUninit :: < libc:: clockid_t > :: uninit ( ) ;
276+ assert_eq ! (
277+ libc:: pthread_condattr_getclock( attr. as_mut_ptr( ) , check_clock_id. as_mut_ptr( ) ) ,
278+ 0
279+ ) ;
280+ assert_eq ! ( check_clock_id. assume_init( ) , clock_id) ;
281+ }
282+
283+ let mut cond: MaybeUninit < libc:: pthread_cond_t > = MaybeUninit :: uninit ( ) ;
284+ assert_eq ! ( libc:: pthread_cond_init( cond. as_mut_ptr( ) , attr. as_ptr( ) ) , 0 ) ;
285+ assert_eq ! ( libc:: pthread_condattr_destroy( attr. as_mut_ptr( ) ) , 0 ) ;
286+ assert_eq ! ( libc:: pthread_cond_destroy( cond. as_mut_ptr( ) ) , 0 ) ;
287+ }
288+ }
289+
264290// std::sync::RwLock does not even used pthread_rwlock any more.
265291// Do some smoke testing of the API surface.
266292fn test_rwlock_libc_static_initializer ( ) {
0 commit comments