Commit 14a81773 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added __pxcptinfoptrs implementation.

parent 62e00e52
......@@ -61,6 +61,14 @@ static BOOL WINAPI msvcrt_console_handler(DWORD ctrlType)
return ret;
}
/*********************************************************************
* __pxcptinfoptrs (MSVCRT.@)
*/
void** CDECL MSVCRT___pxcptinfoptrs(void)
{
return (void**)&msvcrt_get_thread_data()->xcptinfo;
}
typedef void (CDECL *float_handler)(int, int);
/* The exception codes are actually NTSTATUS values */
......@@ -93,8 +101,13 @@ static LONG WINAPI msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
{
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
old_ep = *ep;
*ep = except;
sighandlers[MSVCRT_SIGSEGV] = MSVCRT_SIG_DFL;
handler(MSVCRT_SIGSEGV);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
......@@ -114,6 +127,7 @@ static LONG WINAPI msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
{
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
unsigned int i;
int float_signal = MSVCRT__FPE_INVALID;
......@@ -128,7 +142,11 @@ static LONG WINAPI msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
break;
}
}
old_ep = *ep;
*ep = except;
((float_handler)handler)(MSVCRT_SIGFPE, float_signal);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
......@@ -139,8 +157,13 @@ static LONG WINAPI msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
{
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
old_ep = *ep;
*ep = except;
sighandlers[MSVCRT_SIGILL] = MSVCRT_SIG_DFL;
handler(MSVCRT_SIGILL);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
......@@ -204,22 +227,36 @@ int CDECL MSVCRT_raise(int sig)
switch (sig)
{
case MSVCRT_SIGABRT:
case MSVCRT_SIGFPE:
case MSVCRT_SIGILL:
case MSVCRT_SIGSEGV:
case MSVCRT_SIGINT:
case MSVCRT_SIGTERM:
case MSVCRT_SIGBREAK:
handler = sighandlers[sig];
if (handler == MSVCRT_SIG_DFL) MSVCRT__exit(3);
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
sighandlers[sig] = MSVCRT_SIG_DFL;
old_ep = *ep;
*ep = NULL;
if (sig == MSVCRT_SIGFPE)
((float_handler)handler)(sig, MSVCRT__FPE_EXPLICITGEN);
else
handler(sig);
*ep = old_ep;
}
break;
case MSVCRT_SIGABRT:
case MSVCRT_SIGINT:
case MSVCRT_SIGTERM:
case MSVCRT_SIGBREAK:
handler = sighandlers[sig];
if (handler == MSVCRT_SIG_DFL) MSVCRT__exit(3);
if (handler != MSVCRT_SIG_IGN)
{
sighandlers[sig] = MSVCRT_SIG_DFL;
handler(sig);
}
break;
default:
......
......@@ -200,7 +200,8 @@ struct __thread_data {
struct MSVCRT_tm *time_buffer; /* buffer for localtime/gmtime */
char *efcvt_buffer; /* buffer for ecvt/fcvt */
int unk3[2];
void *unk4[4];
void *unk4[3];
EXCEPTION_POINTERS *xcptinfo;
int fpecode;
MSVCRT_pthreadmbcinfo mbcinfo;
MSVCRT_pthreadlocinfo locinfo;
......
......@@ -250,7 +250,7 @@
@ cdecl __pctype_func() MSVCRT___pctype_func
@ extern __pioinfo MSVCRT___pioinfo
# stub __pwctype_func()
@ stub __pxcptinfoptrs()
@ cdecl __pxcptinfoptrs() MSVCRT___pxcptinfoptrs
@ cdecl __set_app_type(long) MSVCRT___set_app_type
@ extern __setlc_active MSVCRT___setlc_active
@ cdecl __setusermatherr(ptr) MSVCRT___setusermatherr
......
......@@ -42,6 +42,7 @@ typedef void (__cdecl *__sighandler_t)(int);
#define SIG_IGN ((__sighandler_t)1)
#define SIG_ERR ((__sighandler_t)-1)
void** __cdecl __pxcptinfoptrs(void);
__sighandler_t __cdecl signal(int sig, __sighandler_t func);
int __cdecl raise(int sig);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment