test

Dependencies:   mbed Watchdog

Dependents:   STM32-MC_node

Committer:
ommpy
Date:
Mon Jul 06 17:18:59 2020 +0530
Revision:
0:d383e2dee0f7
first commit

Who changed what in which revision?

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