#![no_std]
#![allow(non_snake_case, non_camel_case_types)]
#![cfg_attr(
feature = "cargo-clippy",
allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)
)]
#![deny(missing_docs, intra_doc_link_resolution_failure)]
extern crate libc;
use libc::{c_char, c_int, c_uint, c_void, size_t};
type c_bool = c_int;
#[inline]
pub fn MALLOCX_LG_ALIGN(la: usize) -> c_int {
la as c_int
}
#[inline]
pub fn MALLOCX_ALIGN(aling: usize) -> c_int {
aling.trailing_zeros() as c_int
}
pub const MALLOCX_ZERO: c_int = 0x40;
#[inline]
pub fn MALLOCX_TCACHE(tc: usize) -> c_int {
tc.wrapping_add(2).wrapping_shl(8) as c_int
}
#[inline]
pub fn MALLOCX_TCACHE_NONE() -> c_int {
MALLOCX_TCACHE(!0)
}
#[inline]
pub fn MALLOCX_ARENA(a: usize) -> c_int {
(a as c_int).wrapping_add(1).wrapping_shl(20)
}
extern "C" {
#[cfg_attr(prefixed, link_name = "_rjem_malloc")]
pub fn malloc(size: size_t) -> *mut c_void;
#[cfg_attr(prefixed, link_name = "_rjem_calloc")]
pub fn calloc(number: size_t, size: size_t) -> *mut c_void;
#[cfg_attr(prefixed, link_name = "_rjem_posix_memalign")]
pub fn posix_memalign(ptr: *mut *mut c_void, alignment: size_t, size: size_t) -> c_int;
#[cfg_attr(prefixed, link_name = "_rjem_aligned_alloc")]
pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void;
#[cfg_attr(prefixed, link_name = "_rjem_realloc")]
pub fn realloc(ptr: *mut c_void, size: size_t) -> *mut c_void;
#[cfg_attr(prefixed, link_name = "_rjem_free")]
pub fn free(ptr: *mut c_void);
#[cfg_attr(prefixed, link_name = "_rjem_mallocx")]
pub fn mallocx(size: size_t, flags: c_int) -> *mut c_void;
#[cfg_attr(prefixed, link_name = "_rjem_rallocx")]
pub fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
#[cfg_attr(prefixed, link_name = "_rjem_xallocx")]
pub fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
#[cfg_attr(prefixed, link_name = "_rjem_sallocx")]
pub fn sallocx(ptr: *const c_void, flags: c_int) -> size_t;
#[cfg_attr(prefixed, link_name = "_rjem_dallocx")]
pub fn dallocx(ptr: *mut c_void, flags: c_int);
#[cfg_attr(prefixed, link_name = "_rjem_sdallocx")]
pub fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
#[cfg_attr(prefixed, link_name = "_rjem_nallocx")]
pub fn nallocx(size: size_t, flags: c_int) -> size_t;
#[cfg_attr(prefixed, link_name = "_rjem_malloc_usable_size")]
pub fn malloc_usable_size(ptr: *const c_void) -> size_t;
#[cfg_attr(prefixed, link_name = "_rjem_mallctl")]
pub fn mallctl(
name: *const c_char,
oldp: *mut c_void,
oldlenp: *mut size_t,
newp: *mut c_void,
newlen: size_t,
) -> c_int;
#[cfg_attr(prefixed, link_name = "_rjem_mallctlnametomib")]
pub fn mallctlnametomib(name: *const c_char, mibp: *mut size_t, miblenp: *mut size_t) -> c_int;
#[cfg_attr(prefixed, link_name = "_rjem_mallctlbymib")]
pub fn mallctlbymib(
mib: *const size_t,
miblen: size_t,
oldp: *mut c_void,
oldpenp: *mut size_t,
newp: *mut c_void,
newlen: size_t,
) -> c_int;
#[cfg_attr(prefixed, link_name = "_rjem_malloc_stats_print")]
pub fn malloc_stats_print(
write_cb: Option<unsafe extern "C" fn(*mut c_void, *const c_char)>,
cbopaque: *mut c_void,
opts: *const c_char,
);
#[cfg_attr(prefixed, link_name = "_rjem_malloc_message")]
pub static mut malloc_message:
Option<unsafe extern "C" fn(cbopaque: *mut c_void, s: *const c_char)>;
#[cfg_attr(prefixed, link_name = "_rjem_malloc_conf")]
pub static malloc_conf: Option<&'static c_char>;
}
pub type extent_hooks_t = extent_hooks_s;
#[repr(C)]
#[cfg(not(jemallocator_docs))]
#[derive(Copy, Clone, Default)]
#[doc(hidden)]
#[allow(missing_docs)]
pub struct extent_hooks_s {
pub alloc: Option<
unsafe extern "C" fn(
*mut extent_hooks_t,
*mut c_void,
size_t,
size_t,
*mut c_bool,
*mut c_bool,
c_uint,
) -> *mut c_void,
>,
pub dalloc: Option<
unsafe extern "C" fn(*mut extent_hooks_t, *mut c_void, size_t, c_bool, c_uint) -> c_bool,
>,
pub destroy:
Option<unsafe extern "C" fn(*mut extent_hooks_t, *mut c_void, size_t, c_bool, c_uint)>,
pub commit: Option<
unsafe extern "C" fn(
*mut extent_hooks_t,
*mut c_void,
size_t,
size_t,
size_t,
c_uint,
) -> c_bool,
>,
pub decommit: Option<
unsafe extern "C" fn(
*mut extent_hooks_t,
*mut c_void,
size_t,
size_t,
size_t,
c_uint,
) -> c_bool,
>,
pub purge_lazy: Option<
unsafe extern "C" fn(
*mut extent_hooks_t,
*mut c_void,
size_t,
size_t,
size_t,
c_uint,
) -> c_bool,
>,
pub purge_forced: Option<
unsafe extern "C" fn(
*mut extent_hooks_t,
*mut c_void,
size_t,
size_t,
size_t,
c_uint,
) -> c_bool,
>,
pub split: Option<
unsafe extern "C" fn(
*mut extent_hooks_t,
*mut c_void,
size_t,
size_t,
size_t,
c_bool,
c_uint,
) -> c_bool,
>,
pub merge: Option<
unsafe extern "C" fn(
*mut extent_hooks_t,
*mut c_void,
size_t,
*mut c_void,
size_t,
c_bool,
c_uint,
) -> c_bool,
>,
}
#[repr(C)]
#[cfg(jemallocator_docs)]
#[derive(Copy, Clone, Default)]
pub struct extent_hooks_s {
#[allow(missing_docs)]
pub alloc: Option<extent_alloc_t>,
#[allow(missing_docs)]
pub dalloc: Option<extent_dalloc_t>,
#[allow(missing_docs)]
pub destroy: Option<extent_destroy_t>,
#[allow(missing_docs)]
pub commit: Option<extent_commit_t>,
#[allow(missing_docs)]
pub decommit: Option<extent_decommit_t>,
#[allow(missing_docs)]
pub purge_lazy: Option<extent_purge_t>,
#[allow(missing_docs)]
pub purge_forced: Option<extent_purge_t>,
#[allow(missing_docs)]
pub split: Option<extent_split_t>,
#[allow(missing_docs)]
pub merge: Option<extent_merge_t>,
}
pub type extent_alloc_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
new_addr: *mut c_void,
size: size_t,
alignment: size_t,
zero: *mut c_bool,
commit: *mut c_bool,
arena_ind: c_uint,
) -> *mut c_void;
pub type extent_dalloc_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
addr: *mut c_void,
size: size_t,
committed: c_bool,
arena_ind: c_uint,
) -> c_bool;
pub type extent_destroy_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
addr: *mut c_void,
size: size_t,
committed: c_bool,
arena_ind: c_uint,
);
pub type extent_commit_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
addr: *mut c_void,
size: size_t,
offset: size_t,
length: size_t,
arena_ind: c_uint,
) -> c_bool;
pub type extent_decommit_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
addr: *mut c_void,
size: size_t,
offset: size_t,
length: size_t,
arena_ind: c_uint,
) -> c_bool;
pub type extent_purge_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
addr: *mut c_void,
size: size_t,
offset: size_t,
length: size_t,
arena_ind: c_uint,
) -> c_bool;
pub type extent_split_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
addr: *mut c_void,
size: size_t,
size_a: size_t,
size_b: size_t,
committed: c_bool,
arena_ind: c_uint,
) -> c_bool;
pub type extent_merge_t = unsafe extern "C" fn(
extent_hooks: *mut extent_hooks_t,
addr_a: *mut c_void,
size_a: size_t,
addr_b: *mut c_void,
size_b: size_t,
committed: c_bool,
arena_ind: c_uint,
) -> c_bool;
#[no_mangle]
#[cfg(target_os = "android")]
#[doc(hidden)]
pub extern "C" fn pthread_atfork(
_prefork: *mut u8,
_postfork_parent: *mut u8,
_postfork_child: *mut u8,
) -> i32 {
0
}