diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/dlmalloc | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/dlmalloc')
-rw-r--r-- | vendor/dlmalloc/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/dlmalloc/Cargo.toml | 16 | ||||
-rw-r--r-- | vendor/dlmalloc/src/lib.rs | 11 | ||||
-rw-r--r-- | vendor/dlmalloc/src/xous.rs | 117 |
4 files changed, 141 insertions, 5 deletions
diff --git a/vendor/dlmalloc/.cargo-checksum.json b/vendor/dlmalloc/.cargo-checksum.json index 2d92af155..738314a7e 100644 --- a/vendor/dlmalloc/.cargo-checksum.json +++ b/vendor/dlmalloc/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"8fb851b6256b2897689a27179da1683db869dc6625b7b0e02fba263c3c16a6b7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"e26786bd9af68f3065532fa85b68b8de12e0f6f455240d9a903ae947986aaa5f","build.rs":"1423186016b6fecf4dc2c3a7d506face8f644ec9c3dda035fe485d25a7e6a02d","src/dlmalloc.c":"103602c3fcbe200d5e257cdd7353d84bcc033d887bea3b245321319bf5401f47","src/dlmalloc.rs":"33111e31c78c43a0fffb618a84c0e9644f1bc830167ad25342529919ecc897ad","src/dummy.rs":"00dc39321426add094ab8efba58fb5f886726c06f032b8cb184b3d5fc71ad8ff","src/global.rs":"41a14b65509d87e4b010c3f06550bd3a1b3987e1d8703f6d915285558b4c1f43","src/lib.rs":"cb0e7add0947e2778a79a799554bd2e4765bf2a1bc6662c8cf3b5f1aecfb03ca","src/unix.rs":"9b062bc1f24ae99aa4ccbf621c020e4c3f626f70c3603e51a1fb834375b1bec4","src/wasm.rs":"ca080eab006215b4ec3d1550cb300cec02c62d3bde5e447f04dfdf74d3f87972","tests/global.rs":"6f3ca05b44fb60fd7967d2ca1d11338e177b0266d75454410b82ea704c246892","tests/smoke.rs":"e22bbf7c4d0e297428c5c58d117957e61c21f494d129e6e93f9490360631bc36"},"package":"a6fe28e0bf9357092740362502f5cc7955d8dc125ebda71dec72336c2e15c62e"}
\ No newline at end of file +{"files":{"Cargo.toml":"135ac1479ab9268c8f8912c0018ab1cd3dcb09e45ae598270a533f31d5d508cc","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"e26786bd9af68f3065532fa85b68b8de12e0f6f455240d9a903ae947986aaa5f","build.rs":"1423186016b6fecf4dc2c3a7d506face8f644ec9c3dda035fe485d25a7e6a02d","src/dlmalloc.c":"103602c3fcbe200d5e257cdd7353d84bcc033d887bea3b245321319bf5401f47","src/dlmalloc.rs":"33111e31c78c43a0fffb618a84c0e9644f1bc830167ad25342529919ecc897ad","src/dummy.rs":"00dc39321426add094ab8efba58fb5f886726c06f032b8cb184b3d5fc71ad8ff","src/global.rs":"41a14b65509d87e4b010c3f06550bd3a1b3987e1d8703f6d915285558b4c1f43","src/lib.rs":"2f99d593feaec2e0e618ae7446b72f6d599f7be6d077bd7a2c42f07bbeb1a00d","src/unix.rs":"9b062bc1f24ae99aa4ccbf621c020e4c3f626f70c3603e51a1fb834375b1bec4","src/wasm.rs":"ca080eab006215b4ec3d1550cb300cec02c62d3bde5e447f04dfdf74d3f87972","src/xous.rs":"aa3d4d546119d9abadf58efc2ea1877d93ae8b0a8277aeb7da52d4722936886a","tests/global.rs":"6f3ca05b44fb60fd7967d2ca1d11338e177b0266d75454410b82ea704c246892","tests/smoke.rs":"e22bbf7c4d0e297428c5c58d117957e61c21f494d129e6e93f9490360631bc36"},"package":"203540e710bfadb90e5e29930baf5d10270cec1f43ab34f46f78b147b2de715a"}
\ No newline at end of file diff --git a/vendor/dlmalloc/Cargo.toml b/vendor/dlmalloc/Cargo.toml index a8caf460d..19d4cae06 100644 --- a/vendor/dlmalloc/Cargo.toml +++ b/vendor/dlmalloc/Cargo.toml @@ -11,21 +11,26 @@ [package] name = "dlmalloc" -version = "0.2.3" +version = "0.2.4" authors = ["Alex Crichton <alex@alexcrichton.com>"] -description = "A Rust port of the dlmalloc allocator\n" +description = """ +A Rust port of the dlmalloc allocator +""" homepage = "https://github.com/alexcrichton/dlmalloc-rs" documentation = "https://docs.rs/dlmalloc" readme = "README.md" license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/dlmalloc-rs" + [package.metadata.docs.rs] features = ["global"] + [profile.release] debug-assertions = true [lib] doctest = false + [dependencies.compiler_builtins] version = "0.1.0" optional = true @@ -34,13 +39,18 @@ optional = true version = "1.0.0" optional = true package = "rustc-std-workspace-core" + [dev-dependencies.rand] version = "0.3" [features] debug = [] global = [] -rustc-dep-of-std = ["core", "compiler_builtins/rustc-dep-of-std"] +rustc-dep-of-std = [ + "core", + "compiler_builtins/rustc-dep-of-std", +] + [target."cfg(all(unix, not(target_arch = \"wasm32\")))".dependencies.libc] version = "0.2" default-features = false diff --git a/vendor/dlmalloc/src/lib.rs b/vendor/dlmalloc/src/lib.rs index 238386fbc..b972ccb73 100644 --- a/vendor/dlmalloc/src/lib.rs +++ b/vendor/dlmalloc/src/lib.rs @@ -81,7 +81,16 @@ mod sys; #[path = "unix.rs"] mod sys; -#[cfg(not(any(target_os = "linux", target_os = "macos", target_family = "wasm")))] +#[cfg(target_os = "xous")] +#[path = "xous.rs"] +mod sys; + +#[cfg(not(any( + target_os = "linux", + target_os = "macos", + target_os = "xous", + target_family = "wasm" +)))] #[path = "dummy.rs"] mod sys; diff --git a/vendor/dlmalloc/src/xous.rs b/vendor/dlmalloc/src/xous.rs new file mode 100644 index 000000000..96cb4e0d3 --- /dev/null +++ b/vendor/dlmalloc/src/xous.rs @@ -0,0 +1,117 @@ +use core::ptr; +use Allocator; + +pub struct System { + _priv: (), +} + +impl System { + pub const fn new() -> System { + System { _priv: () } + } +} + +#[cfg(target_arch = "riscv32")] +mod sys { + use core::arch::asm; + + pub fn increase_heap(length: usize) -> Result<(usize, usize), ()> { + let syscall_no_increase_heap = 10usize; + let memory_flags_read_write = 2usize | 4usize; + + let mut a0 = syscall_no_increase_heap; + let mut a1 = length; + let mut a2 = memory_flags_read_write; + + unsafe { + asm!( + "ecall", + inlateout("a0") a0, + inlateout("a1") a1, + inlateout("a2") a2, + out("a3") _, + out("a4") _, + out("a5") _, + out("a6") _, + out("a7") _, + ) + }; + + let result = a0; + let address = a1; + let length = a2; + + // 3 is the "MemoryRange" type, and the result is only valid + // if we get nonzero address and length. + if result == 3 && address != 0 && length != 0 { + Ok((address, length)) + } else { + Err(()) + } + } +} + +unsafe impl Allocator for System { + /// Allocate an additional `size` bytes on the heap, and return a new + /// chunk of memory, as well as the size of the allocation and some + /// flags. Since flags are unused on this platform, they will always + /// be `0`. + fn alloc(&self, size: usize) -> (*mut u8, usize, u32) { + let size = if size == 0 { + 4096 + } else if size & 4095 == 0 { + size + } else { + size + (4096 - (size & 4095)) + }; + + if let Ok((address, length)) = sys::increase_heap(size) { + let start = address - size + length; + (start as *mut u8, size, 0) + } else { + (ptr::null_mut(), 0, 0) + } + } + + fn remap(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize, _can_move: bool) -> *mut u8 { + // TODO + ptr::null_mut() + } + + fn free_part(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize) -> bool { + false + } + + fn free(&self, _ptr: *mut u8, _size: usize) -> bool { + false + } + + fn can_release_part(&self, _flags: u32) -> bool { + false + } + + fn allocates_zeros(&self) -> bool { + true + } + + fn page_size(&self) -> usize { + 4 * 1024 + } +} + +#[cfg(feature = "global")] +pub fn acquire_global_lock() { + // global feature should not be enabled + unimplemented!() +} + +#[cfg(feature = "global")] +pub fn release_global_lock() { + // global feature should not be enabled + unimplemented!() +} + +#[cfg(feature = "global")] +pub unsafe fn enable_alloc_after_fork() { + // platform does not support `fork()` call +} |