Răsfoiți Sursa

fix coding style for windows build patch (#350)

Xu Jun 5 ani în urmă
părinte
comite
1266ebb222

+ 2 - 2
build-scripts/runtime_lib.cmake

@@ -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

+ 1 - 1
core/iwasm/common/arch/invokeNative_ia32.asm

@@ -6,7 +6,7 @@
     .386
     .model flat
     .code
-_invokeNative PROC 
+_invokeNative PROC
     push    ebp
     mov     ebp,esp
     mov     ecx, [ebp+16]          ; ecx = argc */

+ 8 - 6
core/shared/platform/windows/platform_internal.h

@@ -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

+ 13 - 10
core/shared/platform/windows/win_memmap.c

@@ -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;
@@ -17,14 +18,14 @@ void * os_mmap(void *hint, size_t size, int prot, int flags)
     if (request_size < size)
         /* integer overflow */
         return NULL;
-    
+
     if (prot & MMAP_PROT_EXEC) {
         if (prot & MMAP_PROT_WRITE)
             flProtect = PAGE_EXECUTE_READWRITE;
-        else 
+        else
             flProtect = PAGE_EXECUTE_READ;
-    } 
-    else if (prot & MMAP_PROT_WRITE) 
+    }
+    else if (prot & MMAP_PROT_WRITE)
         flProtect = PAGE_READWRITE;
     else if (prot & MMAP_PROT_READ)
         flProtect = PAGE_READONLY;
@@ -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 (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,16 +57,17 @@ os_mprotect(void *addr, size_t size, int prot)
 {
     DWORD AllocType = MEM_RESERVE | MEM_COMMIT;
     DWORD flProtect = PAGE_NOACCESS;
+
     if (!addr)
         return 0;
-    
+
     if (prot & MMAP_PROT_EXEC) {
         if (prot & MMAP_PROT_WRITE)
             flProtect = PAGE_EXECUTE_READWRITE;
-        else 
+        else
             flProtect = PAGE_EXECUTE_READ;
-    } 
-    else if (prot & MMAP_PROT_WRITE) 
+    }
+    else if (prot & MMAP_PROT_WRITE)
         flProtect = PAGE_READWRITE;
     else if (prot & MMAP_PROT_READ)
         flProtect = PAGE_READONLY;
@@ -76,4 +78,5 @@ os_mprotect(void *addr, size_t size, int prot)
 void
 os_dcache_flush(void)
 {
+
 }

+ 10 - 8
core/shared/platform/windows/win_thread.c

@@ -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;
 }
 

+ 1 - 1
core/shared/platform/windows/win_time.c

@@ -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;
 }
 

+ 2 - 2
core/shared/utils/uncommon/bh_read_file.c

@@ -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;
     }

+ 3 - 3
wamr-compiler/build_llvm.py

@@ -59,7 +59,7 @@ def main():
     Path(build_dir_name).mkdir(exist_ok = True)
     build_dir = Path(build_dir_name)
     os.chdir(build_dir)
-    
+
     if ( not Path(llvm_file).exists()):
         core_number = os.cpu_count()
         print("Build llvm with", core_number, " cores")
@@ -81,10 +81,10 @@ 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")
-    
+
     if(current_os == "linux"):
         for line in os.popen("make -j {}".format(core_number)):
             print(line)