Add shortcuts to SwapEndian_16() and SwapEndian_32() internal functions to improve optimization if called with constant inputs.

This commit is contained in:
Dean Camera 2011-08-16 05:00:45 +00:00
parent ef4cff29c3
commit 3478178127
5 changed files with 53 additions and 25 deletions

View file

@ -394,6 +394,9 @@
static inline uint16_t SwapEndian_16(const uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST;
static inline uint16_t SwapEndian_16(const uint16_t Word)
{
if (GCC_IS_COMPILE_CONST(Word))
return SWAPENDIAN_16(Word);
uint8_t Temp;
union
@ -420,6 +423,9 @@
static inline uint32_t SwapEndian_32(const uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST;
static inline uint32_t SwapEndian_32(const uint32_t DWord)
{
if (GCC_IS_COMPILE_CONST(DWord))
return SWAPENDIAN_32(DWord);
uint8_t Temp;
union