From b98a0ba804f388f531106ff9602eb22ee66fe751 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sun, 23 Sep 2018 12:08:44 +0800 Subject: [PATCH] [Kernel] Add ARMCC 6.x support. --- components/finsh/shell.c | 8 +++----- components/libc/compilers/armlibc/mem_std.c | 3 +++ components/libc/compilers/armlibc/stubs.c | 4 ++++ components/net/lwip-2.0.2/src/arch/include/arch/cc.h | 2 +- include/libc/libc_signal.h | 2 +- include/rtdef.h | 9 +++++++-- include/rtlibc.h | 2 +- include/rtthread.h | 2 +- libcpu/arm/cortex-m4/cpuport.c | 11 ++++++++--- libcpu/arm/cortex-m7/cpuport.c | 11 ++++++++--- src/components.c | 4 ++-- src/kservice.c | 2 +- 12 files changed, 40 insertions(+), 20 deletions(-) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index ccd5b97306..441f6c3241 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -55,7 +55,9 @@ static struct rt_thread finsh_thread; ALIGN(RT_ALIGN_SIZE) static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE]; +struct finsh_shell _shell; #endif + struct finsh_shell *shell; static char *finsh_prompt_custom = RT_NULL; @@ -473,9 +475,6 @@ static void shell_push_history(struct finsh_shell *shell) } #endif -#ifndef RT_USING_HEAP -struct finsh_shell _shell; -#endif void finsh_thread_entry(void *parameter) { char ch; @@ -792,7 +791,7 @@ int finsh_system_init(void) rt_thread_t tid; #ifdef FINSH_USING_SYMTAB -#ifdef __CC_ARM /* ARM C Compiler */ +#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM C Compiler */ extern const int FSymTab$$Base; extern const int FSymTab$$Limit; extern const int VSymTab$$Base; @@ -867,4 +866,3 @@ int finsh_system_init(void) return 0; } INIT_APP_EXPORT(finsh_system_init); - diff --git a/components/libc/compilers/armlibc/mem_std.c b/components/libc/compilers/armlibc/mem_std.c index 138ebe9773..4393b5f2af 100644 --- a/components/libc/compilers/armlibc/mem_std.c +++ b/components/libc/compilers/armlibc/mem_std.c @@ -16,8 +16,11 @@ #include "rtthread.h" #ifdef RT_USING_HEAP + +#ifdef __CC_ARM /* avoid the heap and heap-using library functions supplied by arm */ #pragma import(__use_no_heap) +#endif void *malloc(size_t n) { diff --git a/components/libc/compilers/armlibc/stubs.c b/components/libc/compilers/armlibc/stubs.c index b292cd7629..c826c8a0ec 100644 --- a/components/libc/compilers/armlibc/stubs.c +++ b/components/libc/compilers/armlibc/stubs.c @@ -37,7 +37,11 @@ #include "dfs_posix.h" #endif +#ifdef __CLANG_ARM +__asm(".global __use_no_semihosting\n\t"); +#else #pragma import(__use_no_semihosting_swi) +#endif /* Standard IO device handles. */ #define STDIN 0 diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h index 1875d9ab00..77a589276a 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h @@ -46,7 +46,7 @@ #define X32_F "lx" #ifdef RT_USING_LIBC -#if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__) +#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__) #include #else #include diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h index 5db43eb35e..b592b8227e 100644 --- a/include/libc/libc_signal.h +++ b/include/libc/libc_signal.h @@ -71,7 +71,7 @@ typedef struct siginfo siginfo_t; #include #endif -#ifdef __CC_ARM +#if defined(__CC_ARM) || defined(__CLANG_ARM) #include typedef unsigned long sigset_t; diff --git a/include/rtdef.h b/include/rtdef.h index 9379a7db44..92b997151d 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -88,14 +88,19 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ #define RT_UINT32_MAX 0xffffffff /**< Maxium number of UINT32 */ #define RT_TICK_MAX RT_UINT32_MAX /**< Maxium number of tick */ +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +#define __CLANG_ARM +#endif + /* Compiler Related Definitions */ -#ifdef __CC_ARM /* ARM Compiler */ +#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */ #include #define SECTION(x) __attribute__((section(x))) #define RT_UNUSED __attribute__((unused)) #define RT_USED __attribute__((used)) #define ALIGN(n) __attribute__((aligned(n))) - #define RT_WEAK __weak + + #define RT_WEAK __attribute__((weak)) #define rt_inline static __inline /* module compiling */ #ifdef RT_USING_MODULE diff --git a/include/rtlibc.h b/include/rtlibc.h index 385d57500e..020c34764e 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -25,7 +25,7 @@ #include "libc/libc_signal.h" #include "libc/libc_fdset.h" -#if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__) +#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__) typedef signed long off_t; typedef int mode_t; #endif diff --git a/include/rtthread.h b/include/rtthread.h index 82d975d648..f8da2d46bf 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -501,7 +501,7 @@ rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count); rt_int32_t rt_strcmp(const char *cs, const char *ct); rt_size_t rt_strlen(const char *src); char *rt_strdup(const char *s); -#ifdef __CC_ARM +#if defined(__CC_ARM) || defined(__CLANG_ARM) /* leak strdup interface */ char* strdup(const char* str); #endif diff --git a/libcpu/arm/cortex-m4/cpuport.c b/libcpu/arm/cortex-m4/cpuport.c index ed7102f844..1d2184c2d7 100644 --- a/libcpu/arm/cortex-m4/cpuport.c +++ b/libcpu/arm/cortex-m4/cpuport.c @@ -22,9 +22,14 @@ #include -#define USE_FPU /* ARMCC */ ( (defined ( __CC_ARM ) && defined ( __TARGET_FPU_VFP )) \ - /* IAR */ || (defined ( __ICCARM__ ) && defined ( __ARMVFP__ )) \ +#if /* ARMCC */ ( (defined ( __CC_ARM ) && defined ( __TARGET_FPU_VFP )) \ + /* Clang */ || (defined ( __CLANG_ARM ) && defined ( __TARGET_FPU_VFP )) \ + /* IAR */ || (defined ( __ICCARM__ ) && defined ( __ARMVFP__ )) \ /* GNU */ || (defined ( __GNUC__ ) && defined ( __VFP_FP__ ) && !defined(__SOFTFP__)) ) +#define USE_FPU 1 +#else +#define USE_FPU 0 +#endif /* exception and interrupt handler table */ rt_uint32_t rt_interrupt_from_thread; @@ -452,7 +457,7 @@ RT_WEAK void rt_hw_cpu_reset(void) * @return return the index of the first bit set. If value is 0, then this function * shall return 0. */ -#if defined(__CC_ARM) +#if defined(__CC_ARM) || defined(__CLANG_ARM) __asm int __rt_ffs(int value) { CMP r0, #0x00 diff --git a/libcpu/arm/cortex-m7/cpuport.c b/libcpu/arm/cortex-m7/cpuport.c index ed7102f844..1d2184c2d7 100644 --- a/libcpu/arm/cortex-m7/cpuport.c +++ b/libcpu/arm/cortex-m7/cpuport.c @@ -22,9 +22,14 @@ #include -#define USE_FPU /* ARMCC */ ( (defined ( __CC_ARM ) && defined ( __TARGET_FPU_VFP )) \ - /* IAR */ || (defined ( __ICCARM__ ) && defined ( __ARMVFP__ )) \ +#if /* ARMCC */ ( (defined ( __CC_ARM ) && defined ( __TARGET_FPU_VFP )) \ + /* Clang */ || (defined ( __CLANG_ARM ) && defined ( __TARGET_FPU_VFP )) \ + /* IAR */ || (defined ( __ICCARM__ ) && defined ( __ARMVFP__ )) \ /* GNU */ || (defined ( __GNUC__ ) && defined ( __VFP_FP__ ) && !defined(__SOFTFP__)) ) +#define USE_FPU 1 +#else +#define USE_FPU 0 +#endif /* exception and interrupt handler table */ rt_uint32_t rt_interrupt_from_thread; @@ -452,7 +457,7 @@ RT_WEAK void rt_hw_cpu_reset(void) * @return return the index of the first bit set. If value is 0, then this function * shall return 0. */ -#if defined(__CC_ARM) +#if defined(__CC_ARM) || defined(__CLANG_ARM) __asm int __rt_ffs(int value) { CMP r0, #0x00 diff --git a/src/components.c b/src/components.c index 410b20be93..09f0680b55 100644 --- a/src/components.c +++ b/src/components.c @@ -136,7 +136,7 @@ void rt_application_init(void); void rt_hw_board_init(void); int rtthread_startup(void); -#if defined (__CC_ARM) +#if defined(__CC_ARM) || defined(__CLANG_ARM) extern int $Super$$main(void); /* re-define main function */ int $Sub$$main(void) @@ -185,7 +185,7 @@ void main_thread_entry(void *parameter) rt_components_init(); /* invoke system main function */ -#if defined (__CC_ARM) +#if defined(__CC_ARM) || defined(__CLANG_ARM) $Super$$main(); /* for ARMCC. */ #elif defined(__ICCARM__) || defined(__GNUC__) main(); diff --git a/src/kservice.c b/src/kservice.c index a31e5a6f93..e10c093c70 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -525,7 +525,7 @@ char *rt_strdup(const char *s) return tmp; } RTM_EXPORT(rt_strdup); -#ifdef __CC_ARM +#if defined(__CC_ARM) || defined(__CLANG_ARM) char *strdup(const char *s) __attribute__((alias("rt_strdup"))); #endif #endif -- GitLab