mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 06:17:56 +00:00
Correct implementation of memcmp
This commit is contained in:
Generated
+1
-7
@@ -498,11 +498,6 @@ dependencies = [
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memcmp"
|
||||
version = "0.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "memorydb"
|
||||
version = "0.1.1"
|
||||
@@ -731,7 +726,7 @@ dependencies = [
|
||||
"assert_matches 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memcmp 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"native-runtime 0.1.0",
|
||||
"parity-wasm 0.15.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"polkadot-primitives 0.1.0",
|
||||
@@ -1339,7 +1334,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
|
||||
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
||||
"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||
"checksum memcmp 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1b44fee357b6a05a9e22554ded6c1bbe57844b58190295257ac0ad4c5944e1"
|
||||
"checksum memorydb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "013b7e4c5e10c764936ebc6bd3662d8e3c92292d267bf6a42ef3f5cad9c793ee"
|
||||
"checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd"
|
||||
"checksum mio 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0e8411968194c7b139e9105bc4ae7db0bae232af087147e72f0616ebf5fdb9cb"
|
||||
|
||||
@@ -15,7 +15,7 @@ byteorder = "1.1"
|
||||
rustc-hex = "1.0.0"
|
||||
native-runtime = { path = "../native-runtime", version = "0.1" }
|
||||
runtime-std = { path = "../native-runtime/std", version = "0.1" }
|
||||
memcmp = { version = "0.0.6" }
|
||||
libc = { version = "0.2.33" }
|
||||
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.1"
|
||||
|
||||
@@ -59,5 +59,11 @@ error_chain! {
|
||||
description("runtime failure"),
|
||||
display("Runtime error"),
|
||||
}
|
||||
|
||||
/// Runtime failed.
|
||||
InvalidMemoryReference {
|
||||
description("invalid memory reference"),
|
||||
display("Invalid memory reference"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ extern crate byteorder;
|
||||
extern crate rustc_hex;
|
||||
extern crate native_runtime;
|
||||
extern crate runtime_std;
|
||||
extern crate memcmp;
|
||||
extern crate libc;
|
||||
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
//! Rust implementation of Polkadot contracts.
|
||||
|
||||
use libc::{memcmp, c_void};
|
||||
use std::sync::Arc;
|
||||
use std::collections::HashMap;
|
||||
use parity_wasm::{deserialize_buffer, ModuleInstanceInterface, ProgramInstance};
|
||||
use parity_wasm::interpreter::{ItemIndex};
|
||||
use parity_wasm::interpreter::{ItemIndex, DummyUserError};
|
||||
use parity_wasm::RuntimeValue::{I32, I64};
|
||||
use primitives::contract::CallData;
|
||||
use state_machine::{Externalities, CodeExecutor};
|
||||
@@ -96,10 +97,13 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
|
||||
ext_memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 => {
|
||||
if let (Ok(sl1), Ok(sl2))
|
||||
= (this.memory.get(s1, n as usize), this.memory.get(s2, n as usize)) {
|
||||
use memcmp::Memcmp;
|
||||
(&sl1).memcmp(&sl2) as i32
|
||||
unsafe {
|
||||
memcmp(sl1.as_ptr() as *const u8 as *const c_void,
|
||||
sl2.as_ptr() as *const u8 as *const c_void,
|
||||
n as usize) as i32
|
||||
}
|
||||
} else {
|
||||
0
|
||||
return Err(DummyUserError.into());
|
||||
}
|
||||
},
|
||||
ext_memcpy(dest: *mut u8, src: *const u8, count: usize) -> *mut u8 => {
|
||||
|
||||
@@ -22,7 +22,7 @@ pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut
|
||||
ext_memcpy(dest, src, n)
|
||||
}
|
||||
|
||||
/// memcpy extern
|
||||
/// memcmp extern
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
|
||||
ext_memcmp(s1, s2, n)
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user