forked from GitHub/bdwgc-rust
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3abd5dea37 | ||
|
|
ec67abe1ef | ||
|
|
8f73f3d63a | ||
|
|
ca51b73cf5 | ||
|
|
fbc2d363b8 | ||
|
|
7ff5ac5b21 |
11
.cspell.json
Normal file
11
.cspell.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"words": [
|
||||||
|
"dealloc",
|
||||||
|
"finalizer",
|
||||||
|
"gcollect",
|
||||||
|
"libc",
|
||||||
|
"realloc",
|
||||||
|
"repr",
|
||||||
|
"stackbottom"
|
||||||
|
]
|
||||||
|
}
|
||||||
4
.github/dependabot.yml
vendored
4
.github/dependabot.yml
vendored
@@ -1,5 +1,9 @@
|
|||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
- package-ecosystem: cargo
|
- package-ecosystem: cargo
|
||||||
directory: /
|
directory: /
|
||||||
schedule:
|
schedule:
|
||||||
|
|||||||
6
.mergify.yml → .github/mergify.yml
vendored
6
.mergify.yml → .github/mergify.yml
vendored
@@ -3,5 +3,9 @@ pull_request_rules:
|
|||||||
conditions:
|
conditions:
|
||||||
- author=dependabot[bot]
|
- author=dependabot[bot]
|
||||||
actions:
|
actions:
|
||||||
merge:
|
queue:
|
||||||
|
name: default
|
||||||
method: squash
|
method: squash
|
||||||
|
queue_rules:
|
||||||
|
- name: default
|
||||||
|
conditions: []
|
||||||
34
.github/workflows/lint.yaml
vendored
Normal file
34
.github/workflows/lint.yaml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: lint
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- run: cargo clippy -- -D warnings
|
||||||
|
format:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: cargo fmt -- --check
|
||||||
|
spell-check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: streetsidesoftware/cspell-action@main
|
||||||
|
with:
|
||||||
|
files: "**/*.{md,rs}"
|
||||||
|
readme:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: lycheeverse/lychee-action@v1
|
||||||
|
with:
|
||||||
|
fail: true
|
||||||
42
.github/workflows/test.yaml
vendored
42
.github/workflows/test.yaml
vendored
@@ -5,29 +5,37 @@ on:
|
|||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
jobs:
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- run: cargo build
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: Swatinem/rust-cache@v2
|
||||||
- uses: actions-rs/cargo@v1
|
- run: cargo test
|
||||||
|
examples:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
command: build
|
submodules: true
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: -- --check
|
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: clippy
|
|
||||||
- uses: actions-rs/audit-check@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- run: |
|
- run: |
|
||||||
cd examples
|
cd examples
|
||||||
./test.sh
|
./test.sh
|
||||||
- run: |
|
cmake:
|
||||||
git clean -dfx
|
runs-on: ubuntu-latest
|
||||||
cargo build --no-default-features --features cmake
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- run: cargo build --no-default-features --features cmake
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bdwgc-alloc"
|
name = "bdwgc-alloc"
|
||||||
description = "impl GlobalAlloc for bdwgc"
|
description = "impl GlobalAlloc for bdwgc"
|
||||||
version = "0.6.4"
|
version = "0.6.5"
|
||||||
authors = [
|
authors = [
|
||||||
"swgillespie <sean.william.g@gmail.com>",
|
"swgillespie <sean.william.g@gmail.com>",
|
||||||
"Yota Toyama <raviqqe@gmail.com>",
|
"Yota Toyama <raviqqe@gmail.com>",
|
||||||
|
|||||||
11
src/error.rs
11
src/error.rs
@@ -1,3 +1,8 @@
|
|||||||
|
use std::{
|
||||||
|
error,
|
||||||
|
fmt::{self, Display, Formatter},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
description: &'static str,
|
description: &'static str,
|
||||||
@@ -9,13 +14,13 @@ impl Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
|
||||||
write!(formatter, "{}", self.description)
|
write!(formatter, "{}", self.description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
self.description
|
self.description
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/lib.rs
27
src/lib.rs
@@ -1,9 +1,12 @@
|
|||||||
extern crate libc;
|
#![doc = include_str!("../README.md")]
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
|
use alloc::alloc::{GlobalAlloc, Layout};
|
||||||
|
use core::ptr::null;
|
||||||
use libc::{c_int, c_void, size_t};
|
use libc::{c_int, c_void, size_t};
|
||||||
use std::alloc::{GlobalAlloc, Layout};
|
|
||||||
|
|
||||||
const GC_SUCCESS: c_int = 0;
|
const GC_SUCCESS: c_int = 0;
|
||||||
|
|
||||||
@@ -28,11 +31,11 @@ extern "C" {
|
|||||||
fn GC_unregister_my_thread();
|
fn GC_unregister_my_thread();
|
||||||
fn GC_gcollect();
|
fn GC_gcollect();
|
||||||
fn GC_register_finalizer(
|
fn GC_register_finalizer(
|
||||||
obj: *const c_void,
|
ptr: *const c_void,
|
||||||
f: 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,
|
||||||
opt_old_f: *const c_void,
|
opt_old_finalizer: *const c_void,
|
||||||
opt_old_cd: *const c_void,
|
opt_old_client_data: *const c_void,
|
||||||
) -> *mut c_void;
|
) -> *mut c_void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,9 +56,7 @@ impl Allocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
|
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
|
||||||
let mut base = GcStackBase {
|
let mut base = GcStackBase { mem_base: null() };
|
||||||
mem_base: std::ptr::null(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if GC_get_stack_base(&mut base) != GC_SUCCESS {
|
if 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"));
|
||||||
@@ -68,7 +69,7 @@ impl Allocator {
|
|||||||
|
|
||||||
pub unsafe fn set_stack_bottom(bottom: *const u8) {
|
pub unsafe fn set_stack_bottom(bottom: *const u8) {
|
||||||
GC_set_stackbottom(
|
GC_set_stackbottom(
|
||||||
std::ptr::null(),
|
null(),
|
||||||
&GcStackBase {
|
&GcStackBase {
|
||||||
mem_base: bottom as *const libc::c_void,
|
mem_base: bottom as *const libc::c_void,
|
||||||
},
|
},
|
||||||
@@ -84,11 +85,11 @@ impl Allocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn register_finalizer(
|
pub unsafe fn register_finalizer(
|
||||||
obj: *const c_void,
|
ptr: *const c_void,
|
||||||
f: 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(obj, f, client_data, std::ptr::null(), std::ptr::null());
|
GC_register_finalizer(ptr, finalizer, client_data, null(), null());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
vendor/bdwgc
vendored
2
vendor/bdwgc
vendored
Submodule vendor/bdwgc updated: db76b2f831...71f838eb6e
Reference in New Issue
Block a user