forked from GitHub/bdwgc-rust
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' }}
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: ${{ github.ref == 'refs/heads/main' && 'release' || '' }}
|
environment: ${{ github.ref == 'refs/heads/main' && 'release' || '' }}
|
||||||
steps:
|
steps:
|
||||||
@@ -17,7 +19,9 @@ jobs:
|
|||||||
submodules: true
|
submodules: true
|
||||||
- uses: raviqqe/cargo-cache@v1
|
- uses: raviqqe/cargo-cache@v1
|
||||||
- run: cargo install cargo-workspaces
|
- run: cargo install cargo-workspaces
|
||||||
- run: cargo workspaces publish -y --from-git --no-verify
|
- uses: rust-lang/crates-io-auth-action@v1
|
||||||
env:
|
id: auth
|
||||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
||||||
if: github.ref == 'refs/heads/main'
|
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]]
|
[[package]]
|
||||||
name = "bdwgc-alloc"
|
name = "bdwgc-alloc"
|
||||||
version = "0.6.10"
|
version = "0.6.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autotools",
|
"autotools",
|
||||||
"cmake",
|
"cmake",
|
||||||
|
|||||||
14
Cargo.toml
14
Cargo.toml
@@ -1,21 +1,17 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bdwgc-alloc"
|
name = "bdwgc-alloc"
|
||||||
|
version = "0.6.11"
|
||||||
|
edition = "2024"
|
||||||
description = "impl GlobalAlloc for bdwgc"
|
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"
|
repository = "https://github.com/raviqqe/bdwgc-alloc"
|
||||||
edition = "2021"
|
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["autotools"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
autotools = { version = "0.2", optional = true }
|
autotools = { version = "0.2", optional = true }
|
||||||
cmake = { version = "0.1", 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")]
|
#[link(name = "gc", kind = "static")]
|
||||||
extern "C" {
|
unsafe extern "C" {
|
||||||
fn GC_allow_register_threads();
|
fn GC_allow_register_threads();
|
||||||
fn GC_alloc_lock();
|
fn GC_alloc_lock();
|
||||||
fn GC_alloc_unlock();
|
fn GC_alloc_unlock();
|
||||||
@@ -58,8 +58,10 @@ impl Allocator {
|
|||||||
///
|
///
|
||||||
/// This function must be called in a main thread.
|
/// This function must be called in a main thread.
|
||||||
pub unsafe fn initialize() {
|
pub unsafe fn initialize() {
|
||||||
GC_init();
|
unsafe {
|
||||||
GC_allow_register_threads();
|
GC_init();
|
||||||
|
GC_allow_register_threads();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Registers a current thread to a collector.
|
/// Registers a current thread to a collector.
|
||||||
@@ -70,9 +72,9 @@ impl Allocator {
|
|||||||
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
|
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
|
||||||
let mut base = GcStackBase { mem_base: null() };
|
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"));
|
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"));
|
return Err(error::Error::new("failed to register a thread for GC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,12 +90,14 @@ impl Allocator {
|
|||||||
///
|
///
|
||||||
/// The bottom address must be valid.
|
/// The bottom address must be valid.
|
||||||
pub unsafe fn set_stack_bottom(bottom: *const u8) {
|
pub unsafe fn set_stack_bottom(bottom: *const u8) {
|
||||||
GC_set_stackbottom(
|
unsafe {
|
||||||
null(),
|
GC_set_stackbottom(
|
||||||
&GcStackBase {
|
null(),
|
||||||
mem_base: bottom as *const libc::c_void,
|
&GcStackBase {
|
||||||
},
|
mem_base: bottom as *const libc::c_void,
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unregisters a current thread from a collector.
|
/// Unregisters a current thread from a collector.
|
||||||
@@ -102,7 +106,7 @@ impl Allocator {
|
|||||||
///
|
///
|
||||||
/// The thread must be registered already.
|
/// The thread must be registered already.
|
||||||
pub unsafe fn unregister_current_thread() {
|
pub unsafe fn unregister_current_thread() {
|
||||||
GC_unregister_my_thread()
|
unsafe { GC_unregister_my_thread() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs a garbage collection forcibly.
|
/// Runs a garbage collection forcibly.
|
||||||
@@ -120,20 +124,20 @@ impl Allocator {
|
|||||||
finalizer: extern "C" fn(*mut c_void, *mut c_void),
|
finalizer: extern "C" fn(*mut c_void, *mut c_void),
|
||||||
client_data: *const 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 impl GlobalAlloc for Allocator {
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
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) {
|
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 {
|
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