From 47b640181c108ecdbf0acc7b36e42e891eb5a77e Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Sun, 17 May 2026 22:19:54 +0300 Subject: [PATCH 1/4] feat: add android support --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b225349..55ebf35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,7 +48,7 @@ mod sys; #[path = "macos.rs"] mod sys; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "android"))] #[path = "linux.rs"] mod sys; From 96b0545c7c48ed138e8583533fc7d5acc2a2ecba Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Sun, 24 May 2026 20:27:51 +0300 Subject: [PATCH 2/4] fix build --- Cargo.toml | 1 + build.rs | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index e67d179..736e9fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "gear-dlmalloc" version = "0.2.0" +edition = "2015" authors = ["Alex Crichton ", "Gear Technologies"] license = "MIT/Apache-2.0" readme = "README.md" diff --git a/build.rs b/build.rs deleted file mode 100644 index 20aaa4f..0000000 --- a/build.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - #[cfg(feature = "debug")] - println!("cargo:rustc-cfg=debug_assertions"); -} From ab0574bf1f1e11360ee6644cf1ce24ee25adac79 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Sun, 24 May 2026 20:51:13 +0300 Subject: [PATCH 3/4] bump edition to 2021 --- Cargo.toml | 6 +++++- src/dlmalloc.rs | 2 +- src/dlverbose.rs | 8 ++++---- src/global.rs | 12 ++++++------ src/linux.rs | 4 ++-- tests/global.rs | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 736e9fe..eb79627 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gear-dlmalloc" version = "0.2.0" -edition = "2015" +edition = "2021" authors = ["Alex Crichton ", "Gear Technologies"] license = "MIT/Apache-2.0" readme = "README.md" @@ -51,3 +51,7 @@ debug = [] # Verbose allocator work actions verbose = [] + +# See `tests/smoke.rs` for more information on this feature +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(test_lots)'] } diff --git a/src/dlmalloc.rs b/src/dlmalloc.rs index 97b86bc..60ccf5b 100644 --- a/src/dlmalloc.rs +++ b/src/dlmalloc.rs @@ -15,8 +15,8 @@ use crate::common::{align_down, align_up}; use crate::dlassert; use crate::dlverbose; use crate::dlverbose_no_flush; +use crate::sys; use dlverbose::{DL_CHECKS, DL_DEBUG, DL_VERBOSE, VERBOSE_DEL}; -use sys; extern crate static_assertions; diff --git a/src/dlverbose.rs b/src/dlverbose.rs index 56c0060..98c7c29 100644 --- a/src/dlverbose.rs +++ b/src/dlverbose.rs @@ -42,9 +42,9 @@ static mut OUT_BUFFER: StaticStr = StaticStr::new(); #[inline(never)] pub fn dlprint_fn(args: Arguments<'_>) { unsafe { - core::fmt::write(&mut OUT_BUFFER, args).unwrap(); - ext::debug(&OUT_BUFFER, OUT_BUFFER.len()); - OUT_BUFFER.set_len(0); + core::fmt::write(&mut *&raw mut OUT_BUFFER, args).unwrap(); + ext::debug(&*&raw const OUT_BUFFER, (&*&raw const OUT_BUFFER).len()); + (&mut *&raw mut OUT_BUFFER).set_len(0); } } @@ -53,7 +53,7 @@ pub fn dlprint_fn(args: Arguments<'_>) { #[inline(never)] pub fn dlwrite_fn(args: Arguments<'_>) { unsafe { - core::fmt::write(&mut OUT_BUFFER, args).unwrap(); + core::fmt::write(&mut *&raw mut OUT_BUFFER, args).unwrap(); } } diff --git a/src/global.rs b/src/global.rs index ff7011f..c9d78ce 100644 --- a/src/global.rs +++ b/src/global.rs @@ -1,7 +1,7 @@ use core::alloc::{GlobalAlloc, Layout}; use core::ops::{Deref, DerefMut}; -use Dlmalloc; +use crate::Dlmalloc; /// An instance of a "global allocator" backed by `Dlmalloc` /// @@ -36,30 +36,30 @@ pub unsafe fn get_alloced_mem_size() -> usize { ::get_alloced_mem_size(&get()) } -static mut DLMALLOC: Dlmalloc = Dlmalloc(::dlmalloc::DLMALLOC_INIT); +static mut DLMALLOC: Dlmalloc = Dlmalloc(crate::dlmalloc::DLMALLOC_INIT); struct Instance; unsafe fn get() -> Instance { - ::sys::acquire_global_lock(); + crate::sys::acquire_global_lock(); Instance } impl Deref for Instance { type Target = Dlmalloc; fn deref(&self) -> &Dlmalloc { - unsafe { &DLMALLOC } + unsafe { &*&raw const DLMALLOC } } } impl DerefMut for Instance { fn deref_mut(&mut self) -> &mut Dlmalloc { - unsafe { &mut DLMALLOC } + unsafe { &mut *&raw mut DLMALLOC } } } impl Drop for Instance { fn drop(&mut self) { - ::sys::release_global_lock() + crate::sys::release_global_lock() } } diff --git a/src/linux.rs b/src/linux.rs index ba65eb6..459acd6 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -37,10 +37,10 @@ static mut LOCK: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; #[cfg(feature = "global")] pub fn acquire_global_lock() { - unsafe { assert_eq!(libc::pthread_mutex_lock(&mut LOCK), 0) } + unsafe { assert_eq!(libc::pthread_mutex_lock(&mut *&raw mut LOCK), 0) } } #[cfg(feature = "global")] pub fn release_global_lock() { - unsafe { assert_eq!(libc::pthread_mutex_unlock(&mut LOCK), 0) } + unsafe { assert_eq!(libc::pthread_mutex_unlock(&mut *&raw mut LOCK), 0) } } diff --git a/tests/global.rs b/tests/global.rs index af8fc45..d650af2 100644 --- a/tests/global.rs +++ b/tests/global.rs @@ -23,7 +23,7 @@ fn map() { #[test] fn strings() { - format!("foo, bar, {}", "baz"); + let _ = format!("foo, bar, {}", "baz"); } #[test] From ec725d0318f49231fd8db6701a9d4688459b0d83 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Sun, 24 May 2026 20:56:05 +0300 Subject: [PATCH 4/4] bump version to 0.2.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index eb79627..e404c03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gear-dlmalloc" -version = "0.2.0" +version = "0.2.1" edition = "2021" authors = ["Alex Crichton ", "Gear Technologies"] license = "MIT/Apache-2.0"