temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

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