From 7f2429fe2519e9798a255171131a0e9eeb30970b Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 26 Sep 2023 19:30:03 +0000
Subject: [PATCH 1/7] chore(deps): Bump vendor/bdwgc from `4ae9dcd` to
`e8c073d` (#284)
Bumps [vendor/bdwgc](https://github.com/ivmai/bdwgc) from `4ae9dcd` to
`e8c073d`.
Commits
e8c073d
Group char-width fields together in GC_arrays
2fa18d2
AppVeyor: Test enable_dynamic_pointer_mask option
8756a50
Travis CI: Test with --enable-dynamic-pointer-mask
57828b3
Support pointer mask/shift set at runtime
2ea5267
Remove unneeded cast to word in GC_PUSH_ONE_HEAP/STACK
c685131
Turn on MAKE_BACK_GRAPH for all Linux architectures in cmake and
configure
- See full diff in compare
view
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)
---
Dependabot commands and options
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 show ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@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)
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
vendor/bdwgc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vendor/bdwgc b/vendor/bdwgc
index 4ae9dcd..e8c073d 160000
--- a/vendor/bdwgc
+++ b/vendor/bdwgc
@@ -1 +1 @@
-Subproject commit 4ae9dcd8945e5a43b84375631e48e4fafd443a36
+Subproject commit e8c073d786948dd522fa96c9c42d1a362836e1c8
From 1e54b65b9e9bc4e97533a6ce7f5370e29ecc5b9b Mon Sep 17 00:00:00 2001
From: Yota Toyama
Date: Thu, 28 Sep 2023 12:51:38 +1000
Subject: [PATCH 2/7] Refactor (#285)
---
.cspell.json | 4 +++-
Cargo.toml | 1 -
examples/Cargo.toml | 1 +
examples/dynamic_threads/Cargo.toml | 2 +-
examples/dynamic_threads/src/main.rs | 4 +---
examples/free_by_borrow/Cargo.toml | 2 +-
examples/free_by_borrow/src/main.rs | 2 --
examples/free_by_gc/Cargo.toml | 2 +-
examples/free_by_gc/src/main.rs | 4 +---
examples/static_threads/Cargo.toml | 2 +-
examples/static_threads/src/main.rs | 4 +---
src/lib.rs | 31 ++++++++++++++++++++++++++++
12 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/.cspell.json b/.cspell.json
index ddedd2a..11d5e88 100644
--- a/.cspell.json
+++ b/.cspell.json
@@ -1,11 +1,13 @@
{
"words": [
+ "bdwgc",
"dealloc",
"finalizer",
"gcollect",
"libc",
"realloc",
"repr",
- "stackbottom"
+ "stackbottom",
+ "unregisters"
]
}
diff --git a/Cargo.toml b/Cargo.toml
index 96593a9..262a2eb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,6 @@ authors = [
repository = "https://github.com/raviqqe/bdwgc-alloc"
edition = "2021"
license = "MIT"
-build = "build.rs"
[features]
default = ["autotools"]
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 5cb5511..8454b9c 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -1,4 +1,5 @@
[workspace]
+resolver = "2"
members = [
"dynamic_threads",
"free_by_borrow",
diff --git a/examples/dynamic_threads/Cargo.toml b/examples/dynamic_threads/Cargo.toml
index dcdd5f2..6ddf443 100644
--- a/examples/dynamic_threads/Cargo.toml
+++ b/examples/dynamic_threads/Cargo.toml
@@ -2,7 +2,7 @@
name = "dynamic_threads"
version = "0.1.0"
authors = ["Yota Toyama "]
-edition = "2018"
+edition = "2021"
publish = false
[dependencies]
diff --git a/examples/dynamic_threads/src/main.rs b/examples/dynamic_threads/src/main.rs
index bd3365f..915e2e3 100644
--- a/examples/dynamic_threads/src/main.rs
+++ b/examples/dynamic_threads/src/main.rs
@@ -1,5 +1,3 @@
-extern crate bdwgc_alloc;
-
use bdwgc_alloc::Allocator;
use std::alloc::Layout;
@@ -14,7 +12,7 @@ fn main() {
unsafe { Allocator::register_current_thread().unwrap() }
for _ in 0..100 {
- unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
+ let _ = unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
unsafe { Allocator::unregister_current_thread() }
diff --git a/examples/free_by_borrow/Cargo.toml b/examples/free_by_borrow/Cargo.toml
index 9b49a48..79b4828 100644
--- a/examples/free_by_borrow/Cargo.toml
+++ b/examples/free_by_borrow/Cargo.toml
@@ -2,7 +2,7 @@
name = "free_by_borrow"
version = "0.1.0"
authors = ["Yota Toyama "]
-edition = "2018"
+edition = "2021"
publish = false
[dependencies]
diff --git a/examples/free_by_borrow/src/main.rs b/examples/free_by_borrow/src/main.rs
index 673df12..24bd128 100644
--- a/examples/free_by_borrow/src/main.rs
+++ b/examples/free_by_borrow/src/main.rs
@@ -1,5 +1,3 @@
-extern crate bdwgc_alloc;
-
use bdwgc_alloc::Allocator;
#[global_allocator]
diff --git a/examples/free_by_gc/Cargo.toml b/examples/free_by_gc/Cargo.toml
index 49d09bd..74ca1a5 100644
--- a/examples/free_by_gc/Cargo.toml
+++ b/examples/free_by_gc/Cargo.toml
@@ -2,7 +2,7 @@
name = "free_by_gc"
version = "0.1.0"
authors = ["Yota Toyama "]
-edition = "2018"
+edition = "2021"
publish = false
[dependencies]
diff --git a/examples/free_by_gc/src/main.rs b/examples/free_by_gc/src/main.rs
index 94b26ef..2768d74 100644
--- a/examples/free_by_gc/src/main.rs
+++ b/examples/free_by_gc/src/main.rs
@@ -1,5 +1,3 @@
-extern crate bdwgc_alloc;
-
use bdwgc_alloc::Allocator;
use std::alloc::Layout;
@@ -10,6 +8,6 @@ fn main() {
unsafe { Allocator::initialize() }
loop {
- unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
+ let _ = unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
}
diff --git a/examples/static_threads/Cargo.toml b/examples/static_threads/Cargo.toml
index aaa22b7..f6ee965 100644
--- a/examples/static_threads/Cargo.toml
+++ b/examples/static_threads/Cargo.toml
@@ -2,7 +2,7 @@
name = "static_threads"
version = "0.1.0"
authors = ["Yota Toyama "]
-edition = "2018"
+edition = "2021"
publish = false
[dependencies]
diff --git a/examples/static_threads/src/main.rs b/examples/static_threads/src/main.rs
index dda7581..fad7aa6 100644
--- a/examples/static_threads/src/main.rs
+++ b/examples/static_threads/src/main.rs
@@ -1,5 +1,3 @@
-extern crate bdwgc_alloc;
-
use bdwgc_alloc::Allocator;
use std::alloc::Layout;
@@ -13,7 +11,7 @@ fn main() {
unsafe { Allocator::register_current_thread().unwrap() }
loop {
- unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
+ let _ = unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
});
diff --git a/src/lib.rs b/src/lib.rs
index 5a6a9ad..f84c7cc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -42,19 +42,31 @@ extern "C" {
pub struct Allocator;
impl Allocator {
+ /// Locks a collector.
pub fn lock() {
unsafe { GC_alloc_lock() }
}
+ /// Unlocks a collector.
pub fn unlock() {
unsafe { GC_alloc_unlock() }
}
+ /// Initializes a collector.
+ ///
+ /// # Safety
+ ///
+ /// This function must be called in a main thread.
pub unsafe fn initialize() {
GC_init();
GC_allow_register_threads();
}
+ /// Registers a current thread to a collector.
+ ///
+ /// # Safety
+ ///
+ /// This function must not be called in a main thread.
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
let mut base = GcStackBase { mem_base: null() };
@@ -67,6 +79,14 @@ impl Allocator {
Ok(())
}
+ /// Sets a bottom of a stack.
+ ///
+ /// You do not have to call this function in most cases.
+ /// A collector detects the bottom on initialization automatically.
+ ///
+ /// # Safety
+ ///
+ /// The bottom address must be valid.
pub unsafe fn set_stack_bottom(bottom: *const u8) {
GC_set_stackbottom(
null(),
@@ -76,14 +96,25 @@ impl Allocator {
)
}
+ /// Unregisters a current thread from a collector.
+ ///
+ /// # Safety
+ ///
+ /// The thread must be registered already.
pub unsafe fn unregister_current_thread() {
GC_unregister_my_thread()
}
+ /// Runs a garbage collection forcibly.
pub fn force_collect() {
unsafe { GC_gcollect() }
}
+ /// Registers a finalizer of an object.
+ ///
+ /// # Safety
+ ///
+ /// The given finalizer must not be null and handle pointers properly.
pub unsafe fn register_finalizer(
ptr: *const c_void,
finalizer: extern "C" fn(*mut c_void, *mut c_void),
From e59c09749a016209e0af8fda3cbfb446cccc073e Mon Sep 17 00:00:00 2001
From: Yota Toyama
Date: Thu, 28 Sep 2023 12:55:18 +1000
Subject: [PATCH 3/7] Bump version (#286)
---
Cargo.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Cargo.toml b/Cargo.toml
index 262a2eb..c208b0c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "bdwgc-alloc"
description = "impl GlobalAlloc for bdwgc"
-version = "0.6.6"
+version = "0.6.7"
authors = [
"swgillespie ",
"Yota Toyama ",
From f20c12e50806b225fa217a4a255981a732b4ebd3 Mon Sep 17 00:00:00 2001
From: Yota Toyama
Date: Thu, 28 Sep 2023 13:02:00 +1000
Subject: [PATCH 4/7] Fix spell check (#287)
---
.cspell.json | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/.cspell.json b/.cspell.json
index 11d5e88..e2e3512 100644
--- a/.cspell.json
+++ b/.cspell.json
@@ -1,12 +1,17 @@
{
"words": [
+ "autogen",
+ "autotools",
"bdwgc",
+ "cflag",
"dealloc",
"finalizer",
"gcollect",
+ "libatomic",
"libc",
"realloc",
"repr",
+ "rustc",
"stackbottom",
"unregisters"
]
From 9dd6bfd031aa2fdca87757f98571bc846b6e40c3 Mon Sep 17 00:00:00 2001
From: Yota Toyama
Date: Thu, 28 Sep 2023 15:17:12 +1000
Subject: [PATCH 5/7] Refactor test
---
examples/test.sh | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/examples/test.sh b/examples/test.sh
index 8be627e..ef2dd1d 100755
--- a/examples/test.sh
+++ b/examples/test.sh
@@ -4,10 +4,9 @@ set -ex
cargo build
-for cargo_file in */Cargo.toml
-do
- target/debug/$(dirname $cargo_file) &
- pid=$!
- sleep 10
- kill $pid
+for cargo_file in */Cargo.toml; do
+ target/debug/$(dirname $cargo_file) &
+ pid=$!
+ sleep 20
+ kill $pid
done
From 10e16366d70c9a5d29302452d20a784812d86cb3 Mon Sep 17 00:00:00 2001
From: Yota Toyama
Date: Thu, 28 Sep 2023 15:48:03 +1000
Subject: [PATCH 6/7] Refactor example test (#289)
---
.github/workflows/test.yaml | 11 +++++++----
examples/test.sh | 4 ++--
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 37dd1c4..1283c4b 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -22,15 +22,18 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo test
examples:
- runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ os:
+ - ubuntu-latest
+ - macos-latest
+ runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: Swatinem/rust-cache@v2
- - run: |
- cd examples
- ./test.sh
+ - run: examples/test.sh
cmake:
runs-on: ubuntu-latest
steps:
diff --git a/examples/test.sh b/examples/test.sh
index ef2dd1d..a5569b1 100755
--- a/examples/test.sh
+++ b/examples/test.sh
@@ -2,10 +2,10 @@
set -ex
-cargo build
+cd $(dirname $0)
for cargo_file in */Cargo.toml; do
- target/debug/$(dirname $cargo_file) &
+ cargo run --bin $(dirname $cargo_file) &
pid=$!
sleep 20
kill $pid
From 21b6fb35fff336e3299a357db6db12b94ed53149 Mon Sep 17 00:00:00 2001
From: Yota Toyama
Date: Thu, 28 Sep 2023 15:52:43 +1000
Subject: [PATCH 7/7] Fix examples test (#290)
---
.github/workflows/test.yaml | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 1283c4b..6c910e6 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -22,12 +22,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo test
examples:
- strategy:
- matrix:
- os:
- - ubuntu-latest
- - macos-latest
- runs-on: ${{ matrix.os }}
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: