msvcrt: Share the common part of _fpieee_flt between platforms.

This commit is contained in:
Alexandre Julliard 2024-06-04 12:30:13 +02:00
parent 8f2d3e8396
commit b8edf6d920
7 changed files with 39 additions and 29 deletions

View file

@ -21,6 +21,7 @@
#ifndef __MSVCRT_CPPEXCEPT_H
#define __MSVCRT_CPPEXCEPT_H
#include <fpieee.h>
#include "cxx.h"
#define CXX_FRAME_MAGIC_VC6 0x19930520
@ -276,6 +277,8 @@ extern void dump_function_descr( const cxx_function_descr *descr, uintptr_t base
extern void *find_catch_handler( void *object, uintptr_t frame, uintptr_t exc_base,
const tryblock_info *tryblock,
cxx_exception_type *exc_type, uintptr_t image_base );
extern int handle_fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) );
#if _MSVCR_VER >= 80
#define EXCEPTION_MANGLED_NAME ".?AVexception@std@@"

View file

@ -448,6 +448,25 @@ BOOL CDECL __uncaught_exception(void)
return msvcrt_get_thread_data()->processing_throw != 0;
}
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
*/
int __cdecl _fpieee_flt( __msvcrt_ulong code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) )
{
switch (code)
{
case STATUS_FLOAT_DIVIDE_BY_ZERO:
case STATUS_FLOAT_INEXACT_RESULT:
case STATUS_FLOAT_INVALID_OPERATION:
case STATUS_FLOAT_OVERFLOW:
case STATUS_FLOAT_UNDERFLOW:
return handle_fpieee_flt( code, ep, handler );
default:
return EXCEPTION_CONTINUE_SEARCH;
}
}
#if _MSVCR_VER>=70 && _MSVCR_VER<=71
/*********************************************************************

View file

@ -51,10 +51,10 @@ EXCEPTION_DISPOSITION CDECL __CxxFrameHandler(EXCEPTION_RECORD *rec, DWORD frame
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
* handle_fpieee_flt
*/
int __cdecl _fpieee_flt(__msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*))
int handle_fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) )
{
FIXME("(%lx %p %p)\n", exception_code, ep, handler);
return EXCEPTION_CONTINUE_SEARCH;

View file

@ -58,10 +58,10 @@ __ASM_GLOBAL_FUNC( _setjmp, "b _setjmpex" );
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
* handle_fpieee_flt
*/
int __cdecl _fpieee_flt(__msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*))
int handle_fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) )
{
FIXME("(%lx %p %p)\n", exception_code, ep, handler);
return EXCEPTION_CONTINUE_SEARCH;

View file

@ -51,10 +51,10 @@ EXCEPTION_DISPOSITION CDECL __CxxFrameHandler( EXCEPTION_RECORD *rec, ULONG64 fr
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
* handle_fpieee_flt
*/
int __cdecl _fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) )
int handle_fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) )
{
FIXME("(%lx %p %p)\n", exception_code, ep, handler);
return EXCEPTION_CONTINUE_SEARCH;

View file

@ -856,28 +856,15 @@ void __stdcall _seh_longjmp_unwind4(_JUMP_BUFFER *jmp)
}
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
* handle_fpieee_flt
*/
int __cdecl _fpieee_flt(__msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*))
int handle_fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) )
{
FLOATING_SAVE_AREA *ctx = &ep->ContextRecord->FloatSave;
_FPIEEE_RECORD rec;
int ret;
TRACE("(%lx %p %p)\n", exception_code, ep, handler);
switch(exception_code) {
case STATUS_FLOAT_DIVIDE_BY_ZERO:
case STATUS_FLOAT_INEXACT_RESULT:
case STATUS_FLOAT_INVALID_OPERATION:
case STATUS_FLOAT_OVERFLOW:
case STATUS_FLOAT_UNDERFLOW:
break;
default:
return EXCEPTION_CONTINUE_SEARCH;
}
memset(&rec, 0, sizeof(rec));
rec.RoundingMode = ctx->ControlWord >> 10;
switch((ctx->ControlWord >> 8) & 0x3) {
@ -902,7 +889,8 @@ int __cdecl _fpieee_flt(__msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
rec.Cause.Underflow = rec.Enable.Underflow & rec.Status.Underflow;
rec.Cause.Inexact = rec.Enable.Inexact & rec.Status.Inexact;
TRACE("opcode: %lx\n", *(ULONG*)ep->ContextRecord->FloatSave.ErrorOffset);
TRACE("code %lx handler %p opcode %lx\n", exception_code, handler,
*(ULONG*)ep->ContextRecord->FloatSave.ErrorOffset);
if(*(WORD*)ctx->ErrorOffset == 0x35dc) { /* fdiv m64fp */
if(exception_code==STATUS_FLOAT_DIVIDE_BY_ZERO || exception_code==STATUS_FLOAT_INVALID_OPERATION) {

View file

@ -454,10 +454,10 @@ void __cdecl _local_unwind( void *frame, void *target )
}
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
* handle_fpieee_flt
*/
int __cdecl _fpieee_flt(__msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*))
int handle_fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*) )
{
FIXME("(%lx %p %p) opcode: %#I64x\n", exception_code, ep, handler,
*(ULONG64*)ep->ContextRecord->Rip);