]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/LPCUSBLib/Common/Attributes.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / LPCUSBLib / Common / Attributes.h
1 /*\r
2  * @brief Compilers's specific attributes\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * Copyright(C) Dean Camera, 2011, 2012\r
7  * All rights reserved.\r
8  *\r
9  * @par\r
10  * Software that is described herein is for illustrative purposes only\r
11  * which provides customers with programming information regarding the\r
12  * LPC products.  This software is supplied "AS IS" without any warranties of\r
13  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
14  * all warranties, express or implied, including all implied warranties of\r
15  * merchantability, fitness for a particular purpose and non-infringement of\r
16  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
17  * or liability for the use of the software, conveys no license or rights under any\r
18  * patent, copyright, mask work right, or any other intellectual property rights in\r
19  * or to any products. NXP Semiconductors reserves the right to make changes\r
20  * in the software without notification. NXP Semiconductors also makes no\r
21  * representation or warranty that such application will be suitable for the\r
22  * specified use without further testing or modification.\r
23  *\r
24  * @par\r
25  * Permission to use, copy, modify, and distribute this software and its\r
26  * documentation is hereby granted, under NXP Semiconductors' and its\r
27  * licensor's relevant copyrights in the software, without fee, provided that it\r
28  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
29  * copyright, permission, and disclaimer notice must appear in all copies of\r
30  * this code.\r
31 */\r
32 \r
33 \r
34 \r
35 /** @ingroup Group_Common\r
36  *  @defgroup Group_FuncVarAttributes Function/Variable Attributes\r
37  *  @brief Special function/variable attribute macros.\r
38  *\r
39  *  This module contains macros for applying specific attributes to functions and variables to control various\r
40  *  optimizer and code generation features of the compiler. Attributes may be placed in the function prototype\r
41  *  or variable declaration in any order, and multiple attributes can be specified for a single item via a space\r
42  *  separated list.\r
43  *\r
44  *  On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are\r
45  *  critical to the code's function and thus must throw a compile error when used.\r
46  *\r
47  *  @{\r
48  */\r
49 \r
50 #ifndef __LPCUSBlib_FUNCATTR_H__\r
51 #define __LPCUSBlib_FUNCATTR_H__\r
52 \r
53         /* Preprocessor Checks: */\r
54                 #if !defined(__INCLUDE_FROM_COMMON_H)\r
55                         #error Do not include this file directly. Include LPCUSBlib/Common/Common.h instead to gain this functionality.\r
56                 #endif\r
57 \r
58         /* Public Interface - May be used in end-application: */\r
59                 /* Macros: */\r
60                         #if (__GNUC__ >= 3) || defined(__DOXYGEN__)\r
61                                 /** Indicates to the compiler that the function can not ever return, so that any stack restoring or\r
62                                  *  return code may be omitted by the compiler in the resulting binary.\r
63                                  */\r
64                                 #define ATTR_NO_RETURN              __attribute__ ((noreturn))\r
65 \r
66                                 /** Indicates that the function returns a value which should not be ignored by the user code. When\r
67                                  *  applied, any ignored return value from calling the function will produce a compiler warning.\r
68                                  */\r
69                                 #define ATTR_WARN_UNUSED_RESULT     __attribute__ ((warn_unused_result))\r
70 \r
71                                 /** Indicates that the specified parameters of the function are pointers which should never be \c NULL.\r
72                                  *  When applied as a 1-based comma separated list the compiler will emit a warning if the specified\r
73                                  *  parameters are known at compiler time to be \c NULL at the point of calling the function.\r
74                                  */\r
75                                 #define ATTR_NON_NULL_PTR_ARG(...)  __attribute__ ((nonnull (__VA_ARGS__)))\r
76 \r
77                                 /** Removes any preamble or postamble from the function. When used, the function will not have any\r
78                                  *  register or stack saving code. This should be used with caution, and when used the programmer\r
79                                  *  is responsible for maintaining stack and register integrity.\r
80                                  */\r
81                                 #define ATTR_NAKED                  __attribute__ ((naked))\r
82 \r
83                                 /** Prevents the compiler from considering a specified function for in-lining. When applied, the given\r
84                                  *  function will not be in-lined under any circumstances.\r
85                                  */\r
86                                 #define ATTR_NO_INLINE              __attribute__ ((noinline))\r
87 \r
88                                 /** Forces the compiler to inline the specified function. When applied, the given function will be\r
89                                  *  in-lined under all circumstances.\r
90                                  */\r
91                                 #define PRAGMA_ALWAYS_INLINE\r
92                                 #define ATTR_ALWAYS_INLINE          __attribute__ ((always_inline))\r
93 \r
94                                 /** Indicates that the specified function is pure, in that it has no side-effects other than global\r
95                                  *  or parameter variable access.\r
96                                  */\r
97                                 #define ATTR_PURE                   __attribute__ ((pure))\r
98 \r
99                                 /** Indicates that the specified function is constant, in that it has no side effects other than\r
100                                  *  parameter access.\r
101                                  */\r
102                                 #define ATTR_CONST                  __attribute__ ((const))\r
103 \r
104                                 /** Marks a given function as deprecated, which produces a warning if the function is called. */\r
105                                 #define ATTR_DEPRECATED             __attribute__ ((deprecated))\r
106 \r
107                                 /** Marks a function as a weak reference, which can be overridden by other functions with an\r
108                                  *  identical name (in which case the weak reference is discarded at link time).\r
109                                  */\r
110                                 #define PRAGMA_WEAK(func,alias)\r
111                                 #define ATTR_WEAK                   __attribute__ ((weak))\r
112 \r
113                                 /** Marks a function as an alias for another function.\r
114                                  *\r
115                                  *  @param     Func  Name of the function which the given function name should alias.\r
116                                  */\r
117                                 #define ATTR_ALIAS(Func)               __attribute__ ((alias( #Func )))\r
118                         \r
119                                 /** Forces the compiler to not automatically zero the given global variable on startup, so that the\r
120                                  *  current RAM contents is retained. Under most conditions this value will be random due to the\r
121                                  *  behaviour of volatile memory once power is removed, but may be used in some specific circumstances,\r
122                                  *  like the passing of values back after a system watchdog reset.\r
123                                  */\r
124                                 #define ATTR_NO_INIT                __attribute__ ((section (".noinit")))\r
125                                 /** Indicates the minimum alignment in bytes for a variable or struct element.\r
126                                  *\r
127                                  *  @param     Bytes  Minimum number of bytes the item should be aligned to.\r
128                                  */\r
129                                 #define PRAGMA_ALIGN_4096\r
130                                 #define PRAGMA_ALIGN_2048\r
131                                 #define PRAGMA_ALIGN_256\r
132                                 #define PRAGMA_ALIGN_128\r
133                                 #define PRAGMA_ALIGN_64\r
134                                 #define PRAGMA_ALIGN_48\r
135                                 #define PRAGMA_ALIGN_32\r
136                                 #define PRAGMA_ALIGN_4\r
137                                 #define ATTR_ALIGNED(Bytes)                        __attribute__ ((aligned(Bytes)))\r
138 \r
139                                 #define ATTR_DEPRECATED                            __attribute__ ((deprecated))\r
140 #if defined (__CC_ARM)\r
141                                 #define ATTR_ERROR(Message)                        //__attribute__ (( error(Message) ))\r
142 #else\r
143                                 #define ATTR_ERROR(Message)                        __attribute__ (( error(Message) ))\r
144 #endif\r
145                                 #define ATTR_WARNING(Message)                      __attribute__ (( warning(Message) ))\r
146                                 #define ATTR_IAR_PACKED\r
147                                 #define ATTR_PACKED                                        __attribute__ ((packed))\r
148                         #endif\r
149 \r
150                         #if defined(__ICCARM__)\r
151 \r
152                                 /** Indicates to the compiler that the function can not ever return, so that any stack restoring or\r
153                                  *  return code may be omitted by the compiler in the resulting binary.\r
154                                  */\r
155                                 #define ATTR_NO_RETURN              \r
156 \r
157                                 /** Indicates that the function returns a value which should not be ignored by the user code. When\r
158                                  *  applied, any ignored return value from calling the function will produce a compiler warning.\r
159                                  */\r
160                                 #define ATTR_WARN_UNUSED_RESULT\r
161 \r
162                                 /** Indicates that the specified parameters of the function are pointers which should never be \c NULL.\r
163                                  *  When applied as a 1-based comma separated list the compiler will emit a warning if the specified\r
164                                  *  parameters are known at compiler time to be \c NULL at the point of calling the function.\r
165                                  */\r
166                                 #define ATTR_NON_NULL_PTR_ARG(...)\r
167 \r
168                                 /** Removes any preamble or postamble from the function. When used, the function will not have any\r
169                                  *  register or stack saving code. This should be used with caution, and when used the programmer\r
170                                  *  is responsible for maintaining stack and register integrity.\r
171                                  */\r
172                                 #define ATTR_NAKED                  __attribute__ ((naked))\r
173 \r
174                                 /** Prevents the compiler from considering a specified function for in-lining. When applied, the given\r
175                                  *  function will not be in-lined under any circumstances.\r
176                                  */\r
177                                 #define ATTR_NO_INLINE              __attribute__ ((noinline))\r
178 \r
179                                 /** Forces the compiler to inline the specified function. When applied, the given function will be\r
180                                  *  in-lined under all circumstances.\r
181                                  */\r
182                                 #define PRAGMA_ALWAYS_INLINE          _Pragma("inline=forced")\r
183                                 #define ATTR_ALWAYS_INLINE\r
184 \r
185                                 /** Indicates that the specified function is pure, in that it has no side-effects other than global\r
186                                  *  or parameter variable access.\r
187                                  */\r
188                                 #define ATTR_PURE                   __attribute__ ((pure))\r
189 \r
190                                 /** Indicates that the specified function is constant, in that it has no side effects other than\r
191                                  *  parameter access.\r
192                                  */\r
193                                 #define ATTR_CONST\r
194 \r
195                                 /** Marks a given function as deprecated, which produces a warning if the function is called. */\r
196                                 #define ATTR_DEPRECATED//             __attribute__ ((deprecated))\r
197 \r
198                                 /** Marks a function as a weak reference, which can be overridden by other functions with an\r
199                                  *  identical name (in which case the weak reference is discarded at link time).\r
200                                  */\r
201                                 #define _PPTOSTR_(x) #x\r
202                                 #define PRAGMA_WEAK(name, vector) _Pragma(_PPTOSTR_(weak name=vector))\r
203                                 #define ATTR_WEAK\r
204 \r
205                                 /** Marks a function as an alias for another function.\r
206                                  *\r
207                                  *  @param     Func  Name of the function which the given function name should alias.\r
208                                  */\r
209                                 #define ATTR_ALIAS(Func)\r
210                         \r
211                                 /** Forces the compiler to not automatically zero the given global variable on startup, so that the\r
212                                  *  current RAM contents is retained. Under most conditions this value will be random due to the\r
213                                  *  behaviour of volatile memory once power is removed, but may be used in some specific circumstances,\r
214                                  *  like the passing of values back after a system watchdog reset.\r
215                                  */\r
216                                 #define ATTR_NO_INIT                __attribute__ ((section (".noinit")))\r
217                                 /** Indicates the minimum alignment in bytes for a variable or struct element.\r
218                                  *\r
219                                  *  @param     Bytes  Minimum number of bytes the item should be aligned to.\r
220                                  */\r
221                                 #define PRAGMA_ALIGN_4096          _Pragma("data_alignment=4096")\r
222                                 #define PRAGMA_ALIGN_2048          _Pragma("data_alignment=2048")\r
223                                 #define PRAGMA_ALIGN_256           _Pragma("data_alignment=256")\r
224                                 #define PRAGMA_ALIGN_128           _Pragma("data_alignment=128")\r
225                                 #define PRAGMA_ALIGN_64            _Pragma("data_alignment=64")\r
226                                 #define PRAGMA_ALIGN_48            _Pragma("data_alignment=48")\r
227                                 #define PRAGMA_ALIGN_32            _Pragma("data_alignment=32")\r
228                                 #define PRAGMA_ALIGN_4             _Pragma("data_alignment=4")\r
229                                 #define ATTR_ALIGNED(Bytes)\r
230 \r
231                                 //#define ATTR_DEPRECATED                                  __attribute__ ((deprecated))\r
232 \r
233                                 #define ATTR_ERROR(Message)//                      __attribute__ (( error(Message) ))\r
234 \r
235                                 #define ATTR_WARNING(Message)   //                 __attribute__ (( warning(Message) ))\r
236 \r
237                                 #define ATTR_IAR_PACKED                            __packed\r
238 \r
239                                 #define ATTR_PACKED\r
240 \r
241                         #endif\r
242 \r
243                         /** Places the function in one of the initialization sections, which execute before the main function\r
244                          *  of the application. Refer to the avr-libc manual for more information on the initialization sections.\r
245                          *\r
246                          *  @param     SectionIndex  Initialization section number where the function should be placed.\r
247                          */\r
248                         #define ATTR_INIT_SECTION(SectionIndex) __attribute__ ((naked, section (".init" #SectionIndex )))\r
249 \r
250                         /** Marks a variable or struct element for packing into the smallest space available, omitting any\r
251                          *  alignment bytes usually added between fields to optimize field accesses.\r
252                          */\r
253 #endif\r
254 \r
255 /** @} */\r
256 \r