fix coding style for windows build patch (#350)

This commit is contained in:
Xu Jun 2020-08-13 16:40:19 +08:00 committed by GitHub
parent 874cc951c6
commit 1266ebb222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 33 deletions

View File

@ -83,8 +83,8 @@ endif ()
####################### Common sources #######################
if (NOT MSVC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
-Wall -Wno-unused-parameter -Wno-pedantic")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
-Wall -Wno-unused-parameter -Wno-pedantic")
endif ()
# include the build config template file

View File

@ -45,17 +45,19 @@ typedef void *korp_sem;
typedef void *korp_thread;
typedef struct {
korp_sem s;
unsigned int waiting_count;
korp_sem s;
unsigned int waiting_count;
} korp_cond;
#define os_printf printf
#define os_vprintf vprintf
static inline size_t getpagesize() {
SYSTEM_INFO S;
GetNativeSystemInfo(&S);
return S.dwPageSize;
static inline size_t
getpagesize()
{
SYSTEM_INFO S;
GetNativeSystemInfo(&S);
return S.dwPageSize;
}
#ifdef __cplusplus

View File

@ -4,6 +4,7 @@
*/
#include "platform_api_vmcore.h"
void * os_mmap(void *hint, size_t size, int prot, int flags)
{
DWORD AllocType = MEM_RESERVE | MEM_COMMIT;
@ -40,12 +41,12 @@ os_munmap(void *addr, size_t size)
{
size_t page_size = getpagesize();
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, size, MEM_DECOMMIT) == 0) {
os_printf("os_munmap error addr:%p, size:0x%lx, errno:%d\n",
addr, request_size, errno);
addr, request_size, errno);
}
}
}
@ -56,6 +57,7 @@ os_mprotect(void *addr, size_t size, int prot)
{
DWORD AllocType = MEM_RESERVE | MEM_COMMIT;
DWORD flProtect = PAGE_NOACCESS;
if (!addr)
return 0;
@ -76,4 +78,5 @@ os_mprotect(void *addr, size_t size, int prot)
void
os_dcache_flush(void)
{
}

View File

@ -97,22 +97,24 @@ int os_cond_wait(korp_cond *cond, korp_mutex *mutex)
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
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
// until 00:00:00 January 1, 1970
/* Note: some broken versions only have 8 trailing zero's,
the correct epoch has 9 trailing zero's
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);
SYSTEMTIME system_time;
FILETIME file_time;
uint64_t time;
GetSystemTime( &system_time );
SystemTimeToFileTime( &system_time, &file_time );
time = ((uint64_t)file_time.dwLowDateTime ) ;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
time = ((uint64_t)file_time.dwLowDateTime);
time += ((uint64_t)file_time.dwHighDateTime) << 32;
tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
tp->tv_sec = (long)((time - EPOCH) / 10000000L);
tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
return 0;
}

View File

@ -11,6 +11,6 @@ os_time_get_boot_microsecond()
struct timespec ts;
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;
}

View File

@ -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)) {
printf("Read file to buffer failed: open file %s failed.\n",
filename);
filename);
return NULL;
}
if (fstat(file, &stat_buf) != 0) {
printf("Read file to buffer failed: fstat file %s failed.\n",
filename);
filename);
_close(file);
return NULL;
}

View File

@ -81,7 +81,7 @@ def main():
-DLLVM_APPEND_VC_REV:BOOL=OFF'
print(cmd)
for line in os.popen(cmd):
print(line)
print(line)
else:
print("llvm has already been Cmaked")