3636// https://github.com/rust-lang/rust/commit/b90cfc887c31c3e7a9e6d462e2464db1fe506175#diff-43914724af6e464c1da2171e4a9b6c7e607d5bc1203fa95c0ab85be4122605ef
3737// for an example of how to do so.
3838
39+ use std:: os:: raw:: { c_int, c_void} ;
40+
41+ #[ no_mangle]
42+ unsafe extern "C" fn calloc ( items : usize , size : usize ) -> * mut c_void {
43+ fjall:: c:: calloc ( items, size)
44+ }
45+
46+ #[ no_mangle]
47+ unsafe extern "C" fn posix_memalign ( ptr : * mut * mut c_void , size : usize , align : usize ) -> c_int {
48+ fjall:: c:: posix_memalign ( ptr, size, align)
49+ }
50+
51+ #[ no_mangle]
52+ unsafe extern "C" fn aligned_alloc ( size : usize , align : usize ) -> * mut c_void {
53+ fjall:: c:: aligned_alloc ( size, align)
54+ }
55+
56+ #[ no_mangle]
57+ unsafe extern "C" fn malloc ( size : usize ) -> * mut c_void {
58+ fjall:: c:: malloc ( size)
59+ }
60+
61+ #[ no_mangle]
62+ unsafe extern "C" fn realloc ( ptr : * mut c_void , size : usize ) -> * mut c_void {
63+ fjall:: c:: realloc ( ptr, size)
64+ }
65+
66+ #[ no_mangle]
67+ unsafe extern "C" fn free ( ptr : * mut c_void ) {
68+ fjall:: c:: free ( ptr) ;
69+ }
70+
3971#[ unix_sigpipe = "sig_dfl" ]
4072fn main ( ) {
4173 // See the comment at the top of this file for an explanation of this.
42- #[ cfg( feature = "jemalloc-sys" ) ]
4374 {
44- use std:: os:: raw:: { c_int, c_void} ;
45-
4675 #[ used]
47- static _F1: unsafe extern "C" fn ( usize , usize ) -> * mut c_void = jemalloc_sys :: calloc;
76+ static _F1: unsafe extern "C" fn ( usize , usize ) -> * mut c_void = calloc;
4877 #[ used]
49- static _F2: unsafe extern "C" fn ( * mut * mut c_void , usize , usize ) -> c_int =
50- jemalloc_sys:: posix_memalign;
78+ static _F2: unsafe extern "C" fn ( * mut * mut c_void , usize , usize ) -> c_int = posix_memalign;
5179 #[ used]
52- static _F3: unsafe extern "C" fn ( usize , usize ) -> * mut c_void = jemalloc_sys :: aligned_alloc;
80+ static _F3: unsafe extern "C" fn ( usize , usize ) -> * mut c_void = aligned_alloc;
5381 #[ used]
54- static _F4: unsafe extern "C" fn ( usize ) -> * mut c_void = jemalloc_sys :: malloc;
82+ static _F4: unsafe extern "C" fn ( usize ) -> * mut c_void = malloc;
5583 #[ used]
56- static _F5: unsafe extern "C" fn ( * mut c_void , usize ) -> * mut c_void = jemalloc_sys :: realloc;
84+ static _F5: unsafe extern "C" fn ( * mut c_void , usize ) -> * mut c_void = realloc;
5785 #[ used]
58- static _F6: unsafe extern "C" fn ( * mut c_void ) = jemalloc_sys :: free;
59-
86+ static _F6: unsafe extern "C" fn ( * mut c_void ) = free;
87+ /*
6088 // On OSX, jemalloc doesn't directly override malloc/free, but instead
6189 // registers itself with the allocator's zone APIs in a ctor. However,
6290 // the linker doesn't seem to consider ctors as "used" when statically
@@ -69,7 +97,7 @@ fn main() {
6997
7098 #[used]
7199 static _F7: unsafe extern "C" fn() = _rjem_je_zone_register;
72- }
100+ }*/
73101 }
74102
75103 rustc_driver:: main ( )
0 commit comments