File tree 3 files changed +37
-0
lines changed
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -76,8 +76,20 @@ impl Condvar {
76
76
}
77
77
78
78
#[ inline]
79
+ #[ cfg( not( target_os = "dragonfly" ) ) ]
79
80
pub unsafe fn destroy ( & self ) {
80
81
let r = ffi:: pthread_cond_destroy ( self . inner . get ( ) ) ;
81
82
debug_assert_eq ! ( r, 0 ) ;
82
83
}
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
+ }
83
95
}
Original file line number Diff line number Diff line change @@ -48,8 +48,20 @@ impl Mutex {
48
48
ffi:: pthread_mutex_trylock ( self . inner . get ( ) ) == 0
49
49
}
50
50
#[ inline]
51
+ #[ cfg( not( target_os = "dragonfly" ) ) ]
51
52
pub unsafe fn destroy ( & self ) {
52
53
let r = ffi:: pthread_mutex_destroy ( self . inner . get ( ) ) ;
53
54
debug_assert_eq ! ( r, 0 ) ;
54
55
}
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
+ }
55
67
}
Original file line number Diff line number Diff line change @@ -50,8 +50,21 @@ impl RWLock {
50
50
#[ inline]
51
51
pub unsafe fn write_unlock ( & self ) { self . read_unlock ( ) }
52
52
#[ inline]
53
+ #[ cfg( not( target_os = "dragonfly" ) ) ]
53
54
pub unsafe fn destroy ( & self ) {
54
55
let r = ffi:: pthread_rwlock_destroy ( self . inner . get ( ) ) ;
55
56
debug_assert_eq ! ( r, 0 ) ;
56
57
}
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
+ }
57
70
}
You can’t perform that action at this time.
0 commit comments