Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

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