diff --git a/Cargo.lock b/Cargo.lock index 10df224ead628..7055a757b252e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,7 +57,7 @@ dependencies = [ name = "alloc" version = "0.0.0" dependencies = [ - "boehm", + "bdwgc", "compiler_builtins", "core", "rand", @@ -305,7 +305,7 @@ dependencies = [ ] [[package]] -name = "boehm" +name = "bdwgc" version = "0.1.0" dependencies = [ "cmake", @@ -5010,7 +5010,7 @@ version = "0.0.0" dependencies = [ "addr2line", "alloc", - "boehm", + "bdwgc", "cfg-if", "compiler_builtins", "core", diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index ac642a58c7b4d..fb9b0890f2357 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -9,7 +9,7 @@ autobenches = false edition = "2021" [dependencies] -boehm = { path = "../boehm"} +bdwgc = { path = "../bdwgc"} core = { path = "../core" } compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std'] } diff --git a/library/alloc/src/gc.rs b/library/alloc/src/gc.rs index a7f9e1e124ab7..c1e4a74bf12db 100644 --- a/library/alloc/src/gc.rs +++ b/library/alloc/src/gc.rs @@ -54,14 +54,14 @@ unsafe impl GlobalAlloc for GcAllocator { #[inline] unsafe fn gc_malloc(layout: Layout) -> *mut u8 { if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { - unsafe { boehm::GC_malloc(layout.size()) as *mut u8 } + unsafe { bdwgc::GC_malloc(layout.size()) as *mut u8 } } else { let mut out = ptr::null_mut(); // posix_memalign requires that the alignment be a multiple of `sizeof(void*)`. // Since these are all powers of 2, we can just use max. unsafe { let align = layout.align().max(core::mem::size_of::()); - let ret = boehm::GC_posix_memalign(&mut out, align, layout.size()); + let ret = bdwgc::GC_posix_memalign(&mut out, align, layout.size()); if ret != 0 { ptr::null_mut() } else { out as *mut u8 } } } @@ -70,7 +70,7 @@ unsafe fn gc_malloc(layout: Layout) -> *mut u8 { #[inline] unsafe fn gc_realloc(ptr: *mut u8, old_layout: Layout, new_size: usize) -> *mut u8 { if old_layout.align() <= MIN_ALIGN && old_layout.align() <= new_size { - unsafe { boehm::GC_realloc(ptr, new_size) as *mut u8 } + unsafe { bdwgc::GC_realloc(ptr, new_size) as *mut u8 } } else { unsafe { let new_layout = Layout::from_size_align_unchecked(new_size, old_layout.align()); @@ -90,11 +90,11 @@ unsafe fn gc_realloc(ptr: *mut u8, old_layout: Layout, new_size: usize) -> *mut unsafe fn gc_free(ptr: *mut u8, layout: Layout) { if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { unsafe { - boehm::GC_free(ptr); + bdwgc::GC_free(ptr); } } else { unsafe { - boehm::GC_free(boehm::GC_base(ptr)); + bdwgc::GC_free(bdwgc::GC_base(ptr)); } } } @@ -117,18 +117,18 @@ unsafe impl Allocator for GcAllocator { impl GcAllocator { pub fn force_gc() { - unsafe { boehm::GC_gcollect() } + unsafe { bdwgc::GC_gcollect() } } } pub fn init() { - unsafe { boehm::GC_init() } + unsafe { bdwgc::GC_init() } } pub fn suppress_warnings() { - unsafe { boehm::GC_set_warn_proc(&boehm::GC_ignore_warn_proc as *const _ as *mut u8) }; + unsafe { bdwgc::GC_set_warn_proc(&bdwgc::GC_ignore_warn_proc as *const _ as *mut u8) }; } pub fn thread_registered() -> bool { - unsafe { boehm::GC_thread_is_registered() != 0 } + unsafe { bdwgc::GC_thread_is_registered() != 0 } } diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index e2f94910d1b2b..695c95604f23a 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -222,7 +222,7 @@ mod testing; #[allow(unused_extern_crates)] #[allow(missing_docs)] #[unstable(feature = "gc", issue = "none")] -pub extern crate boehm; +pub extern crate bdwgc; // Module with internal macros used by other modules (needs to be included before other modules). #[macro_use] diff --git a/library/alloc/tests/gc.rs b/library/alloc/tests/gc.rs index cda051e56566f..19c73434e5efb 100644 --- a/library/alloc/tests/gc.rs +++ b/library/alloc/tests/gc.rs @@ -28,7 +28,7 @@ fn large_alignment() { } #[test] -fn boehm_issue_589() { +fn bdwgc_issue_589() { // Test the specific size / alignment problem raised in [1]. // // [1]: https://github.com/ivmai/bdwgc/issues/589 diff --git a/library/boehm/Cargo.toml b/library/bdwgc/Cargo.toml similarity index 96% rename from library/boehm/Cargo.toml rename to library/bdwgc/Cargo.toml index 522b7febf3cfe..3c1e721cae21d 100644 --- a/library/boehm/Cargo.toml +++ b/library/bdwgc/Cargo.toml @@ -1,7 +1,7 @@ cargo-features = ["public-dependency"] [package] -name = "boehm" +name = "bdwgc" version = "0.1.0" authors = ["Jake Hughes "] edition = "2021" diff --git a/library/boehm/build.rs b/library/bdwgc/build.rs similarity index 63% rename from library/boehm/build.rs rename to library/bdwgc/build.rs index 7344faa4bfb25..b64188169fbf7 100644 --- a/library/boehm/build.rs +++ b/library/bdwgc/build.rs @@ -3,10 +3,10 @@ use std::env; use std::path::PathBuf; use std::process::Command; -const BOEHM_REPO: &str = "https://github.com/softdevteam/bdwgc.git"; -const BOEHM_ATOMICS_REPO: &str = "https://github.com/ivmai/libatomic_ops.git"; -const BOEHM_DEFAULT_SRC_DIR: &str = "bdwgc"; -const BOEHM_BUILD_DIR: &str = "lib"; +const BDWGC_REPO: &str = "https://github.com/softdevteam/bdwgc.git"; +const BDWGC_ATOMICS_REPO: &str = "https://github.com/ivmai/libatomic_ops.git"; +const BDWGC_DEFAULT_SRC_DIR: &str = "bdwgc"; +const BDWGC_BUILD_DIR: &str = "lib"; #[cfg(not(all(target_pointer_width = "64", target_arch = "x86_64")))] compile_error!("Requires x86_64 with 64 bit pointer width."); @@ -24,22 +24,22 @@ where fn main() { let out_dir = env::var("OUT_DIR").unwrap(); - let mut boehm_src = PathBuf::from(&out_dir); + let mut bdwgc_src = PathBuf::from(&out_dir); - match env::var("BOEHM") { - Ok(path) => boehm_src.push(path), - Err(_) => boehm_src.push(BOEHM_DEFAULT_SRC_DIR), + match env::var("BDWGC") { + Ok(path) => bdwgc_src.push(path), + Err(_) => bdwgc_src.push(BDWGC_DEFAULT_SRC_DIR), } let mut build_dir = PathBuf::from(&out_dir); - build_dir.push(BOEHM_BUILD_DIR); + build_dir.push(BDWGC_BUILD_DIR); - if !boehm_src.exists() && env::var("BOEHM").is_err() { - run("git", |cmd| cmd.arg("clone").arg(BOEHM_REPO).arg(&boehm_src)); - run("git", |cmd| cmd.arg("clone").arg(BOEHM_ATOMICS_REPO).current_dir(&boehm_src)); + if !bdwgc_src.exists() && env::var("BDWGC").is_err() { + run("git", |cmd| cmd.arg("clone").arg(BDWGC_REPO).arg(&bdwgc_src)); + run("git", |cmd| cmd.arg("clone").arg(BDWGC_ATOMICS_REPO).current_dir(&bdwgc_src)); } - let mut build = cmake::Config::new(&boehm_src); + let mut build = cmake::Config::new(&bdwgc_src); build .pic(true) .define("BUILD_SHARED_LIBS", "OFF") diff --git a/library/boehm/src/lib.rs b/library/bdwgc/src/lib.rs similarity index 100% rename from library/boehm/src/lib.rs rename to library/bdwgc/src/lib.rs diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index ebfd73d072aad..5ca5d73473416 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["dylib", "rlib"] [dependencies] alloc = { path = "../alloc", public = true } cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] } -boehm = { path = "../boehm" } +bdwgc = { path = "../bdwgc" } panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core", public = true } diff --git a/library/std/src/gc.rs b/library/std/src/gc.rs index 077d5742dcd2e..1bd9220bfd309 100644 --- a/library/std/src/gc.rs +++ b/library/std/src/gc.rs @@ -267,7 +267,7 @@ impl Gc { } unsafe { - boehm::GC_register_finalizer_no_order( + bdwgc::GC_register_finalizer_no_order( self.ptr.as_ptr() as *mut u8, Some(finalizer::), null_mut(), @@ -281,7 +281,7 @@ impl Gc { pub fn unregister_finalizer(&mut self) { let ptr = self.ptr.as_ptr() as *mut GcBox as *mut u8; unsafe { - boehm::GC_register_finalizer( + bdwgc::GC_register_finalizer( ptr, None, ::core::ptr::null_mut(), diff --git a/library/std/src/sys/common/thread_local/os_local.rs b/library/std/src/sys/common/thread_local/os_local.rs index 2856fd1ce7725..60ee20c90a252 100644 --- a/library/std/src/sys/common/thread_local/os_local.rs +++ b/library/std/src/sys/common/thread_local/os_local.rs @@ -3,11 +3,11 @@ use crate::cell::Cell; use crate::sys_common::thread_local_key::StaticKey as OsStaticKey; use crate::{fmt, marker, panic, ptr}; -use alloc::boehm; +use alloc::bdwgc; /// A buffer of pointers to each thread local variable. /// -/// The Boehm GC can't locate GC pointers stored inside POSIX thread locals, so +/// The BDWGC can't locate GC pointers stored inside POSIX thread locals, so /// this struct keeps track of pointers to thread local data, which the GC then /// uses as part of its marking rootset. /// @@ -31,11 +31,11 @@ impl TLSRoots { /// Push a root to the current thread's TLS rootset. This lazily /// initialises the backing vector. fn push(root: *mut u8) { - let mut rootset = unsafe { boehm::GC_tls_rootset() as *mut Vec<*mut u8> }; + let mut rootset = unsafe { bdwgc::GC_tls_rootset() as *mut Vec<*mut u8> }; if rootset.is_null() { let v = Vec::new(); let buf: *mut Vec<*mut u8> = Box::into_raw(Box::new(v)); - unsafe { boehm::GC_init_tls_rootset(buf as *mut u8) }; + unsafe { bdwgc::GC_init_tls_rootset(buf as *mut u8) }; rootset = buf } unsafe { (&mut *rootset).push(root) }; diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index ff132c65ec5eb..04428d16be930 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -85,7 +85,7 @@ impl Thread { }; } - let ret = alloc::boehm::GC_pthread_create(&mut native, &attr, thread_start, p as *mut _); + let ret = alloc::bdwgc::GC_pthread_create(&mut native, &attr, thread_start, p as *mut _); // Note: if the thread creation fails and this assert fails, then p will // be leaked. However, an alternative design could cause double-free // which is clearly worse. @@ -267,7 +267,7 @@ impl Thread { pub fn join(self) { unsafe { - let ret = alloc::boehm::GC_pthread_join(self.id, ptr::null_mut()); + let ret = alloc::bdwgc::GC_pthread_join(self.id, ptr::null_mut()); mem::forget(self); assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret)); } @@ -286,7 +286,7 @@ impl Thread { impl Drop for Thread { fn drop(&mut self) { - let ret = unsafe { alloc::boehm::GC_pthread_detach(self.id) }; + let ret = unsafe { alloc::bdwgc::GC_pthread_detach(self.id) }; debug_assert_eq!(ret, 0); } }