Skip to content

Commit

Permalink
Dummy atomic support (#92)
Browse files Browse the repository at this point in the history
* Dummy atomic implementation
make some crates(like bytes, log) work on ckb-vm
  • Loading branch information
XuJiandong committed Jun 13, 2024
1 parent 56c7541 commit da5a078
Show file tree
Hide file tree
Showing 10 changed files with 959 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ dlopen-c = ["libc"]
build-with-clang = []
libc = []
ckb2023 = []
# work with `target-feature=-a` Cargo flag
dummy-atomic = []

[build-dependencies]
cc = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This library contains several modules that help you write CKB contract with Rust
* `debug!` macro: a `println!` like macro helps debugging
* `entry!` macro: defines contract entry point
* `default_alloc!` macro: defines global allocator for no-std rust

* `dummy_atomic` module: dummy atomic operations
### Memory allocator

Default allocator uses a mixed allocation strategy:
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ fn main() {
setup_compiler_flags(&mut build);
build.compile("libc");
}
if target_arch != "riscv64" && cfg!(feature = "dummy-atomic") {
println!("cargo:warning=This build script intentionally failed: feature `dummy-atomic` can't be used in non risc-v target");
std::process::exit(1);
}
}

fn setup_compiler_flags(build: &mut cc::Build) {
Expand Down
14 changes: 14 additions & 0 deletions contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion contracts/ckb-std-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ckb-std = { path = "../../", features = [ "dlopen-c" ] }
ckb-std = { path = "../../", features = [ "dlopen-c", "dummy-atomic" ] }
blake2b-ref = { version = "0.3", default-features = false }
bytes = { version = "1.6.0", default-features = false }
log = { version = "0.4.17", default-features = false }
Loading

0 comments on commit da5a078

Please sign in to comment.