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