scudo_sys/
lib.rs

1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14#![no_std]
15use libc::{c_ulong, c_void, size_t};
16
17type ChunkCallback = extern "C" fn(base: c_ulong, size: size_t, arg: *mut c_void);
18
19extern "C" {
20    pub static SCUDO_MIN_ALIGN: size_t;
21    /// Allocate memory with the global Scudo allocator.
22    pub fn scudo_allocate(size: size_t, align: size_t) -> *mut c_void;
23
24    /// Deallocate memory allocated by the global Scudo allocator.
25    pub fn scudo_deallocate(ptr: *mut c_void, size: size_t, align: size_t);
26
27    /// Iterate over all chunks iterated by the global Scudo allocator.
28    pub fn scudo_iterate(callback: ChunkCallback, arg: *mut c_void);
29
30    /// Locks the global Scudo allocator.
31    pub fn scudo_enable();
32
33    /// Unlocks the global Scudo allocator.
34    pub fn scudo_disable();
35
36    /// Prints allocation statistics from the global Scudo allocator.
37    pub fn scudo_print_stats();
38}