mbed library sources. Supersedes mbed-src.

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

Committer:
<>
Date:
Tue Mar 14 16:40:56 2017 +0000
Revision:
160:d5399cc887bb
Child:
167:e84263d55307
This updates the lib to the mbed lib v138

Who changed what in which revision?

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