mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

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