mirror of
https://github.com/dhewm/dhewm3.git
synced 2024-11-22 20:51:20 +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 commit is contained in:
parent
aca8c24c3a
commit
b756276b54
4 changed files with 8 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;
|
||||
|
||||
|
|
|
@ -2389,7 +2389,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
|
||||
|
@ -96,6 +99,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#define ALIGN16( x ) x __attribute__ ((aligned (16)))
|
||||
#define PACKED __attribute__((packed))
|
||||
#define ID_INLINE inline
|
||||
#define ID_MAYBE_INLINE inline
|
||||
#define ID_STATIC_TEMPLATE
|
||||
#define assertmem( x, y )
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue