Add support for M_USE_EXTERN_FINE_GRAINED to enable / disable inline semantics alongside the translation unit by redefining it when needed
This commit is contained in:
1 parent
0bd1bcb68e
commit
19ce371533
1 file changed
+13
-2
@@ -274,6 +274,11 @@ M_BEGIN_PROTECTED_CODE
|
||||
/************************* LINKAGE **************************/
|
||||
/************************************************************/
|
||||
|
||||
/* Define default values */
|
||||
#ifndef M_USE_EXTERN_FINE_GRAINED
|
||||
#define M_USE_EXTERN_FINE_GRAINED 0
|
||||
#endif
|
||||
|
||||
/* The following semantics apply to inline in C99:
|
||||
- inline: No generation of an extern visible function. May inline or may call the external function.
|
||||
- extern inline: externally visible code is emitted, so at most one translation unit can use this.
|
||||
@@ -285,15 +290,21 @@ M_BEGIN_PROTECTED_CODE
|
||||
This is only supported by GCC and CLANG.
|
||||
Otherwise uses the classic "M_INLINE"
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(M_USE_EXTERN_DECL)
|
||||
#if !defined( __cplusplus) && defined(__GNUC__) && defined(M_USE_EXTERN_DECL)
|
||||
#define M_INLINE __attribute__ ((noinline)) inline
|
||||
#elif defined(__GNUC__) && defined(M_USE_EXTERN_DEF)
|
||||
#elif !defined( __cplusplus) && defined(__GNUC__) && defined(M_USE_EXTERN_DEF)
|
||||
#define M_INLINE __attribute__ ((noinline)) extern inline
|
||||
#elif !defined( __cplusplus) && defined(__GNUC__) && M_USE_EXTERN_FINE_GRAINED
|
||||
#define M_INLINE \
|
||||
M_IF(M_EQUAL(M_USE_EXTERN_FINE_GRAINED, 2))(__attribute__ ((noinline)) inline, \
|
||||
M_IF(M_EQUAL(M_USE_EXTERN_FINE_GRAINED, 3))(__attribute__ ((noinline)) extern inline, \
|
||||
static inline))
|
||||
#else
|
||||
#define M_INLINE static inline
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/************************************************************/
|
||||
/********************* MEMORY handling **********************/
|
||||
/************************************************************/
|
||||
|
||||
Reference in new issue
Block a user