mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-05-29 18:08:56 -06:00
Bump version (#465)
This commit is contained in:
10
.github/workflows/release.yaml
vendored
10
.github/workflows/release.yaml
vendored
@@ -9,6 +9,8 @@ concurrency:
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
jobs:
|
||||
release:
|
||||
permissions:
|
||||
id-token: write
|
||||
runs-on: ubuntu-latest
|
||||
environment: ${{ github.ref == 'refs/heads/main' && 'release' || '' }}
|
||||
steps:
|
||||
@@ -17,7 +19,9 @@ jobs:
|
||||
submodules: true
|
||||
- uses: raviqqe/cargo-cache@v1
|
||||
- run: cargo install cargo-workspaces
|
||||
- run: cargo workspaces publish -y --from-git --no-verify
|
||||
env:
|
||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
- uses: rust-lang/crates-io-auth-action@v1
|
||||
id: auth
|
||||
if: github.ref == 'refs/heads/main'
|
||||
- run: cargo workspaces publish -y --from-git ${{ github.ref != 'refs/heads/main' && '--dry-run' || '' }}
|
||||
env:
|
||||
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -13,7 +13,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bdwgc-alloc"
|
||||
version = "0.6.10"
|
||||
version = "0.6.11"
|
||||
dependencies = [
|
||||
"autotools",
|
||||
"cmake",
|
||||
|
||||
14
Cargo.toml
14
Cargo.toml
@@ -1,21 +1,17 @@
|
||||
[package]
|
||||
name = "bdwgc-alloc"
|
||||
version = "0.6.11"
|
||||
edition = "2024"
|
||||
description = "impl GlobalAlloc for bdwgc"
|
||||
version = "0.6.10"
|
||||
authors = [
|
||||
"swgillespie <sean.william.g@gmail.com>",
|
||||
"Yota Toyama <raviqqe@gmail.com>",
|
||||
]
|
||||
repository = "https://github.com/raviqqe/bdwgc-alloc"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
[features]
|
||||
default = ["autotools"]
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
autotools = { version = "0.2", optional = true }
|
||||
cmake = { version = "0.1", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["autotools"]
|
||||
|
||||
36
src/lib.rs
36
src/lib.rs
@@ -17,7 +17,7 @@ struct GcStackBase {
|
||||
}
|
||||
|
||||
#[link(name = "gc", kind = "static")]
|
||||
extern "C" {
|
||||
unsafe extern "C" {
|
||||
fn GC_allow_register_threads();
|
||||
fn GC_alloc_lock();
|
||||
fn GC_alloc_unlock();
|
||||
@@ -58,8 +58,10 @@ impl Allocator {
|
||||
///
|
||||
/// This function must be called in a main thread.
|
||||
pub unsafe fn initialize() {
|
||||
GC_init();
|
||||
GC_allow_register_threads();
|
||||
unsafe {
|
||||
GC_init();
|
||||
GC_allow_register_threads();
|
||||
}
|
||||
}
|
||||
|
||||
/// Registers a current thread to a collector.
|
||||
@@ -70,9 +72,9 @@ impl Allocator {
|
||||
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
|
||||
let mut base = GcStackBase { mem_base: null() };
|
||||
|
||||
if GC_get_stack_base(&mut base) != GC_SUCCESS {
|
||||
if unsafe { GC_get_stack_base(&mut base) } != GC_SUCCESS {
|
||||
return Err(error::Error::new("failed to get stack base"));
|
||||
} else if GC_register_my_thread(&base) != GC_SUCCESS {
|
||||
} else if unsafe { GC_register_my_thread(&base) } != GC_SUCCESS {
|
||||
return Err(error::Error::new("failed to register a thread for GC"));
|
||||
}
|
||||
|
||||
@@ -88,12 +90,14 @@ impl Allocator {
|
||||
///
|
||||
/// The bottom address must be valid.
|
||||
pub unsafe fn set_stack_bottom(bottom: *const u8) {
|
||||
GC_set_stackbottom(
|
||||
null(),
|
||||
&GcStackBase {
|
||||
mem_base: bottom as *const libc::c_void,
|
||||
},
|
||||
)
|
||||
unsafe {
|
||||
GC_set_stackbottom(
|
||||
null(),
|
||||
&GcStackBase {
|
||||
mem_base: bottom as *const libc::c_void,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Unregisters a current thread from a collector.
|
||||
@@ -102,7 +106,7 @@ impl Allocator {
|
||||
///
|
||||
/// The thread must be registered already.
|
||||
pub unsafe fn unregister_current_thread() {
|
||||
GC_unregister_my_thread()
|
||||
unsafe { GC_unregister_my_thread() }
|
||||
}
|
||||
|
||||
/// Runs a garbage collection forcibly.
|
||||
@@ -120,20 +124,20 @@ impl Allocator {
|
||||
finalizer: extern "C" fn(*mut c_void, *mut c_void),
|
||||
client_data: *const c_void,
|
||||
) {
|
||||
GC_register_finalizer(ptr, finalizer, client_data, null(), null());
|
||||
unsafe { GC_register_finalizer(ptr, finalizer, client_data, null(), null()) };
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl GlobalAlloc for Allocator {
|
||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||
GC_malloc(layout.size()) as *mut u8
|
||||
(unsafe { GC_malloc(layout.size()) }) as *mut u8
|
||||
}
|
||||
|
||||
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
|
||||
GC_free(ptr as *mut c_void)
|
||||
unsafe { GC_free(ptr as *mut c_void) }
|
||||
}
|
||||
|
||||
unsafe fn realloc(&self, ptr: *mut u8, _layout: Layout, size: usize) -> *mut u8 {
|
||||
GC_realloc(ptr as *mut c_void, size) as *mut u8
|
||||
(unsafe { GC_realloc(ptr as *mut c_void, size) }) as *mut u8
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user