 |
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."
73#if defined(__ICCARM__)
74#define MBED_PACKED(struct) __packed struct
76#define MBED_PACKED(struct) struct __attribute__((packed))
93#if __cplusplus >= 201103
94#define MBED_ALIGN(N) alignas(N)
95#elif __STDC_VERSION__ >= 201112
96#define MBED_ALIGN(N) _Alignas(N)
97#elif defined(__ICCARM__)
98#define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
100#define MBED_ALIGN(N) __attribute__((aligned(N)))
116#if defined(__GNUC__) || defined(__clang__)
117#define MBED_UNUSED __attribute__((__unused__))
134#if defined(__GNUC__) || defined(__clang__)
135#define MBED_USED __attribute__((used))
136#elif defined(__ICCARM__)
137#define MBED_USED __root
168#if defined(__ICCARM__)
169#define MBED_WEAK __weak
170#elif defined(__MINGW32__)
173#define MBED_WEAK __attribute__((weak))
209#if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
210#define MBED_COMPILER_BARRIER() asm volatile("" : : : "memory")
212#error "Missing MBED_COMPILER_BARRIER implementation"
244#define MBED_BARRIER() MBED_COMPILER_BARRIER()
258#if defined(__GNUC__) || defined(__clang__)
259#define MBED_PURE __attribute__((const))
277#if defined(__GNUC__) || defined(__clang__)
278#define MBED_NOINLINE __attribute__((noinline))
279#elif defined(__ICCARM__)
280#define MBED_NOINLINE _Pragma("inline=never")
298#ifndef MBED_FORCEINLINE
299#if defined(__GNUC__) || defined(__clang__)
300#define MBED_FORCEINLINE inline __attribute__((always_inline))
301#elif defined(__ICCARM__)
302#define MBED_FORCEINLINE _Pragma("inline=forced")
304#define MBED_FORCEINLINE inline
321#if __cplusplus >= 201103
322#define MBED_NORETURN [[noreturn]]
323#elif __STDC_VERSION__ >= 201112
324#define MBED_NORETURN _Noreturn
325#elif defined(__GNUC__) || defined(__clang__)
326#define MBED_NORETURN __attribute__((noreturn))
327#elif defined(__ICCARM__)
328#define MBED_NORETURN __noreturn
352#ifndef MBED_UNREACHABLE
353#if (defined(__GNUC__) || defined(__clang__))
354#define MBED_UNREACHABLE __builtin_unreachable()
356#define MBED_UNREACHABLE while (1)
380#ifndef MBED_FALLTHROUGH
381#if __cplusplus >= 201703
382#define MBED_FALLTHROUGH [[fallthrough]]
383#elif defined(__clang__)
384#if __cplusplus >= 201103
385#define MBED_FALLTHROUGH [[clang::fallthrough]]
386#elif __has_attribute(fallthrough)
387#define MBED_FALLTHROUGH __attribute__((fallthrough))
389#define MBED_FALLTHROUGH
391#elif defined (__GNUC__)
392#define MBED_FALLTHROUGH __attribute__((fallthrough))
394#define MBED_FALLTHROUGH
410#ifndef MBED_DEPRECATED
411#if defined(__GNUC__) || defined(__clang__)
412#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
414#define MBED_DEPRECATED(M)
434#define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
450#ifndef MBED_CALLER_ADDR
451#if (defined(__GNUC__) || defined(__clang__))
452#define MBED_CALLER_ADDR() __builtin_extract_return_addr(__builtin_return_address(0))
454#define MBED_CALLER_ADDR() (NULL)
459#if (defined(__GNUC__) || defined(__clang__))
460#define MBED_SECTION(name) __attribute__ ((section (name)))
461#elif defined(__ICCARM__)
462#define MBED_SECTION(name) _Pragma(MBED_STRINGIFY(location=name))
464#error "Missing MBED_SECTION directive"
478#ifndef MBED_PRETTY_FUNCTION
479#define MBED_PRETTY_FUNCTION __PRETTY_FUNCTION__
484#define MBED_NONCACHED_SECTION_NAME ".noncached"
489#define MBED_NONCACHED MBED_SECTION(MBED_NONCACHED_SECTION_NAME)
492#define MBED_NONCACHED
497#define MBED_PRINTF(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx, first_param_idx)))
499#define MBED_PRINTF(format_idx, first_param_idx)
503#ifndef MBED_PRINTF_METHOD
505#define MBED_PRINTF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx+1, first_param_idx == 0 ? 0 : first_param_idx+1)))
507#define MBED_PRINTF_METHOD(format_idx, first_param_idx)
513#define MBED_SCANF(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx, first_param_idx)))
515#define MBED_SCANF(format_idx, first_param_idx)
519#ifndef MBED_SCANF_METHOD
521#define MBED_SCANF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx+1, first_param_idx == 0 ? 0 : first_param_idx+1)))
523#define MBED_SCANF_METHOD(format_idx, first_param_idx)
531#define MBED_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
532#elif defined(__ICCARM__)
533#define MBED_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
535#define MBED_FILENAME __FILE__
540#if defined(TOOLCHAIN_ARM)
545typedef int FILEHANDLE;
550#define WEAK MBED_WEAK
554#define PACKED MBED_PACKED()
572#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3L)
573#if defined (__ICCARM__)
574#define MBED_NONSECURE_ENTRY __cmse_nonsecure_entry
576#define MBED_NONSECURE_ENTRY __attribute__((cmse_nonsecure_entry))
579#define MBED_NONSECURE_ENTRY