diff options
author | Juan Carlos <juancarlospaco@gmail.com> | 2023-05-27 15:52:08 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-27 20:52:08 +0200 |
commit | b96c501836a7434fd4e76ad24a3d87b01cdcb2e0 (patch) | |
tree | 6da6f32cc96964634fc4ec989cf3d55e01dce64d /lib | |
parent | d5ba14db619eb52cb97f66f37cd04a240d84223d (diff) | |
download | Nim-b96c501836a7434fd4e76ad24a3d87b01cdcb2e0.tar.gz |
Refactor pragma inline (#21930)
* Add __force_inline support
Diffstat (limited to 'lib')
-rw-r--r-- | lib/nimbase.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/nimbase.h b/lib/nimbase.h index 3a1289b6f..1b9268881 100644 --- a/lib/nimbase.h +++ b/lib/nimbase.h @@ -84,20 +84,29 @@ __AVR__ # define __DECLSPEC_SUPPORTED 1 #endif -/* calling convention mess ----------------------------------------------- */ -#if defined(__GNUC__) || defined(__TINYC__) - /* these should support C99's inline */ -# define N_INLINE(rettype, name) inline rettype name -#elif defined(__BORLANDC__) || defined(_MSC_VER) -/* Borland's compiler is really STRANGE here; note that the __fastcall - keyword cannot be before the return type, but __inline cannot be after - the return type, so we do not handle this mess in the code generator - but rather here. */ + +/* Calling conventions and inline attributes for the supported C compilers */ +#if defined(__GNUC__) || defined(__clang__) /* GCC and Clang */ +# if __has_attribute(__forceinline) +# define N_INLINE(rettype, name) __attribute__((__forceinline)) rettype name +# else +# define N_INLINE(rettype, name) inline rettype name +# endif +#elif defined(_MSC_VER) /* MSVC */ +# if _MSC_VER > 1200 +# define N_INLINE(rettype, name) __forceinline rettype name +# else +# define N_INLINE(rettype, name) inline rettype name +# endif +#elif defined(__TINYC__) || defined(__BORLANDC__) /* TinyC and BorlandC */ # define N_INLINE(rettype, name) __inline rettype name -#else /* others are less picky: */ -# define N_INLINE(rettype, name) rettype __inline name +#elif defined(__AVR__) /* Atmel Advanced Virtual RISC */ +# define N_INLINE(rettype, name) inline rettype name +#else /* Unsupported C compilers */ +# define N_INLINE(rettype, name) rettype name #endif + #define N_INLINE_PTR(rettype, name) rettype (*name) #if defined(__cplusplus) |