mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-24 13:31:18 +00:00
ID_MAYBE_INLINE for not-forced inlining
On Windows, ID_INLINE does __forceinline, which is bad if the function calls alloca() and is called in a loop.. So use just __inline there so the compiler can choose not to inline (if called in a loop). This didn't cause actual stack overflows as far as I know, but it could (and MSVC warns about it). (This includes "Fix ID_MAYBE_INLINE on non-Windows platforms")
This commit is contained in:
parent
a0065803ff
commit
541ba91e61
4 changed files with 11 additions and 4 deletions
|
@ -204,7 +204,7 @@ idCurve::RombergIntegral
|
|||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE float idCurve<type>::RombergIntegral( const float t0, const float t1, const int order ) const {
|
||||
ID_MAYBE_INLINE float idCurve<type>::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<type>::GetLengthBetweenKnots( const int i0, const int i1 ) const {
|
||||
ID_MAYBE_INLINE float idCurve<type>::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 );
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 ) );
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue