Sfoglia il codice sorgente

Fix clang compile warnings (#3396)

Benbuck Nason 1 anno fa
parent
commit
432a940735

+ 9 - 0
core/iwasm/common/arch/invokeNative_general.c

@@ -6,6 +6,11 @@
 #include "../wasm_runtime_common.h"
 #include "../wasm_exec_env.h"
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-non-prototype"
+#endif
+
 void
 invokeNative(void (*native_code)(), uint32 argv[], uint32 argc)
 {
@@ -112,3 +117,7 @@ invokeNative(void (*native_code)(), uint32 argv[], uint32 argc)
         }
     }
 }
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif

+ 7 - 7
core/iwasm/include/wasm_c_api.h

@@ -433,7 +433,7 @@ struct wasm_ref_t;
 
 typedef struct wasm_val_t {
   wasm_valkind_t kind;
-  uint8_t __paddings[7];
+  uint8_t _paddings[7];
   union {
     int32_t i32;
     int64_t i64;
@@ -864,12 +864,12 @@ static inline void* wasm_val_ptr(const wasm_val_t* val) {
 #endif
 }
 
-#define WASM_I32_VAL(i) {.kind = WASM_I32, .__paddings = {0}, .of = {.i32 = i}}
-#define WASM_I64_VAL(i) {.kind = WASM_I64, .__paddings = {0}, .of = {.i64 = i}}
-#define WASM_F32_VAL(z) {.kind = WASM_F32, .__paddings = {0}, .of = {.f32 = z}}
-#define WASM_F64_VAL(z) {.kind = WASM_F64, .__paddings = {0}, .of = {.f64 = z}}
-#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, .__paddings = {0}, .of = {.ref = r}}
-#define WASM_INIT_VAL {.kind = WASM_ANYREF, .__paddings = {0}, .of = {.ref = NULL}}
+#define WASM_I32_VAL(i) {.kind = WASM_I32, ._paddings = {0}, .of = {.i32 = i}}
+#define WASM_I64_VAL(i) {.kind = WASM_I64, ._paddings = {0}, .of = {.i64 = i}}
+#define WASM_F32_VAL(z) {.kind = WASM_F32, ._paddings = {0}, .of = {.f32 = z}}
+#define WASM_F64_VAL(z) {.kind = WASM_F64, ._paddings = {0}, .of = {.f64 = z}}
+#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, ._paddings = {0}, .of = {.ref = r}}
+#define WASM_INIT_VAL {.kind = WASM_ANYREF, ._paddings = {0}, .of = {.ref = NULL}}
 
 #define KILOBYTE(n) ((n) * 1024)
 

+ 1 - 1
core/iwasm/include/wasm_export.h

@@ -255,7 +255,7 @@ struct wasm_ref_t;
 
 typedef struct wasm_val_t {
     wasm_valkind_t kind;
-    uint8_t __paddings[7];
+    uint8_t _paddings[7];
     union {
         /* also represent a function index */
         int32_t i32;

+ 1 - 1
core/iwasm/interpreter/wasm_runtime.h

@@ -112,7 +112,7 @@ struct WASMMemoryInstance {
 
     /* Four-byte paddings to ensure the layout of WASMMemoryInstance is the same
      * in both 64-bit and 32-bit */
-    uint8 __paddings[4];
+    uint8 _paddings[4];
 
     /* Number bytes per page */
     uint32 num_bytes_per_page;

+ 3 - 0
core/shared/mem-alloc/ems/ems_gc.h

@@ -70,7 +70,10 @@ typedef enum {
     GC_STAT_MAX
 } GC_STAT_INDEX;
 
+#ifndef GC_FINALIZER_T_DEFINED
+#define GC_FINALIZER_T_DEFINED
 typedef void (*gc_finalizer_t)(void *obj, void *data);
+#endif
 
 #ifndef EXTRA_INFO_NORMAL_NODE_CNT
 #define EXTRA_INFO_NORMAL_NODE_CNT 32

+ 3 - 0
core/shared/mem-alloc/mem_alloc.h

@@ -17,7 +17,10 @@ extern "C" {
 
 typedef void *mem_allocator_t;
 
+#ifndef GC_FINALIZER_T_DEFINED
+#define GC_FINALIZER_T_DEFINED
 typedef void (*gc_finalizer_t)(void *obj, void *data);
+#endif
 
 mem_allocator_t
 mem_allocator_create(void *mem, uint32_t size);