Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/iwasm/aot/arch/aot_reloc_riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
if (error_buf != NULL)
snprintf(error_buf, error_buf_size,
"Load relocation section failed: "
"invalid relocation type %d.",
"invalid relocation type %" PRIu32 ".",
reloc_type);
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/common/wasm_application.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
char *endptr = NULL;
bh_assert(argv[i] != NULL);
if (argv[i][0] == '\0') {
snprintf(buf, sizeof(buf), "invalid input argument %d", i);
snprintf(buf, sizeof(buf), "invalid input argument %" PRId32, i);
wasm_runtime_set_exception(module_inst, buf);
goto fail;
}
Expand Down Expand Up @@ -554,8 +554,8 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
break;
}
if (endptr && *endptr != '\0' && *endptr != '_') {
snprintf(buf, sizeof(buf), "invalid input argument %d: %s", i,
argv[i]);
snprintf(buf, sizeof(buf), "invalid input argument %" PRId32 ": %s",
i, argv[i]);
wasm_runtime_set_exception(module_inst, buf);
goto fail;
}
Expand All @@ -573,7 +573,7 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
switch (type->types[type->param_count + j]) {
case VALUE_TYPE_I32:
{
os_printf("0x%x:i32", argv1[k]);
os_printf("0x%" PRIx32 ":i32", argv1[k]);
k++;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/compilation/aot_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,12 +2490,12 @@ aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base,
switch (value_type) {
case VALUE_TYPE_F32:
/* Store the raw int bits of f32 const as a hex string */
snprintf(buf, sizeof(buf), "f32#%08X", value->i32);
snprintf(buf, sizeof(buf), "f32#%08" PRIX32, value->i32);
const_ptr_type = F32_PTR_TYPE;
break;
case VALUE_TYPE_F64:
/* Store the raw int bits of f64 const as a hex string */
snprintf(buf, sizeof(buf), "f64#%016" PRIx64, value->i64);
snprintf(buf, sizeof(buf), "f64#%016" PRIX64, value->i64);
const_ptr_type = F64_PTR_TYPE;
break;
default:
Expand Down
5 changes: 3 additions & 2 deletions core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -3733,8 +3733,9 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
if (argc < function->param_cell_num) {
char buf[128];
snprintf(buf, sizeof(buf),
"invalid argument count %u, must be no smaller than %u", argc,
function->param_cell_num);
"invalid argument count %" PRIu32
", must be no smaller than %" PRIu32,
argc, (uint32)function->param_cell_num);
wasm_set_exception(module_inst, buf);
return;
}
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ exit_wrapper(wasm_exec_env_t exec_env, int32 status)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char buf[32];
snprintf(buf, sizeof(buf), "env.exit(%i)", status);
snprintf(buf, sizeof(buf), "env.exit(%" PRId32 ")", status);
wasm_runtime_set_exception(module_inst, buf);
}

Expand Down Expand Up @@ -1012,7 +1012,7 @@ abort_wrapper(wasm_exec_env_t exec_env, int32 code)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char buf[32];
snprintf(buf, sizeof(buf), "env.abort(%i)", code);
snprintf(buf, sizeof(buf), "env.abort(%" PRId32 ")", code);
wasm_runtime_set_exception(module_inst, buf);
}

Expand All @@ -1021,7 +1021,7 @@ abortStackOverflow_wrapper(wasm_exec_env_t exec_env, int32 code)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char buf[32];
snprintf(buf, sizeof(buf), "env.abortStackOverflow(%i)", code);
snprintf(buf, sizeof(buf), "env.abortStackOverflow(%" PRId32 ")", code);
wasm_runtime_set_exception(module_inst, buf);
}

Expand All @@ -1030,7 +1030,7 @@ nullFunc_X_wrapper(wasm_exec_env_t exec_env, int32 code)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char buf[32];
snprintf(buf, sizeof(buf), "env.nullFunc_X(%i)", code);
snprintf(buf, sizeof(buf), "env.nullFunc_X(%" PRId32 ")", code);
wasm_runtime_set_exception(module_inst, buf);
}

Expand Down
10 changes: 6 additions & 4 deletions core/shared/mem-alloc/ems/ems_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,8 @@ void
gc_dump_heap_stats(gc_heap_t *heap)
{
os_printf("heap: %p, heap start: %p\n", heap, heap->base_addr);
os_printf("total free: %u, current: %u, highmark: %u\n",
os_printf("total free: %" PRIu32 ", current: %" PRIu32
", highmark: %" PRIu32 "\n",
heap->total_free_size, heap->current_size, heap->highmark_size);
os_printf("g_total_malloc=%lu, g_total_free=%lu, occupied=%lu\n",
g_total_malloc, g_total_free, g_total_malloc - g_total_free);
Expand Down Expand Up @@ -765,9 +766,10 @@ gci_dump(gc_heap_t *heap)
return;
}

os_printf("#%d %08x %x %x %d %c %d\n", i,
(int32)((char *)cur - (char *)heap->base_addr), ut, p, mark,
inuse, (int32)hmu_obj_size(size));
os_printf("#%d %08" PRIx32 " %" PRIx32 " %d %d"
" %c %" PRId32 "\n",
i, (int32)((char *)cur - (char *)heap->base_addr), (int32)ut,
p, mark, inuse, (int32)hmu_obj_size(size));
#if BH_ENABLE_GC_VERIFY != 0
if (inuse == 'V') {
gc_object_prefix_t *prefix = (gc_object_prefix_t *)(cur + 1);
Expand Down
10 changes: 5 additions & 5 deletions core/shared/mem-alloc/ems/ems_kfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ gc_init_with_pool(char *buf, gc_size_t buf_size)
gc_size_t heap_max_size;

if (buf_size < APP_HEAP_SIZE_MIN) {
os_printf("[GC_ERROR]heap init buf size (%u) < %u\n", buf_size,
APP_HEAP_SIZE_MIN);
os_printf("[GC_ERROR]heap init buf size (%" PRIu32 ") < %" PRIu32 "\n",
buf_size, (uint32)APP_HEAP_SIZE_MIN);
return NULL;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ gc_init_with_struct_and_pool(char *struct_buf, gc_size_t struct_buf_size,
}

if (struct_buf_size < sizeof(gc_handle_t)) {
os_printf("[GC_ERROR]heap init struct buf size (%u) < %zu\n",
os_printf("[GC_ERROR]heap init struct buf size (%" PRIu32 ") < %zu\n",
struct_buf_size, sizeof(gc_handle_t));
return NULL;
}
Expand All @@ -104,8 +104,8 @@ gc_init_with_struct_and_pool(char *struct_buf, gc_size_t struct_buf_size,
}

if (pool_buf_size < APP_HEAP_SIZE_MIN) {
os_printf("[GC_ERROR]heap init buf size (%u) < %u\n", pool_buf_size,
APP_HEAP_SIZE_MIN);
os_printf("[GC_ERROR]heap init buf size (%" PRIu32 ") < %u\n",
pool_buf_size, APP_HEAP_SIZE_MIN);
return NULL;
}

Expand Down
42 changes: 42 additions & 0 deletions core/shared/platform/include/platform_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,48 @@ typedef int64_t int64;

typedef void *(*thread_start_routine_t)(void *);

#ifndef PRId32
#define PRId32 "d"
#endif
#ifndef PRIi32
#define PRIi32 "i"
#endif
#ifndef PRIu32
#define PRIu32 "u"
#endif
#ifndef PRIx32
#define PRIx32 "x"
#endif
#ifndef PRIX32
#define PRIX32 "X"
#endif

#ifndef __PRI64_PREFIX
#if UINTPTR_MAX == UINT64_MAX
#define __PRI64_PREFIX "l"
#define __PRIPTR_PREFIX "l"
#else
#define __PRI64_PREFIX "ll"
#define __PRIPTR_PREFIX
#endif
#endif

#ifndef PRId64
#define PRId64 __PRI64_PREFIX "d"
#endif
#ifndef PRIu64
#define PRIu64 __PRI64_PREFIX "u"
#endif
#ifndef PRIx64
#define PRIx64 __PRI64_PREFIX "x"
#endif
#ifndef PRIX64
#define PRIX64 __PRI64_PREFIX "X"
#endif
#ifndef PRIXPTR
#define PRIXPTR __PRIPTR_PREFIX "X"
#endif

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 7 additions & 4 deletions core/shared/utils/bh_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...)
s = t % 60;
mills = (uint32)(usec % 1000);

snprintf(buf, sizeof(buf), "%02u:%02u:%02u:%03u", h, m, s, mills);
snprintf(buf, sizeof(buf),
"%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ":%03" PRIu32, h, m, s,
mills);

os_printf("[%s - %X]: ", buf, (uint32)(uintptr_t)self);
os_printf("[%s - %" PRIXPTR "]: ", buf, (uintptr_t)self);

if (file)
os_printf("%s, line %d, ", file, line);
Expand Down Expand Up @@ -71,8 +73,9 @@ bh_print_time(const char *prompt)

total_time_ms += curr_time_ms - last_time_ms;

os_printf("%-48s time of last stage: %u ms, total time: %u ms\n", prompt,
curr_time_ms - last_time_ms, total_time_ms);
os_printf("%-48s time of last stage: %" PRIu32 " ms, total time: %" PRIu32
" ms\n",
prompt, curr_time_ms - last_time_ms, total_time_ms);

last_time_ms = curr_time_ms;
}