mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-09-26 12:13:39 -06:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccc273a168 |
@@ -1,11 +0,0 @@
|
|||||||
name: setup
|
|
||||||
description: Sets up a build environment
|
|
||||||
inputs: {}
|
|
||||||
outputs: {}
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
|
||||||
- uses: homebrew/actions/setup-homebrew@e99025eb970cfa124b8284a35463d87426917478 # main
|
|
||||||
- run: brew install autoconf automake libtool
|
|
||||||
shell: sh
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
name: document
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pages: write
|
|
||||||
id-token: write
|
|
||||||
jobs:
|
|
||||||
document:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
|
|
||||||
- uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
|
||||||
- run: cargo doc --no-deps
|
|
||||||
- run: rm target/doc/.lock
|
|
||||||
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
|
|
||||||
with:
|
|
||||||
path: target/doc
|
|
||||||
- uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
@@ -5,38 +5,28 @@ on:
|
|||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
jobs:
|
jobs:
|
||||||
clippy:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
- uses: swatinem/rust-cache@v2
|
||||||
- run: cargo clippy -- -D warnings
|
- run: cargo clippy -- -D warnings
|
||||||
format:
|
format:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@v6
|
||||||
- run: cargo fmt --all -- --check
|
- run: cargo fmt -- --check
|
||||||
spell-check:
|
spell-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@v6
|
||||||
- uses: streetsidesoftware/cspell-action@6f3c77c1406bc930f944ba97e9801a22e42caf58 # v9.1.0
|
- uses: streetsidesoftware/cspell-action@main
|
||||||
with:
|
with:
|
||||||
files: "**/*.{md,rs}"
|
files: "**/*.{md,rs}"
|
||||||
readme:
|
readme:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@v6
|
||||||
- uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0
|
- uses: lycheeverse/lychee-action@v2
|
||||||
lint:
|
|
||||||
needs:
|
|
||||||
- clippy
|
|
||||||
- format
|
|
||||||
- spell-check
|
|
||||||
- readme
|
|
||||||
if: always()
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- run: for result in ${{ join(needs.*.result, ' ') }}; do [ $result = success ]; done
|
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: ${{ github.ref == 'refs/heads/main' && 'release' || '' }}
|
environment: ${{ github.ref == 'refs/heads/main' && 'release' || '' }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
- uses: swatinem/rust-cache@v2
|
||||||
- run: cargo install cargo-workspaces
|
- run: cargo install cargo-workspaces
|
||||||
- uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5
|
- uses: rust-lang/crates-io-auth-action@v1
|
||||||
id: auth
|
id: auth
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
- run: >
|
- run: >
|
||||||
|
|||||||
+29
-54
@@ -6,59 +6,34 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
- ubuntu-26.04-arm
|
|
||||||
- macos-latest
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- uses: ./.github/actions/setup
|
|
||||||
- run: cargo build
|
|
||||||
unit_test:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
- ubuntu-26.04-arm
|
|
||||||
- macos-latest
|
|
||||||
options:
|
|
||||||
-
|
|
||||||
- --no-default-features --features cmake
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- uses: ./.github/actions/setup
|
|
||||||
- run: cargo test ${{ matrix.options }}
|
|
||||||
examples:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
- ubuntu-26.04-arm
|
|
||||||
- macos-latest
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- uses: ./.github/actions/setup
|
|
||||||
- run: tools/example_test.sh
|
|
||||||
test:
|
|
||||||
needs:
|
|
||||||
- build
|
|
||||||
- unit_test
|
|
||||||
- examples
|
|
||||||
if: always()
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: for result in ${{ join(needs.*.result, ' ') }}; do [ $result = success ]; done
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: swatinem/rust-cache@v2
|
||||||
|
- run: cargo build
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: swatinem/rust-cache@v2
|
||||||
|
- run: cargo test
|
||||||
|
examples:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: swatinem/rust-cache@v2
|
||||||
|
- run: tools/example_test.sh
|
||||||
|
cmake:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: swatinem/rust-cache@v2
|
||||||
|
- run: cargo build --no-default-features --features cmake
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
.cargo_cache
|
.cargo_cache
|
||||||
target
|
target
|
||||||
|
.direnv
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[submodule "vendor/bdwgc"]
|
[submodule "vendor/bdwgc"]
|
||||||
path = bdwgc-alloc-sys/vendor/bdwgc
|
path = vendor/bdwgc
|
||||||
url = https://github.com/bdwgc/bdwgc
|
url = https://github.com/bdwgc/bdwgc
|
||||||
[submodule "vendor/libatomic_ops"]
|
[submodule "vendor/libatomic_ops"]
|
||||||
path = bdwgc-alloc-sys/vendor/libatomic_ops
|
path = vendor/libatomic_ops
|
||||||
url = https://github.com/bdwgc/libatomic_ops
|
url = https://github.com/bdwgc/libatomic_ops
|
||||||
|
|||||||
Generated
+5
-208
@@ -2,15 +2,6 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aho-corasick"
|
|
||||||
version = "1.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autotools"
|
name = "autotools"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
@@ -22,45 +13,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bdwgc-alloc"
|
name = "bdwgc-alloc"
|
||||||
version = "0.6.15"
|
version = "0.6.13"
|
||||||
dependencies = [
|
|
||||||
"bdwgc-alloc-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bdwgc-alloc-sys"
|
|
||||||
version = "0.6.15"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autotools",
|
"autotools",
|
||||||
"bindgen",
|
|
||||||
"cmake",
|
"cmake",
|
||||||
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bindgen"
|
|
||||||
version = "0.73.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "787ef8ef523575546b106a58213d6e6b06198a05c2f757258c68a74273670cfa"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"cexpr",
|
|
||||||
"clang-sys",
|
|
||||||
"log",
|
|
||||||
"prettyplease",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"regex",
|
|
||||||
"rustc-hash",
|
|
||||||
"shlex 2.0.1",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "2.13.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.49"
|
version = "1.2.49"
|
||||||
@@ -68,33 +27,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215"
|
checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"shlex 1.3.0",
|
"shlex",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cexpr"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
|
||||||
dependencies = [
|
|
||||||
"nom",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "1.0.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clang-sys"
|
|
||||||
version = "1.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
|
|
||||||
dependencies = [
|
|
||||||
"glob",
|
|
||||||
"libc",
|
|
||||||
"libloading",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -133,118 +66,11 @@ dependencies = [
|
|||||||
"bdwgc-alloc",
|
"bdwgc-alloc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glob"
|
|
||||||
version = "0.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.189"
|
version = "0.2.186"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libloading"
|
|
||||||
version = "0.8.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"windows-link",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "log"
|
|
||||||
version = "0.4.34"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memchr"
|
|
||||||
version = "2.8.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "minimal-lexical"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nom"
|
|
||||||
version = "7.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
"minimal-lexical",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "prettyplease"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.107"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.47"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex"
|
|
||||||
version = "1.13.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
|
||||||
dependencies = [
|
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-automata",
|
|
||||||
"regex-syntax",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-automata"
|
|
||||||
version = "0.4.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
|
||||||
dependencies = [
|
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-syntax",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-syntax"
|
|
||||||
version = "0.8.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-hash"
|
|
||||||
version = "2.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "shlex"
|
||||||
@@ -252,38 +78,9 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "shlex"
|
|
||||||
version = "2.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "static_threads"
|
name = "static_threads"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bdwgc-alloc",
|
"bdwgc-alloc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "3.0.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-ident"
|
|
||||||
version = "1.0.26"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-link"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
||||||
|
|||||||
+20
-12
@@ -1,21 +1,29 @@
|
|||||||
|
[package]
|
||||||
|
name = "bdwgc-alloc"
|
||||||
|
version = "0.6.13"
|
||||||
|
edition = "2024"
|
||||||
|
description = "impl GlobalAlloc for bdwgc"
|
||||||
|
repository = "https://github.com/raviqqe/bdwgc-alloc"
|
||||||
|
license = "MIT"
|
||||||
|
categories = ["api-bindings", "memory-management", "no-std", "no-std::no-alloc"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "3"
|
resolver = "3"
|
||||||
members = ["bdwgc-alloc", "bdwgc-alloc-sys", "examples/*"]
|
members = ["examples/*"]
|
||||||
default-members = ["bdwgc-alloc", "bdwgc-alloc-sys"]
|
|
||||||
|
|
||||||
[workspace.package]
|
[dependencies]
|
||||||
version = "0.6.15"
|
libc = "0.2.186"
|
||||||
edition = "2024"
|
|
||||||
repository = "https://github.com/bdwgc/bdwgc-rust"
|
|
||||||
license = "MIT"
|
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[build-dependencies]
|
||||||
|
autotools = { version = "0.2.7", optional = true }
|
||||||
|
cmake = { version = "0.1.58", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["autotools"]
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
alloc_instead_of_core = "deny"
|
alloc_instead_of_core = "deny"
|
||||||
dbg_macro = "deny"
|
dbg_macro = "deny"
|
||||||
missing_const_for_fn = "deny"
|
missing_const_for_fn = "deny"
|
||||||
std_instead_of_alloc = "deny"
|
std_instead_of_alloc = "deny"
|
||||||
std_instead_of_core = "deny"
|
std_instead_of_core = "deny"
|
||||||
|
|
||||||
[workspace.lints.rust]
|
|
||||||
missing_docs = "deny"
|
|
||||||
warnings = "deny"
|
|
||||||
|
|||||||
@@ -2,17 +2,15 @@
|
|||||||
|
|
||||||
[](https://github.com/bdwgc/bdwgc-rust/actions)
|
[](https://github.com/bdwgc/bdwgc-rust/actions)
|
||||||
[](https://crates.io/crates/bdwgc-alloc)
|
[](https://crates.io/crates/bdwgc-alloc)
|
||||||
[](https://github.com/bdwgc/bdwgc-rust/blob/main/LICENSE)
|
[](LICENSE)
|
||||||
|
|
||||||
[`GlobalAlloc`](https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html) implementation for [`bdwgc`][bdwgc], the conservative garbage collector.
|
[`GlobalAlloc`](https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html) implementation for [`bdwgc`][bdwgc], the conservative garbage collector.
|
||||||
|
|
||||||
This crate is for use cases in which developers need to integrate [`bdwgc`][bdwgc] into their programs written in Rust (e.g. writing a runtime library in Rust for their own programming language whose GC is done by [`bdwgc`][bdwgc].)
|
This crate is for use cases in which developers need to integrate [`bdwgc`][bdwgc] into their programs written in Rust (e.g. writing a runtime library in Rust for their own programming language whose GC is done by [`bdwgc`][bdwgc].)
|
||||||
|
|
||||||
The raw bindings to the C API of [`bdwgc`][bdwgc] that this crate is built on are available as the `bdwgc-alloc-sys` crate.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
See [`examples`](https://github.com/bdwgc/bdwgc-rust/tree/main/examples) directory.
|
See [`examples`](examples) directory.
|
||||||
|
|
||||||
By default [`bdwgc`][bdwgc] is built with autotools. To build with cmake, enable the `cmake` feature:
|
By default [`bdwgc`][bdwgc] is built with autotools. To build with cmake, enable the `cmake` feature:
|
||||||
|
|
||||||
@@ -22,6 +20,6 @@ cargo build --no-default-features --features cmake
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT](https://github.com/bdwgc/bdwgc-rust/blob/main/LICENSE)
|
[MIT](LICENSE)
|
||||||
|
|
||||||
[bdwgc]: https://github.com/bdwgc/bdwgc
|
[bdwgc]: https://github.com/bdwgc/bdwgc
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "bdwgc-alloc-sys"
|
|
||||||
version.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
description = "Rust bindings to the bdwgc C API"
|
|
||||||
documentation = "https://bdwgc.github.io/bdwgc-rust/bdwgc_alloc_sys/"
|
|
||||||
repository.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
categories = ["external-ffi-bindings", "memory-management", "no-std", "no-std::no-alloc"]
|
|
||||||
links = "gc"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
autotools = { version = "0.2.7", optional = true }
|
|
||||||
bindgen = "0.73.2"
|
|
||||||
cmake = { version = "0.1.58", optional = true }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["autotools"]
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[[test]]
|
|
||||||
name = "collector"
|
|
||||||
harness = false
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# bdwgc-alloc-sys
|
|
||||||
|
|
||||||
[](https://github.com/bdwgc/bdwgc-rust/actions)
|
|
||||||
[](https://github.com/bdwgc/bdwgc-rust/blob/main/LICENSE)
|
|
||||||
|
|
||||||
Rust bindings to the C API of [`bdwgc`][bdwgc], the conservative garbage collector.
|
|
||||||
|
|
||||||
This crate builds [`bdwgc`][bdwgc] from its vendored source and links it statically. The bindings are generated from its headers at build time by [`bindgen`](https://github.com/rust-lang/rust-bindgen), which requires `libclang`.
|
|
||||||
|
|
||||||
See the [`bdwgc-alloc`](https://crates.io/crates/bdwgc-alloc) crate for a [`GlobalAlloc`](https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html) implementation on top of these bindings.
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cargo add bdwgc-alloc-sys
|
|
||||||
```
|
|
||||||
|
|
||||||
By default [`bdwgc`][bdwgc] is built with autotools. To build with cmake, enable the `cmake` feature:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cargo add bdwgc-alloc-sys --no-default-features --features cmake
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
[MIT](https://github.com/bdwgc/bdwgc-rust/blob/main/LICENSE)
|
|
||||||
|
|
||||||
[bdwgc]: https://github.com/bdwgc/bdwgc
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
//! A build script.
|
|
||||||
|
|
||||||
use core::error::Error;
|
|
||||||
use std::{env, path::PathBuf};
|
|
||||||
|
|
||||||
// cspell: ignore reconf
|
|
||||||
|
|
||||||
const LIB_ATOMIC_OPS_DIR: &str = "vendor/libatomic_ops";
|
|
||||||
const LIB_GC_DIR: &str = "vendor/bdwgc";
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
|
||||||
build_library()?;
|
|
||||||
|
|
||||||
bindgen::builder()
|
|
||||||
.header(format!("{LIB_GC_DIR}/include/gc.h"))
|
|
||||||
.clang_arg(format!("-I{LIB_GC_DIR}/include"))
|
|
||||||
.clang_arg("-DGC_THREADS")
|
|
||||||
.use_core()
|
|
||||||
.allowlist_item("GC_.*")
|
|
||||||
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed)
|
|
||||||
.generate()?
|
|
||||||
.write_to_file(PathBuf::from(env::var("OUT_DIR")?).join("bindings.rs"))?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg_select! {
|
|
||||||
feature = "cmake" => {
|
|
||||||
fn build_library() -> Result<(), Box<dyn Error>> {
|
|
||||||
use cmake::Config;
|
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
let libatomic_include_path = Path::new(LIB_ATOMIC_OPS_DIR)
|
|
||||||
.join("src")
|
|
||||||
.canonicalize()?
|
|
||||||
.display()
|
|
||||||
.to_string()
|
|
||||||
.replace(r"\\?\", "");
|
|
||||||
|
|
||||||
let dst = Config::new(LIB_GC_DIR)
|
|
||||||
.profile("Release")
|
|
||||||
.define("GC_BUILD_SHARED_LIBS", "FALSE")
|
|
||||||
.cflag(format!("-I{}", libatomic_include_path))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
println!(
|
|
||||||
"cargo:rustc-link-search=native={}",
|
|
||||||
dst.join("lib").display()
|
|
||||||
);
|
|
||||||
println!("cargo:rustc-link-lib=static=gc");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
feature = "autotools" => {
|
|
||||||
fn build_library() -> Result<(), Box<dyn Error>> {
|
|
||||||
let dst = autotools::Config::new(LIB_ATOMIC_OPS_DIR)
|
|
||||||
.reconf("-i")
|
|
||||||
.cflag("-fPIC")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
println!(
|
|
||||||
"cargo:rustc-link-search=native={}",
|
|
||||||
dst.join("lib").display()
|
|
||||||
);
|
|
||||||
println!("cargo:rustc-link-lib=static=atomic_ops");
|
|
||||||
|
|
||||||
let dst = autotools::Config::new(LIB_GC_DIR)
|
|
||||||
.reconf("-i")
|
|
||||||
.cflag(format!(
|
|
||||||
// spell-checker: disable-next-line
|
|
||||||
"-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC",
|
|
||||||
dst.join("include").display()
|
|
||||||
))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
println!(
|
|
||||||
"cargo:rustc-link-search=native={}",
|
|
||||||
dst.join("lib").display()
|
|
||||||
);
|
|
||||||
println!("cargo:rustc-link-lib=static=gc");
|
|
||||||
|
|
||||||
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
|
||||||
std::process::Command::new("sh")
|
|
||||||
.arg("-c")
|
|
||||||
.arg(format!("cd {dir} && git clean -dfx"))
|
|
||||||
.output()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#![doc = include_str!("../README.md")]
|
|
||||||
#![no_std]
|
|
||||||
#![allow(missing_docs)]
|
|
||||||
#![allow(non_camel_case_types)]
|
|
||||||
#![allow(non_snake_case)]
|
|
||||||
#![allow(non_upper_case_globals)]
|
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
//! A smoke test of the bindings.
|
|
||||||
|
|
||||||
use bdwgc_alloc_sys::{
|
|
||||||
GC_SUCCESS, GC_allow_register_threads, GC_free, GC_gcollect, GC_get_stack_base, GC_init,
|
|
||||||
GC_malloc, GC_realloc, GC_register_finalizer, GC_register_my_thread, GC_stack_base,
|
|
||||||
GC_unregister_my_thread,
|
|
||||||
};
|
|
||||||
use core::{
|
|
||||||
ffi::c_void,
|
|
||||||
ptr::null_mut,
|
|
||||||
sync::atomic::{AtomicUsize, Ordering},
|
|
||||||
};
|
|
||||||
use std::thread::spawn;
|
|
||||||
|
|
||||||
const TOTAL_COUNT: usize = 1 << 10;
|
|
||||||
|
|
||||||
static FINALIZED_COUNT: AtomicUsize = AtomicUsize::new(0);
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
unsafe {
|
|
||||||
GC_init();
|
|
||||||
GC_allow_register_threads();
|
|
||||||
}
|
|
||||||
|
|
||||||
allocate();
|
|
||||||
finalize();
|
|
||||||
register_thread();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn allocate() {
|
|
||||||
let ptr = unsafe { GC_malloc(42) };
|
|
||||||
assert!(!ptr.is_null());
|
|
||||||
|
|
||||||
let ptr = unsafe { GC_realloc(ptr, 84) };
|
|
||||||
assert!(!ptr.is_null());
|
|
||||||
|
|
||||||
unsafe { GC_free(ptr) };
|
|
||||||
}
|
|
||||||
|
|
||||||
fn finalize() {
|
|
||||||
extern "C" fn count(_object: *mut c_void, _client_data: *mut c_void) {
|
|
||||||
FINALIZED_COUNT.fetch_add(1, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in 0..TOTAL_COUNT {
|
|
||||||
unsafe {
|
|
||||||
GC_register_finalizer(
|
|
||||||
GC_malloc(42),
|
|
||||||
Some(count),
|
|
||||||
null_mut(),
|
|
||||||
null_mut(),
|
|
||||||
null_mut(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe { GC_gcollect() };
|
|
||||||
|
|
||||||
// TODO Is there any way to collect all?
|
|
||||||
assert!(FINALIZED_COUNT.load(Ordering::Relaxed) > TOTAL_COUNT / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn register_thread() {
|
|
||||||
spawn(|| {
|
|
||||||
let mut base = GC_stack_base {
|
|
||||||
mem_base: null_mut(),
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(unsafe { GC_get_stack_base(&mut base) }, GC_SUCCESS);
|
|
||||||
assert_eq!(unsafe { GC_register_my_thread(&base) }, GC_SUCCESS);
|
|
||||||
assert!(!unsafe { GC_malloc(42) }.is_null());
|
|
||||||
assert_eq!(unsafe { GC_unregister_my_thread() }, GC_SUCCESS);
|
|
||||||
})
|
|
||||||
.join()
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
Vendored
-1
Submodule bdwgc-alloc-sys/vendor/bdwgc deleted from 2547e33aa8
@@ -1,20 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "bdwgc-alloc"
|
|
||||||
version.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
description = "impl GlobalAlloc for bdwgc"
|
|
||||||
documentation = "https://bdwgc.github.io/bdwgc-rust/bdwgc_alloc/"
|
|
||||||
repository.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
categories = ["api-bindings", "memory-management", "no-std", "no-std::no-alloc"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bdwgc-alloc-sys = { version = "0.6.15", path = "../bdwgc-alloc-sys", default-features = false }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["autotools"]
|
|
||||||
autotools = ["bdwgc-alloc-sys/autotools"]
|
|
||||||
cmake = ["bdwgc-alloc-sys/cmake"]
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../README.md
|
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
const LIB_ATOMIC_OPS_DIR: &str = "vendor/libatomic_ops";
|
||||||
|
const LIB_GC_DIR: &str = "vendor/bdwgc";
|
||||||
|
|
||||||
|
#[cfg(feature = "autotools")]
|
||||||
|
fn main() {
|
||||||
|
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||||
|
std::process::Command::new("sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(format!("cd {dir} && ./autogen.sh"))
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
let dst = autotools::Config::new(LIB_ATOMIC_OPS_DIR)
|
||||||
|
.cflag("-fPIC")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-search=native={}",
|
||||||
|
dst.join("lib64").display()
|
||||||
|
);
|
||||||
|
println!("cargo:rustc-link-lib=static=atomic_ops");
|
||||||
|
|
||||||
|
let dst = autotools::Config::new(LIB_GC_DIR)
|
||||||
|
.cflag(format!(
|
||||||
|
// spell-checker: disable-next-line
|
||||||
|
"-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC",
|
||||||
|
dst.join("include").display()
|
||||||
|
))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-search=native={}",
|
||||||
|
dst.join("lib64").display()
|
||||||
|
);
|
||||||
|
println!("cargo:rustc-link-lib=static=gc");
|
||||||
|
|
||||||
|
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||||
|
std::process::Command::new("sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(format!("cd {dir} && git clean -dfx"))
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "cmake")]
|
||||||
|
fn main() {
|
||||||
|
use cmake::Config;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
let libatomic_include_path = Path::new(LIB_ATOMIC_OPS_DIR)
|
||||||
|
.join("src")
|
||||||
|
.canonicalize()
|
||||||
|
.unwrap()
|
||||||
|
.display()
|
||||||
|
.to_string()
|
||||||
|
.replace(r"\\?\", "");
|
||||||
|
|
||||||
|
let dst = Config::new(LIB_GC_DIR)
|
||||||
|
.profile("Release")
|
||||||
|
.define("GC_BUILD_SHARED_LIBS", "FALSE")
|
||||||
|
.cflag(format!("-I{}", libatomic_include_path))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-search=native={}",
|
||||||
|
dst.join("lib64").display()
|
||||||
|
);
|
||||||
|
println!("cargo:rustc-link-lib=static=gc");
|
||||||
|
}
|
||||||
@@ -3,17 +3,14 @@
|
|||||||
"autogen",
|
"autogen",
|
||||||
"autotools",
|
"autotools",
|
||||||
"bdwgc",
|
"bdwgc",
|
||||||
"bindgen",
|
|
||||||
"canonicalize",
|
"canonicalize",
|
||||||
"cflag",
|
"cflag",
|
||||||
"clippy",
|
"clippy",
|
||||||
"dealloc",
|
"dealloc",
|
||||||
"finalizer",
|
"finalizer",
|
||||||
"gcollect",
|
"gcollect",
|
||||||
"gitsubmodule",
|
|
||||||
"libatomic",
|
"libatomic",
|
||||||
"libc",
|
"libc",
|
||||||
"libclang",
|
|
||||||
"realloc",
|
"realloc",
|
||||||
"repr",
|
"repr",
|
||||||
"rustc",
|
"rustc",
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ edition = "2024"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bdwgc-alloc = { path = "../../bdwgc-alloc" }
|
bdwgc-alloc = { path = "../.." }
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ edition = "2024"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bdwgc-alloc = { path = "../../bdwgc-alloc" }
|
bdwgc-alloc = { path = "../.." }
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ edition = "2024"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bdwgc-alloc = { path = "../../bdwgc-alloc" }
|
bdwgc-alloc = { path = "../.." }
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ edition = "2024"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bdwgc-alloc = { path = "../../bdwgc-alloc" }
|
bdwgc-alloc = { path = "../.." }
|
||||||
|
|||||||
Generated
+66
@@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"fenix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1779185128,
|
||||||
|
"narHash": "sha256-Kl2bkmwZJD3n2KWDxuIlturZ7emqRK+anpD1LmDwpmY=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "b7bd9323fe26a3b4f4bddbb2c2a1dacabced2f88",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1778869304,
|
||||||
|
"narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "d233902339c02a9c334e7e593de68855ad26c4cb",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"fenix": "fenix",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-analyzer-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1779074864,
|
||||||
|
"narHash": "sha256-0M3WqsWmtXmv9Ev/vnFfCHosWvISDwiuuhQ104UO3CI=",
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"rev": "cdfe408d4b436e806ff525cb3e67588a6a009ed1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
fenix = {
|
||||||
|
url = "github:nix-community/fenix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, fenix, ... }:
|
||||||
|
let
|
||||||
|
supportedSystems = [
|
||||||
|
"aarch64-darwin" "aarch64-linux"
|
||||||
|
"x86_64-darwin" "x86_64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
each-system = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
inherit system;
|
||||||
|
});
|
||||||
|
|
||||||
|
overlays = [
|
||||||
|
fenix.overlays.default
|
||||||
|
];
|
||||||
|
|
||||||
|
in {
|
||||||
|
_pkgs = each-system ({ pkgs, ... }: pkgs);
|
||||||
|
|
||||||
|
devShells = each-system ({ pkgs, lib, ... }: {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
pkgs.pkg-config
|
||||||
|
(pkgs.fenix.complete.withComponents [
|
||||||
|
"cargo" "clippy" "rust-src" "rustc" "rustfmt"
|
||||||
|
])
|
||||||
|
pkgs.rust-analyzer-nightly
|
||||||
|
pkgs.cmake
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
nixConfig = {
|
||||||
|
extra-substituters = [
|
||||||
|
"https://fenix.cachix.org"
|
||||||
|
];
|
||||||
|
extra-trusted-public-keys = [
|
||||||
|
"fenix.cachix.org-1:ecJhr+RdYEdcVgUkjruiYhjbBloIEGov7bos90cZi0Q="
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,18 +3,41 @@
|
|||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
use bdwgc_alloc_sys::{
|
use core::alloc::{GlobalAlloc, Layout};
|
||||||
GC_SUCCESS, GC_alloc_lock, GC_alloc_unlock, GC_allow_register_threads, GC_free, GC_gcollect,
|
use core::ptr::null;
|
||||||
GC_get_stack_base, GC_init, GC_malloc, GC_realloc, GC_register_finalizer,
|
use libc::{c_int, c_void, size_t};
|
||||||
GC_register_my_thread, GC_set_stackbottom, GC_stack_base, GC_unregister_my_thread,
|
|
||||||
};
|
const GC_SUCCESS: c_int = 0;
|
||||||
use core::{
|
|
||||||
alloc::{GlobalAlloc, Layout},
|
#[repr(C)]
|
||||||
ffi::c_void,
|
struct GcStackBase {
|
||||||
ptr::null_mut,
|
mem_base: *const c_void,
|
||||||
};
|
// TODO: Add reg_base field to support IA64.
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "gc", kind = "static")]
|
||||||
|
unsafe extern "C" {
|
||||||
|
fn GC_allow_register_threads();
|
||||||
|
fn GC_alloc_lock();
|
||||||
|
fn GC_alloc_unlock();
|
||||||
|
fn GC_free(ptr: *mut c_void);
|
||||||
|
fn GC_get_stack_base(stack_base: *mut GcStackBase) -> c_int;
|
||||||
|
fn GC_init();
|
||||||
|
fn GC_malloc(size: size_t) -> *mut c_void;
|
||||||
|
fn GC_realloc(ptr: *mut c_void, size: size_t) -> *mut c_void;
|
||||||
|
fn GC_register_my_thread(stack_base: *const GcStackBase) -> c_int;
|
||||||
|
fn GC_set_stackbottom(thread: *const c_void, stack_bottom: *const GcStackBase);
|
||||||
|
fn GC_unregister_my_thread();
|
||||||
|
fn GC_gcollect();
|
||||||
|
fn GC_register_finalizer(
|
||||||
|
ptr: *const c_void,
|
||||||
|
finalizer: extern "C" fn(*mut c_void, *mut c_void),
|
||||||
|
client_data: *const c_void,
|
||||||
|
opt_old_finalizer: *const c_void,
|
||||||
|
opt_old_client_data: *const c_void,
|
||||||
|
) -> *mut c_void;
|
||||||
|
}
|
||||||
|
|
||||||
/// An allocator.
|
|
||||||
pub struct Allocator;
|
pub struct Allocator;
|
||||||
|
|
||||||
impl Allocator {
|
impl Allocator {
|
||||||
@@ -46,9 +69,7 @@ impl Allocator {
|
|||||||
///
|
///
|
||||||
/// This function must not be called in a main thread.
|
/// This function must not be called in a main thread.
|
||||||
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
|
pub unsafe fn register_current_thread() -> Result<(), error::Error> {
|
||||||
let mut base = GC_stack_base {
|
let mut base = GcStackBase { mem_base: null() };
|
||||||
mem_base: null_mut(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if unsafe { 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"));
|
||||||
@@ -70,9 +91,9 @@ impl Allocator {
|
|||||||
pub unsafe fn set_stack_bottom(bottom: *const u8) {
|
pub unsafe fn set_stack_bottom(bottom: *const u8) {
|
||||||
unsafe {
|
unsafe {
|
||||||
GC_set_stackbottom(
|
GC_set_stackbottom(
|
||||||
null_mut(),
|
null(),
|
||||||
&GC_stack_base {
|
&GcStackBase {
|
||||||
mem_base: bottom.cast_mut().cast(),
|
mem_base: bottom as *const libc::c_void,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -84,7 +105,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() {
|
||||||
unsafe { GC_unregister_my_thread() };
|
unsafe { GC_unregister_my_thread() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs a garbage collection forcibly.
|
/// Runs a garbage collection forcibly.
|
||||||
@@ -102,15 +123,7 @@ 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,
|
||||||
) {
|
) {
|
||||||
unsafe {
|
unsafe { GC_register_finalizer(ptr, finalizer, client_data, null(), null()) };
|
||||||
GC_register_finalizer(
|
|
||||||
ptr.cast_mut(),
|
|
||||||
Some(finalizer),
|
|
||||||
client_data.cast_mut(),
|
|
||||||
null_mut(),
|
|
||||||
null_mut(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+1
Submodule vendor/bdwgc added at 82028767b4
Reference in New Issue
Block a user