Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
53: Tweaks to Boehm multithreaded API r=ltratt a=jacob-hughes

These are some minor changes that need fixing before this can be used properly in rustgc. Mostly because I misunderstood the way the Boehm API works the first time around.

Co-authored-by: Jake Hughes <[email protected]>
  • Loading branch information
bors[bot] and jacob-hughes authored Apr 6, 2021
2 parents 42025e0 + acfdf9a commit ed4ec8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion allocator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ compile_error!("Requires x86_64 with 64 bit pointer width.");
static POINTER_MASK: &str = "-DPOINTER_MASK=0xFFFFFFFFFFFFFFF8";
static FPIC: &str = "-fPIC";
static MULTITHREADED: &str = "-DGC_ALWAYS_MULTITHREADED";
static NO_INCREMENTAL: &str = "-DGC_DISABLE_INCREMENTAL";

fn run<F>(name: &str, mut configure: F)
where
Expand Down Expand Up @@ -46,7 +47,10 @@ fn main() {
run("./configure", |cmd| {
cmd.arg("--enable-static").arg("--disable-shared").env(
"CFLAGS",
format!("{} {} {}", POINTER_MASK, FPIC, MULTITHREADED),
format!(
"{} {} {} {}",
POINTER_MASK, FPIC, MULTITHREADED, NO_INCREMENTAL
),
)
});

Expand Down
6 changes: 4 additions & 2 deletions allocator/src/boehm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ extern "C" {

pub(crate) fn GC_gcollect();

pub(crate) fn GC_start_performance_measurement();

pub(crate) fn GC_get_full_gc_total_time() -> usize;

pub(crate) fn GC_get_prof_stats(prof_stats: *mut ProfileStats, stats_size: usize) -> usize;
Expand All @@ -77,4 +75,8 @@ extern "C" {
pub(crate) fn GC_register_my_thread(stack_base: *mut u8) -> i32;

pub(crate) fn GC_unregister_my_thread() -> i32;

pub(crate) fn GC_allow_register_threads();

pub(crate) fn GC_init();
}
12 changes: 8 additions & 4 deletions allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,25 @@ impl GcAllocator {
}

pub fn init() {
unsafe { boehm::GC_start_performance_measurement() };
unsafe { boehm::GC_init() }
}

/// Returns true if thread was successfully registered.
pub unsafe fn register_thread(stack_base: *mut u8) -> bool {
boehm::GC_register_my_thread(stack_base) != 0
boehm::GC_register_my_thread(stack_base) == 0
}

/// Returns true if thread was successfully unregistered.
pub unsafe fn unregister_thread() -> bool {
boehm::GC_unregister_my_thread() != 0
boehm::GC_unregister_my_thread() == 0
}

pub fn thread_registered() -> bool {
unsafe { boehm::GC_thread_is_registered() != 0 }
unsafe { boehm::GC_thread_is_registered() == 0 }
}

pub fn allow_register_threads() {
unsafe { boehm::GC_allow_register_threads() }
}
}

Expand Down

0 comments on commit ed4ec8c

Please sign in to comment.