123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439 |
- #ifndef MBED_TOOLCHAIN_H
- #define MBED_TOOLCHAIN_H
- #include "mbed_preprocessor.h"
- #if !defined(__GNUC__) \
- && !defined(__CC_ARM) \
- && !defined(__clang__) \
- && !defined(__ICCARM__)
- #warning "This compiler is not yet supported."
- #endif
- #ifndef MBED_PACKED
- #if defined(__ICCARM__)
- #define MBED_PACKED(struct) __packed struct
- #else
- #define MBED_PACKED(struct) struct __attribute__((packed))
- #endif
- #endif
- #ifndef MBED_ALIGN
- #if defined(__ICCARM__)
- #define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
- #else
- #define MBED_ALIGN(N) __attribute__((aligned(N)))
- #endif
- #endif
- #ifndef MBED_UNUSED
- #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
- #define MBED_UNUSED __attribute__((__unused__))
- #else
- #define MBED_UNUSED
- #endif
- #endif
- #ifndef MBED_USED
- #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
- #define MBED_USED __attribute__((used))
- #elif defined(__ICCARM__)
- #define MBED_USED __root
- #else
- #define MBED_USED
- #endif
- #endif
- #ifndef MBED_WEAK
- #if defined(__ICCARM__)
- #define MBED_WEAK __weak
- #else
- #define MBED_WEAK __attribute__((weak))
- #endif
- #endif
- #ifndef MBED_PURE
- #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
- #define MBED_PURE __attribute__((const))
- #else
- #define MBED_PURE
- #endif
- #endif
- #ifndef MBED_NOINLINE
- #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
- #define MBED_NOINLINE __attribute__((noinline))
- #elif defined(__ICCARM__)
- #define MBED_NOINLINE _Pragma("inline=never")
- #else
- #define MBED_NOINLINE
- #endif
- #endif
- #ifndef MBED_FORCEINLINE
- #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
- #define MBED_FORCEINLINE static inline __attribute__((always_inline))
- #elif defined(__ICCARM__)
- #define MBED_FORCEINLINE _Pragma("inline=forced") static
- #else
- #define MBED_FORCEINLINE static inline
- #endif
- #endif
- #ifndef MBED_NORETURN
- #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
- #define MBED_NORETURN __attribute__((noreturn))
- #elif defined(__ICCARM__)
- #define MBED_NORETURN __noreturn
- #else
- #define MBED_NORETURN
- #endif
- #endif
- #ifndef MBED_UNREACHABLE
- #if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
- #define MBED_UNREACHABLE __builtin_unreachable()
- #else
- #define MBED_UNREACHABLE while (1)
- #endif
- #endif
- #ifndef MBED_DEPRECATED
- #if defined(__CC_ARM)
- #define MBED_DEPRECATED(M) __attribute__((deprecated))
- #elif defined(__GNUC__) || defined(__clang__)
- #define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
- #else
- #define MBED_DEPRECATED(M)
- #endif
- #endif
- #define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
- #ifndef MBED_CALLER_ADDR
- #if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
- #define MBED_CALLER_ADDR() __builtin_extract_return_addr(__builtin_return_address(0))
- #elif defined(__CC_ARM)
- #define MBED_CALLER_ADDR() __builtin_return_address(0)
- #else
- #define MBED_CALLER_ADDR() (NULL)
- #endif
- #endif
- #ifndef MBED_SECTION
- #if (defined(__GNUC__) || defined(__clang__)) || defined(__CC_ARM)
- #define MBED_SECTION(name) __attribute__ ((section (name)))
- #elif defined(__ICCARM__)
- #define MBED_SECTION(name) _Pragma(MBED_STRINGIFY(location=name))
- #else
- #error "Missing MBED_SECTION directive"
- #endif
- #endif
- #ifndef MBED_PRETTY_FUNCTION
- #define MBED_PRETTY_FUNCTION __PRETTY_FUNCTION__
- #endif
- #ifndef MBED_PRINTF
- #if defined(__GNUC__) || defined(__CC_ARM)
- #define MBED_PRINTF(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx, first_param_idx)))
- #else
- #define MBED_PRINTF(format_idx, first_param_idx)
- #endif
- #endif
- #ifndef MBED_PRINTF_METHOD
- #if defined(__GNUC__) || defined(__CC_ARM)
- #define MBED_PRINTF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__printf__, format_idx+1, first_param_idx+1)))
- #else
- #define MBED_PRINTF_METHOD(format_idx, first_param_idx)
- #endif
- #endif
- #ifndef MBED_SCANF
- #if defined(__GNUC__) || defined(__CC_ARM)
- #define MBED_SCANF(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx, first_param_idx)))
- #else
- #define MBED_SCANF(format_idx, first_param_idx)
- #endif
- #endif
- #ifndef MBED_SCANF_METHOD
- #if defined(__GNUC__) || defined(__CC_ARM)
- #define MBED_SCANF_METHOD(format_idx, first_param_idx) __attribute__ ((__format__(__scanf__, format_idx+1, first_param_idx+1)))
- #else
- #define MBED_SCANF_METHOD(format_idx, first_param_idx)
- #endif
- #endif
- #ifndef MBED_FILENAME
- #if defined(__CC_ARM)
- #define MBED_FILENAME __MODULE__
- #elif defined(__GNUC__)
- #define MBED_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
- #elif defined(__ICCARM__)
- #define MBED_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
- #else
- #define MBED_FILENAME __FILE__
- #endif
- #endif
- #if defined(TOOLCHAIN_ARM)
- #include <rt_sys.h>
- #endif
- #ifndef FILEHANDLE
- typedef int FILEHANDLE;
- #endif
- #ifndef WEAK
- #define WEAK MBED_WEAK
- #endif
- #ifndef PACKED
- #define PACKED MBED_PACKED()
- #endif
- #ifndef EXTERN
- #define EXTERN extern
- #endif
- #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3L)
- #if defined (__ICCARM__)
- #define MBED_NONSECURE_ENTRY __cmse_nonsecure_entry
- #else
- #define MBED_NONSECURE_ENTRY __attribute__((cmse_nonsecure_entry))
- #endif
- #else
- #define MBED_NONSECURE_ENTRY
- #endif
- #endif
|