|
|
@@ -13,14 +13,19 @@
|
|
|
#include "bh_platform.h"
|
|
|
|
|
|
extern "C" {
|
|
|
-typedef void (*os_print_function_t)(const char *message);
|
|
|
+typedef int (*os_print_function_t)(const char *message);
|
|
|
extern void
|
|
|
os_set_print_function(os_print_function_t pf);
|
|
|
|
|
|
-void
|
|
|
+int
|
|
|
enclave_print(const char *message)
|
|
|
{
|
|
|
- ocall_print(message);
|
|
|
+ int bytes_written = 0;
|
|
|
+
|
|
|
+ if (SGX_SUCCESS != ocall_print(&bytes_written, message))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ return bytes_written;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -589,16 +594,16 @@ ecall_iwasm_main(uint8_t *wasm_file_buf, uint32_t wasm_file_size)
|
|
|
|
|
|
/* initialize runtime environment */
|
|
|
if (!wasm_runtime_full_init(&init_args)) {
|
|
|
- ocall_print("Init runtime environment failed.");
|
|
|
- ocall_print("\n");
|
|
|
+ enclave_print("Init runtime environment failed.");
|
|
|
+ enclave_print("\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
/* load WASM module */
|
|
|
if (!(wasm_module = wasm_runtime_load(wasm_file_buf, wasm_file_size,
|
|
|
error_buf, sizeof(error_buf)))) {
|
|
|
- ocall_print(error_buf);
|
|
|
- ocall_print("\n");
|
|
|
+ enclave_print(error_buf);
|
|
|
+ enclave_print("\n");
|
|
|
goto fail1;
|
|
|
}
|
|
|
|
|
|
@@ -606,16 +611,16 @@ ecall_iwasm_main(uint8_t *wasm_file_buf, uint32_t wasm_file_size)
|
|
|
if (!(wasm_module_inst =
|
|
|
wasm_runtime_instantiate(wasm_module, 16 * 1024, 16 * 1024,
|
|
|
error_buf, sizeof(error_buf)))) {
|
|
|
- ocall_print(error_buf);
|
|
|
- ocall_print("\n");
|
|
|
+ enclave_print(error_buf);
|
|
|
+ enclave_print("\n");
|
|
|
goto fail2;
|
|
|
}
|
|
|
|
|
|
/* execute the main function of wasm app */
|
|
|
wasm_application_execute_main(wasm_module_inst, 0, NULL);
|
|
|
if ((exception = wasm_runtime_get_exception(wasm_module_inst))) {
|
|
|
- ocall_print(exception);
|
|
|
- ocall_print("\n");
|
|
|
+ enclave_print(exception);
|
|
|
+ enclave_print("\n");
|
|
|
}
|
|
|
|
|
|
/* destroy the module instance */
|