From 7b78af8b306bb17a033e71d6847b320dc9c233b9 Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Fri, 7 Aug 2009 09:36:53 +0000 Subject: [PATCH] - Add inlined assembly for MSVC to _clearfp, _control87, _fpreset, _logb and _statusfp, move fpreset into arch-specific directory and remove x86 #ifdefs from the code. - Disable warning C4733 for __wine_push_frame and __wine_pop_frame svn path=/trunk/; revision=42458 --- reactos/lib/sdk/crt/crt.rbuild | 3 ++- reactos/lib/sdk/crt/float/i386/clearfp.c | 4 ++-- reactos/lib/sdk/crt/float/i386/cntrlfp.c | 18 ++++++++---------- reactos/lib/sdk/crt/float/{ => i386}/fpreset.c | 4 ++-- reactos/lib/sdk/crt/float/i386/logb.c | 4 ++++ reactos/lib/sdk/crt/float/i386/statfp.c | 11 +++++------ .../sdk/crt/include/internal/wine/cppexcept.h | 11 +++++++++++ 7 files changed, 34 insertions(+), 21 deletions(-) rename reactos/lib/sdk/crt/float/{ => i386}/fpreset.c (85%) diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild index 70324067f7c..8a9cf951a43 100644 --- a/reactos/lib/sdk/crt/crt.rbuild +++ b/reactos/lib/sdk/crt/crt.rbuild @@ -81,7 +81,6 @@ copysign.c fpclass.c fpecode.c - fpreset.c isnan.c nafter.c scalb.c @@ -89,6 +88,7 @@ clearfp.c cntrlfp.c + fpreset.c logb.c statfp.c @@ -97,6 +97,7 @@ clearfp.c cntrlfp.c + fpreset.c logb.c statfp.c diff --git a/reactos/lib/sdk/crt/float/i386/clearfp.c b/reactos/lib/sdk/crt/float/i386/clearfp.c index e42d67a2cfc..d34c33a0d99 100644 --- a/reactos/lib/sdk/crt/float/i386/clearfp.c +++ b/reactos/lib/sdk/crt/float/i386/clearfp.c @@ -18,10 +18,10 @@ unsigned int _statusfp( void ); unsigned int CDECL _clearfp(void) { unsigned int retVal = _statusfp(); -#if defined(__GNUC__) && defined(__i386__) +#if defined(__GNUC__) __asm__ __volatile__( "fnclex" ); #else - FIXME(":Not Implemented\n"); + __asm fnclex; #endif return retVal; } diff --git a/reactos/lib/sdk/crt/float/i386/cntrlfp.c b/reactos/lib/sdk/crt/float/i386/cntrlfp.c index 836f54bb3bd..2cc46d8bf4b 100644 --- a/reactos/lib/sdk/crt/float/i386/cntrlfp.c +++ b/reactos/lib/sdk/crt/float/i386/cntrlfp.c @@ -29,12 +29,7 @@ unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask) { -#ifdef __i386__ return _control87( newval, mask & ~_EM_DENORMAL ); -#else - FIXME(":Not Implemented!\n"); - return 0; -#endif } /********************************************************************* @@ -42,14 +37,17 @@ unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask) */ unsigned int CDECL _control87(unsigned int newval, unsigned int mask) { -#if defined(__GNUC__) && defined(__i386__) unsigned int fpword = 0; unsigned int flags = 0; TRACE("(%08x, %08x): Called\n", newval, mask); /* Get fp control word */ +#if defined(__GNUC__) __asm__ __volatile__( "fstcw %0" : "=m" (fpword) : ); +#else + __asm fstcw [fpword]; +#endif TRACE("Control word before : %08x\n", fpword); @@ -98,11 +96,11 @@ unsigned int CDECL _control87(unsigned int newval, unsigned int mask) TRACE("Control word after : %08x\n", fpword); /* Put fp control word */ +#if defined(__GNUC__) __asm__ __volatile__( "fldcw %0" : : "m" (fpword) ); - - return flags; #else - FIXME(":Not Implemented!\n"); - return 0; + __asm fldcw [fpword]; #endif + + return flags; } diff --git a/reactos/lib/sdk/crt/float/fpreset.c b/reactos/lib/sdk/crt/float/i386/fpreset.c similarity index 85% rename from reactos/lib/sdk/crt/float/fpreset.c rename to reactos/lib/sdk/crt/float/i386/fpreset.c index f73446402fd..6cee5e885b3 100644 --- a/reactos/lib/sdk/crt/float/fpreset.c +++ b/reactos/lib/sdk/crt/float/i386/fpreset.c @@ -15,9 +15,9 @@ */ void CDECL _fpreset(void) { -#if defined(__GNUC__) && defined(__i386__) +#if defined(__GNUC__) __asm__ __volatile__( "fninit" ); #else - FIXME(":Not Implemented!\n"); + __asm fninit; #endif } diff --git a/reactos/lib/sdk/crt/float/i386/logb.c b/reactos/lib/sdk/crt/float/i386/logb.c index ac6bbb857db..b0bd79930ee 100644 --- a/reactos/lib/sdk/crt/float/i386/logb.c +++ b/reactos/lib/sdk/crt/float/i386/logb.c @@ -29,6 +29,10 @@ double _logb (double __x) ("fxtract\n\t" : "=t" (__junk), "=u" (__val) : "0" (__x)); #else + __asm fld [__x]; + __asm fxtract; + __asm fstp st(0); + __asm fstp [__val]; #endif /*__GNUC__*/ return __val; } diff --git a/reactos/lib/sdk/crt/float/i386/statfp.c b/reactos/lib/sdk/crt/float/i386/statfp.c index 9df070ba32e..9ea1beb3ddd 100644 --- a/reactos/lib/sdk/crt/float/i386/statfp.c +++ b/reactos/lib/sdk/crt/float/i386/statfp.c @@ -24,19 +24,18 @@ */ unsigned int CDECL _statusfp(void) { - unsigned int retVal = 0; -#if defined(__GNUC__) && defined(__i386__) + unsigned int retVal = 0; unsigned int fpword; - +#if defined(__GNUC__) __asm__ __volatile__( "fstsw %0" : "=m" (fpword) : ); +#else + __asm fstsw [fpword]; +#endif if (fpword & 0x1) retVal |= _SW_INVALID; if (fpword & 0x2) retVal |= _SW_DENORMAL; if (fpword & 0x4) retVal |= _SW_ZERODIVIDE; if (fpword & 0x8) retVal |= _SW_OVERFLOW; if (fpword & 0x10) retVal |= _SW_UNDERFLOW; if (fpword & 0x20) retVal |= _SW_INEXACT; -#else - FIXME(":Not implemented!\n"); -#endif return retVal; } diff --git a/reactos/lib/sdk/crt/include/internal/wine/cppexcept.h b/reactos/lib/sdk/crt/include/internal/wine/cppexcept.h index 426fb60a973..0ea323a2326 100644 --- a/reactos/lib/sdk/crt/include/internal/wine/cppexcept.h +++ b/reactos/lib/sdk/crt/include/internal/wine/cppexcept.h @@ -53,6 +53,12 @@ #define EH_NESTED_CALL 0x10 #ifndef _M_ARM + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4733) +#endif + static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame ) { frame->Next = (struct _EXCEPTION_REGISTRATION_RECORD *)__readfsdword(0); @@ -65,6 +71,11 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTR __writefsdword(0, (unsigned long)frame->Next); return frame->Next; } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #endif #define __TRY _SEH2_TRY -- 2.17.1