mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 07:21:54 +00:00
Fix windows link error and clear windows warnings (#2463)
- Fix windows wamrc link error: aot_generate_tempfile_name undefined. - Clear windows compile warnings. - And rename folder `samples/bh_atomic` and `samples/mem_allocator` to `samples/bh-atomic` and `samples/mem-allocator`.
This commit is contained in:
parent
e360b7a919
commit
923e8d6471
|
@ -2735,6 +2735,33 @@ aot_generate_tempfile_name(const char *prefix, const char *extension,
|
|||
snprintf(buffer + name_len, len - name_len, ".%s", extension);
|
||||
return buffer;
|
||||
}
|
||||
#else
|
||||
|
||||
errno_t
|
||||
_mktemp_s(char *nameTemplate, size_t sizeInChars);
|
||||
|
||||
char *
|
||||
aot_generate_tempfile_name(const char *prefix, const char *extension,
|
||||
char *buffer, uint32 len)
|
||||
{
|
||||
int name_len;
|
||||
|
||||
name_len = snprintf(buffer, len, "%s-XXXXXX", prefix);
|
||||
|
||||
if (_mktemp_s(buffer, name_len + 1) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check if buffer length is enough */
|
||||
/* name_len + '.' + extension + '\0' */
|
||||
if (name_len + 1 + strlen(extension) + 1 > len) {
|
||||
aot_set_last_error("temp file name too long.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf(buffer + name_len, len - name_len, ".%s", extension);
|
||||
return buffer;
|
||||
}
|
||||
#endif /* end of !(defined(_WIN32) || defined(_WIN32_)) */
|
||||
|
||||
bool
|
||||
|
|
|
@ -2403,7 +2403,7 @@ aot_resolve_object_data_sections(AOTObjectData *obj_data)
|
|||
&& !strcmp(name, "__llvm_prf_cnts")) {
|
||||
snprintf(buf, sizeof(buf), "%s%u", name,
|
||||
llvm_prf_cnts_idx++);
|
||||
size = strlen(buf) + 1;
|
||||
size = (uint32)(strlen(buf) + 1);
|
||||
if (!(data_section->name = wasm_runtime_malloc(size))) {
|
||||
aot_set_last_error(
|
||||
"allocate memory for data section name failed.");
|
||||
|
@ -2416,7 +2416,7 @@ aot_resolve_object_data_sections(AOTObjectData *obj_data)
|
|||
&& !strcmp(name, "__llvm_prf_data")) {
|
||||
snprintf(buf, sizeof(buf), "%s%u", name,
|
||||
llvm_prf_data_idx++);
|
||||
size = strlen(buf) + 1;
|
||||
size = (uint32)(strlen(buf) + 1);
|
||||
if (!(data_section->name = wasm_runtime_malloc(size))) {
|
||||
aot_set_last_error(
|
||||
"allocate memory for data section name failed.");
|
||||
|
@ -2520,15 +2520,15 @@ read_stack_usage_file(const AOTCompContext *comp_ctx, const char *filename,
|
|||
}
|
||||
if (prefix == aot_func_prefix) {
|
||||
if (sz < precheck_stack_size_min) {
|
||||
precheck_stack_size_min = sz;
|
||||
precheck_stack_size_min = (uint32)sz;
|
||||
}
|
||||
if (sz > precheck_stack_size_max) {
|
||||
precheck_stack_size_max = sz;
|
||||
precheck_stack_size_max = (uint32)sz;
|
||||
}
|
||||
precheck_found++;
|
||||
continue;
|
||||
}
|
||||
sizes[func_idx] = sz;
|
||||
sizes[func_idx] = (uint32)sz;
|
||||
found++;
|
||||
}
|
||||
fclose(fp);
|
||||
|
@ -2651,7 +2651,7 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|
|||
* aot_emit_object_data_section_info will emit this copy.
|
||||
*/
|
||||
obj_data->stack_sizes_section_name = sec_name;
|
||||
obj_data->stack_sizes_offset = addr;
|
||||
obj_data->stack_sizes_offset = (uint32)addr;
|
||||
obj_data->stack_sizes = wasm_runtime_malloc(
|
||||
obj_data->func_count * sizeof(*obj_data->stack_sizes));
|
||||
if (obj_data->stack_sizes == NULL) {
|
||||
|
@ -2975,7 +2975,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
|||
|| !strcmp(group->section_name, ".rel.text")) {
|
||||
snprintf(buf, sizeof(buf), "%s%u", relocation->symbol_name,
|
||||
prof_section_idx);
|
||||
size = strlen(buf) + 1;
|
||||
size = (uint32)(strlen(buf) + 1);
|
||||
if (!(relocation->symbol_name = wasm_runtime_malloc(size))) {
|
||||
aot_set_last_error(
|
||||
"allocate memory for relocation symbol name failed.");
|
||||
|
@ -2990,7 +2990,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
|||
19)) {
|
||||
snprintf(buf, sizeof(buf), "%s%u", relocation->symbol_name,
|
||||
prof_section_idx);
|
||||
size = strlen(buf) + 1;
|
||||
size = (uint32)(strlen(buf) + 1);
|
||||
if (!(relocation->symbol_name = wasm_runtime_malloc(size))) {
|
||||
aot_set_last_error(
|
||||
"allocate memory for relocation symbol name failed.");
|
||||
|
@ -3156,7 +3156,7 @@ aot_resolve_object_relocation_groups(AOTObjectData *obj_data)
|
|||
|| !strcmp(name, ".rel__llvm_prf_data"))) {
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%s%u", name, llvm_prf_data_idx);
|
||||
size = strlen(buf) + 1;
|
||||
size = (uint32)(strlen(buf) + 1);
|
||||
if (!(relocation_group->section_name =
|
||||
wasm_runtime_malloc(size))) {
|
||||
aot_set_last_error(
|
||||
|
|
|
@ -237,9 +237,10 @@ get_inst_extra_offset(AOTCompContext *comp_ctx)
|
|||
const AOTCompData *comp_data = comp_ctx->comp_data;
|
||||
uint32 table_count = comp_data->import_table_count + comp_data->table_count;
|
||||
uint64 offset = get_tbl_inst_offset(comp_ctx, NULL, table_count);
|
||||
bh_assert(offset <= UINT_MAX);
|
||||
offset = align_uint(offset, 8);
|
||||
return offset;
|
||||
uint32 offset_32 = (uint32)offset;
|
||||
bh_assert(offset <= UINT32_MAX);
|
||||
offset_32 = align_uint((uint32)offset_32, 8);
|
||||
return offset_32;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -309,8 +310,8 @@ aot_add_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
unsigned int param_count = LLVMCountParams(precheck_func);
|
||||
uint64 sz = param_count * sizeof(LLVMValueRef);
|
||||
uint32 param_count = LLVMCountParams(precheck_func);
|
||||
uint32 sz = param_count * (uint32)sizeof(LLVMValueRef);
|
||||
params = wasm_runtime_malloc(sz);
|
||||
if (params == NULL) {
|
||||
goto fail;
|
||||
|
@ -626,8 +627,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
|
|||
if (comp_ctx->is_indirect_mode) {
|
||||
/* avoid LUT relocations ("switch-table") */
|
||||
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
|
||||
comp_ctx->context, "no-jump-tables", strlen("no-jump-tables"),
|
||||
"true", strlen("true"));
|
||||
comp_ctx->context, "no-jump-tables",
|
||||
(uint32)strlen("no-jump-tables"), "true", (uint32)strlen("true"));
|
||||
LLVMAddAttributeAtIndex(func, LLVMAttributeFunctionIndex,
|
||||
attr_no_jump_tables);
|
||||
}
|
||||
|
@ -2081,7 +2082,7 @@ jit_stack_size_callback(void *user_data, const char *name, size_t namelen,
|
|||
return;
|
||||
}
|
||||
/* ensure NUL termination */
|
||||
bh_memcpy_s(buf, sizeof(buf), name, namelen);
|
||||
bh_memcpy_s(buf, (uint32)sizeof(buf), name, (uint32)namelen);
|
||||
buf[namelen] = 0;
|
||||
|
||||
ret = sscanf(buf, AOT_FUNC_INTERNAL_PREFIX "%" SCNu32, &func_idx);
|
||||
|
@ -2102,7 +2103,7 @@ jit_stack_size_callback(void *user_data, const char *name, size_t namelen,
|
|||
|
||||
/* Note: -1 == AOT_NEG_ONE from aot_create_stack_sizes */
|
||||
bh_assert(comp_ctx->jit_stack_sizes[func_idx] == (uint32)-1);
|
||||
comp_ctx->jit_stack_sizes[func_idx] = stack_size + call_size;
|
||||
comp_ctx->jit_stack_sizes[func_idx] = (uint32)stack_size + call_size;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
Loading…
Reference in New Issue
Block a user