mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-06-18 02:59:21 +00:00
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:
parent
5c69543c54
commit
5257dd8a48
|
@ -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)
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
#define DEFAULT_MEM_ALLOCATOR MEM_ALLOCATOR_EMS
|
||||
|
||||
/* Beihai log system */
|
||||
#ifndef BEIHAI_ENABLE_LOG
|
||||
#define BEIHAI_ENABLE_LOG 1
|
||||
#endif
|
||||
|
||||
/* Beihai debugger support */
|
||||
#define BEIHAI_ENABLE_TOOL_AGENT 1
|
||||
|
@ -129,3 +127,7 @@
|
|||
/* Default base offset of external memory space */
|
||||
#define DEFAULT_EXT_MEM_BASE_OFFSET (-2 * BH_GB)
|
||||
|
||||
#ifndef bh_printf
|
||||
#define bh_printf printf
|
||||
#endif
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@ typedef int64_t int64;
|
|||
#define wa_free bh_free
|
||||
#define wa_strdup bh_strdup
|
||||
|
||||
#define bh_printf printf
|
||||
|
||||
typedef aos_task_t korp_thread;
|
||||
typedef korp_thread *korp_tid;
|
||||
typedef aos_task_t *aos_tid_t;
|
||||
|
|
|
@ -52,7 +52,7 @@ void bh_set_print_function(bh_print_function_t pf)
|
|||
print_function = pf;
|
||||
}
|
||||
|
||||
int bh_printf(const char *message, ...)
|
||||
int bh_printf_sgx(const char *message, ...)
|
||||
{
|
||||
if (print_function != NULL) {
|
||||
char msg[FIXED_BUFFER_SIZE] = { '\0' };
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int bh_printf(const char *message, ...);
|
||||
extern int bh_printf_sgx(const char *message, ...);
|
||||
|
||||
typedef uint64_t uint64;
|
||||
typedef int64_t int64;
|
||||
|
|
|
@ -77,8 +77,6 @@ typedef void* (*thread_start_routine_t)(void*);
|
|||
#define wa_free bh_free
|
||||
#define wa_strdup bh_strdup
|
||||
|
||||
#define bh_printf printf
|
||||
|
||||
int snprintf(char *buffer, size_t count, const char *format, ...);
|
||||
double fmod(double x, double y);
|
||||
float fmodf(float x, float y);
|
||||
|
|
|
@ -75,8 +75,6 @@ typedef void* (*thread_start_routine_t)(void*);
|
|||
#define wa_free bh_free
|
||||
#define wa_strdup bh_strdup
|
||||
|
||||
#define bh_printf printf
|
||||
|
||||
int snprintf(char *buffer, size_t count, const char *format, ...);
|
||||
double fmod(double x, double y);
|
||||
float fmodf(float x, float y);
|
||||
|
|
|
@ -78,8 +78,6 @@ typedef void* (*thread_start_routine_t)(void*);
|
|||
#define wa_malloc bh_malloc
|
||||
#define wa_free bh_free
|
||||
|
||||
#define bh_printf printf
|
||||
|
||||
/* Unit test framework is based on C++, where the declaration of
|
||||
snprintf is different. */
|
||||
#ifndef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue
Block a user