File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -76,8 +76,20 @@ impl Condvar {
7676 }
7777
7878 #[ inline]
79+ #[ cfg( not( target_os = "dragonfly" ) ) ]
7980 pub unsafe fn destroy ( & self ) {
8081 let r = ffi:: pthread_cond_destroy ( self . inner . get ( ) ) ;
8182 debug_assert_eq ! ( r, 0 ) ;
8283 }
84+
85+ #[ inline]
86+ #[ cfg( target_os = "dragonfly" ) ]
87+ pub unsafe fn destroy ( & self ) {
88+ let r = ffi:: pthread_cond_destroy ( self . inner . get ( ) ) ;
89+ // On DragonFly pthread_cond_destroy() returns EINVAL if called on
90+ // a condvar that was just initialized with
91+ // ffi::PTHREAD_COND_INITIALIZER. Once it is used or
92+ // pthread_cond_init() is called, this behaviour no longer occurs.
93+ debug_assert ! ( r == 0 || r == libc:: EINVAL ) ;
94+ }
8395}
Original file line number Diff line number Diff line change @@ -48,8 +48,20 @@ impl Mutex {
4848 ffi:: pthread_mutex_trylock ( self . inner . get ( ) ) == 0
4949 }
5050 #[ inline]
51+ #[ cfg( not( target_os = "dragonfly" ) ) ]
5152 pub unsafe fn destroy ( & self ) {
5253 let r = ffi:: pthread_mutex_destroy ( self . inner . get ( ) ) ;
5354 debug_assert_eq ! ( r, 0 ) ;
5455 }
56+ #[ inline]
57+ #[ cfg( target_os = "dragonfly" ) ]
58+ pub unsafe fn destroy ( & self ) {
59+ use libc;
60+ let r = ffi:: pthread_mutex_destroy ( self . inner . get ( ) ) ;
61+ // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a
62+ // mutex that was just initialized with ffi::PTHREAD_MUTEX_INITIALIZER.
63+ // Once it is used (locked/unlocked) or pthread_mutex_init() is called,
64+ // this behaviour no longer occurs.
65+ debug_assert ! ( r == 0 || r == libc:: EINVAL ) ;
66+ }
5567}
Original file line number Diff line number Diff line change @@ -50,8 +50,21 @@ impl RWLock {
5050 #[ inline]
5151 pub unsafe fn write_unlock ( & self ) { self . read_unlock ( ) }
5252 #[ inline]
53+ #[ cfg( not( target_os = "dragonfly" ) ) ]
5354 pub unsafe fn destroy ( & self ) {
5455 let r = ffi:: pthread_rwlock_destroy ( self . inner . get ( ) ) ;
5556 debug_assert_eq ! ( r, 0 ) ;
5657 }
58+
59+ #[ inline]
60+ #[ cfg( target_os = "dragonfly" ) ]
61+ pub unsafe fn destroy ( & self ) {
62+ use libc;
63+ let r = ffi:: pthread_rwlock_destroy ( self . inner . get ( ) ) ;
64+ // On DragonFly pthread_rwlock_destroy() returns EINVAL if called on a
65+ // rwlock that was just initialized with
66+ // ffi::PTHREAD_RWLOCK_INITIALIZER. Once it is used (locked/unlocked)
67+ // or pthread_rwlock_init() is called, this behaviour no longer occurs.
68+ debug_assert ! ( r == 0 || r == libc:: EINVAL ) ;
69+ }
5770}
You can’t perform that action at this time.
0 commit comments