diff --git a/idlib/math/Curve.h b/idlib/math/Curve.h index c8f9979..5c9e804 100644 --- a/idlib/math/Curve.h +++ b/idlib/math/Curve.h @@ -204,7 +204,7 @@ idCurve::RombergIntegral ==================== */ template< class type > -ID_INLINE float idCurve::RombergIntegral( const float t0, const float t1, const int order ) const { +ID_MAYBE_INLINE float idCurve::RombergIntegral(const float t0, const float t1, const int order) const { int i, j, k, m, n; float sum, delta; float *temp[2]; @@ -242,7 +242,7 @@ idCurve::GetLengthBetweenKnots ==================== */ template< class type > -ID_INLINE float idCurve::GetLengthBetweenKnots( const int i0, const int i1 ) const { +ID_MAYBE_INLINE float idCurve::GetLengthBetweenKnots(const int i0, const int i1) const { float length = 0.0f; for ( int i = i0; i < i1; i++ ) { length += RombergIntegral( times[i], times[i+1], 5 ); diff --git a/idlib/math/Lcp.cpp b/idlib/math/Lcp.cpp index 13ad756..f61c86a 100644 --- a/idlib/math/Lcp.cpp +++ b/idlib/math/Lcp.cpp @@ -340,7 +340,7 @@ idLCP_Square::CalcForceDelta modifies this->delta_f ============ */ -ID_INLINE void idLCP_Square::CalcForceDelta( int d, float dir ) { +ID_MAYBE_INLINE void idLCP_Square::CalcForceDelta(int d, float dir) { int i; float *ptr; diff --git a/idlib/math/Matrix.h b/idlib/math/Matrix.h index 4a8935a..c6cb187 100644 --- a/idlib/math/Matrix.h +++ b/idlib/math/Matrix.h @@ -2390,7 +2390,7 @@ ID_INLINE void idMatX::Clamp( float min, float max ) { } } -ID_INLINE idMatX &idMatX::SwapRows( int r1, int r2 ) { +ID_MAYBE_INLINE idMatX &idMatX::SwapRows(int r1, int r2) { float *ptr; ptr = (float *) _alloca16( numColumns * sizeof( float ) ); diff --git a/sys/platform.h b/sys/platform.h index 2c4ce98..d9a9a5b 100644 --- a/sys/platform.h +++ b/sys/platform.h @@ -85,6 +85,9 @@ If you have questions concerning this license or the applicable additional terms #define ALIGN16( x ) __declspec(align(16)) x #define PACKED #define ID_INLINE __forceinline +// DG: alternative to forced inlining of ID_INLINE for functions that do alloca() +// and are called in a loop so inlining them might cause stack overflow +#define ID_MAYBE_INLINE __inline #define ID_STATIC_TEMPLATE static #define assertmem( x, y ) assert( _CrtIsValidPointer( x, y, true ) ) #else @@ -161,6 +164,10 @@ If you have questions concerning this license or the applicable additional terms #endif +#ifndef ID_MAYBE_INLINE +// for MSVC it's __inline, otherwise just inline should work +#define ID_MAYBE_INLINE inline +#endif // ID_MAYBE_INLINE #ifdef __GNUC__ #define id_attribute(x) __attribute__(x)