• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------------
2  * Copyright (c) Huawei Technologies Co., Ltd. 2013-2018. All rights reserved.
3  * Description: compiler related definitions
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  * 1. Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
9  * of conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  * --------------------------------------------------------------------------- */
26 
27 #ifndef _LOS_COMPILER_H
28 #define _LOS_COMPILER_H
29 
30 #ifdef __cplusplus
31 #if __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 #endif /* __cplusplus */
35 
36 /* for IAR Compiler */
37 #ifdef __ICCARM__
38 
39 #ifndef ASM
40 #define ASM           __asm
41 #endif
42 
43 #ifndef asm
44 #define asm           __asm
45 #endif
46 
47 #ifndef INLINE
48 #define INLINE        inline
49 #endif
50 
51 #ifndef STATIC_INLINE
52 #define STATIC_INLINE static inline
53 #endif
54 
55 #ifndef USED
56 #define USED          __root
57 #endif
58 
59 #ifndef WEAK
60 #define WEAK          __weak
61 #endif
62 
63 /* for ARM Compiler */
64 #elif defined(__CC_ARM)
65 
66 #ifndef ASM
67 #define ASM           __asm
68 #endif
69 
70 #ifndef asm
71 #define asm           __asm
72 #endif
73 
74 #ifndef INLINE
75 #define INLINE        __inline
76 #endif
77 
78 #ifndef STATIC_INLINE
79 #define STATIC_INLINE static __inline
80 #endif
81 
82 #ifndef USED
83 #define USED          __attribute__((used))
84 #endif
85 
86 #ifndef WEAK
87 #define WEAK          __attribute__((weak))
88 #endif
89 
90 #ifndef CLZ
91 #define CLZ           __clz
92 #endif
93 
94 #pragma anon_unions
95 
96 /* for GNU Compiler */
97 #elif defined(__GNUC__)
98 
99 #ifndef ASM
100 #define ASM           __asm
101 #endif
102 
103 #ifndef asm
104 #define asm           __asm
105 #endif
106 
107 #ifndef INLINE
108 #define INLINE        inline
109 #endif
110 
111 #ifndef STATIC_INLINE
112 #define STATIC_INLINE static inline
113 #endif
114 
115 #ifndef USED
116 #define USED          __attribute__((used))
117 #endif
118 
119 #ifndef WEAK
120 #define WEAK          __attribute__((__weak__))
121 #endif
122 
123 #ifndef CLZ
124 #define CLZ           __builtin_clz
125 #endif
126 
127 #ifdef typeof
128 #undef typeof
129 #endif
130 #define typeof                  __typeof__
131 #else
132 #error Unknown compiler.
133 #endif
134 
135 #ifdef __cplusplus
136 #if __cplusplus
137 }
138 #endif /* __cplusplus */
139 #endif /* __cplusplus */
140 
141 #endif /* _LOS_COMPILER_H */
142