1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "nel/misc/check_fpu.h"
22 #include "nel/misc/fast_floor.h"
25 #pragma optimize("", off )
35 int CFpuChecker::_RefFpuCtrl
= 0x00090013;
38 CFpuChecker::CFpuChecker()
42 CFpuChecker::~CFpuChecker()
47 void CFpuChecker::dumpFpu(int value
)
49 nlwarning("_MCW_DN = %s", value
& _MCW_DN
? "_DN_FLUSH" : "_DN_SAVE");
50 nlwarning("_MCW_EM = %x", _MCW_EM
);
51 switch(value
& _MCW_EM
)
53 case _EM_INVALID
: nlwarning("_EM_INVALID"); break;
54 case _EM_DENORMAL
: nlwarning("_EM_DENORMAL"); break;
55 case _EM_ZERODIVIDE
: nlwarning("_EM_ZERODIVIDE"); break;
56 case _EM_OVERFLOW
: nlwarning("_EM_OVERFLOW"); break;
57 case _EM_UNDERFLOW
: nlwarning("_EM_UNDERFLOW"); break;
58 case _EM_INEXACT
: nlwarning("_EM_INEXACT"); break;
60 nlwarning("_MCW_EM = %x", value
& _MCW_EM
);
63 nlwarning("_MCW_IC = %s", value
& _MCW_IC
? "_IC_AFFINE" : "_IC_PROJECTIVE");
64 switch(value
& _MCW_RC
)
66 case _RC_CHOP
: nlwarning("_RC_CHOP"); break;
67 case _RC_UP
: nlwarning("_RC_UP"); ; break;
68 case _RC_DOWN
: nlwarning("_RC_DOWN"); break;
69 case _RC_NEAR
: nlwarning("_RC_NEAR"); break;
71 switch(value
& _MCW_PC
)
73 case _PC_24
: nlwarning("_PC_24"); break;
74 case _PC_53
: nlwarning("_PC_53"); ; break;
75 case _PC_64
: nlwarning("_PC_64"); break;
81 void CFpuChecker::check()
83 #if defined(NL_OS_WINDOWS) && defined(NL_COMP_VC6)
84 // don't Check if in a user control state
85 if (NLMISC::OptFastFloorCWStackPtr
!= NLMISC::OptFastFloorCWStack
) return;
87 // check standard control state
88 volatile int cfp
= _controlfp(0, 0);
89 if ((cfp
& ~_MCW_EM
) != (_RefFpuCtrl
& ~_MCW_EM
))
92 nlwarning("=========================");
94 nlwarning("Current = ");
95 nlwarning("=========================");
104 #endif // NL_OS_WINDOWS