Przeglądaj źródła

[Kernel] Add ARMCC 6.x support.

Bernard Xiong 6 lat temu
rodzic
commit
b98a0ba804

+ 3 - 5
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);
-

+ 3 - 0
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)
 {

+ 4 - 0
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

+ 1 - 1
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 <sys/errno.h>
 #else
 #include <errno.h>

+ 1 - 1
include/libc/libc_signal.h

@@ -71,7 +71,7 @@ typedef struct siginfo siginfo_t;
 #include <sys/signal.h>
 #endif
 
-#ifdef __CC_ARM
+#if defined(__CC_ARM) || defined(__CLANG_ARM)
 #include <signal.h>
 typedef unsigned long sigset_t;
 

+ 7 - 2
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 <stdarg.h>
     #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

+ 1 - 1
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

+ 1 - 1
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

+ 8 - 3
libcpu/arm/cortex-m4/cpuport.c

@@ -22,9 +22,14 @@
 
 #include <rtthread.h>
 
-#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

+ 8 - 3
libcpu/arm/cortex-m7/cpuport.c

@@ -22,9 +22,14 @@
 
 #include <rtthread.h>
 
-#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

+ 2 - 2
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();

+ 1 - 1
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