@@ -43,8 +43,7 @@ use libc::{c_int, c_void, size_t};
43
43
extern {
44
44
fn je_mallocx ( size : size_t , flags : c_int ) -> * mut c_void ;
45
45
fn je_rallocx ( ptr : * mut c_void , size : size_t , flags : c_int ) -> * mut c_void ;
46
- fn je_xallocx ( ptr : * mut c_void , size : size_t , extra : size_t ,
47
- flags : c_int ) -> size_t ;
46
+ fn je_xallocx ( ptr : * mut c_void , size : size_t , extra : size_t , flags : c_int ) -> size_t ;
48
47
fn je_sdallocx ( ptr : * mut c_void , size : size_t , flags : c_int ) ;
49
48
fn je_nallocx ( size : size_t , flags : c_int ) -> size_t ;
50
49
}
@@ -63,40 +62,52 @@ const MIN_ALIGN: usize = 8;
63
62
const MIN_ALIGN : usize = 16 ;
64
63
65
64
// MALLOCX_ALIGN(a) macro
66
- fn mallocx_align ( a : usize ) -> c_int { a. trailing_zeros ( ) as c_int }
65
+ fn mallocx_align ( a : usize ) -> c_int {
66
+ a. trailing_zeros ( ) as c_int
67
+ }
67
68
68
69
fn align_to_flags ( align : usize ) -> c_int {
69
- if align <= MIN_ALIGN { 0 } else { mallocx_align ( align) }
70
+ if align <= MIN_ALIGN {
71
+ 0
72
+ } else {
73
+ mallocx_align ( align)
74
+ }
70
75
}
71
76
72
77
#[ no_mangle]
73
- pub extern fn __rust_allocate ( size : usize , align : usize ) -> * mut u8 {
78
+ pub extern "C" fn __rust_allocate ( size : usize , align : usize ) -> * mut u8 {
74
79
let flags = align_to_flags ( align) ;
75
80
unsafe { je_mallocx ( size as size_t , flags) as * mut u8 }
76
81
}
77
82
78
83
#[ no_mangle]
79
- pub extern fn __rust_reallocate ( ptr : * mut u8 , _old_size : usize , size : usize ,
80
- align : usize ) -> * mut u8 {
84
+ pub extern "C" fn __rust_reallocate ( ptr : * mut u8 ,
85
+ _old_size : usize ,
86
+ size : usize ,
87
+ align : usize )
88
+ -> * mut u8 {
81
89
let flags = align_to_flags ( align) ;
82
90
unsafe { je_rallocx ( ptr as * mut c_void , size as size_t , flags) as * mut u8 }
83
91
}
84
92
85
93
#[ no_mangle]
86
- pub extern fn __rust_reallocate_inplace ( ptr : * mut u8 , _old_size : usize ,
87
- size : usize , align : usize ) -> usize {
94
+ pub extern "C" fn __rust_reallocate_inplace ( ptr : * mut u8 ,
95
+ _old_size : usize ,
96
+ size : usize ,
97
+ align : usize )
98
+ -> usize {
88
99
let flags = align_to_flags ( align) ;
89
100
unsafe { je_xallocx ( ptr as * mut c_void , size as size_t , 0 , flags) as usize }
90
101
}
91
102
92
103
#[ no_mangle]
93
- pub extern fn __rust_deallocate ( ptr : * mut u8 , old_size : usize , align : usize ) {
104
+ pub extern "C" fn __rust_deallocate ( ptr : * mut u8 , old_size : usize , align : usize ) {
94
105
let flags = align_to_flags ( align) ;
95
106
unsafe { je_sdallocx ( ptr as * mut c_void , old_size as size_t , flags) }
96
107
}
97
108
98
109
#[ no_mangle]
99
- pub extern fn __rust_usable_size ( size : usize , align : usize ) -> usize {
110
+ pub extern "C" fn __rust_usable_size ( size : usize , align : usize ) -> usize {
100
111
let flags = align_to_flags ( align) ;
101
112
unsafe { je_nallocx ( size as size_t , flags) as usize }
102
113
}
0 commit comments