Skip to content

Commit b76f511

Browse files
author
Bingle
committed
[WIP] Update median to support floats
1 parent 72774ea commit b76f511

File tree

8 files changed

+330
-17
lines changed

8 files changed

+330
-17
lines changed

app/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern "C" {
3333
retval: *mut sgx_status_t,
3434
binary: *const u8,
3535
binary_len: usize,
36-
result_out: *mut i32,
36+
result_out: *mut f32,
3737
) -> sgx_status_t;
3838
}
3939

@@ -72,7 +72,7 @@ fn main() {
7272

7373
let binary = fs::read(WASM_FILE).unwrap();
7474

75-
let mut result_out = 0i32;
75+
let mut result_out = 0f32;
7676

7777
let result = unsafe {
7878
exec_wasm_test(

enclave/Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enclave/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ default = []
1313
[dependencies]
1414
wasmi-impl = { path = "../wasmi-impl" }
1515
wasmi = { version = "0.11.0", default-features = false }
16+
serde-json-wasm = "0.3.2"
1617

1718
[target.'cfg(not(target_env = "sgx"))'.dependencies] # You can remove what you don't need, except types and tstd
1819
sgx_types = { git = "https://github.com/apache/teaclave-sgx-sdk.git" }

enclave/Enclave.edl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enclave {
2626
trusted
2727
{
2828
/* ECALLs */
29-
public sgx_status_t exec_wasm_test([in, count=binary_len] const uint8_t* binary, size_t binary_len, [out] int32_t* result_out);
29+
public sgx_status_t exec_wasm_test([in, count=binary_len] const uint8_t* binary, size_t binary_len, [out] float* result_out);
3030
};
3131
untrusted
3232
{

enclave/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ use std::slice;
4040
pub unsafe extern "C" fn exec_wasm_test(
4141
binary: *const u8,
4242
binary_len: usize,
43-
result_out: *mut i32,
43+
result_out: *mut f32,
4444
) -> sgx_status_t {
4545
if binary.is_null() {
4646
return sgx_status_t::SGX_ERROR_INVALID_PARAMETER;
4747
}
4848
// Safety: SGX generated code will check that the pointer is valid.
4949
let binary_slice = unsafe { slice::from_raw_parts(binary, binary_len) };
50-
let data = b"[1,2,3,4,5]";
50+
let data = b"[1.24,2.0,3.4,4.7,5.5]";
5151
unsafe {
5252
*result_out = match wasmi_impl::exec_wasm_with_data(binary_slice, data) {
53-
Ok(Some(wasmi::RuntimeValue::I32(ret))) => ret,
53+
Ok(Some(wasmi::RuntimeValue::F32(ret))) => ret.to_float(),
5454
Ok(_) | Err(_) => return sgx_status_t::SGX_ERROR_UNEXPECTED,
5555
}
5656
};

0 commit comments

Comments
 (0)