Skip to content

Commit 2ce778f

Browse files
committed
chore: support ckb2021
1 parent 98985a2 commit 2ce778f

File tree

8 files changed

+36
-24
lines changed

8 files changed

+36
-24
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ckb-std"
3-
version = "0.7.4"
3+
version = "0.8.0"
44
authors = ["Nervos network"]
55
edition = "2018"
66
license = "MIT"
@@ -19,6 +19,6 @@ simulator = [ "ckb-x64-simulator" ]
1919
cc = "1.0"
2020

2121
[dependencies]
22-
ckb-types = { package = "ckb-standalone-types", version = "0.0.1-pre.1", default-features = false, optional = true }
22+
ckb-types = { package = "ckb-standalone-types", version = "0.1.1", default-features = false, optional = true }
2323
buddy-alloc = { version = "0.4.1", optional = true }
24-
ckb-x64-simulator = { version = "0.4.0", optional = true }
24+
ckb-x64-simulator = { version = "0.5.0", optional = true }

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TARGET := riscv64imac-unknown-none-elf
2-
DOCKER_IMAGE := jjy0/ckb-capsule-recipe-rust:2020-9-28
2+
DOCKER_IMAGE := thewawar/ckb-capsule:2021-08-16
33
CC := riscv64-unknown-elf-gcc
44

55
default: integration-in-docker

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ fn main() {
2828
cc::Build::new()
2929
.file("src/asm/syscall.S")
3030
.compile("ckb-syscall");
31-
build.
32-
flag("-Wno-nonnull-compare")
31+
build
32+
.flag("-Wno-nonnull-compare")
3333
.flag("-nostartfiles")
3434
.compile("dl-c-impl");
3535
} else {

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2020-09-28
1+
nightly-2021-08-16

src/dynamic_loading_c_impl.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
use crate::error::SysError;
21
use crate::debug;
2+
use crate::error::SysError;
3+
use core::ffi::c_void;
34
use core::marker::PhantomData;
45
use core::mem::{size_of, zeroed};
5-
use core::ffi::c_void;
66
use core::ptr::null;
77

8-
#[link(name = "dl-c-impl", kind="static")]
8+
#[link(name = "dl-c-impl", kind = "static")]
99
extern "C" {
10-
fn ckb_dlopen2(dep_cell_hash: *const u8, hash_type: u8,
11-
aligned_addr: *mut u8, aligned_size: usize, handle: *mut *const c_void,
12-
consumed_size: *mut usize) -> isize;
10+
fn ckb_dlopen2(
11+
dep_cell_hash: *const u8,
12+
hash_type: u8,
13+
aligned_addr: *mut u8,
14+
aligned_size: usize,
15+
handle: *mut *const c_void,
16+
consumed_size: *mut usize,
17+
) -> isize;
1318
fn ckb_dlsym(handle: *const c_void, symbol: *const u8) -> usize;
1419
}
1520

@@ -91,7 +96,10 @@ impl Library {
9196
}
9297
let ptr = ckb_dlsym(self.handle, s.as_ptr());
9398
if ptr == 0 {
94-
debug!("warning, ckb_dlsym returns 0, handle = {:?}, symbol = {:?}", self.handle, symbol);
99+
debug!(
100+
"warning, ckb_dlsym returns 0, handle = {:?}, symbol = {:?}",
101+
self.handle, symbol
102+
);
95103
None
96104
} else {
97105
Some(Symbol::new(ptr))
@@ -102,7 +110,6 @@ impl Library {
102110
const RISCV_PGSIZE_SHIFT: usize = 12;
103111
const RISCV_PGSIZE: usize = 1 << RISCV_PGSIZE_SHIFT; // 4096
104112

105-
106113
#[repr(C)]
107114
#[repr(align(4096))]
108115
pub struct CKBDLContext<T>(T);
@@ -126,14 +133,20 @@ impl<T> CKBDLContext<T> {
126133
}
127134

128135
unsafe {
129-
let mut handle : *const c_void = null();
130-
let mut consumed_size : usize = 0;
131-
let hash_type : u8 = 0;
136+
let mut handle: *const c_void = null();
137+
let mut consumed_size: usize = 0;
138+
let hash_type: u8 = 0;
132139
let mut library = Library::new();
133140
let aligned_size = size;
134141
let aligned_addr = (&mut self.0 as *mut T).cast::<u8>().add(offset);
135-
let code = ckb_dlopen2(dep_cell_data_hash.as_ptr(), hash_type, aligned_addr,
136-
aligned_size, &mut handle as *mut *const c_void, &mut consumed_size as *mut usize);
142+
let code = ckb_dlopen2(
143+
dep_cell_data_hash.as_ptr(),
144+
hash_type,
145+
aligned_addr,
146+
aligned_size,
147+
&mut handle as *mut *const c_void,
148+
&mut consumed_size as *mut usize,
149+
);
137150
if code != 0 {
138151
debug!("warning, ckb_dlopen2 return {:?}", code);
139152
return Err(Error::OpenFailed(code));

test/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ edition = "2018"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
ckb-tool = "0.3"
11-
ckb-testtool = "0.3"
10+
ckb-testtool = "0.5"

test/contract/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2018"
88

99
[dependencies]
1010
ckb-std = { path = "../.." }
11-
blake2b-ref = { version = "0.1", default-features = false }
11+
blake2b-ref = { version = "0.3", default-features = false }
1212

1313
[build-dependencies]
1414
blake2b-rs = "0.1.5"

test/src/contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use ckb_testtool::context::Context;
2-
use ckb_tool::ckb_types::{bytes::Bytes, core::TransactionBuilder, packed::*, prelude::*};
2+
use ckb_testtool::ckb_types::{bytes::Bytes, core::TransactionBuilder, packed::*, prelude::*};
33
use std::fs::File;
44
use std::io::Read;
55

0 commit comments

Comments
 (0)