BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:fbdae7e6d805 1
borlanic 0:fbdae7e6d805 2 /** \addtogroup platform */
borlanic 0:fbdae7e6d805 3 /** @{*/
borlanic 0:fbdae7e6d805 4 /**
borlanic 0:fbdae7e6d805 5 * \defgroup platform_toolchain Toolchain functions
borlanic 0:fbdae7e6d805 6 * @{
borlanic 0:fbdae7e6d805 7 */
borlanic 0:fbdae7e6d805 8
borlanic 0:fbdae7e6d805 9 /* mbed Microcontroller Library
borlanic 0:fbdae7e6d805 10 * Copyright (c) 2006-2013 ARM Limited
borlanic 0:fbdae7e6d805 11 *
borlanic 0:fbdae7e6d805 12 * Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:fbdae7e6d805 13 * you may not use this file except in compliance with the License.
borlanic 0:fbdae7e6d805 14 * You may obtain a copy of the License at
borlanic 0:fbdae7e6d805 15 *
borlanic 0:fbdae7e6d805 16 * http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:fbdae7e6d805 17 *
borlanic 0:fbdae7e6d805 18 * Unless required by applicable law or agreed to in writing, software
borlanic 0:fbdae7e6d805 19 * distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:fbdae7e6d805 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:fbdae7e6d805 21 * See the License for the specific language governing permissions and
borlanic 0:fbdae7e6d805 22 * limitations under the License.
borlanic 0:fbdae7e6d805 23 */
borlanic 0:fbdae7e6d805 24 #ifndef MBED_TOOLCHAIN_H
borlanic 0:fbdae7e6d805 25 #define MBED_TOOLCHAIN_H
borlanic 0:fbdae7e6d805 26
borlanic 0:fbdae7e6d805 27 #include "mbed_preprocessor.h"
borlanic 0:fbdae7e6d805 28
borlanic 0:fbdae7e6d805 29
borlanic 0:fbdae7e6d805 30 // Warning for unsupported compilers
borlanic 0:fbdae7e6d805 31 #if !defined(__GNUC__) /* GCC */ \
borlanic 0:fbdae7e6d805 32 && !defined(__CC_ARM) /* ARMCC */ \
borlanic 0:fbdae7e6d805 33 && !defined(__clang__) /* LLVM/Clang */ \
borlanic 0:fbdae7e6d805 34 && !defined(__ICCARM__) /* IAR */
borlanic 0:fbdae7e6d805 35 #warning "This compiler is not yet supported."
borlanic 0:fbdae7e6d805 36 #endif
borlanic 0:fbdae7e6d805 37
borlanic 0:fbdae7e6d805 38
borlanic 0:fbdae7e6d805 39 // Attributes
borlanic 0:fbdae7e6d805 40
borlanic 0:fbdae7e6d805 41 /** MBED_PACKED
borlanic 0:fbdae7e6d805 42 * Pack a structure, preventing any padding from being added between fields.
borlanic 0:fbdae7e6d805 43 *
borlanic 0:fbdae7e6d805 44 * @code
borlanic 0:fbdae7e6d805 45 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 46 *
borlanic 0:fbdae7e6d805 47 * MBED_PACKED(struct) foo {
borlanic 0:fbdae7e6d805 48 * char x;
borlanic 0:fbdae7e6d805 49 * int y;
borlanic 0:fbdae7e6d805 50 * };
borlanic 0:fbdae7e6d805 51 * @endcode
borlanic 0:fbdae7e6d805 52 */
borlanic 0:fbdae7e6d805 53 #ifndef MBED_PACKED
borlanic 0:fbdae7e6d805 54 #if defined(__ICCARM__)
borlanic 0:fbdae7e6d805 55 #define MBED_PACKED(struct) __packed struct
borlanic 0:fbdae7e6d805 56 #else
borlanic 0:fbdae7e6d805 57 #define MBED_PACKED(struct) struct __attribute__((packed))
borlanic 0:fbdae7e6d805 58 #endif
borlanic 0:fbdae7e6d805 59 #endif
borlanic 0:fbdae7e6d805 60
borlanic 0:fbdae7e6d805 61 /** MBED_ALIGN(N)
borlanic 0:fbdae7e6d805 62 * Declare a variable to be aligned on an N-byte boundary.
borlanic 0:fbdae7e6d805 63 *
borlanic 0:fbdae7e6d805 64 * @note
borlanic 0:fbdae7e6d805 65 * IAR does not support alignment greater than word size on the stack
borlanic 0:fbdae7e6d805 66 *
borlanic 0:fbdae7e6d805 67 * @code
borlanic 0:fbdae7e6d805 68 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 69 *
borlanic 0:fbdae7e6d805 70 * MBED_ALIGN(16) char a;
borlanic 0:fbdae7e6d805 71 * @endcode
borlanic 0:fbdae7e6d805 72 */
borlanic 0:fbdae7e6d805 73 #ifndef MBED_ALIGN
borlanic 0:fbdae7e6d805 74 #if defined(__ICCARM__)
borlanic 0:fbdae7e6d805 75 #define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
borlanic 0:fbdae7e6d805 76 #else
borlanic 0:fbdae7e6d805 77 #define MBED_ALIGN(N) __attribute__((aligned(N)))
borlanic 0:fbdae7e6d805 78 #endif
borlanic 0:fbdae7e6d805 79 #endif
borlanic 0:fbdae7e6d805 80
borlanic 0:fbdae7e6d805 81 /** MBED_UNUSED
borlanic 0:fbdae7e6d805 82 * Declare a function argument to be unused, suppressing compiler warnings
borlanic 0:fbdae7e6d805 83 *
borlanic 0:fbdae7e6d805 84 * @code
borlanic 0:fbdae7e6d805 85 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 86 *
borlanic 0:fbdae7e6d805 87 * void foo(MBED_UNUSED int arg) {
borlanic 0:fbdae7e6d805 88 *
borlanic 0:fbdae7e6d805 89 * }
borlanic 0:fbdae7e6d805 90 * @endcode
borlanic 0:fbdae7e6d805 91 */
borlanic 0:fbdae7e6d805 92 #ifndef MBED_UNUSED
borlanic 0:fbdae7e6d805 93 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 94 #define MBED_UNUSED __attribute__((__unused__))
borlanic 0:fbdae7e6d805 95 #else
borlanic 0:fbdae7e6d805 96 #define MBED_UNUSED
borlanic 0:fbdae7e6d805 97 #endif
borlanic 0:fbdae7e6d805 98 #endif
borlanic 0:fbdae7e6d805 99
borlanic 0:fbdae7e6d805 100 /** MBED_USED
borlanic 0:fbdae7e6d805 101 * Inform the compiler that a static variable is to be retained in the object file, even if it is unreferenced.
borlanic 0:fbdae7e6d805 102 *
borlanic 0:fbdae7e6d805 103 * @code
borlanic 0:fbdae7e6d805 104 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 105 *
borlanic 0:fbdae7e6d805 106 * MBED_USED int foo;
borlanic 0:fbdae7e6d805 107 *
borlanic 0:fbdae7e6d805 108 * @endcode
borlanic 0:fbdae7e6d805 109 */
borlanic 0:fbdae7e6d805 110 #ifndef MBED_USED
borlanic 0:fbdae7e6d805 111 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 112 #define MBED_USED __attribute__((used))
borlanic 0:fbdae7e6d805 113 #elif defined(__ICCARM__)
borlanic 0:fbdae7e6d805 114 #define MBED_USED __root
borlanic 0:fbdae7e6d805 115 #else
borlanic 0:fbdae7e6d805 116 #define MBED_USED
borlanic 0:fbdae7e6d805 117 #endif
borlanic 0:fbdae7e6d805 118 #endif
borlanic 0:fbdae7e6d805 119
borlanic 0:fbdae7e6d805 120 /** MBED_WEAK
borlanic 0:fbdae7e6d805 121 * Mark a function as being weak.
borlanic 0:fbdae7e6d805 122 *
borlanic 0:fbdae7e6d805 123 * @note
borlanic 0:fbdae7e6d805 124 * Functions should only be marked as weak in the source file. The header file
borlanic 0:fbdae7e6d805 125 * should contain a regular function declaration to insure the function is emitted.
borlanic 0:fbdae7e6d805 126 * A function marked weak will not be emitted if an alternative non-weak
borlanic 0:fbdae7e6d805 127 * implementation is defined.
borlanic 0:fbdae7e6d805 128 *
borlanic 0:fbdae7e6d805 129 * @note
borlanic 0:fbdae7e6d805 130 * Weak functions are not friendly to making code re-usable, as they can only
borlanic 0:fbdae7e6d805 131 * be overridden once (and if they are multiply overridden the linker will emit
borlanic 0:fbdae7e6d805 132 * no warning). You should not normally use weak symbols as part of the API to
borlanic 0:fbdae7e6d805 133 * re-usable modules.
borlanic 0:fbdae7e6d805 134 *
borlanic 0:fbdae7e6d805 135 * @code
borlanic 0:fbdae7e6d805 136 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 137 *
borlanic 0:fbdae7e6d805 138 * MBED_WEAK void foo() {
borlanic 0:fbdae7e6d805 139 * // a weak implementation of foo that can be overriden by a definition
borlanic 0:fbdae7e6d805 140 * // without __weak
borlanic 0:fbdae7e6d805 141 * }
borlanic 0:fbdae7e6d805 142 * @endcode
borlanic 0:fbdae7e6d805 143 */
borlanic 0:fbdae7e6d805 144 #ifndef MBED_WEAK
borlanic 0:fbdae7e6d805 145 #if defined(__ICCARM__)
borlanic 0:fbdae7e6d805 146 #define MBED_WEAK __weak
borlanic 0:fbdae7e6d805 147 #else
borlanic 0:fbdae7e6d805 148 #define MBED_WEAK __attribute__((weak))
borlanic 0:fbdae7e6d805 149 #endif
borlanic 0:fbdae7e6d805 150 #endif
borlanic 0:fbdae7e6d805 151
borlanic 0:fbdae7e6d805 152 /** MBED_PURE
borlanic 0:fbdae7e6d805 153 * Hint to the compiler that a function depends only on parameters
borlanic 0:fbdae7e6d805 154 *
borlanic 0:fbdae7e6d805 155 * @code
borlanic 0:fbdae7e6d805 156 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 157 *
borlanic 0:fbdae7e6d805 158 * MBED_PURE int foo(int arg){
borlanic 0:fbdae7e6d805 159 * // no access to global variables
borlanic 0:fbdae7e6d805 160 * }
borlanic 0:fbdae7e6d805 161 * @endcode
borlanic 0:fbdae7e6d805 162 */
borlanic 0:fbdae7e6d805 163 #ifndef MBED_PURE
borlanic 0:fbdae7e6d805 164 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 165 #define MBED_PURE __attribute__((const))
borlanic 0:fbdae7e6d805 166 #else
borlanic 0:fbdae7e6d805 167 #define MBED_PURE
borlanic 0:fbdae7e6d805 168 #endif
borlanic 0:fbdae7e6d805 169 #endif
borlanic 0:fbdae7e6d805 170
borlanic 0:fbdae7e6d805 171 /** MBED_NOINLINE
borlanic 0:fbdae7e6d805 172 * Declare a function that must not be inlined.
borlanic 0:fbdae7e6d805 173 *
borlanic 0:fbdae7e6d805 174 * @code
borlanic 0:fbdae7e6d805 175 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 176 *
borlanic 0:fbdae7e6d805 177 * MBED_NOINLINE void foo() {
borlanic 0:fbdae7e6d805 178 *
borlanic 0:fbdae7e6d805 179 * }
borlanic 0:fbdae7e6d805 180 * @endcode
borlanic 0:fbdae7e6d805 181 */
borlanic 0:fbdae7e6d805 182 #ifndef MBED_NOINLINE
borlanic 0:fbdae7e6d805 183 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 184 #define MBED_NOINLINE __attribute__((noinline))
borlanic 0:fbdae7e6d805 185 #elif defined(__ICCARM__)
borlanic 0:fbdae7e6d805 186 #define MBED_NOINLINE _Pragma("inline=never")
borlanic 0:fbdae7e6d805 187 #else
borlanic 0:fbdae7e6d805 188 #define MBED_NOINLINE
borlanic 0:fbdae7e6d805 189 #endif
borlanic 0:fbdae7e6d805 190 #endif
borlanic 0:fbdae7e6d805 191
borlanic 0:fbdae7e6d805 192 /** MBED_FORCEINLINE
borlanic 0:fbdae7e6d805 193 * Declare a function that must always be inlined. Failure to inline
borlanic 0:fbdae7e6d805 194 * such a function will result in an error.
borlanic 0:fbdae7e6d805 195 *
borlanic 0:fbdae7e6d805 196 * @code
borlanic 0:fbdae7e6d805 197 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 198 *
borlanic 0:fbdae7e6d805 199 * MBED_FORCEINLINE void foo() {
borlanic 0:fbdae7e6d805 200 *
borlanic 0:fbdae7e6d805 201 * }
borlanic 0:fbdae7e6d805 202 * @endcode
borlanic 0:fbdae7e6d805 203 */
borlanic 0:fbdae7e6d805 204 #ifndef MBED_FORCEINLINE
borlanic 0:fbdae7e6d805 205 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 206 #define MBED_FORCEINLINE static inline __attribute__((always_inline))
borlanic 0:fbdae7e6d805 207 #elif defined(__ICCARM__)
borlanic 0:fbdae7e6d805 208 #define MBED_FORCEINLINE _Pragma("inline=forced") static
borlanic 0:fbdae7e6d805 209 #else
borlanic 0:fbdae7e6d805 210 #define MBED_FORCEINLINE static inline
borlanic 0:fbdae7e6d805 211 #endif
borlanic 0:fbdae7e6d805 212 #endif
borlanic 0:fbdae7e6d805 213
borlanic 0:fbdae7e6d805 214 /** MBED_NORETURN
borlanic 0:fbdae7e6d805 215 * Declare a function that will never return.
borlanic 0:fbdae7e6d805 216 *
borlanic 0:fbdae7e6d805 217 * @code
borlanic 0:fbdae7e6d805 218 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 219 *
borlanic 0:fbdae7e6d805 220 * MBED_NORETURN void foo() {
borlanic 0:fbdae7e6d805 221 * // must never return
borlanic 0:fbdae7e6d805 222 * while (1) {}
borlanic 0:fbdae7e6d805 223 * }
borlanic 0:fbdae7e6d805 224 * @endcode
borlanic 0:fbdae7e6d805 225 */
borlanic 0:fbdae7e6d805 226 #ifndef MBED_NORETURN
borlanic 0:fbdae7e6d805 227 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 228 #define MBED_NORETURN __attribute__((noreturn))
borlanic 0:fbdae7e6d805 229 #elif defined(__ICCARM__)
borlanic 0:fbdae7e6d805 230 #define MBED_NORETURN __noreturn
borlanic 0:fbdae7e6d805 231 #else
borlanic 0:fbdae7e6d805 232 #define MBED_NORETURN
borlanic 0:fbdae7e6d805 233 #endif
borlanic 0:fbdae7e6d805 234 #endif
borlanic 0:fbdae7e6d805 235
borlanic 0:fbdae7e6d805 236 /** MBED_UNREACHABLE
borlanic 0:fbdae7e6d805 237 * An unreachable statement. If the statement is reached,
borlanic 0:fbdae7e6d805 238 * behaviour is undefined. Useful in situations where the compiler
borlanic 0:fbdae7e6d805 239 * cannot deduce the unreachability of code.
borlanic 0:fbdae7e6d805 240 *
borlanic 0:fbdae7e6d805 241 * @code
borlanic 0:fbdae7e6d805 242 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 243 *
borlanic 0:fbdae7e6d805 244 * void foo(int arg) {
borlanic 0:fbdae7e6d805 245 * switch (arg) {
borlanic 0:fbdae7e6d805 246 * case 1: return 1;
borlanic 0:fbdae7e6d805 247 * case 2: return 2;
borlanic 0:fbdae7e6d805 248 * ...
borlanic 0:fbdae7e6d805 249 * }
borlanic 0:fbdae7e6d805 250 * MBED_UNREACHABLE;
borlanic 0:fbdae7e6d805 251 * }
borlanic 0:fbdae7e6d805 252 * @endcode
borlanic 0:fbdae7e6d805 253 */
borlanic 0:fbdae7e6d805 254 #ifndef MBED_UNREACHABLE
borlanic 0:fbdae7e6d805 255 #if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
borlanic 0:fbdae7e6d805 256 #define MBED_UNREACHABLE __builtin_unreachable()
borlanic 0:fbdae7e6d805 257 #else
borlanic 0:fbdae7e6d805 258 #define MBED_UNREACHABLE while (1)
borlanic 0:fbdae7e6d805 259 #endif
borlanic 0:fbdae7e6d805 260 #endif
borlanic 0:fbdae7e6d805 261
borlanic 0:fbdae7e6d805 262 /** MBED_DEPRECATED("message string")
borlanic 0:fbdae7e6d805 263 * Mark a function declaration as deprecated, if it used then a warning will be
borlanic 0:fbdae7e6d805 264 * issued by the compiler possibly including the provided message. Note that not
borlanic 0:fbdae7e6d805 265 * all compilers are able to display the message.
borlanic 0:fbdae7e6d805 266 *
borlanic 0:fbdae7e6d805 267 * @code
borlanic 0:fbdae7e6d805 268 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 269 *
borlanic 0:fbdae7e6d805 270 * MBED_DEPRECATED("don't foo any more, bar instead")
borlanic 0:fbdae7e6d805 271 * void foo(int arg);
borlanic 0:fbdae7e6d805 272 * @endcode
borlanic 0:fbdae7e6d805 273 */
borlanic 0:fbdae7e6d805 274 #ifndef MBED_DEPRECATED
borlanic 0:fbdae7e6d805 275 #if defined(__CC_ARM)
borlanic 0:fbdae7e6d805 276 #define MBED_DEPRECATED(M) __attribute__((deprecated))
borlanic 0:fbdae7e6d805 277 #elif defined(__GNUC__) || defined(__clang__)
borlanic 0:fbdae7e6d805 278 #define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
borlanic 0:fbdae7e6d805 279 #else
borlanic 0:fbdae7e6d805 280 #define MBED_DEPRECATED(M)
borlanic 0:fbdae7e6d805 281 #endif
borlanic 0:fbdae7e6d805 282 #endif
borlanic 0:fbdae7e6d805 283
borlanic 0:fbdae7e6d805 284 /** MBED_DEPRECATED_SINCE("version", "message string")
borlanic 0:fbdae7e6d805 285 * Mark a function declaration as deprecated, noting that the declaration was
borlanic 0:fbdae7e6d805 286 * deprecated on the specified version. If the function is used then a warning
borlanic 0:fbdae7e6d805 287 * will be issued by the compiler possibly including the provided message.
borlanic 0:fbdae7e6d805 288 * Note that not all compilers are able to display this message.
borlanic 0:fbdae7e6d805 289 *
borlanic 0:fbdae7e6d805 290 * @code
borlanic 0:fbdae7e6d805 291 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 292 *
borlanic 0:fbdae7e6d805 293 * MBED_DEPRECATED_SINCE("mbed-os-5.1", "don't foo any more, bar instead")
borlanic 0:fbdae7e6d805 294 * void foo(int arg);
borlanic 0:fbdae7e6d805 295 * @endcode
borlanic 0:fbdae7e6d805 296 */
borlanic 0:fbdae7e6d805 297 #define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
borlanic 0:fbdae7e6d805 298
borlanic 0:fbdae7e6d805 299 /** MBED_CALLER_ADDR()
borlanic 0:fbdae7e6d805 300 * Returns the caller of the current function.
borlanic 0:fbdae7e6d805 301 *
borlanic 0:fbdae7e6d805 302 * @note
borlanic 0:fbdae7e6d805 303 * This macro is only implemented for GCC and ARMCC.
borlanic 0:fbdae7e6d805 304 *
borlanic 0:fbdae7e6d805 305 * @code
borlanic 0:fbdae7e6d805 306 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 307 *
borlanic 0:fbdae7e6d805 308 * printf("This function was called from %p", MBED_CALLER_ADDR());
borlanic 0:fbdae7e6d805 309 * @endcode
borlanic 0:fbdae7e6d805 310 *
borlanic 0:fbdae7e6d805 311 * @return Address of the calling function
borlanic 0:fbdae7e6d805 312 */
borlanic 0:fbdae7e6d805 313 #ifndef MBED_CALLER_ADDR
borlanic 0:fbdae7e6d805 314 #if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
borlanic 0:fbdae7e6d805 315 #define MBED_CALLER_ADDR() __builtin_extract_return_addr(__builtin_return_address(0))
borlanic 0:fbdae7e6d805 316 #elif defined(__CC_ARM)
borlanic 0:fbdae7e6d805 317 #define MBED_CALLER_ADDR() __builtin_return_address(0)
borlanic 0:fbdae7e6d805 318 #else
borlanic 0:fbdae7e6d805 319 #define MBED_CALLER_ADDR() (NULL)
borlanic 0:fbdae7e6d805 320 #endif
borlanic 0:fbdae7e6d805 321 #endif
borlanic 0:fbdae7e6d805 322
borlanic 0:fbdae7e6d805 323 #ifndef MBED_SECTION
borlanic 0:fbdae7e6d805 324 #if (defined(__GNUC__) || defined(__clang__)) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 325 #define MBED_SECTION(name) __attribute__ ((section (name)))
borlanic 0:fbdae7e6d805 326 #elif defined(__ICCARM__)
borlanic 0:fbdae7e6d805 327 #define MBED_SECTION(name) _Pragma(MBED_STRINGIFY(location=name))
borlanic 0:fbdae7e6d805 328 #else
borlanic 0:fbdae7e6d805 329 #error "Missing MBED_SECTION directive"
borlanic 0:fbdae7e6d805 330 #endif
borlanic 0:fbdae7e6d805 331 #endif
borlanic 0:fbdae7e6d805 332
borlanic 0:fbdae7e6d805 333 /**
borlanic 0:fbdae7e6d805 334 * Macro expanding to a string literal of the enclosing function name.
borlanic 0:fbdae7e6d805 335 *
borlanic 0:fbdae7e6d805 336 * The string returned takes into account language specificity and yield human
borlanic 0:fbdae7e6d805 337 * readable content.
borlanic 0:fbdae7e6d805 338 *
borlanic 0:fbdae7e6d805 339 * As an example, if the macro is used within a C++ function then the string
borlanic 0:fbdae7e6d805 340 * literal containing the function name will contain the complete signature of
borlanic 0:fbdae7e6d805 341 * the function - including template parameters - and namespace qualifications.
borlanic 0:fbdae7e6d805 342 */
borlanic 0:fbdae7e6d805 343 #ifndef MBED_PRETTY_FUNCTION
borlanic 0:fbdae7e6d805 344 #define MBED_PRETTY_FUNCTION __PRETTY_FUNCTION__
borlanic 0:fbdae7e6d805 345 #endif
borlanic 0:fbdae7e6d805 346
borlanic 0:fbdae7e6d805 347 #ifndef MBED_PRINTF
borlanic 0:fbdae7e6d805 348 #if defined(__GNUC__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 349 #define MBED_PRINTF(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx, first_param_idx)))
borlanic 0:fbdae7e6d805 350 #else
borlanic 0:fbdae7e6d805 351 #define MBED_PRINTF(format_idx, first_param_idx)
borlanic 0:fbdae7e6d805 352 #endif
borlanic 0:fbdae7e6d805 353 #endif
borlanic 0:fbdae7e6d805 354
borlanic 0:fbdae7e6d805 355 #ifndef MBED_PRINTF_METHOD
borlanic 0:fbdae7e6d805 356 #if defined(__GNUC__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 357 #define MBED_PRINTF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx+1, first_param_idx+1)))
borlanic 0:fbdae7e6d805 358 #else
borlanic 0:fbdae7e6d805 359 #define MBED_PRINTF_METHOD(format_idx, first_param_idx)
borlanic 0:fbdae7e6d805 360 #endif
borlanic 0:fbdae7e6d805 361 #endif
borlanic 0:fbdae7e6d805 362
borlanic 0:fbdae7e6d805 363 #ifndef MBED_SCANF
borlanic 0:fbdae7e6d805 364 #if defined(__GNUC__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 365 #define MBED_SCANF(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx, first_param_idx)))
borlanic 0:fbdae7e6d805 366 #else
borlanic 0:fbdae7e6d805 367 #define MBED_SCANF(format_idx, first_param_idx)
borlanic 0:fbdae7e6d805 368 #endif
borlanic 0:fbdae7e6d805 369 #endif
borlanic 0:fbdae7e6d805 370
borlanic 0:fbdae7e6d805 371 #ifndef MBED_SCANF_METHOD
borlanic 0:fbdae7e6d805 372 #if defined(__GNUC__) || defined(__CC_ARM)
borlanic 0:fbdae7e6d805 373 #define MBED_SCANF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx+1, first_param_idx+1)))
borlanic 0:fbdae7e6d805 374 #else
borlanic 0:fbdae7e6d805 375 #define MBED_SCANF_METHOD(format_idx, first_param_idx)
borlanic 0:fbdae7e6d805 376 #endif
borlanic 0:fbdae7e6d805 377 #endif
borlanic 0:fbdae7e6d805 378
borlanic 0:fbdae7e6d805 379 // Macro containing the filename part of the value of __FILE__. Defined as
borlanic 0:fbdae7e6d805 380 // string literal.
borlanic 0:fbdae7e6d805 381 #ifndef MBED_FILENAME
borlanic 0:fbdae7e6d805 382 #if defined(__CC_ARM)
borlanic 0:fbdae7e6d805 383 #define MBED_FILENAME __MODULE__
borlanic 0:fbdae7e6d805 384 #elif defined(__GNUC__)
borlanic 0:fbdae7e6d805 385 #define MBED_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
borlanic 0:fbdae7e6d805 386 #elif defined(__ICCARM__)
borlanic 0:fbdae7e6d805 387 #define MBED_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
borlanic 0:fbdae7e6d805 388 #else
borlanic 0:fbdae7e6d805 389 #define MBED_FILENAME __FILE__
borlanic 0:fbdae7e6d805 390 #endif
borlanic 0:fbdae7e6d805 391 #endif // #ifndef MBED_FILENAME
borlanic 0:fbdae7e6d805 392
borlanic 0:fbdae7e6d805 393 // FILEHANDLE declaration
borlanic 0:fbdae7e6d805 394 #if defined(TOOLCHAIN_ARM)
borlanic 0:fbdae7e6d805 395 #include <rt_sys.h>
borlanic 0:fbdae7e6d805 396 #endif
borlanic 0:fbdae7e6d805 397
borlanic 0:fbdae7e6d805 398 #ifndef FILEHANDLE
borlanic 0:fbdae7e6d805 399 typedef int FILEHANDLE;
borlanic 0:fbdae7e6d805 400 #endif
borlanic 0:fbdae7e6d805 401
borlanic 0:fbdae7e6d805 402 // Backwards compatibility
borlanic 0:fbdae7e6d805 403 #ifndef WEAK
borlanic 0:fbdae7e6d805 404 #define WEAK MBED_WEAK
borlanic 0:fbdae7e6d805 405 #endif
borlanic 0:fbdae7e6d805 406
borlanic 0:fbdae7e6d805 407 #ifndef PACKED
borlanic 0:fbdae7e6d805 408 #define PACKED MBED_PACKED()
borlanic 0:fbdae7e6d805 409 #endif
borlanic 0:fbdae7e6d805 410
borlanic 0:fbdae7e6d805 411 #ifndef EXTERN
borlanic 0:fbdae7e6d805 412 #define EXTERN extern
borlanic 0:fbdae7e6d805 413 #endif
borlanic 0:fbdae7e6d805 414
borlanic 0:fbdae7e6d805 415 /** MBED_NONSECURE_ENTRY
borlanic 0:fbdae7e6d805 416 * Declare a function that can be called from non-secure world or secure world
borlanic 0:fbdae7e6d805 417 *
borlanic 0:fbdae7e6d805 418 * @code
borlanic 0:fbdae7e6d805 419 * #include "mbed_toolchain.h"
borlanic 0:fbdae7e6d805 420 *
borlanic 0:fbdae7e6d805 421 * MBED_NONSECURE_ENTRY void foo() {
borlanic 0:fbdae7e6d805 422 *
borlanic 0:fbdae7e6d805 423 * }
borlanic 0:fbdae7e6d805 424 * @endcode
borlanic 0:fbdae7e6d805 425 */
borlanic 0:fbdae7e6d805 426 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3L)
borlanic 0:fbdae7e6d805 427 #if defined (__ICCARM__)
borlanic 0:fbdae7e6d805 428 #define MBED_NONSECURE_ENTRY __cmse_nonsecure_entry
borlanic 0:fbdae7e6d805 429 #else
borlanic 0:fbdae7e6d805 430 #define MBED_NONSECURE_ENTRY __attribute__((cmse_nonsecure_entry))
borlanic 0:fbdae7e6d805 431 #endif
borlanic 0:fbdae7e6d805 432 #else
borlanic 0:fbdae7e6d805 433 #define MBED_NONSECURE_ENTRY
borlanic 0:fbdae7e6d805 434 #endif
borlanic 0:fbdae7e6d805 435
borlanic 0:fbdae7e6d805 436 #endif
borlanic 0:fbdae7e6d805 437
borlanic 0:fbdae7e6d805 438 /** @}*/
borlanic 0:fbdae7e6d805 439 /** @}*/