Skip to content

Commit c5b9779

Browse files
committed
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.
1 parent a65b1a7 commit c5b9779

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

components/TARGET_PSA/services/storage/common/psa_storage_common_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static psa_status_t convert_status(int status)
127127
* \param n[in] number of bits to shift right
128128
* \return the result
129129
*/
130-
MBED_FORCEINLINE uint32_t lsr32(uint32_t x, uint32_t n)
130+
static MBED_FORCEINLINE uint32_t lsr32(uint32_t x, uint32_t n)
131131
{
132132
return x >> n;
133133
}
@@ -140,7 +140,7 @@ MBED_FORCEINLINE uint32_t lsr32(uint32_t x, uint32_t n)
140140
* \param n[in] number of bits to shift right
141141
* \return the result
142142
*/
143-
MBED_FORCEINLINE uint64_t lsr64(uint64_t x, uint32_t n)
143+
static MBED_FORCEINLINE uint64_t lsr64(uint64_t x, uint32_t n)
144144
{
145145
return x >> n;
146146
}

platform/mbed_toolchain.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@
277277
*/
278278
#ifndef MBED_FORCEINLINE
279279
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
280-
#define MBED_FORCEINLINE static inline __attribute__((always_inline))
280+
#define MBED_FORCEINLINE inline __attribute__((always_inline))
281281
#elif defined(__ICCARM__)
282-
#define MBED_FORCEINLINE _Pragma("inline=forced") static
282+
#define MBED_FORCEINLINE _Pragma("inline=forced")
283283
#else
284-
#define MBED_FORCEINLINE static inline
284+
#define MBED_FORCEINLINE inline
285285
#endif
286286
#endif
287287

0 commit comments

Comments
 (0)