mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Thu Nov 08 11:46:34 2018 +0000
Revision:
188:bcfe06ba3d64
Parent:
187:0387e8f68319
Child:
189:f392fc9709a3
mbed-dev library. Release version 164

Who changed what in which revision?

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