mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-03-12 00:45:28 +00:00
Implement GetCurrentThreadStackLimits() for Windows 7 (#914)
And fix compilation error of when build wamrc, fix compilation warnings
This commit is contained in:
parent
ac3f7dcc0e
commit
89a1c8220d
|
@ -3114,7 +3114,7 @@ aot_unload(AOTModule *module)
|
|||
wasm_runtime_free(module->aux_func_indexes);
|
||||
}
|
||||
if (module->aux_func_names) {
|
||||
wasm_runtime_free(module->aux_func_names);
|
||||
wasm_runtime_free((void *)module->aux_func_names);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -459,8 +459,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
|
|||
}
|
||||
case WASM_OP_REF_FUNC:
|
||||
{
|
||||
uint32 func_idx;
|
||||
|
||||
if (!comp_ctx->enable_ref_types) {
|
||||
goto unsupport_ref_types;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
#include <stdint.h>
|
||||
#include <malloc.h>
|
||||
#include <process.h>
|
||||
#include <winsock2.h>
|
||||
#include <Windows.h>
|
||||
#include <BaseTsd.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -556,6 +556,31 @@ os_cond_signal(korp_cond *cond)
|
|||
|
||||
static os_thread_local_attribute uint8 *thread_stack_boundary = NULL;
|
||||
|
||||
#if _WIN32_WINNT < 0x0602
|
||||
static ULONG
|
||||
GetCurrentThreadStackLimits_Win7(PULONG_PTR p_low_limit,
|
||||
PULONG_PTR p_high_limit)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
NT_TIB *tib = (NT_TIB *)NtCurrentTeb();
|
||||
|
||||
if (!tib) {
|
||||
os_printf("warning: NtCurrentTeb() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*p_high_limit = (ULONG_PTR)tib->StackBase;
|
||||
|
||||
if (VirtualQuery(tib->StackLimit, &mbi, sizeof(mbi))) {
|
||||
*p_low_limit = (ULONG_PTR)mbi.AllocationBase;
|
||||
return 0;
|
||||
}
|
||||
|
||||
os_printf("warning: VirtualQuery() failed\n");
|
||||
return GetLastError();
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8 *
|
||||
os_thread_get_stack_boundary()
|
||||
{
|
||||
|
@ -566,7 +591,13 @@ os_thread_get_stack_boundary()
|
|||
return thread_stack_boundary;
|
||||
|
||||
page_size = os_getpagesize();
|
||||
#if _WIN32_WINNT >= 0x0602
|
||||
GetCurrentThreadStackLimits(&low_limit, &high_limit);
|
||||
#else
|
||||
if (0 != GetCurrentThreadStackLimits_Win7(&low_limit, &high_limit)) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
/* 4 pages are set unaccessible by system, we reserved
|
||||
one more page at least for safety */
|
||||
thread_stack_boundary = (uint8 *)(uintptr_t)low_limit + page_size * 5;
|
||||
|
|
Loading…
Reference in New Issue
Block a user