diff --git a/BUILD.gn b/BUILD.gn index e069f52d..aa5e3a7f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -29,9 +29,17 @@ import("config.gni") +LITEOS_LOS_CONFIG_H = rebase_path("$LITEOSTOPDIR/kernel/include/los_config.h") + config("los_config") { cflags = [ "-Werror" ] + asmflags = [ + "-DCLZ=CLZ", + "-imacros", + "$LITEOS_LOS_CONFIG_H", + ] + include_dirs = [ "//kernel/liteos_m/kernel/include", "//kernel/liteos_m/kernel/arch/include", diff --git a/components/cppsupport/los_cppsupport.c b/components/cppsupport/los_cppsupport.c index 057c3ba2..0603dfa6 100644 --- a/components/cppsupport/los_cppsupport.c +++ b/components/cppsupport/los_cppsupport.c @@ -31,7 +31,6 @@ #include "los_cppsupport.h" - typedef VOID (*InitFunc)(VOID); INT32 LOS_CppSystemInit(UINTPTR initArrayStart, UINTPTR initArrayEnd) @@ -39,12 +38,10 @@ INT32 LOS_CppSystemInit(UINTPTR initArrayStart, UINTPTR initArrayEnd) UINTPTR *start; InitFunc initFunc = NULL; - for (start = (UINTPTR *)initArrayStart; start < (UINTPTR *)initArrayEnd; start++){ + for (start = (UINTPTR *)initArrayStart; start < (UINTPTR *)initArrayEnd; start++) { initFunc = (InitFunc)(*start); initFunc(); } return 0; } - - diff --git a/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile b/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile index 94f5b63f..3c0d34c5 100644 --- a/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile +++ b/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile @@ -176,7 +176,7 @@ $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ + $(AS) -c $(CFLAGS) $(ASFLAGS) $< -o $@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile $(LDSCRIPT) $(CC) $(OBJECTS) $(LDFLAGS) -o $@ diff --git a/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk b/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk index fa673356..0ac24ece 100644 --- a/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk +++ b/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk @@ -36,9 +36,11 @@ C_INCLUDES += -I. \ -I$(LITEOSTOPDIR)/kernel/arch/include \ -I$(LITEOSTOPDIR)/kernel/arch/risc-v/nuclei/gcc +ASFLAGS += -imacros $(LITEOSTOPDIR)/kernel/include/los_config.h -DCLZ=CLZ + # list of ASM .S program objects OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMS_SOURCES:.S=.o))) vpath %.S $(sort $(dir $(ASMS_SOURCES))) $(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) $< -o $@ + $(CC) -c $(CFLAGS) $(ASFLAGS) $< -o $@ diff --git a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile index 2405a7a2..2d47e18b 100644 --- a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile +++ b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile @@ -178,7 +178,7 @@ $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ + $(AS) -c $(CFLAGS) $(ASFLAGS) $< -o $@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile $(LDSCRIPT) $(CC) $(OBJECTS) $(LDFLAGS) -o $@ diff --git a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk index c6202e32..cd59fec8 100644 --- a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk +++ b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk @@ -36,9 +36,11 @@ C_INCLUDES += -I. \ -I$(LITEOSTOPDIR)/kernel/arch/include \ -I$(LITEOSTOPDIR)/kernel/arch/risc-v/nuclei/gcc +ASFLAGS += -imacros $(LITEOSTOPDIR)/kernel/include/los_config.h -DCLZ=CLZ + # list of ASM .S program objects OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMS_SOURCES:.S=.o))) vpath %.S $(sort $(dir $(ASMS_SOURCES))) $(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) $< -o $@ + $(CC) -c $(CFLAGS) $(ASFLAGS) $< -o $@ diff --git a/utils/los_compiler.h b/utils/los_compiler.h index d5b2cdee..33add0f8 100644 --- a/utils/los_compiler.h +++ b/utils/los_compiler.h @@ -194,7 +194,7 @@ extern "C" { * Allow inline sections */ #ifndef LITE_OS_SEC_ALW_INLINE -#define LITE_OS_SEC_ALW_INLINE //__attribute__((always_inline)) +#define LITE_OS_SEC_ALW_INLINE // __attribute__((always_inline)) #endif /** @@ -210,7 +210,7 @@ extern "C" { * .Text section (Code section) */ #ifndef LITE_OS_SEC_TEXT -#define LITE_OS_SEC_TEXT //__attribute__((section(".sram.text"))) +#define LITE_OS_SEC_TEXT // __attribute__((section(".sram.text"))) #endif /** @@ -226,7 +226,7 @@ extern "C" { * .Text.init section */ #ifndef LITE_OS_SEC_TEXT_INIT -#define LITE_OS_SEC_TEXT_INIT //__attribute__((section(".dyn.text"))) +#define LITE_OS_SEC_TEXT_INIT // __attribute__((section(".dyn.text"))) #endif /** @@ -234,7 +234,7 @@ extern "C" { * .Data section */ #ifndef LITE_OS_SEC_DATA -#define LITE_OS_SEC_DATA //__attribute__((section(".dyn.data"))) +#define LITE_OS_SEC_DATA // __attribute__((section(".dyn.data"))) #endif /** @@ -242,7 +242,7 @@ extern "C" { * .Data.init section */ #ifndef LITE_OS_SEC_DATA_INIT -#define LITE_OS_SEC_DATA_INIT //__attribute__((section(".dyn.data"))) +#define LITE_OS_SEC_DATA_INIT // __attribute__((section(".dyn.data"))) #endif /** @@ -250,7 +250,7 @@ extern "C" { * Not initialized variable section */ #ifndef LITE_OS_SEC_BSS -#define LITE_OS_SEC_BSS //__attribute__((section(".sym.bss"))) +#define LITE_OS_SEC_BSS // __attribute__((section(".sym.bss"))) #endif /** @@ -270,34 +270,34 @@ extern "C" { #endif #ifndef LITE_OS_SEC_TEXT_DATA -#define LITE_OS_SEC_TEXT_DATA //__attribute__((section(".dyn.data"))) -#define LITE_OS_SEC_TEXT_BSS //__attribute__((section(".dyn.bss"))) -#define LITE_OS_SEC_TEXT_RODATA //__attribute__((section(".dyn.rodata"))) +#define LITE_OS_SEC_TEXT_DATA // __attribute__((section(".dyn.data"))) +#define LITE_OS_SEC_TEXT_BSS // __attribute__((section(".dyn.bss"))) +#define LITE_OS_SEC_TEXT_RODATA // __attribute__((section(".dyn.rodata"))) #endif #ifndef LITE_OS_SEC_SYMDATA -#define LITE_OS_SEC_SYMDATA //__attribute__((section(".sym.data"))) +#define LITE_OS_SEC_SYMDATA // __attribute__((section(".sym.data"))) #endif #ifndef LITE_OS_SEC_SYMBSS -#define LITE_OS_SEC_SYMBSS //__attribute__((section(".sym.bss"))) +#define LITE_OS_SEC_SYMBSS // __attribute__((section(".sym.bss"))) #endif #ifndef LITE_OS_SEC_KEEP_DATA_DDR -#define LITE_OS_SEC_KEEP_DATA_DDR //__attribute__((section(".keep.data.ddr"))) +#define LITE_OS_SEC_KEEP_DATA_DDR // __attribute__((section(".keep.data.ddr"))) #endif #ifndef LITE_OS_SEC_KEEP_TEXT_DDR -#define LITE_OS_SEC_KEEP_TEXT_DDR //__attribute__((section(".keep.text.ddr"))) +#define LITE_OS_SEC_KEEP_TEXT_DDR // __attribute__((section(".keep.text.ddr"))) #endif #ifndef LITE_OS_SEC_KEEP_DATA_SRAM -#define LITE_OS_SEC_KEEP_DATA_SRAM //__attribute__((section(".keep.data.sram"))) +#define LITE_OS_SEC_KEEP_DATA_SRAM // __attribute__((section(".keep.data.sram"))) #endif #ifndef LITE_OS_SEC_KEEP_TEXT_SRAM -#define LITE_OS_SEC_KEEP_TEXT_SRAM //__attribute__((section(".keep.text.sram"))) +#define LITE_OS_SEC_KEEP_TEXT_SRAM // __attribute__((section(".keep.text.sram"))) #endif #ifndef LITE_OS_SEC_BSS_MINOR @@ -378,7 +378,7 @@ typedef signed int INTPTR; * @ingroup los_base * Align the tail of the object with the base address addr, with size bytes being the smallest unit of alignment. */ -#define TRUNCATE(addr, size) ((addr) & ~((size)-1)) +#define TRUNCATE(addr, size) ((addr) & ~((size) - 1)) /**