Skip to content

Commit

Permalink
Core: Fixed inline functions to use consistent code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonatanAntoni committed Oct 17, 2017
1 parent 5f7b3c8 commit b91922a
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 98 deletions.
20 changes: 14 additions & 6 deletions CMSIS/Core/Include/cmsis_armcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,16 @@ __attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint3
*/
__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
{
if ((sat >= 1U) && (sat <= 32U)) {
if ((sat >= 1U) && (sat <= 32U))
{
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
const int32_t min = -1 - max ;
if (val > max) {
if (val > max)
{
return max;
} else if (val < min) {
}
else if (val < min)
{
return min;
}
}
Expand All @@ -758,11 +762,15 @@ __attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint3
*/
__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
{
if (sat <= 31U) {
if (sat <= 31U)
{
const uint32_t max = ((1U << sat) - 1U);
if (val > (int32_t)max) {
if (val > (int32_t)max)
{
return max;
} else if (val < 0) {
}
else if (val < 0)
{
return 0U;
}
}
Expand Down
23 changes: 16 additions & 7 deletions CMSIS/Core/Include/cmsis_armclang.h
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,8 @@ __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
{
op2 %= 32U;
if (op2 == 0U) {
if (op2 == 0U)
{
return op1;
}
return (op1 >> op2) | (op1 << (32U - op2));
Expand Down Expand Up @@ -1065,12 +1066,16 @@ __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
*/
__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
{
if ((sat >= 1U) && (sat <= 32U)) {
if ((sat >= 1U) && (sat <= 32U))
{
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
const int32_t min = -1 - max ;
if (val > max) {
if (val > max)
{
return max;
} else if (val < min) {
}
else if (val < min)
{
return min;
}
}
Expand All @@ -1086,11 +1091,15 @@ __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
*/
__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
{
if (sat <= 31U) {
if (sat <= 31U)
{
const uint32_t max = ((1U << sat) - 1U);
if (val > (int32_t)max) {
if (val > (int32_t)max)
{
return max;
} else if (val < 0) {
}
else if (val < 0)
{
return 0U;
}
}
Expand Down
23 changes: 16 additions & 7 deletions CMSIS/Core/Include/cmsis_gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,8 @@ __STATIC_FORCEINLINE int16_t __REVSH(int16_t value)
__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
{
op2 %= 32U;
if (op2 == 0U) {
if (op2 == 0U)
{
return op1;
}
return (op1 >> op2) | (op1 << (32U - op2));
Expand Down Expand Up @@ -1238,12 +1239,16 @@ __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
*/
__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
{
if ((sat >= 1U) && (sat <= 32U)) {
if ((sat >= 1U) && (sat <= 32U))
{
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
const int32_t min = -1 - max ;
if (val > max) {
if (val > max)
{
return max;
} else if (val < min) {
}
else if (val < min)
{
return min;
}
}
Expand All @@ -1259,11 +1264,15 @@ __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
*/
__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
{
if (sat <= 31U) {
if (sat <= 31U)
{
const uint32_t max = ((1U << sat) - 1U);
if (val > (int32_t)max) {
if (val > (int32_t)max)
{
return max;
} else if (val < 0) {
}
else if (val < 0)
{
return 0U;
}
}
Expand Down
Loading

0 comments on commit b91922a

Please sign in to comment.