Added likely/unlikely infrastructure in RT, implementation details in the port layer. Added an __CH_USED() macro for voiding expression results.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14527 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
8e025cd39c
commit
b81214fbc4
|
@ -120,6 +120,20 @@
|
|||
* compiler.
|
||||
*/
|
||||
#define CC_ROMCONST const
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely true.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_LIKELY(x) x
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely false.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_UNLIKELY(x) x
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -120,6 +120,20 @@
|
|||
* compiler.
|
||||
*/
|
||||
#define CC_ROMCONST const
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely true.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely false.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -120,6 +120,20 @@
|
|||
* compiler.
|
||||
*/
|
||||
#define CC_ROMCONST const
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely true.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_LIKELY(x) x
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely false.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_UNLIKELY(x) x
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -120,6 +120,20 @@
|
|||
* compiler.
|
||||
*/
|
||||
#define CC_ROMCONST const
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely true.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_LIKELY(x) x
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely false.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_UNLIKELY(x) x
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -120,6 +120,20 @@
|
|||
* compiler.
|
||||
*/
|
||||
#define CC_ROMCONST const
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely true.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_LIKELY(x) x
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely false.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define CC_UNLIKELY(x) x
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -101,6 +101,28 @@ typedef uint64_t port_stkalign_t;
|
|||
*/
|
||||
#define SIZEOF_PTR PORT_ARCH_SIZEOF_DATA_PTR
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely true.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#if defined(CC_LIKELY) || defined(__DOXYGEN__)
|
||||
#define PORT_LIKELY(x) CC_LIKELY(x)
|
||||
#else
|
||||
#define PORT_LIKELY(x) x
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely false.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#if defined(CC_UNLIKELY) || defined(__DOXYGEN__)
|
||||
#define PORT_UNLIKELY(x) CC_UNLIKELY(x)
|
||||
#else
|
||||
#define PORT_UNLIKELY(x) x
|
||||
#endif
|
||||
|
||||
#endif /* CHTYPES_H */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -146,7 +146,7 @@ typedef struct ch_os_instance os_instance_t;
|
|||
*
|
||||
* @param[in] a literal to be string-ified
|
||||
*/
|
||||
#define __CH_STRINGIFY(a) #a
|
||||
#define __CH_STRINGIFY(a) #a
|
||||
|
||||
/**
|
||||
* @brief Structure field offset utility.
|
||||
|
@ -161,6 +161,39 @@ typedef struct ch_os_instance os_instance_t;
|
|||
((size_t)((char *)&((st *)0)->m - (char *)0)) \
|
||||
/*lint -restore*/
|
||||
|
||||
/**
|
||||
* @brief Marks an expression result as used.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#define __CH_USED(x) (void)(x)
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely true.
|
||||
* @note No namespace prefix for this macro because it is commonly defined
|
||||
* by operating systems.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#if defined(PORT_LIKELY) || defined(__DOXYGEN__)
|
||||
#define likely(x) PORT_LIKELY(x)
|
||||
#else
|
||||
#define likely(x) x
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Marks a boolean expression as likely false.
|
||||
* @note No namespace prefix for this macro because it is commonly defined
|
||||
* by operating systems.
|
||||
*
|
||||
* @param[in] x a valid expression
|
||||
*/
|
||||
#if defined(PORT_UNLIKELY) || defined(__DOXYGEN__)
|
||||
#define unlikely(x) PORT_UNLIKELY(x)
|
||||
#else
|
||||
#define unlikely(x) x
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
Loading…
Reference in New Issue