Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# using [clang-formt-12 options](https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html)
# using [clang-format-18 options](https://releases.llvm.org/18.1.0/tools/clang/docs/ClangFormatStyleOptions.html)
RawStringFormats:
- Language: Cpp
Delimiters:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding_guidelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions:

jobs:
compliance_job:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v7.0.0
Expand Down
18 changes: 9 additions & 9 deletions ci/coding_guidelines_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import sys
import unittest

CLANG_FORMAT_CMD = "clang-format-14"
GIT_CLANG_FORMAT_CMD = "git-clang-format-14"
CLANG_FORMAT_CMD = "clang-format-18"
GIT_CLANG_FORMAT_CMD = "git-clang-format-18"

# glob style patterns
EXCLUDE_PATHS = [
Expand Down Expand Up @@ -92,29 +92,29 @@ def run_clang_format(file_path: Path, root: Path) -> bool:

def run_clang_format_diff(root: Path, commits: str) -> bool:
"""
Use `clang-format-14` or `git-clang-format-14` to check code format of
Use `clang-format-18` or `git-clang-format-18` to check code format of
the PR, with a commit range specified. It is required to format the
code before committing the PR, or it might fail to pass the CI check:

1. Install clang-format-14.0.0
1. Install clang-format-18

You can download the package from
https://github.com/llvm/llvm-project/releases
and install it.

For Debian/Ubuntu, we can probably use
`sudo apt-get install clang-format-14`.
`sudo apt-get install clang-format-18`.

Homebrew has it as a part of llvm@14.
Homebrew has it as a part of llvm@18.
```shell
brew install llvm@14
/usr/local/opt/llvm@14/bin/clang-format
brew install llvm@18
/usr/local/opt/llvm@18/bin/clang-format
```

2. Format the C/C++ source file
``` shell
cd path/to/wamr/root
clang-format-14 --style file -i path/to/file
clang-format-18 --style file -i path/to/file
```

The code wrapped by `/* clang-format off */` and `/* clang-format on */`
Expand Down
6 changes: 3 additions & 3 deletions ci/pre_commit_hook_sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This is a sample of pre-commit hook that can be used to make your code fit the WAMR CI code style requirements.
# You need to have clang-format-12 installed to use this hook.
# You need to have clang-format-18 installed to use this hook.
# To add this pre-commit hook, copy it to <path_to_wamr>/.git/hooks/pre-commit
# (you don't need any extensions here)

Expand All @@ -22,10 +22,10 @@ is_c_or_cpp_file() {
# Loop through staged files and apply command "abc" to C and C++ files
for staged_file in $(git diff --cached --name-only); do
if is_c_or_cpp_file "$staged_file"; then
clang-format-12 -Werror --style file --dry-run "$staged_file" 2>/dev/null
clang-format-18 -Werror --style file --dry-run "$staged_file" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Issues are found in $staged_file. Applying the fix"
clang-format-12 --style file -i "$staged_file"
clang-format-18 --style file -i "$staged_file"
fi
git add "$staged_file" # Add the modified file back to staging
fi
Expand Down
3 changes: 2 additions & 1 deletion core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5553,7 +5553,8 @@ aot_const_str_set_insert(const uint8 *str, int32 len, AOTModule *module,
#if WASM_ENABLE_DYNAMIC_AOT_DEBUG != 0
AOTModule *g_dynamic_aot_module = NULL;

void __attribute__((noinline)) __enable_dynamic_aot_debug(void)
void __attribute__((noinline))
__enable_dynamic_aot_debug(void)
{
/* empty implementation. */
}
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/aot/debug/elf32.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
****************************************************************************/

#define ELF32_ST_BIND(i) ((i) >> 4)
#define ELF32_ST_TYPE(i) ((i)&0xf)
#define ELF32_ST_INFO(b, t) (((b) << 4) | ((t)&0xf))
#define ELF32_ST_TYPE(i) ((i) & 0xf)
#define ELF32_ST_INFO(b, t) (((b) << 4) | ((t) & 0xf))

/* Definitions for Elf32_Rel*::r_info */

#define ELF32_R_SYM(i) ((i) >> 8)
#define ELF32_R_TYPE(i) ((i)&0xff)
#define ELF32_R_INFO(s, t) (((s) << 8) | ((t)&0xff))
#define ELF32_R_TYPE(i) ((i) & 0xff)
#define ELF32_R_INFO(s, t) (((s) << 8) | ((t) & 0xff))

#if 0
#define ELF_R_SYM(i) ELF32_R_SYM(i)
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/aot/debug/elf64.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
/* Definitions for Elf64_Rel*::r_info */

#define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i)&0xffffffffL)
#define ELF64_R_INFO(s, t) (((s) << 32) + ((t)&0xffffffffL))
#define ELF64_R_TYPE(i) ((i) & 0xffffffffL)
#define ELF64_R_INFO(s, t) (((s) << 32) + ((t) & 0xffffffffL))

#if 0
#define ELF_R_SYM(i) ELF64_R_SYM(i)
Expand Down
6 changes: 4 additions & 2 deletions core/iwasm/common/gc/stringref/stringref_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
/******************* gc finalizer *****************/
void
wasm_string_destroy(WASMString str_obj)
{}
{
}

/******************* opcode functions *****************/

Expand Down Expand Up @@ -133,4 +134,5 @@ wasm_string_rewind(WASMString str_obj, uint32 pos, uint32 count,

void
wasm_string_dump(WASMString str_obj)
{}
{
}
3 changes: 2 additions & 1 deletion core/iwasm/common/wasm_blocking_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ wasm_runtime_begin_blocking_op(wasm_exec_env_t env)

void
wasm_runtime_end_blocking_op(wasm_exec_env_t env)
{}
{
}

#endif /* WASM_ENABLE_THREAD_MGR && OS_ENABLE_WAKEUP_BLOCKING_OP */
11 changes: 6 additions & 5 deletions core/iwasm/common/wasm_c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -3248,11 +3248,12 @@ wasm_func_copy(const wasm_func_t *func)
return NULL;
}

if (!(cloned = func->with_env ? wasm_func_new_with_env_basic(
func->store, func->type, func->u.cb_env.cb,
func->u.cb_env.env, func->u.cb_env.finalizer)
: wasm_func_new_basic(func->store, func->type,
func->u.cb))) {
if (!(cloned =
func->with_env
? wasm_func_new_with_env_basic(
func->store, func->type, func->u.cb_env.cb,
func->u.cb_env.env, func->u.cb_env.finalizer)
: wasm_func_new_basic(func->store, func->type, func->u.cb))) {
goto failed;
}

Expand Down
6 changes: 3 additions & 3 deletions core/iwasm/compilation/aot_emit_aot_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

#define CHECK_SIZE(size) \
do { \
if (size == (uint32)-1) { \
if (size == (uint32) - 1) { \
aot_set_last_error("get symbol size failed."); \
return (uint32)-1; \
return (uint32) - 1; \
} \
} while (0)

Expand Down Expand Up @@ -3674,7 +3674,7 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
unsigned int stack_consumption_to_call_wrapped_func =
musttail ? 0
: aot_estimate_stack_usage_for_function_call(
comp_ctx, func_ctx->aot_func->func_type);
comp_ctx, func_ctx->aot_func->func_type);

/*
* LLVM seems to eliminate calls to an empty function
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/compilation/aot_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ jit_stack_size_callback(void *user_data, const char *name, size_t namelen,
stack_consumption_to_call_wrapped_func =
musttail ? 0
: aot_estimate_stack_usage_for_function_call(
comp_ctx, func_ctx->aot_func->func_type);
comp_ctx, func_ctx->aot_func->func_type);
LOG_VERBOSE("func %.*s stack %u + %zu + %u", (int)namelen, name,
stack_consumption_to_call_wrapped_func, stack_size, call_size);

Expand Down
6 changes: 4 additions & 2 deletions core/iwasm/compilation/aot_orc_extra2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ MyCompiler::MyCompiler(llvm::orc::JITTargetMachineBuilder JTMB, cb_t cb,
, JTMB(std::move(JTMB))
, cb(cb)
, cb_data(cb_data)
{}
{
}

class PrintStackSizes : public llvm::MachineFunctionPass
{
Expand All @@ -59,7 +60,8 @@ PrintStackSizes::PrintStackSizes(cb_t cb, void *cb_data)
: MachineFunctionPass(ID)
, cb(cb)
, cb_data(cb_data)
{}
{
}

char PrintStackSizes::ID = 0;

Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/compilation/debug/dwarf_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" {

typedef unsigned int LLDBLangType;
#define LLDB_TO_LLVM_LANG_TYPE(lldb_lang_type) \
(LLVMDWARFSourceLanguage)(((lldb_lang_type) > 0 ? (lldb_lang_type)-1 : 1))
(LLVMDWARFSourceLanguage)(((lldb_lang_type) > 0 ? (lldb_lang_type) - 1 : 1))

struct AOTCompData;
typedef struct AOTCompData *aot_comp_data_t;
Expand Down
3 changes: 2 additions & 1 deletion core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ class JitErrorHandler : public ErrorHandler

JitErrorHandler()
: err(kErrorOk)
{}
{
}

void handleError(Error e, const char *msg, BaseEmitter *base) override
{
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/fast-jit/jit_ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -1866,14 +1866,14 @@ jit_cc_update_cfg(JitCompContext *cc);
*/
#define JIT_FOREACH_BLOCK_REVERSE(CC, I, B) \
for ((I) = (CC)->_ann._label_num; (I) > 2; (I)--) \
if (((B) = (CC)->_ann._label_basic_block[(I)-1]))
if (((B) = (CC)->_ann._label_basic_block[(I) - 1]))

/**
* The version that includes entry and exit block.
*/
#define JIT_FOREACH_BLOCK_REVERSE_ENTRY_EXIT(CC, I, B) \
for ((I) = (CC)->_ann._label_num; (I) > 0; (I)--) \
if (((B) = (CC)->_ann._label_basic_block[(I)-1]))
if (((B) = (CC)->_ann._label_basic_block[(I) - 1]))

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/libraries/debug-engine/debug_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ typedef enum WasmAddressType {
#define WASM_ADDR(type, id, offset) \
(((uint64)type << 62) | ((uint64)0 << 32) | ((uint64)offset << 0))

#define WASM_ADDR_TYPE(addr) (((addr)&0xC000000000000000) >> 62)
#define WASM_ADDR_OFFSET(addr) (((addr)&0x00000000FFFFFFFF))
#define WASM_ADDR_TYPE(addr) (((addr) & 0xC000000000000000) >> 62)
#define WASM_ADDR_OFFSET(addr) (((addr) & 0x00000000FFFFFFFF))

#define INVALIED_ADDR (0xFFFFFFFFFFFFFFFF)

Expand Down
14 changes: 7 additions & 7 deletions core/shared/mem-alloc/ems/ems_gc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ hmu_verify(void *vheap, hmu_t *hmu);

#endif /* end of BH_ENABLE_GC_VERIFY */

#define hmu_obj_size(s) ((s)-OBJ_EXTRA_SIZE)
#define hmu_obj_size(s) ((s) - OBJ_EXTRA_SIZE)

#define GC_ALIGN_8(s) (((uint32)(s) + 7) & (uint32)~7)

Expand Down Expand Up @@ -201,11 +201,11 @@ hmu_verify(void *vheap, hmu_t *hmu);

/* Get magic pointer from aligned object pointer */
#define ALIGNED_ALLOC_GET_MAGIC_PTR(obj) \
((uint32_t *)((char *)(obj)-ALIGNED_ALLOC_MAGIC_SIZE))
((uint32_t *)((char *)(obj) - ALIGNED_ALLOC_MAGIC_SIZE))

/* Get offset pointer from aligned object pointer */
#define ALIGNED_ALLOC_GET_OFFSET_PTR(obj) \
((uint32_t *)((char *)(obj)-ALIGNED_ALLOC_METADATA_SIZE))
((uint32_t *)((char *)(obj) - ALIGNED_ALLOC_METADATA_SIZE))

/* Extra overhead for aligned allocations beyond normal OBJ_EXTRA_SIZE */
#define ALIGNED_ALLOC_EXTRA_OVERHEAD ALIGNED_ALLOC_METADATA_SIZE
Expand Down Expand Up @@ -433,10 +433,10 @@ __pragma(pack(pop));
bh_static_assert(sizeof(hmu_tree_node_t) == 8 + 3 * sizeof(void *));
bh_static_assert(offsetof(hmu_tree_node_t, left) == 4);

#define ASSERT_TREE_NODE_ALIGNED_ACCESS(tree_node) \
do { \
bh_assert((((uintptr_t)&tree_node->left) & (sizeof(uintptr_t) - 1)) \
== 0); \
#define ASSERT_TREE_NODE_ALIGNED_ACCESS(tree_node) \
do { \
bh_assert((((uintptr_t) & tree_node->left) & (sizeof(uintptr_t) - 1)) \
== 0); \
} while (0)

typedef struct gc_heap_struct {
Expand Down
9 changes: 6 additions & 3 deletions core/shared/platform/alios/alios_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ os_realloc(void *ptr, unsigned size)

void
os_free(void *ptr)
{}
{
}

int
os_dumps_proc_mem_info(char *out, unsigned int size)
Expand Down Expand Up @@ -74,11 +75,13 @@ os_mprotect(void *addr, size_t size, int prot)

void
os_dcache_flush()
{}
{
}

void
os_icache_flush(void *start, size_t len)
{}
{
}

os_raw_file_handle
os_invalid_raw_handle(void)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/alios/alios_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,5 @@ os_thread_get_stack_boundary()

void
os_thread_jit_write_protect_np(bool enabled)
{}
{
}
3 changes: 2 additions & 1 deletion core/shared/platform/android/platform_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ bh_platform_init()

void
bh_platform_destroy()
{}
{
}

int
os_printf(const char *fmt, ...)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/common/freertos/freertos_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ os_realloc(void *ptr, unsigned size)

void
os_free(void *ptr)
{}
{
}

int
os_dumps_proc_mem_info(char *out, unsigned int size)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/common/posix/posix_memmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ os_mprotect(void *addr, size_t size, int prot)

void
os_dcache_flush(void)
{}
{
}

void
os_icache_flush(void *start, size_t len)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/cosmopolitan/platform_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ bh_platform_init()

void
bh_platform_destroy()
{}
{
}

int
os_printf(const char *format, ...)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/darwin/platform_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ bh_platform_init()

void
bh_platform_destroy()
{}
{
}

int
os_printf(const char *format, ...)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/esp-idf/espidf_memmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ void

void
os_icache_flush(void *start, size_t len)
{}
{
}

#if (WASM_MEM_DUAL_BUS_MIRROR != 0)
void *
Expand Down
Loading
Loading