|
Mbed OS Reference
|
Loading...
Searching...
No Matches
17#ifndef MBED_TOOLCHAIN_H
18#define MBED_TOOLCHAIN_H
20#include "platform/mbed_preprocessor.h"
23#ifndef __error_t_defined
24#define __error_t_defined 1
31#ifndef __DO_NOT_LINK_PROMISE_WITH_ASSERT
32#define __DO_NOT_LINK_PROMISE_WITH_ASSERT
37#if defined(__ICCARM__)
42#if !defined(__GNUC__) \
43 && !defined(__clang__) \
44 && !defined(__ICCARM__)
45#warning "This compiler is not yet supported."
71#if defined(__ICCARM__)
72#define MBED_PACKED(struct) __packed struct
74#define MBED_PACKED(struct) struct __attribute__((packed))
91#if __cplusplus >= 201103
92#define MBED_ALIGN(N) alignas(N)
93#elif __STDC_VERSION__ >= 201112
94#define MBED_ALIGN(N) _Alignas(N)
95#elif defined(__ICCARM__)
96#define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
98#define MBED_ALIGN(N) __attribute__((aligned(N)))
114#if defined(__GNUC__) || defined(__clang__)
115#define MBED_UNUSED __attribute__((__unused__))
132#if defined(__GNUC__) || defined(__clang__)
133#define MBED_USED __attribute__((used))
134#elif defined(__ICCARM__)
135#define MBED_USED __root
166#if defined(__ICCARM__)
167#define MBED_WEAK __weak
168#elif defined(__MINGW32__)
171#define MBED_WEAK __attribute__((weak))
207#if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
208#define MBED_COMPILER_BARRIER() asm volatile("" : : : "memory")
210#error "Missing MBED_COMPILER_BARRIER implementation"
242#define MBED_BARRIER() MBED_COMPILER_BARRIER()
256#if defined(__GNUC__) || defined(__clang__)
257#define MBED_PURE __attribute__((const))
275#if defined(__GNUC__) || defined(__clang__)
276#define MBED_NOINLINE __attribute__((noinline))
277#elif defined(__ICCARM__)
278#define MBED_NOINLINE _Pragma("inline=never")
296#ifndef MBED_FORCEINLINE
297#if defined(__GNUC__) || defined(__clang__)
298#define MBED_FORCEINLINE inline __attribute__((always_inline))
299#elif defined(__ICCARM__)
300#define MBED_FORCEINLINE _Pragma("inline=forced")
302#define MBED_FORCEINLINE inline
319#if __cplusplus >= 201103
320#define MBED_NORETURN [[noreturn]]
321#elif __STDC_VERSION__ >= 201112
322#define MBED_NORETURN _Noreturn
323#elif defined(__GNUC__) || defined(__clang__)
324#define MBED_NORETURN __attribute__((noreturn))
325#elif defined(__ICCARM__)
326#define MBED_NORETURN __noreturn
350#ifndef MBED_UNREACHABLE
351#if (defined(__GNUC__) || defined(__clang__))
352#define MBED_UNREACHABLE __builtin_unreachable()
354#define MBED_UNREACHABLE while (1)
378#ifndef MBED_FALLTHROUGH
379#if __cplusplus >= 201703
380#define MBED_FALLTHROUGH [[fallthrough]]
381#elif defined(__clang__)
382#if __cplusplus >= 201103
383#define MBED_FALLTHROUGH [[clang::fallthrough]]
384#elif __has_attribute(fallthrough)
385#define MBED_FALLTHROUGH __attribute__((fallthrough))
387#define MBED_FALLTHROUGH
389#elif defined (__GNUC__)
390#define MBED_FALLTHROUGH __attribute__((fallthrough))
392#define MBED_FALLTHROUGH
408#ifndef MBED_DEPRECATED
409#if defined(__GNUC__) || defined(__clang__)
410#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
412#define MBED_DEPRECATED(M)
429#define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
445#ifndef MBED_CALLER_ADDR
446#if (defined(__GNUC__) || defined(__clang__))
447#define MBED_CALLER_ADDR() __builtin_extract_return_addr(__builtin_return_address(0))
449#define MBED_CALLER_ADDR() (NULL)
454#if (defined(__GNUC__) || defined(__clang__))
455#define MBED_SECTION(name) __attribute__ ((section (name)))
456#elif defined(__ICCARM__)
457#define MBED_SECTION(name) _Pragma(MBED_STRINGIFY(location=name))
459#error "Missing MBED_SECTION directive"
473#ifndef MBED_PRETTY_FUNCTION
474#define MBED_PRETTY_FUNCTION __PRETTY_FUNCTION__
479#define MBED_PRINTF(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx, first_param_idx)))
481#define MBED_PRINTF(format_idx, first_param_idx)
485#ifndef MBED_PRINTF_METHOD
487#define MBED_PRINTF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx+1, first_param_idx == 0 ? 0 : first_param_idx+1)))
489#define MBED_PRINTF_METHOD(format_idx, first_param_idx)
495#define MBED_SCANF(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx, first_param_idx)))
497#define MBED_SCANF(format_idx, first_param_idx)
501#ifndef MBED_SCANF_METHOD
503#define MBED_SCANF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx+1, first_param_idx == 0 ? 0 : first_param_idx+1)))
505#define MBED_SCANF_METHOD(format_idx, first_param_idx)
513#define MBED_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
514#elif defined(__ICCARM__)
515#define MBED_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
517#define MBED_FILENAME __FILE__
522#if defined(TOOLCHAIN_ARM)
527typedef int FILEHANDLE;
532#define WEAK MBED_WEAK
536#define PACKED MBED_PACKED()
554#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3L)
555#if defined (__ICCARM__)
556#define MBED_NONSECURE_ENTRY __cmse_nonsecure_entry
558#define MBED_NONSECURE_ENTRY __attribute__((cmse_nonsecure_entry))
561#define MBED_NONSECURE_ENTRY