1
+ use alloc:: { self , Layout } ;
1
2
use num:: NonZeroUsize ;
2
3
use slice;
3
4
use str;
@@ -147,6 +148,7 @@ impl RWLock {
147
148
self . __write_unlock ( rguard, wguard) ;
148
149
}
149
150
151
+ // only used by __rust_rwlock_unlock below
150
152
#[ inline]
151
153
unsafe fn unlock ( & self ) {
152
154
let rguard = self . readers . lock ( ) ;
@@ -164,6 +166,7 @@ impl RWLock {
164
166
165
167
const EINVAL : i32 = 22 ;
166
168
169
+ // used by libunwind port
167
170
#[ no_mangle]
168
171
pub unsafe extern "C" fn __rust_rwlock_rdlock ( p : * mut RWLock ) -> i32 {
169
172
if p. is_null ( ) {
@@ -190,6 +193,8 @@ pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RWLock) -> i32 {
190
193
return 0 ;
191
194
}
192
195
196
+ // the following functions are also used by the libunwind port. They're
197
+ // included here to make sure parallel codegen and LTO don't mess things up.
193
198
#[ no_mangle]
194
199
pub unsafe extern "C" fn __rust_print_err ( m : * mut u8 , s : i32 ) {
195
200
if s < 0 {
@@ -206,6 +211,16 @@ pub unsafe extern "C" fn __rust_abort() {
206
211
:: sys:: abort_internal ( ) ;
207
212
}
208
213
214
+ #[ no_mangle]
215
+ pub unsafe extern "C" fn __rust_c_alloc ( size : usize , align : usize ) -> * mut u8 {
216
+ alloc:: alloc ( Layout :: from_size_align_unchecked ( size, align) )
217
+ }
218
+
219
+ #[ no_mangle]
220
+ pub unsafe extern "C" fn __rust_c_dealloc ( ptr : * mut u8 , size : usize , align : usize ) {
221
+ alloc:: dealloc ( ptr, Layout :: from_size_align_unchecked ( size, align) )
222
+ }
223
+
209
224
#[ cfg( test) ]
210
225
mod tests {
211
226
0 commit comments