mirror of https://github.com/ARMmbed/mbed-os.git
Added MBED prefix to attributes
parent
3f7fbe696d
commit
4c7a4de673
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
|
|
||||||
/** PACKED
|
/** MBED_PACKED
|
||||||
* Pack a structure, preventing any padding from being added between fields.
|
* Pack a structure, preventing any padding from being added between fields.
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
|
@ -37,55 +37,55 @@
|
||||||
* typedef struct {
|
* typedef struct {
|
||||||
* char x;
|
* char x;
|
||||||
* int y;
|
* int y;
|
||||||
* } PACKED foo;
|
* } MBED_PACKED foo;
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef PACKED
|
#ifndef MBED_PACKED
|
||||||
#if defined(__ICCARM__)
|
#if defined(__ICCARM__)
|
||||||
#define PACKED __packed
|
#define MBED_PACKED __packed
|
||||||
#else
|
#else
|
||||||
#define PACKED __attribute__((packed))
|
#define MBED_PACKED __attribute__((packed))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** ALIGN(N)
|
/** MBED_ALIGN(N)
|
||||||
* Declare a variable to be aligned on an N-byte boundary.
|
* Declare a variable to be aligned on an N-byte boundary.
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* #include "toolchain.h"
|
* #include "toolchain.h"
|
||||||
*
|
*
|
||||||
* ALIGN(16) char a;
|
* MBED_ALIGN(16) char a;
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef ALIGN
|
#ifndef MBED_ALIGN
|
||||||
#if defined(__ICCARM__)
|
#if defined(__ICCARM__)
|
||||||
#define _ALIGN(N) _Pragma(#N)
|
#define _MBED_ALIGN(N) _Pragma(#N)
|
||||||
#define ALIGN(N) _ALIGN(data_alignment=N)
|
#define MBED_ALIGN(N) _MBED_ALIGN(data_alignment=N)
|
||||||
#else
|
#else
|
||||||
#define ALIGN(N) __attribute__((aligned(N)))
|
#define MBED_ALIGN(N) __attribute__((aligned(N)))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** UNUSED
|
/** MBED_UNUSED
|
||||||
* Declare a function argument to be unused, suppressing compiler warnings
|
* Declare a function argument to be unused, suppressing compiler warnings
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* #include "toolchain.h"
|
* #include "toolchain.h"
|
||||||
*
|
*
|
||||||
* void foo(UNUSED int arg) {
|
* void foo(MBED_UNUSED int arg) {
|
||||||
*
|
*
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef UNUSED
|
#ifndef MBED_UNUSED
|
||||||
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
||||||
#define UNUSED __attribute__((__unused__))
|
#define MBED_UNUSED __attribute__((__unused__))
|
||||||
#else
|
#else
|
||||||
#define UNUSED
|
#define MBED_UNUSED
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** WEAK
|
/** MBED_WEAK
|
||||||
* Mark a function as being weak.
|
* Mark a function as being weak.
|
||||||
*
|
*
|
||||||
* @note
|
* @note
|
||||||
|
@ -97,84 +97,84 @@
|
||||||
* @code
|
* @code
|
||||||
* #include "toolchain.h"
|
* #include "toolchain.h"
|
||||||
*
|
*
|
||||||
* WEAK void foo() {
|
* MBED_WEAK void foo() {
|
||||||
* // a weak implementation of foo that can be overriden by a definition
|
* // a weak implementation of foo that can be overriden by a definition
|
||||||
* // without __weak
|
* // without __weak
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef WEAK
|
#ifndef MBED_WEAK
|
||||||
#if defined(__ICCARM__)
|
#if defined(__ICCARM__)
|
||||||
#define WEAK __weak
|
#define MBED_WEAK __weak
|
||||||
#else
|
#else
|
||||||
#define WEAK __attribute__((weak))
|
#define MBED_WEAK __attribute__((weak))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** PURE
|
/** MBED_PURE
|
||||||
* Hint to the compiler that a function depends only on parameters
|
* Hint to the compiler that a function depends only on parameters
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* #include "toolchain.h"
|
* #include "toolchain.h"
|
||||||
*
|
*
|
||||||
* PURE int foo(int arg){
|
* MBED_PURE int foo(int arg){
|
||||||
* // no access to global variables
|
* // no access to global variables
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef PURE
|
#ifndef MBED_PURE
|
||||||
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
||||||
#define PURE __attribute__((const))
|
#define MBED_PURE __attribute__((const))
|
||||||
#else
|
#else
|
||||||
#define PURE
|
#define MBED_PURE
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** FORCEINLINE
|
/** MBED_FORCEINLINE
|
||||||
* Declare a function that must always be inlined. Failure to inline
|
* Declare a function that must always be inlined. Failure to inline
|
||||||
* such a function will result in an error.
|
* such a function will result in an error.
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* #include "toolchain.h"
|
* #include "toolchain.h"
|
||||||
*
|
*
|
||||||
* FORCEINLINE void foo() {
|
* MBED_FORCEINLINE void foo() {
|
||||||
*
|
*
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef FORCEINLINE
|
#ifndef MBED_FORCEINLINE
|
||||||
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
||||||
#define FORCEINLINE static inline __attribute__((always_inline))
|
#define MBED_FORCEINLINE static inline __attribute__((always_inline))
|
||||||
#elif defined(__ICCARM__)
|
#elif defined(__ICCARM__)
|
||||||
#define FORCEINLINE _Pragma("inline=force") static
|
#define MBED_FORCEINLINE _Pragma("inline=force") static
|
||||||
#else
|
#else
|
||||||
#define FORCEINLINE static inline
|
#define MBED_FORCEINLINE static inline
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** NORETURN
|
/** MBED_NORETURN
|
||||||
* Declare a function that will never return.
|
* Declare a function that will never return.
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* #include "toolchain.h"
|
* #include "toolchain.h"
|
||||||
*
|
*
|
||||||
* NORETURN void foo() {
|
* MBED_NORETURN void foo() {
|
||||||
* // must never return
|
* // must never return
|
||||||
* while (1) {}
|
* while (1) {}
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef NORETURN
|
#ifndef MBED_NORETURN
|
||||||
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
||||||
#define NORETURN __attribute__((noreturn))
|
#define MBED_NORETURN __attribute__((noreturn))
|
||||||
#elif defined(__ICCARM__)
|
#elif defined(__ICCARM__)
|
||||||
#define NORETURN __noreturn
|
#define MBED_NORETURN __noreturn
|
||||||
#else
|
#else
|
||||||
#define NORETURN
|
#define MBED_NORETURN
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** UNREACHABLE
|
/** MBED_UNREACHABLE
|
||||||
* An unreachable statement. If the statement is reached,
|
* An unreachable statement. If the statement is reached,
|
||||||
* behaviour is undefined. Useful in situations where the compiler
|
* behaviour is undefined. Useful in situations where the compiler
|
||||||
* cannot deduce the unreachability of code.
|
* cannot deduce the unreachability of code.
|
||||||
|
@ -188,19 +188,19 @@
|
||||||
* case 2: return 2;
|
* case 2: return 2;
|
||||||
* ...
|
* ...
|
||||||
* }
|
* }
|
||||||
* UNREACHABLE;
|
* MBED_UNREACHABLE;
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef UNREACHABLE
|
#ifndef MBED_UNREACHABLE
|
||||||
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
|
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
|
||||||
#define UNREACHABLE __builtin_unreachable()
|
#define MBED_UNREACHABLE __builtin_unreachable()
|
||||||
#else
|
#else
|
||||||
#define UNREACHABLE while (1)
|
#define MBED_UNREACHABLE while (1)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** DEPRECATED("message string")
|
/** MBED_DEPRECATED("message string")
|
||||||
* Mark a function declaration as deprecated, if it used then a warning will be
|
* Mark a function declaration as deprecated, if it used then a warning will be
|
||||||
* issued by the compiler possibly including the provided message. Note that not
|
* issued by the compiler possibly including the provided message. Note that not
|
||||||
* all compilers are able to display the message.
|
* all compilers are able to display the message.
|
||||||
|
@ -208,17 +208,17 @@
|
||||||
* @code
|
* @code
|
||||||
* #include "toolchain.h"
|
* #include "toolchain.h"
|
||||||
*
|
*
|
||||||
* DEPRECATED("don't foo any more, bar instead")
|
* MBED_DEPRECATED("don't foo any more, bar instead")
|
||||||
* void foo(int arg);
|
* void foo(int arg);
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef DEPRECATED
|
#ifndef MBED_DEPRECATED
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#define DEPRECATED(M) __attribute__((deprecated(M)))
|
#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
|
||||||
#elif defined(__CC_ARM)
|
#elif defined(__CC_ARM)
|
||||||
#define DEPRECATED(M) __attribute__((deprecated))
|
#define MBED_DEPRECATED(M) __attribute__((deprecated))
|
||||||
#else
|
#else
|
||||||
#define DEPRECATED(M)
|
#define MBED_DEPRECATED(M)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -233,6 +233,10 @@ typedef int FILEHANDLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Backwards compatibility
|
// Backwards compatibility
|
||||||
|
#ifndef WEAK
|
||||||
|
#define WEAK MBED_WEAK
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EXTERN
|
#ifndef EXTERN
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue