Skip to content

Commit ed4ec8c

Browse files
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]>
2 parents 42025e0 + acfdf9a commit ed4ec8c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

allocator/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ compile_error!("Requires x86_64 with 64 bit pointer width.");
1212
static POINTER_MASK: &str = "-DPOINTER_MASK=0xFFFFFFFFFFFFFFF8";
1313
static FPIC: &str = "-fPIC";
1414
static MULTITHREADED: &str = "-DGC_ALWAYS_MULTITHREADED";
15+
static NO_INCREMENTAL: &str = "-DGC_DISABLE_INCREMENTAL";
1516

1617
fn run<F>(name: &str, mut configure: F)
1718
where
@@ -46,7 +47,10 @@ fn main() {
4647
run("./configure", |cmd| {
4748
cmd.arg("--enable-static").arg("--disable-shared").env(
4849
"CFLAGS",
49-
format!("{} {} {}", POINTER_MASK, FPIC, MULTITHREADED),
50+
format!(
51+
"{} {} {} {}",
52+
POINTER_MASK, FPIC, MULTITHREADED, NO_INCREMENTAL
53+
),
5054
)
5155
});
5256

allocator/src/boehm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ extern "C" {
5757

5858
pub(crate) fn GC_gcollect();
5959

60-
pub(crate) fn GC_start_performance_measurement();
61-
6260
pub(crate) fn GC_get_full_gc_total_time() -> usize;
6361

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

7977
pub(crate) fn GC_unregister_my_thread() -> i32;
78+
79+
pub(crate) fn GC_allow_register_threads();
80+
81+
pub(crate) fn GC_init();
8082
}

allocator/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,25 @@ impl GcAllocator {
148148
}
149149

150150
pub fn init() {
151-
unsafe { boehm::GC_start_performance_measurement() };
151+
unsafe { boehm::GC_init() }
152152
}
153153

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

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

164164
pub fn thread_registered() -> bool {
165-
unsafe { boehm::GC_thread_is_registered() != 0 }
165+
unsafe { boehm::GC_thread_is_registered() == 0 }
166+
}
167+
168+
pub fn allow_register_threads() {
169+
unsafe { boehm::GC_allow_register_threads() }
166170
}
167171
}
168172

0 commit comments

Comments
 (0)