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