Remote "static" from MBED_FORCEINLINE

Static keyword causes problems when trying to use force-inlined
functions from normal inlined functions. This is not legal:

    static inline void forced() { }

    inline void normal() { forced(); }

You cannot reference internal-linkage things from external-linkage
inline functions.

Removal of the static implies that in C there would need to be a
non-inline definition in case anyone calls it non-inlined, but if the
force attribute is doing its job, that should not happen.

Only significant in-tree user of the MBED_FORCEINLINE macro is
the atomic operations - making this change permits atomic operations
from non-static inline functions.
pull/10609/head
Kevin Bracey 2019-06-27 16:12:30 +03:00
parent a65b1a76ac
commit c5b9779858
2 changed files with 5 additions and 5 deletions

View File

@ -127,7 +127,7 @@ static psa_status_t convert_status(int status)
* \param n[in] number of bits to shift right
* \return the result
*/
MBED_FORCEINLINE uint32_t lsr32(uint32_t x, uint32_t n)
static MBED_FORCEINLINE uint32_t lsr32(uint32_t x, uint32_t n)
{
return x >> n;
}
@ -140,7 +140,7 @@ MBED_FORCEINLINE uint32_t lsr32(uint32_t x, uint32_t n)
* \param n[in] number of bits to shift right
* \return the result
*/
MBED_FORCEINLINE uint64_t lsr64(uint64_t x, uint32_t n)
static MBED_FORCEINLINE uint64_t lsr64(uint64_t x, uint32_t n)
{
return x >> n;
}

View File

@ -277,11 +277,11 @@
*/
#ifndef MBED_FORCEINLINE
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
#define MBED_FORCEINLINE static inline __attribute__((always_inline))
#define MBED_FORCEINLINE inline __attribute__((always_inline))
#elif defined(__ICCARM__)
#define MBED_FORCEINLINE _Pragma("inline=forced") static
#define MBED_FORCEINLINE _Pragma("inline=forced")
#else
#define MBED_FORCEINLINE static inline
#define MBED_FORCEINLINE inline
#endif
#endif