File tree 5 files changed +47
-261
lines changed
5 files changed +47
-261
lines changed Original file line number Diff line number Diff line change
1
+ //! The functions in this module are needed by libunwind. These symbols are named
2
+ //! in pre-link args for the target specification, so keep that in sync.
3
+
4
+ #![ cfg( not( test) ) ]
5
+
6
+ use crate :: sys:: sync:: RwLock ;
7
+
8
+ // Verify that the byte pattern libunwind uses to initialize an RwLock is
9
+ // equivalent to the value of RwLock::new(). If the value changes,
10
+ // `src/UnwindRustSgx.h` in libunwind needs to be changed too.
11
+ const _: ( ) = unsafe {
12
+ let bits_rust: usize = crate :: mem:: transmute ( RwLock :: new ( ) ) ;
13
+ assert ! ( bits_rust == 0 ) ;
14
+ } ;
15
+
16
+ const EINVAL : i32 = 22 ;
17
+
18
+ #[ no_mangle]
19
+ pub unsafe extern "C" fn __rust_rwlock_rdlock ( p : * mut RwLock ) -> i32 {
20
+ if p. is_null ( ) {
21
+ return EINVAL ;
22
+ }
23
+
24
+ // We cannot differentiate between reads an writes in unlock and therefore
25
+ // always use a write-lock. Unwinding isn't really in the hot path anyway.
26
+ unsafe { ( * p) . write ( ) } ;
27
+ return 0 ;
28
+ }
29
+
30
+ #[ no_mangle]
31
+ pub unsafe extern "C" fn __rust_rwlock_wrlock ( p : * mut RwLock ) -> i32 {
32
+ if p. is_null ( ) {
33
+ return EINVAL ;
34
+ }
35
+ unsafe { ( * p) . write ( ) } ;
36
+ return 0 ;
37
+ }
38
+
39
+ #[ no_mangle]
40
+ pub unsafe extern "C" fn __rust_rwlock_unlock ( p : * mut RwLock ) -> i32 {
41
+ if p. is_null ( ) {
42
+ return EINVAL ;
43
+ }
44
+ unsafe { ( * p) . write_unlock ( ) } ;
45
+ return 0 ;
46
+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub mod fd;
17
17
pub mod fs;
18
18
#[ path = "../unsupported/io.rs" ]
19
19
pub mod io;
20
+ mod libunwind_integration;
20
21
pub mod net;
21
22
pub mod os;
22
23
#[ path = "../unsupported/pipe.rs" ]
Original file line number Diff line number Diff line change @@ -52,10 +52,6 @@ impl<T> WaitVariable<T> {
52
52
WaitVariable { queue : WaitQueue :: new ( ) , lock : var }
53
53
}
54
54
55
- pub fn queue_empty ( & self ) -> bool {
56
- self . queue . is_empty ( )
57
- }
58
-
59
55
pub fn lock_var ( & self ) -> & T {
60
56
& self . lock
61
57
}
@@ -98,19 +94,6 @@ impl Default for WaitQueue {
98
94
}
99
95
}
100
96
101
- impl < ' a , T > WaitGuard < ' a , T > {
102
- /// Returns which TCSes will be notified when this guard drops.
103
- pub fn notified_tcs ( & self ) -> NotifiedTcs {
104
- self . notified_tcs
105
- }
106
-
107
- /// Drop this `WaitGuard`, after dropping another `guard`.
108
- pub fn drop_after < U > ( self , guard : U ) {
109
- drop ( guard) ;
110
- drop ( self ) ;
111
- }
112
- }
113
-
114
97
impl < ' a , T > Deref for WaitGuard < ' a , T > {
115
98
type Target = SpinMutexGuard < ' a , WaitVariable < T > > ;
116
99
@@ -141,10 +124,6 @@ impl WaitQueue {
141
124
WaitQueue { inner : UnsafeList :: new ( ) }
142
125
}
143
126
144
- pub fn is_empty ( & self ) -> bool {
145
- self . inner . is_empty ( )
146
- }
147
-
148
127
/// Adds the calling thread to the `WaitVariable`'s wait queue, then wait
149
128
/// until a wakeup event.
150
129
///
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments