From c24f4a0539843b30e1bc10d74ff6f4d61a48274c Mon Sep 17 00:00:00 2001 From: david Date: Sat, 22 Dec 2001 19:10:37 +0000 Subject: [PATCH] Enable floating-point exceptions for Linux/x86 systems. See the beginning of main() for the exceptions that can be enabled (only divide-by-zero is enabled by default, but you can uncomment any ones you want); eventually, FlightGear should run cleanly with all FPEs enabled. --- src/Main/main.cxx | 61 +++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 9970247e1..d835bbd48 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -25,6 +25,10 @@ # include #endif +#if defined(__linux__) && defined(__386__) +# include +#endif + #include #include @@ -974,48 +978,8 @@ void fgUpdateTimeDepCalcs() { } // update the view angle - FGViewer *v = globals->get_current_view(); - for ( i = 0; i < multi_loop; i++ ) { - if ( fabs(v->get_goal_view_offset() - v->get_view_offset()) < 0.05 ) { - v->set_view_offset( v->get_goal_view_offset() ); - break; - } else { - // move current_view.view_offset towards - // current_view.goal_view_offset - if ( v->get_goal_view_offset() > v->get_view_offset() ) - { - if ( v->get_goal_view_offset() - v->get_view_offset() < SGD_PI ){ - v->inc_view_offset( 0.01 ); - } else { - v->inc_view_offset( -0.01 ); - } - } else { - if ( v->get_view_offset() - v->get_goal_view_offset() < SGD_PI ){ - v->inc_view_offset( -0.01 ); - } else { - v->inc_view_offset( 0.01 ); - } - } - if ( v->get_view_offset() > SGD_2PI ) { - v->inc_view_offset( -SGD_2PI ); - } else if ( v->get_view_offset() < 0 ) { - v->inc_view_offset( SGD_2PI ); - } - } - } + globals->get_current_view()->update(multi_loop); - double tmp = -(l->sun_rotation + SGD_PI) - - (cur_fdm_state->get_Psi() - - globals->get_current_view()->get_view_offset() ); - while ( tmp < 0.0 ) { - tmp += SGD_2PI; - } - while ( tmp > SGD_2PI ) { - tmp -= SGD_2PI; - } - /* printf("Psi = %.2f, viewoffset = %.2f sunrot = %.2f rottosun = %.2f\n", - FG_Psi * SGD_RADIANS_TO_DEGREES, current_view.view_offset * SGD_RADIANS_TO_DEGREES, - -(l->sun_rotation+SGD_PI) * SGD_RADIANS_TO_DEGREES, tmp * SGD_RADIANS_TO_DEGREES); */ l->UpdateAdjFog(); // Update solar system @@ -1024,7 +988,7 @@ void fgUpdateTimeDepCalcs() { cur_fdm_state->get_Latitude() ); // Update radio stack model - current_radiostack->update(1); // FIXME: use dt + current_radiostack->update(multi_loop); } @@ -1809,6 +1773,19 @@ int mainLoop( int argc, char **argv ) { // Main entry point; catch any exceptions that have made it this far. int main ( int argc, char **argv ) { + // Enable floating-point exceptions for Linux/x86 +#if defined(__linux__) && defined(__386__) + int fpe_flags = 0; +// fpe_flags |= _FPU_MASK_IM; // invalid operation +// fpe_flags |= _FPU_MASK_DM; // denormalized operand + fpe_flags |= _FPU_MASK_ZM; // zero-divide +// fpe_flags |= _FPU_MASK_OM; // overflow +// fpe_flags |= _FPU_MASK_UM; // underflow +// fpe_flags |= _FPU_MASK_PM; // precision (inexact result) + _FPU_SETCW(fpe_flags); +#endif + + // Enable floating-point exceptions for Windows #if defined( _MSC_VER ) && defined( DEBUG ) // Christian, we should document what this does _control87( _EM_INEXACT, _MCW_EM ); -- 2.39.5