diff options
author | Thilo Schulz <arny@ats.s.bawue.de> | 2011-06-13 09:56:39 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-09 23:15:55 +0000 |
commit | 6a71409a0622050f9a682d4e3b02419c444febe5 (patch) | |
tree | 7766ff71304d04c6e42de7dd7d48ed7e7e0fac59 /src/sys/sys_win32.c | |
parent | b15804d39f71e9be202818288726777d1ca8ac09 (diff) |
- Add MASM assembler files for MSVC x64 projects to support vm_x86 in x64 mode - Clean up ftol()/snapvector() mess - Make use of SSE instructions for ftol()/snapvector() if available - move ftol/snapvector pure assembler to inline assembler, this will add x86_64 and improve support for different calling conventions - Set FPU control word at program startup to get consistent behaviour on all platforms
Diffstat (limited to 'src/sys/sys_win32.c')
-rw-r--r-- | src/sys/sys_win32.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/sys/sys_win32.c b/src/sys/sys_win32.c index f91b26b1..4fddfdc0 100644 --- a/src/sys/sys_win32.c +++ b/src/sys/sys_win32.c @@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include <wincrypt.h> #include <shlobj.h> #include <psapi.h> +#include <float.h> // Used to determine where to store user-specific files static char homePath[ MAX_OSPATH ] = { 0 }; @@ -47,14 +48,38 @@ static char homePath[ MAX_OSPATH ] = { 0 }; static UINT timerResolution = 0; #endif -#ifdef __WIN64__ -void Sys_SnapVector( float *v ) +/* +================ +Sys_SetFPUCW +Set FPU control word to default value +================ +*/ + +#ifndef _RC_CHOP +// mingw doesn't seem to have these defined :( + + #define _MCW_EM 0x0008001fU + #define _MCW_RC 0x00000300U + #define _MCW_PC 0x00030000U + #define _RC_CHOP 0x00000300U + #define _PC_53 0x00010000U + + unsigned int _controlfp(unsigned int new, unsigned int mask); +#endif + +#define FPUCWMASK1 (_MCW_RC | _MCW_EM) +#define FPUCW (_RC_CHOP | _MCW_EM | _PC_53) + +#ifdef idx64 +#define FPUCWMASK (FPUCWMASK1) +#else +#define FPUCWMASK (FPUCWMASK1 | _MCW_PC) +#endif + +void Sys_SetFloatEnv(void) { - v[0] = rint(v[0]); - v[1] = rint(v[1]); - v[2] = rint(v[2]); + _controlfp(FPUCW, FPUCWMASK); } -#endif /* ================ @@ -136,34 +161,6 @@ int Sys_Milliseconds (void) return sys_curtime; } -#ifndef __GNUC__ //see snapvectora.s -/* -================ -Sys_SnapVector -================ -*/ -void Sys_SnapVector( float *v ) -{ - int i; - float f; - - f = *v; - __asm fld f; - __asm fistp i; - *v = i; - v++; - f = *v; - __asm fld f; - __asm fistp i; - *v = i; - v++; - f = *v; - __asm fld f; - __asm fistp i; - *v = i; -} -#endif - /* ================ Sys_RandomBytes @@ -715,9 +712,12 @@ void Sys_PlatformInit( void ) { #ifndef DEDICATED TIMECAPS ptc; - const char *SDL_VIDEODRIVER = getenv( "SDL_VIDEODRIVER" ); +#endif + + Sys_SetFloatEnv(); +#ifndef DEDICATED if( SDL_VIDEODRIVER ) { Com_Printf( "SDL_VIDEODRIVER is externally set to \"%s\", " |