1+ use alloc:: { self , Layout } ;
12use num:: NonZeroUsize ;
23use slice;
34use str;
@@ -147,6 +148,7 @@ impl RWLock {
147148 self . __write_unlock ( rguard, wguard) ;
148149 }
149150
151+ // only used by __rust_rwlock_unlock below
150152 #[ inline]
151153 unsafe fn unlock ( & self ) {
152154 let rguard = self . readers . lock ( ) ;
@@ -164,6 +166,7 @@ impl RWLock {
164166
165167const EINVAL : i32 = 22 ;
166168
169+ // used by libunwind port
167170#[ no_mangle]
168171pub unsafe extern "C" fn __rust_rwlock_rdlock ( p : * mut RWLock ) -> i32 {
169172 if p. is_null ( ) {
@@ -190,6 +193,8 @@ pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RWLock) -> i32 {
190193 return 0 ;
191194}
192195
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.
193198#[ no_mangle]
194199pub unsafe extern "C" fn __rust_print_err ( m : * mut u8 , s : i32 ) {
195200 if s < 0 {
@@ -206,6 +211,16 @@ pub unsafe extern "C" fn __rust_abort() {
206211 :: sys:: abort_internal ( ) ;
207212}
208213
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+
209224#[ cfg( test) ]
210225mod tests {
211226
0 commit comments