From 7703ddb44ce79db48d9f09e6e50135ca6230bf94 Mon Sep 17 00:00:00 2001 From: Guillaume Endignoux <guillaumee@google.com> Date: Tue, 3 Mar 2020 19:32:25 +0100 Subject: [PATCH] Add comment about AtomicUsize. --- patches/libtock-rs/07-debug_allocations.patch | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/patches/libtock-rs/07-debug_allocations.patch b/patches/libtock-rs/07-debug_allocations.patch index 0b874be..13d2eaf 100644 --- a/patches/libtock-rs/07-debug_allocations.patch +++ b/patches/libtock-rs/07-debug_allocations.patch @@ -11,10 +11,10 @@ index 386a9ed..af3c5db 100644 [dev-dependencies] corepack = { version = "0.4.0", default-features = false, features = ["alloc"] } diff --git a/src/entry_point.rs b/src/entry_point.rs -index 2fe5c40..c978ee5 100644 +index 2fe5c40..545d163 100644 --- a/src/entry_point.rs +++ b/src/entry_point.rs -@@ -368,22 +368,77 @@ pub unsafe extern "C" fn rust_start(app_start: usize, stacktop: usize, app_heap_ +@@ -368,22 +368,82 @@ pub unsafe extern "C" fn rust_start(app_start: usize, stacktop: usize, app_heap_ } } @@ -33,6 +33,11 @@ index 2fe5c40..c978ee5 100644 static mut HEAP: Heap = Heap::empty(); -struct TockAllocator; ++// With the "debug_allocations" feature, we use `AtomicUsize` to store the ++// statistics because: ++// - it is `Sync`, so we can use it in a static object (the allocator), ++// - it implements interior mutability, so we can use it in the allocator ++// methods (that take an immutable `&self` reference). +struct TockAllocator { + #[cfg(feature = "debug_allocations")] + count: AtomicUsize, -- GitLab