更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_toolchain.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/**
33 * @defgroup los_toolchain
34 * @ingroup kernel
35 */
36
37#ifndef _LOS_TOOLCHAIN_H
38#define _LOS_TOOLCHAIN_H
39
40#if defined ( __ICCARM__ )
41#include "iccarm_builtin.h"
42#endif
43
44#ifdef __cplusplus
45#if __cplusplus
46extern "C" {
47#endif /* __cplusplus */
48#endif /* __cplusplus */
49
50#ifndef UNUSED
51#define UNUSED(var) \
52 do { \
53 (void)var; \
54 } while (0)
55#endif
56
57/* for ARM Compiler */ //GCC 编译器的内置函数
58#if defined ( __CC_ARM )
59#ifndef ASM
60#define ASM __asm
61#endif
62
63#ifndef INLINE
64#define INLINE __inline
65#endif
66
67#ifndef STATIC_INLINE
68#define STATIC_INLINE static __inline
69#endif
70
71#ifndef USED
72#define USED __attribute__((used))
73#endif
74
75#ifndef WEAK
76#define WEAK __attribute__((weak))
77#endif
78
79#ifndef CLZ
80#define CLZ(value) (__clz(value))
81#endif
82
83#ifndef NORETURN
84#define NORETURN __declspec(noreturn)
85#endif
86
87#ifndef DEPRECATED
88#define DEPRECATED __attribute__((deprecated))
89#endif
90
91/* for IAR Compiler */
92#elif defined ( __ICCARM__ )
93
94#ifndef ASM
95#define ASM __asm
96#endif
97
98#ifndef INLINE
99#define INLINE inline
100#endif
101
102#ifndef STATIC_INLINE
103#define STATIC_INLINE static inline
104#endif
105
106#ifndef USED
107#define USED __root
108#endif
109
110#ifndef WEAK
111#define WEAK __weak
112#endif
113
114#ifndef CLZ
115#define CLZ(value) (__iar_builtin_CLZ(value))
116#endif
117
118#ifndef CTZ
119#define CTZ(value) (__UNDEFINED(value))
120#endif
121
122#ifndef NORETURN
123#define NORETURN __attribute__ ((__noreturn__))
124#endif
125
126#ifndef DEPRECATED
127#define DEPRECATED __attribute__((deprecated))
128#endif
129
130/* for GNU Compiler */
131#elif defined ( __GNUC__ )
132
133#ifndef ASM
134#define ASM __asm
135#endif
136
137#ifndef INLINE
138#define INLINE __inline
139#endif
140
141#ifndef STATIC_INLINE
142#define STATIC_INLINE static inline
143#endif
144
145#ifndef USED
146#define USED __attribute__((used))
147#endif
148
149#ifndef WEAK
150#define WEAK __attribute__((weak))
151#endif
152
153#ifndef CLZ
154#define CLZ(value) (__builtin_clz(value))
155#endif
156
157#ifndef CTZ
158#define CTZ(value) (__builtin_ctz(value))
159#endif
160
161#ifndef NORETURN
162#define NORETURN __attribute__ ((__noreturn__))
163#endif
164
165#ifndef DEPRECATED
166#define DEPRECATED __attribute__((deprecated))
167#endif
168
169#else
170#error Unknown compiler.
171#endif
172
173#ifdef __cplusplus
174#if __cplusplus
175}
176#endif /* __cplusplus */
177#endif /* __cplusplus */
178
179#endif /* _LOS_TOOLCHAIN_H */