From f0dc995c6740ab1a3a64cbb5c7a182b68bfcc22a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 18 Aug 2015 00:11:03 +0900 Subject: [PATCH] Handle c99 inline vs gnu89 inline. The meaning of "extern inline" and "inline" swaps between the two, and gcc-5 uses c99 inline. --- config.d/compiling.m4 | 21 +++++++++++++++++++++ include/QF/math/vector.h | 4 ++-- include/QF/mathlib.h | 8 ++++---- include/gib_parse.h | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/config.d/compiling.m4 b/config.d/compiling.m4 index a27ef04c5..457882d09 100644 --- a/config.d/compiling.m4 +++ b/config.d/compiling.m4 @@ -14,6 +14,27 @@ if test "x$CFLAGS" != "x"; then fi AC_MSG_RESULT([$leave_cflags_alone]) +AC_MSG_CHECKING(for C99 inline) +c99_inline=no +AC_TRY_LINK( + [inline int foo (int x) { return x * x; } + int (*bar) (int) = foo;], + [], + c99_inline=no + AC_MSG_RESULT(no), + c99_inline=yes + AC_DEFINE(HAVE_C99INLINE, extern, [define this if using c99 inline]) + AC_MSG_RESULT(yes) +) +AH_VERBATIM([HAVE_C99INLINE], +[/* Define this if the GCC __attribute__ keyword is available */ +#undef HAVE_C99INLINE +#ifdef HAVE_C99INLINE +# define GNU89INLINE +#else +# define GNU89INLINE extern +#endif]) + if test "x$GCC" = xyes; then set $CC shift diff --git a/include/QF/math/vector.h b/include/QF/math/vector.h index db9aa36ca..994ffee62 100644 --- a/include/QF/math/vector.h +++ b/include/QF/math/vector.h @@ -183,10 +183,10 @@ void _VectorSubtract (const vec3_t veca, const vec3_t vecb, vec3_t out); void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross); vec_t _VectorNormalize (vec3_t v); // returns vector length -extern inline float VectorNormalize (vec3_t v); // returns vector length +GNU89INLINE inline float VectorNormalize (vec3_t v); // returns vector length #ifndef IMPLEMENT_VectorNormalize -extern inline +GNU89INLINE inline #else VISIBLE #endif diff --git a/include/QF/mathlib.h b/include/QF/mathlib.h index 75c427ced..498dbd2d0 100644 --- a/include/QF/mathlib.h +++ b/include/QF/mathlib.h @@ -174,11 +174,11 @@ void RotatePointAroundVector (vec3_t dst, const vec3_t axis, } while (0) extern plane_t * const frustum; -extern inline qboolean R_CullBox (const vec3_t mins, const vec3_t maxs); -extern inline qboolean R_CullSphere (const vec3_t origin, const float radius); +GNU89INLINE inline qboolean R_CullBox (const vec3_t mins, const vec3_t maxs); +GNU89INLINE inline qboolean R_CullSphere (const vec3_t origin, const float radius); #ifndef IMPLEMENT_R_Cull -extern inline +GNU89INLINE inline #else VISIBLE #endif @@ -194,7 +194,7 @@ R_CullBox (const vec3_t mins, const vec3_t maxs) } #ifndef IMPLEMENT_R_Cull -extern inline +GNU89INLINE inline #else VISIBLE #endif diff --git a/include/gib_parse.h b/include/gib_parse.h index c9be84248..a6dae25c0 100644 --- a/include/gib_parse.h +++ b/include/gib_parse.h @@ -30,7 +30,7 @@ #include "gib_tree.h" -inline qboolean GIB_Escaped (const char *str, int i); +qboolean GIB_Escaped (const char *str, int i); char GIB_Parse_Match_Brace (const char *str, unsigned int *i); char GIB_Parse_Match_Backtick (const char *str, unsigned int *i);