Use one libc wrapper copy for sgx and other platforms (#107)
And remove bh_printf macro for other platform header files
This commit is contained in:
@ -414,7 +414,7 @@ sprintf_out(int c, struct str_context *ctx)
|
||||
static int
|
||||
printf_out(int c, struct str_context *ctx)
|
||||
{
|
||||
printf("%c", c);
|
||||
bh_printf("%c", c);
|
||||
ctx->count++;
|
||||
return c;
|
||||
}
|
||||
@ -542,13 +542,13 @@ _puts_wrapper(int32 str_offset)
|
||||
return 0;
|
||||
|
||||
str = addr_app_to_native(str_offset);
|
||||
return printf("%s\n", str);
|
||||
return bh_printf("%s\n", str);
|
||||
}
|
||||
|
||||
static int
|
||||
_putchar_wrapper(int c)
|
||||
{
|
||||
printf("%c", c);
|
||||
bh_printf("%c", c);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -699,7 +699,10 @@ _strcpy_wrapper(int32 dst_offset, int32 src_offset)
|
||||
|
||||
dst = addr_app_to_native(dst_offset);
|
||||
src = addr_app_to_native(src_offset);
|
||||
strcpy(dst, src);
|
||||
while (*src != '\0')
|
||||
*dst++ = *src++;
|
||||
*dst = '\0';
|
||||
|
||||
return dst_offset;
|
||||
}
|
||||
|
||||
@ -842,7 +845,7 @@ static void
|
||||
_llvm_stackrestore_wrapper(uint32 llvm_stack)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst();
|
||||
printf("_llvm_stackrestore called!\n");
|
||||
bh_printf("_llvm_stackrestore called!\n");
|
||||
wasm_runtime_set_llvm_stack(module_inst, llvm_stack);
|
||||
}
|
||||
|
||||
@ -850,7 +853,7 @@ static uint32
|
||||
_llvm_stacksave_wrapper()
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst();
|
||||
printf("_llvm_stacksave called!\n");
|
||||
bh_printf("_llvm_stacksave called!\n");
|
||||
return wasm_runtime_get_llvm_stack(module_inst);
|
||||
}
|
||||
|
||||
@ -905,13 +908,13 @@ nullFunc_X_wrapper(int32 code)
|
||||
static void
|
||||
print_i32_wrapper(int i32)
|
||||
{
|
||||
printf("%d\n", i32);
|
||||
bh_printf("%d\n", i32);
|
||||
}
|
||||
|
||||
static void
|
||||
print_wrapper(int i32)
|
||||
{
|
||||
printf("%d\n", i32);
|
||||
bh_printf("%d\n", i32);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ set (WASM_LIBC_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
include_directories(${WASM_LIBC_DIR})
|
||||
|
||||
|
||||
file (GLOB_RECURSE source_all ${WASM_LIBC_DIR}/libc_wrapper.c)
|
||||
file (GLOB_RECURSE source_all ${WASM_LIBC_DIR}/*.c)
|
||||
|
||||
set (WASM_LIBC_SOURCE ${source_all})
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set (WASM_LIBC_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
include_directories(${WASM_LIBC_DIR})
|
||||
|
||||
|
||||
file (GLOB_RECURSE source_all ${WASM_LIBC_DIR}/libc_wrapper_sgx.c)
|
||||
|
||||
set (WASM_LIBC_SOURCE ${source_all})
|
||||
|
||||
@ -26,6 +26,7 @@ add_definitions(-DUSE_SGX=1)
|
||||
add_definitions(-DOPS_INPUT_OUTPUT=1)
|
||||
add_definitions(-DOPS_UNSAFE_BUFFERS=0)
|
||||
add_definitions(-DWASM_ENABLE_LOG=0)
|
||||
add_definitions(-Dbh_printf=bh_printf_sgx)
|
||||
|
||||
# Enable repl mode if want to test spec cases
|
||||
# add_definitions(-DWASM_ENABLE_REPL)
|
||||
@ -71,19 +72,19 @@ include (../../runtime/platform/${PLATFORM}/platform.cmake)
|
||||
include (../../runtime/utils/utils.cmake)
|
||||
include (../../runtime/vmcore-wasm/vmcore.cmake)
|
||||
include (../../lib/native/base/wasm_lib_base.cmake)
|
||||
include (../../lib/native/libc/wasm_libc_sgx.cmake)
|
||||
include (../../lib/native/libc/wasm_libc.cmake)
|
||||
include (${SHARED_LIB_DIR}/platform/${PLATFORM}/shared_platform.cmake)
|
||||
include (${SHARED_LIB_DIR}/mem-alloc/mem_alloc.cmake)
|
||||
|
||||
#add_executable (iwasm main.c ext_lib_export.c)
|
||||
|
||||
include (${SHARED_LIB_DIR}/utils/shared_utils.cmake)
|
||||
|
||||
add_library (vmlib
|
||||
ext_lib_export.c
|
||||
${WASM_PLATFORM_LIB_SOURCE}
|
||||
${WASM_UTILS_LIB_SOURCE}
|
||||
${VMCORE_LIB_SOURCE}
|
||||
${WASM_LIB_BASE_DIR}/base_lib_export.c
|
||||
${WASM_LIBC_SOURCE}
|
||||
${PLATFORM_SHARED_SOURCE}
|
||||
${MEM_ALLOC_SHARED_SOURCE})
|
||||
${MEM_ALLOC_SHARED_SOURCE}
|
||||
${UTILS_SHARED_SOURCE})
|
||||
|
||||
add_library (extlib ext_lib_export.c)
|
||||
|
||||
Reference in New Issue
Block a user