From 004e5bfd60e661ef8e9d2d13d6f4cd3e6e080362 Mon Sep 17 00:00:00 2001 From: Shell Date: Sat, 30 Mar 2024 17:58:38 +0800 Subject: [PATCH] [fixup] aarch64 UMP compiler error (#8677) Signed-off-by: Shell --- components/drivers/ofw/base.c | 2 +- components/drivers/ofw/irq.c | 2 +- components/drivers/pic/pic_rthw.c | 2 +- components/libc/compilers/common/ctime.c | 3 ++- components/lwp/lwp_internal.c | 2 +- components/lwp/lwp_syscall.c | 2 +- components/mm/mm_page.c | 8 ++++---- libcpu/aarch64/common/SConscript | 4 ++-- libcpu/aarch64/common/interrupt.c | 23 +++++++++++++---------- libcpu/aarch64/common/mmu.c | 3 ++- tools/ci/cpp_check.py | 3 ++- 11 files changed, 30 insertions(+), 24 deletions(-) diff --git a/components/drivers/ofw/base.c b/components/drivers/ofw/base.c index 117c723807..8d629a9f67 100644 --- a/components/drivers/ofw/base.c +++ b/components/drivers/ofw/base.c @@ -1474,7 +1474,7 @@ static const char *ofw_get_prop_fuzzy_name(const struct rt_ofw_node *np, const c char *sf, split_field[64]; rt_size_t len = 0, max_ak = 0; const char *str, *result = RT_NULL; - RT_BITMAP_DECLARE(ak, sizeof(split_field)); + RT_BITMAP_DECLARE(ak, sizeof(split_field)) = {0}; struct rt_ofw_prop *prop; /* diff --git a/components/drivers/ofw/irq.c b/components/drivers/ofw/irq.c index 3ca299bf70..d5b2fb5a30 100755 --- a/components/drivers/ofw/irq.c +++ b/components/drivers/ofw/irq.c @@ -624,7 +624,7 @@ int rt_ofw_get_irq(struct rt_ofw_node *np, int index) if ((rt_int64_t)cpuid >= 0) { - RT_DECLARE_BITMAP(affinity, RT_CPUS_NR) = { 0 }; + RT_BITMAP_DECLARE(affinity, RT_CPUS_NR) = { 0 }; rt_bitmap_set_bit(affinity, cpuid); diff --git a/components/drivers/pic/pic_rthw.c b/components/drivers/pic/pic_rthw.c index b46c7bc26d..e83f12a1fa 100644 --- a/components/drivers/pic/pic_rthw.c +++ b/components/drivers/pic/pic_rthw.c @@ -66,7 +66,7 @@ void rt_hw_interrupt_uninstall(int vector, rt_isr_handler_t handler, void *param #if defined(RT_USING_SMP) || defined(RT_USING_AMP) void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask) { - RT_DECLARE_BITMAP(cpu_masks, RT_CPUS_NR) = { cpu_mask }; + RT_BITMAP_DECLARE(cpu_masks, RT_CPUS_NR) = { cpu_mask }; rt_pic_irq_send_ipi(ipi_vector, cpu_masks); } diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c index a1bb3c439d..c6602698ff 100644 --- a/components/libc/compilers/common/ctime.c +++ b/components/libc/compilers/common/ctime.c @@ -879,7 +879,8 @@ static void rtthread_timer_wrapper(void *timerobj) } #ifdef RT_USING_SMART /* this field is named as tid in musl */ - int tid = *(int *)&timer->sigev_notify_function; + void *ptid = &timer->sigev_notify_function; + int tid = *(int *)ptid; struct lwp_timer_event_param *data = rt_container_of(timer->work, struct lwp_timer_event_param, work); data->signo = timer->sigev_signo; diff --git a/components/lwp/lwp_internal.c b/components/lwp/lwp_internal.c index e460a1ac3f..1fc68f2e73 100644 --- a/components/lwp/lwp_internal.c +++ b/components/lwp/lwp_internal.c @@ -89,7 +89,7 @@ static rt_err_t _mutex_take_safe(rt_mutex_t mtx, rt_int32_t timeout, int flags) } else { - rc = -RT_EINVAL; + rc = -RT_ERROR; LOG_W("%s: mtx should not be NULL", __func__); RT_ASSERT(0); } diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 5d9cf05b63..585101b71f 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -2700,7 +2700,7 @@ sysret_t sys_execve(const char *path, char *const argv[], char *const envp[]) */ RT_ASSERT(rt_list_entry(lwp->t_grp.prev, struct rt_thread, sibling) == thread); - strncpy(thread->parent.name, run_name + last_backslash, RT_NAME_MAX); + strncpy(thread->parent.name, run_name + last_backslash, RT_NAME_MAX - 1); strncpy(lwp->cmd, new_lwp->cmd, RT_NAME_MAX); rt_free(lwp->exe_file); lwp->exe_file = strndup(new_lwp->exe_file, DFS_PATH_MAX); diff --git a/components/mm/mm_page.c b/components/mm/mm_page.c index fcae953a2d..ab3b898224 100644 --- a/components/mm/mm_page.c +++ b/components/mm/mm_page.c @@ -109,7 +109,7 @@ static void _collect() rt_page_t page = _trace_head; if (!page) { - LOG_RAW("ok! ALLOC CNT %ld\n", _alloc_cnt); + rt_kprintf("ok! ALLOC CNT %ld\n", _alloc_cnt); } else { @@ -159,7 +159,7 @@ void _report(rt_page_t page, size_t size_bits, char *msg) { void *pg_va = rt_page_page2addr(page); LOG_W("%s: %p, allocator: %p, size bits: %lx", msg, pg_va, page->caller, page->trace_size); - LOG_RAW("backtrace\n"); + rt_kprintf("backtrace\n"); rt_backtrace(); } @@ -175,7 +175,7 @@ static void _trace_free(rt_page_t page, void *caller, size_t size_bits) } else if (page->trace_size != size_bits) { - LOG_RAW("free with size bits %lx\n", size_bits); + rt_kprintf("free with size bits %lx\n", size_bits); _report(page, size_bits, "incompatible size bits parameter"); return ; } @@ -636,7 +636,7 @@ void list_page(void) rt_kprintf("[0x%08p]", rt_page_page2addr(hp)); hp = hp->next; } - LOG_RAW("\n"); + rt_kprintf("\n"); } rt_spin_unlock_irqrestore(&_spinlock, level); diff --git a/libcpu/aarch64/common/SConscript b/libcpu/aarch64/common/SConscript index 7a36cad1ad..92740f55de 100644 --- a/libcpu/aarch64/common/SConscript +++ b/libcpu/aarch64/common/SConscript @@ -12,8 +12,8 @@ if GetDepend('RT_USING_OFW') == False: SrcRemove(src, ['setup.c', 'cpu_psci.c', 'psci.c']) if GetDepend('RT_USING_PIC') == True: - SrcRemove(src, ['gicv3.c', 'gic.c', 'interrupt.c', 'gtimer.c']) - + SrcRemove(src, ['gicv3.c', 'gic.c', 'gtimer.c']) + group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH) # build for sub-directory diff --git a/libcpu/aarch64/common/interrupt.c b/libcpu/aarch64/common/interrupt.c index 570859aee6..55f6a82f31 100644 --- a/libcpu/aarch64/common/interrupt.c +++ b/libcpu/aarch64/common/interrupt.c @@ -16,10 +16,6 @@ #include "gicv3.h" #include "ioremap.h" - -/* exception and interrupt handler table */ -struct rt_irq_desc isr_table[MAX_HANDLERS]; - #ifndef RT_USING_SMP /* Those variables will be accessed in ISR, so we need to share them. */ rt_ubase_t rt_interrupt_from_thread = 0; @@ -27,6 +23,11 @@ rt_ubase_t rt_interrupt_to_thread = 0; rt_ubase_t rt_thread_switch_interrupt_flag = 0; #endif +#ifndef RT_USING_PIC + +/* exception and interrupt handler table */ +struct rt_irq_desc isr_table[MAX_HANDLERS]; + #ifndef RT_CPUS_NR #define RT_CPUS_NR 1 #endif @@ -138,17 +139,17 @@ void rt_hw_interrupt_mask(int vector) #ifdef SOC_BCM283x if (vector < 32) { - IRQ_DISABLE1 = (1 << vector); + IRQ_DISABLE1 = (1UL << vector); } else if (vector < 64) { vector = vector % 32; - IRQ_DISABLE2 = (1 << vector); + IRQ_DISABLE2 = (1UL << vector); } else { vector = vector - 64; - IRQ_DISABLE_BASIC = (1 << vector); + IRQ_DISABLE_BASIC = (1UL << vector); } #else arm_gic_mask(0, vector); @@ -164,17 +165,17 @@ void rt_hw_interrupt_umask(int vector) #ifdef SOC_BCM283x if (vector < 32) { - IRQ_ENABLE1 = (1 << vector); + IRQ_ENABLE1 = (1UL << vector); } else if (vector < 64) { vector = vector % 32; - IRQ_ENABLE2 = (1 << vector); + IRQ_ENABLE2 = (1UL << vector); } else { vector = vector - 64; - IRQ_ENABLE_BASIC = (1 << vector); + IRQ_ENABLE_BASIC = (1UL << vector); } #else arm_gic_umask(0, vector); @@ -416,6 +417,8 @@ void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler) } #endif +#endif /* RT_USING_PIC */ + #if defined(FINSH_USING_MSH) && defined(RT_USING_INTERRUPT_INFO) int list_isr() { diff --git a/libcpu/aarch64/common/mmu.c b/libcpu/aarch64/common/mmu.c index e9f0f4e999..9583b9d207 100644 --- a/libcpu/aarch64/common/mmu.c +++ b/libcpu/aarch64/common/mmu.c @@ -690,6 +690,7 @@ static unsigned long *_query(rt_aspace_t aspace, void *vaddr, int *plvl_shf) if (!(cur_lv_tbl[off] & MMU_TYPE_USED)) { + *plvl_shf = level_shift; return (void *)0; } @@ -709,11 +710,11 @@ static unsigned long *_query(rt_aspace_t aspace, void *vaddr, int *plvl_shf) off &= MMU_LEVEL_MASK; page = cur_lv_tbl[off]; + *plvl_shf = level_shift; if (!(page & MMU_TYPE_USED)) { return (void *)0; } - *plvl_shf = level_shift; return &cur_lv_tbl[off]; } diff --git a/tools/ci/cpp_check.py b/tools/ci/cpp_check.py index dc9f6610b9..e7b2847c4a 100644 --- a/tools/ci/cpp_check.py +++ b/tools/ci/cpp_check.py @@ -27,9 +27,10 @@ class CPPCheck: [ 'cppcheck', '-DRT_ASSERT(x)=', - '-Drt_list_for_each_entry(a,b,c)=a=(void*)b', + '-Drt_list_for_each_entry(a,b,c)=a=(void*)b;', '-I include', '-I thread/components/finsh', + # it's okay because CI will do the real compilation to check this '--suppress=syntaxError', '--enable=warning', 'performance',