From 373311a8d4b7c4cea0fc6ce652948c8f467f18e8 Mon Sep 17 00:00:00 2001 From: casaroli Date: Thu, 20 Oct 2022 15:26:57 +0200 Subject: [PATCH] Suppress the warnings when building with GCC11 (#1622) Add pragma to ignore "-Waddress-of-packed-member" Adds `void` parameter to the prototype of some functions to make them have strict declarations --- core/iwasm/aot/arch/aot_reloc_xtensa.c | 13 +++++++++++++ .../platform/include/platform_api_extension.h | 6 +++--- core/shared/utils/bh_hashmap.h | 2 +- core/shared/utils/bh_queue.h | 2 +- core/shared/utils/runtime_timer.h | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/core/iwasm/aot/arch/aot_reloc_xtensa.c b/core/iwasm/aot/arch/aot_reloc_xtensa.c index b5b262a5a6..7da471dfe7 100644 --- a/core/iwasm/aot/arch/aot_reloc_xtensa.c +++ b/core/iwasm/aot/arch/aot_reloc_xtensa.c @@ -263,10 +263,23 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr, imm16 = (int16)(relative_offset >> 2); /* write back the imm16 to the l32r instruction */ + + /* GCC >= 9 complains if we have a pointer that could be + * unaligned. This can happen because the struct is packed. + * These pragma are to suppress the warnings because the + * function put_imm16_to_addr already handles unaligned + * pointers correctly. */ +#if __GNUC__ >= 9 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif if (is_little_endian()) put_imm16_to_addr(imm16, &l32r_insn->l.imm16); else put_imm16_to_addr(imm16, &l32r_insn->b.imm16); +#if __GNUC__ >= 9 +#pragma GCC diagnostic pop +#endif break; } diff --git a/core/shared/platform/include/platform_api_extension.h b/core/shared/platform/include/platform_api_extension.h index c214c88fae..23f6443732 100644 --- a/core/shared/platform/include/platform_api_extension.h +++ b/core/shared/platform/include/platform_api_extension.h @@ -99,19 +99,19 @@ os_thread_exit(void *retval); * @return 0 if success, -1 otherwise */ int -os_thread_env_init(); +os_thread_env_init(void); /** * Destroy current thread environment */ void -os_thread_env_destroy(); +os_thread_env_destroy(void); /** * Whether the thread environment is initialized */ bool -os_thread_env_inited(); +os_thread_env_inited(void); /** * Suspend execution of the calling thread for (at least) diff --git a/core/shared/utils/bh_hashmap.h b/core/shared/utils/bh_hashmap.h index 018f05131c..ef06960fb5 100644 --- a/core/shared/utils/bh_hashmap.h +++ b/core/shared/utils/bh_hashmap.h @@ -141,7 +141,7 @@ bh_hash_map_get_struct_size(HashMap *hashmap); * @return the memory space occupied by HashMapElem structure */ uint32 -bh_hash_map_get_elem_struct_size(); +bh_hash_map_get_elem_struct_size(void); /** * Traverse the hash map and call the callback function diff --git a/core/shared/utils/bh_queue.h b/core/shared/utils/bh_queue.h index 394fed9e73..c15f435266 100644 --- a/core/shared/utils/bh_queue.h +++ b/core/shared/utils/bh_queue.h @@ -40,7 +40,7 @@ typedef void (*bh_queue_handle_msg_callback)(void *message, void *arg); typedef void (*bh_msg_cleaner)(void *msg); bh_queue * -bh_queue_create(); +bh_queue_create(void); void bh_queue_destroy(bh_queue *queue); diff --git a/core/shared/utils/runtime_timer.h b/core/shared/utils/runtime_timer.h index 00db298342..b8d90c5ffb 100644 --- a/core/shared/utils/runtime_timer.h +++ b/core/shared/utils/runtime_timer.h @@ -13,7 +13,7 @@ extern "C" { #endif uint64 -bh_get_tick_ms(); +bh_get_tick_ms(void); uint32 bh_get_elpased_ms(uint32 *last_system_clock);