6 Commits

Author SHA1 Message Date
Yota Toyama
3abd5dea37 chore: Release bdwgc-alloc version 0.6.5 2023-05-21 13:09:40 +10:00
Yota Toyama
ec67abe1ef Update CI (#254) 2023-05-21 03:08:06 +00:00
Yota Toyama
8f73f3d63a Refactor (#253) 2023-05-21 02:35:25 +00:00
dependabot[bot]
ca51b73cf5 chore(deps): Bump vendor/bdwgc from 5f6df10 to 71f838e (#252)
Bumps [vendor/bdwgc](https://github.com/ivmai/bdwgc) from `5f6df10` to
`71f838e`.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="71f838eb6e"><code>71f838e</code></a>
Add debug logging to GC_clear_exclusion_table and
GC_exclude_static_roots</li>
<li><a
href="0b35c12b3f"><code>0b35c12</code></a>
Allow GC_push_roots to work even when no exclusions registered</li>
<li><a
href="a06340cc0b"><code>a06340c</code></a>
Fix GC_excl_table overrun on overflow in GC_exclude_static_roots</li>
<li><a
href="0a65033c4a"><code>0a65033</code></a>
Fix overlapping region assertion in mark_some if malloc redirect on
Linux</li>
<li><a
href="18e5b12da8"><code>18e5b12</code></a>
Clear GC_thread_key thread-local value on unregistering the thread</li>
<li><a
href="cd465f79c5"><code>cd465f7</code></a>
Fix GC_unregister_my_thread call before GC functions usage</li>
<li>See full diff in <a
href="5f6df10a93...71f838eb6e">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-16 20:00:37 +00:00
dependabot[bot]
fbc2d363b8 chore(deps): Bump vendor/bdwgc from db76b2f to 5f6df10 (#251)
Bumps [vendor/bdwgc](https://github.com/ivmai/bdwgc) from `db76b2f` to
`5f6df10`.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="5f6df10a93"><code>5f6df10</code></a>
Make comparisons to the lowest heap boundary strict</li>
<li><a
href="ffc64167e4"><code>ffc6416</code></a>
Fix old name (typo) of gc_priv.h</li>
<li><a
href="1c2d6cf543"><code>1c2d6cf</code></a>
Fix comparisons to heap boundary in GC_get_back_ptr_info and
GC_mark_from</li>
<li><a
href="a0a416a8a9"><code>a0a416a</code></a>
Fix assertion in GC_mark_from regarding
GC_least_plausible_heap_addr</li>
<li>See full diff in <a
href="db76b2f831...5f6df10a93">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-15 20:01:31 +00:00
Yota Toyama
7ff5ac5b21 Refactor (#250) 2023-05-15 17:40:34 +08:00
9 changed files with 103 additions and 36 deletions

11
.cspell.json Normal file
View File

@@ -0,0 +1,11 @@
{
"words": [
"dealloc",
"finalizer",
"gcollect",
"libc",
"realloc",
"repr",
"stackbottom"
]
}

View File

@@ -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:

View File

@@ -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
View 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

View File

@@ -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

View File

@@ -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>",

View File

@@ -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
} }

View File

@@ -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