diff --git a/components/finsh/shell.c b/components/finsh/shell.c index ccd5b973063154bea7396ca09d1e4ee9e89f2629..441f6c3241745a98e7ed9dafdb3c85d7fe331ebe 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 138ebe977345a863c226f950e0c007eb59f18617..4393b5f2af1ffb3b09c3155c2f5a9e2153454698 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 b292cd7629834a25c4194ea545baac46e36d6eff..c826c8a0ec8dc62d419b7af5ec3224f16868db3a 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 1875d9ab00e0fcdba5261423dbab2f45627f3277..77a589276a1c4496fc62d3a947568df35f70afc4 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 5db43eb35e8b369265ecf655e498a9fc273bf761..b592b8227ede36ed5c72d5585bd0574e06951ebe 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 9379a7db4473d53da8bc3e37eb421e6dc5a28e99..92b997151d9c923ffae79248be5d312bc942d6c1 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 385d57500e60b71d5098bc48f2c5e1f0651bf5d9..020c34764ea5c8c9b0fe33cfc8df10c49ebe4ebf 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 82d975d6482e041a41d800b1a9c8b928bfa7addb..f8da2d46bf4e22efb9fa294fde13c2e22d489206 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 ed7102f844cdc36dd414e7e1a4b69bf79986f6e8..1d2184c2d729407b7786be224f4b209471d93b7b 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 ed7102f844cdc36dd414e7e1a4b69bf79986f6e8..1d2184c2d729407b7786be224f4b209471d93b7b 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 410b20be939f283f3058fb3b2029304a198c8b9d..09f0680b5572b0339d63e106a4f06e75fc64de65 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 a31e5a6f93a7cef43f818de475bf4f243f6da252..e10c093c70b33c61ae2bf68283f7d66440392199 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