From 5f41a2b8e293895f59371b0545a266088681c7c8 Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Sun, 24 Sep 2023 16:56:08 +1000 Subject: [PATCH 1/3] Set pointer mask --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 2cbf54e..ee0ce3c 100644 --- a/build.rs +++ b/build.rs @@ -23,7 +23,7 @@ fn main() { let dst = autotools::Config::new(LIB_GC_DIR) .cflag(format!( - "-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC", + "-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC -D POINTER_MASK=0x7", dst.join("include").display() )) .build(); From a4bcbf2c7b85d4b08b1a4b5d0939fc17ce5d68ad Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Sun, 24 Sep 2023 17:01:53 +1000 Subject: [PATCH 2/3] Call memalign --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5a6a9ad..561523b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,7 @@ extern "C" { fn GC_get_stack_base(stack_base: *mut GcStackBase) -> c_int; fn GC_init(); fn GC_malloc(size: size_t) -> *mut c_void; + fn GC_memalign(align: size_t, size: size_t) -> *mut c_void; fn GC_realloc(ptr: *mut c_void, size: size_t) -> *mut c_void; fn GC_register_my_thread(stack_base: *const GcStackBase) -> c_int; fn GC_set_stackbottom(thread: *const c_void, stack_bottom: *const GcStackBase); @@ -95,7 +96,7 @@ impl Allocator { unsafe impl GlobalAlloc for Allocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - GC_malloc(layout.size()) as *mut u8 + GC_memalign(layout.align(), layout.size()) as *mut u8 } unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { From 08d549315bb1b8c3e72145e88588d1ad1148dc3d Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Sun, 24 Sep 2023 20:23:45 +1000 Subject: [PATCH 3/3] Fix --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index ee0ce3c..ba7fea0 100644 --- a/build.rs +++ b/build.rs @@ -59,7 +59,10 @@ fn main() { let dst = Config::new(LIB_GC_DIR) .profile("Release") .define("BUILD_SHARED_LIBS", "FALSE") - .cflag(format!("-I{}", libatomic_include_path)) + .cflag(format!( + "-I{} -DPOINTER_MASK=0x7", + libatomic_include_path, foo + )) .build(); println!(