1 /*
2  * Copyright (C) 2017 ALLWINNERTECH TECHNOLOGY CO., LTD. All rights reserved.
3  *
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions
6  *  are met:
7  *    1. Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *    2. Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the
12  *       distribution.
13  *    3. Neither the name of ALLWINNERTECH TECHNOLOGY CO., LTD. nor the names of
14  *       its contributors may be used to endorse or promote products derived
15  *       from this software without specific prior written permission.
16  *
17  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef _COMPILER_H_
31 #define _COMPILER_H_
32 
33 #if defined(__CC_ARM)
34 /* ARM Compiler */
35 
36 #define inline      __inline
37 //#define __inline  __inline
38 #define __inline__  __inline
39 
40 #ifndef __always_inline
41 #define __always_inline __forceinline
42 #endif
43 
44 #ifndef __noinline
45 #define __noinline
46 #endif
47 
48 #if defined(__GNUC__)
49 /* ARM Compiler support GNU */
50 #define __packed    __attribute__((__packed__))
51 #else
52 //#define __packed  __packed
53 #endif
54 //#define __asm     __asm
55 //#define __weak    __weak
56 
57 #elif defined(__GNUC__)
58 /* GNU Compiler */
59 
60 // #include <sys/cdefs.h>
61 
62 //#define inline    inline
63 #define __inline    inline
64 #define __inline__  inline
65 
66 #ifdef __always_inline
67 #undef __always_inline  /* already defined in <sys/cdefs.h> */
68 #define __always_inline inline __attribute__((always_inline))
69 #else
70 #define __always_inline inline __attribute__((always_inline))
71 #endif
72 
73 #ifndef __noinline
74 #define __noinline  __attribute__((__noinline__))
75 #endif
76 
77 // #define __packed __attribute__((__packed__))
78 #define __asm       asm
79 #define __weak      __attribute__((weak))
80 
81 #ifdef __CONFIG_XIP_SECTION_FUNC_LEVEL
82 #define __xip_text      __attribute__((section (".xip_text")))
83 #define __xip_rodata    __attribute__((section (".xip_rodata")))
84 #define __nonxip_text   __attribute__((section (".nonxip_text")))
85 #define __nonxip_data   __attribute__((section (".nonxip_data")))
86 #define __nonxip_rodata __attribute__((section (".nonxip_rodata")))
87 #else /* __CONFIG_XIP_SECTION_FUNC_LEVEL */
88 #define __xip_text
89 #define __xip_rodata
90 #define __nonxip_text
91 #define __nonxip_data
92 #define __nonxip_rodata
93 #endif /* __CONFIG_XIP_SECTION_FUNC_LEVEL */
94 
95 #else
96 #error "Compiler not supported."
97 #endif
98 
99 #endif /* _COMPILER_H_ */
100