mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
fix coding style for windows build patch (#350)
This commit is contained in:
parent
874cc951c6
commit
1266ebb222
|
@ -83,8 +83,8 @@ endif ()
|
||||||
|
|
||||||
####################### Common sources #######################
|
####################### Common sources #######################
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
|
||||||
-Wall -Wno-unused-parameter -Wno-pedantic")
|
-Wall -Wno-unused-parameter -Wno-pedantic")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# include the build config template file
|
# include the build config template file
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
.386
|
.386
|
||||||
.model flat
|
.model flat
|
||||||
.code
|
.code
|
||||||
_invokeNative PROC
|
_invokeNative PROC
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
mov ecx, [ebp+16] ; ecx = argc */
|
mov ecx, [ebp+16] ; ecx = argc */
|
||||||
|
|
|
@ -45,17 +45,19 @@ typedef void *korp_sem;
|
||||||
typedef void *korp_thread;
|
typedef void *korp_thread;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
korp_sem s;
|
korp_sem s;
|
||||||
unsigned int waiting_count;
|
unsigned int waiting_count;
|
||||||
} korp_cond;
|
} korp_cond;
|
||||||
|
|
||||||
#define os_printf printf
|
#define os_printf printf
|
||||||
#define os_vprintf vprintf
|
#define os_vprintf vprintf
|
||||||
|
|
||||||
static inline size_t getpagesize() {
|
static inline size_t
|
||||||
SYSTEM_INFO S;
|
getpagesize()
|
||||||
GetNativeSystemInfo(&S);
|
{
|
||||||
return S.dwPageSize;
|
SYSTEM_INFO S;
|
||||||
|
GetNativeSystemInfo(&S);
|
||||||
|
return S.dwPageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform_api_vmcore.h"
|
#include "platform_api_vmcore.h"
|
||||||
|
|
||||||
void * os_mmap(void *hint, size_t size, int prot, int flags)
|
void * os_mmap(void *hint, size_t size, int prot, int flags)
|
||||||
{
|
{
|
||||||
DWORD AllocType = MEM_RESERVE | MEM_COMMIT;
|
DWORD AllocType = MEM_RESERVE | MEM_COMMIT;
|
||||||
|
@ -17,14 +18,14 @@ void * os_mmap(void *hint, size_t size, int prot, int flags)
|
||||||
if (request_size < size)
|
if (request_size < size)
|
||||||
/* integer overflow */
|
/* integer overflow */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (prot & MMAP_PROT_EXEC) {
|
if (prot & MMAP_PROT_EXEC) {
|
||||||
if (prot & MMAP_PROT_WRITE)
|
if (prot & MMAP_PROT_WRITE)
|
||||||
flProtect = PAGE_EXECUTE_READWRITE;
|
flProtect = PAGE_EXECUTE_READWRITE;
|
||||||
else
|
else
|
||||||
flProtect = PAGE_EXECUTE_READ;
|
flProtect = PAGE_EXECUTE_READ;
|
||||||
}
|
}
|
||||||
else if (prot & MMAP_PROT_WRITE)
|
else if (prot & MMAP_PROT_WRITE)
|
||||||
flProtect = PAGE_READWRITE;
|
flProtect = PAGE_READWRITE;
|
||||||
else if (prot & MMAP_PROT_READ)
|
else if (prot & MMAP_PROT_READ)
|
||||||
flProtect = PAGE_READONLY;
|
flProtect = PAGE_READONLY;
|
||||||
|
@ -40,12 +41,12 @@ os_munmap(void *addr, size_t size)
|
||||||
{
|
{
|
||||||
size_t page_size = getpagesize();
|
size_t page_size = getpagesize();
|
||||||
size_t request_size = (size + page_size - 1) & ~(page_size - 1);
|
size_t request_size = (size + page_size - 1) & ~(page_size - 1);
|
||||||
|
|
||||||
if (addr) {
|
if (addr) {
|
||||||
|
|
||||||
if (VirtualFree(addr, 0, MEM_RELEASE) == 0) {
|
if (VirtualFree(addr, 0, MEM_RELEASE) == 0) {
|
||||||
if (VirtualFree(addr, size, MEM_DECOMMIT) == 0) {
|
if (VirtualFree(addr, size, MEM_DECOMMIT) == 0) {
|
||||||
os_printf("os_munmap error addr:%p, size:0x%lx, errno:%d\n",
|
os_printf("os_munmap error addr:%p, size:0x%lx, errno:%d\n",
|
||||||
addr, request_size, errno);
|
addr, request_size, errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,16 +57,17 @@ os_mprotect(void *addr, size_t size, int prot)
|
||||||
{
|
{
|
||||||
DWORD AllocType = MEM_RESERVE | MEM_COMMIT;
|
DWORD AllocType = MEM_RESERVE | MEM_COMMIT;
|
||||||
DWORD flProtect = PAGE_NOACCESS;
|
DWORD flProtect = PAGE_NOACCESS;
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (prot & MMAP_PROT_EXEC) {
|
if (prot & MMAP_PROT_EXEC) {
|
||||||
if (prot & MMAP_PROT_WRITE)
|
if (prot & MMAP_PROT_WRITE)
|
||||||
flProtect = PAGE_EXECUTE_READWRITE;
|
flProtect = PAGE_EXECUTE_READWRITE;
|
||||||
else
|
else
|
||||||
flProtect = PAGE_EXECUTE_READ;
|
flProtect = PAGE_EXECUTE_READ;
|
||||||
}
|
}
|
||||||
else if (prot & MMAP_PROT_WRITE)
|
else if (prot & MMAP_PROT_WRITE)
|
||||||
flProtect = PAGE_READWRITE;
|
flProtect = PAGE_READWRITE;
|
||||||
else if (prot & MMAP_PROT_READ)
|
else if (prot & MMAP_PROT_READ)
|
||||||
flProtect = PAGE_READONLY;
|
flProtect = PAGE_READONLY;
|
||||||
|
@ -76,4 +78,5 @@ os_mprotect(void *addr, size_t size, int prot)
|
||||||
void
|
void
|
||||||
os_dcache_flush(void)
|
os_dcache_flush(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,22 +97,24 @@ int os_cond_wait(korp_cond *cond, korp_mutex *mutex)
|
||||||
|
|
||||||
int gettimeofday(struct timeval * tp, struct timezone * tzp)
|
int gettimeofday(struct timeval * tp, struct timezone * tzp)
|
||||||
{
|
{
|
||||||
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
|
/* Note: some broken versions only have 8 trailing zero's,
|
||||||
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
the correct epoch has 9 trailing zero's
|
||||||
// until 00:00:00 January 1, 1970
|
This magic number is the number of 100 nanosecond intervals
|
||||||
|
since January 1, 1601 (UTC) until 00:00:00 January 1, 1970 */
|
||||||
static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
|
static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
|
||||||
|
|
||||||
SYSTEMTIME system_time;
|
SYSTEMTIME system_time;
|
||||||
FILETIME file_time;
|
FILETIME file_time;
|
||||||
uint64_t time;
|
uint64_t time;
|
||||||
|
|
||||||
GetSystemTime( &system_time );
|
GetSystemTime(&system_time);
|
||||||
SystemTimeToFileTime( &system_time, &file_time );
|
SystemTimeToFileTime(&system_time, &file_time);
|
||||||
time = ((uint64_t)file_time.dwLowDateTime ) ;
|
time = ((uint64_t)file_time.dwLowDateTime);
|
||||||
time += ((uint64_t)file_time.dwHighDateTime) << 32;
|
time += ((uint64_t)file_time.dwHighDateTime) << 32;
|
||||||
|
|
||||||
tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
|
tp->tv_sec = (long)((time - EPOCH) / 10000000L);
|
||||||
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
|
tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,6 @@ os_time_get_boot_microsecond()
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
timespec_get(&ts, TIME_UTC);
|
timespec_get(&ts, TIME_UTC);
|
||||||
|
|
||||||
return ((uint64) ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000;
|
return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,13 @@ bh_read_file_to_buffer(const char *filename, uint32 *ret_size)
|
||||||
|
|
||||||
if (_sopen_s(&file, filename, _O_RDONLY| _O_BINARY, _SH_DENYNO, 0)) {
|
if (_sopen_s(&file, filename, _O_RDONLY| _O_BINARY, _SH_DENYNO, 0)) {
|
||||||
printf("Read file to buffer failed: open file %s failed.\n",
|
printf("Read file to buffer failed: open file %s failed.\n",
|
||||||
filename);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(file, &stat_buf) != 0) {
|
if (fstat(file, &stat_buf) != 0) {
|
||||||
printf("Read file to buffer failed: fstat file %s failed.\n",
|
printf("Read file to buffer failed: fstat file %s failed.\n",
|
||||||
filename);
|
filename);
|
||||||
_close(file);
|
_close(file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ def main():
|
||||||
Path(build_dir_name).mkdir(exist_ok = True)
|
Path(build_dir_name).mkdir(exist_ok = True)
|
||||||
build_dir = Path(build_dir_name)
|
build_dir = Path(build_dir_name)
|
||||||
os.chdir(build_dir)
|
os.chdir(build_dir)
|
||||||
|
|
||||||
if ( not Path(llvm_file).exists()):
|
if ( not Path(llvm_file).exists()):
|
||||||
core_number = os.cpu_count()
|
core_number = os.cpu_count()
|
||||||
print("Build llvm with", core_number, " cores")
|
print("Build llvm with", core_number, " cores")
|
||||||
|
@ -81,10 +81,10 @@ def main():
|
||||||
-DLLVM_APPEND_VC_REV:BOOL=OFF'
|
-DLLVM_APPEND_VC_REV:BOOL=OFF'
|
||||||
print(cmd)
|
print(cmd)
|
||||||
for line in os.popen(cmd):
|
for line in os.popen(cmd):
|
||||||
print(line)
|
print(line)
|
||||||
else:
|
else:
|
||||||
print("llvm has already been Cmaked")
|
print("llvm has already been Cmaked")
|
||||||
|
|
||||||
if(current_os == "linux"):
|
if(current_os == "linux"):
|
||||||
for line in os.popen("make -j {}".format(core_number)):
|
for line in os.popen("make -j {}".format(core_number)):
|
||||||
print(line)
|
print(line)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user