游戏王对战板,目前code还是空的

Committer:
WFKnight
Date:
Thu Jun 21 13:51:43 2018 +0000
Revision:
0:9b3d4731edbb
UART, RTOS, LED

Who changed what in which revision?

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