ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

xcptfil.c
Go to the documentation of this file.
00001 #include <precomp.h>
00002 #include "internal/wine/msvcrt.h"
00003 #include "internal/wine/cppexcept.h"
00004 
00005 typedef void (*sighandler_t)(int);
00006 static sighandler_t sighandlers[NSIG] = { SIG_DFL };
00007 
00008 /* The exception codes are actually NTSTATUS values */
00009 static const struct
00010 {
00011     NTSTATUS status;
00012     int signal;
00013 } float_exception_map[] = {
00014  { EXCEPTION_FLT_DENORMAL_OPERAND, _FPE_DENORMAL },
00015  { EXCEPTION_FLT_DIVIDE_BY_ZERO, _FPE_ZERODIVIDE },
00016  { EXCEPTION_FLT_INEXACT_RESULT, _FPE_INEXACT },
00017  { EXCEPTION_FLT_INVALID_OPERATION, _FPE_INVALID },
00018  { EXCEPTION_FLT_OVERFLOW, _FPE_OVERFLOW },
00019  { EXCEPTION_FLT_STACK_CHECK, _FPE_STACKOVERFLOW },
00020  { EXCEPTION_FLT_UNDERFLOW, _FPE_UNDERFLOW },
00021 };
00022 
00023 /*
00024  * @implemented
00025  */
00026 int CDECL
00027 _XcptFilter(NTSTATUS ExceptionCode,
00028             struct _EXCEPTION_POINTERS *  except)
00029 {
00030     LONG ret = EXCEPTION_CONTINUE_SEARCH;
00031     sighandler_t handler;
00032 
00033     if (!except || !except->ExceptionRecord)
00034         return EXCEPTION_CONTINUE_SEARCH;
00035 
00036     switch (except->ExceptionRecord->ExceptionCode)
00037     {
00038     case EXCEPTION_ACCESS_VIOLATION:
00039         if ((handler = sighandlers[SIGSEGV]) != SIG_DFL)
00040         {
00041             if (handler != SIG_IGN)
00042             {
00043                 sighandlers[SIGSEGV] = SIG_DFL;
00044                 handler(SIGSEGV);
00045             }
00046             ret = EXCEPTION_CONTINUE_EXECUTION;
00047         }
00048         break;
00049     /* According to msdn,
00050      * the FPE signal handler takes as a second argument the type of
00051      * floating point exception.
00052      */
00053     case EXCEPTION_FLT_DENORMAL_OPERAND:
00054     case EXCEPTION_FLT_DIVIDE_BY_ZERO:
00055     case EXCEPTION_FLT_INEXACT_RESULT:
00056     case EXCEPTION_FLT_INVALID_OPERATION:
00057     case EXCEPTION_FLT_OVERFLOW:
00058     case EXCEPTION_FLT_STACK_CHECK:
00059     case EXCEPTION_FLT_UNDERFLOW:
00060         if ((handler = sighandlers[SIGFPE]) != SIG_DFL)
00061         {
00062             if (handler != SIG_IGN)
00063             {
00064                 unsigned int i;
00065                 int float_signal = _FPE_INVALID;
00066 
00067                 sighandlers[SIGFPE] = SIG_DFL;
00068                 for (i = 0; i < sizeof(float_exception_map) /
00069                          sizeof(float_exception_map[0]); i++)
00070                 {
00071                     if (float_exception_map[i].status ==
00072                         except->ExceptionRecord->ExceptionCode)
00073                     {
00074                         float_signal = float_exception_map[i].signal;
00075                         break;
00076                     }
00077                 }
00078                 ((float_handler)handler)(SIGFPE, float_signal);
00079             }
00080             ret = EXCEPTION_CONTINUE_EXECUTION;
00081         }
00082         break;
00083     case EXCEPTION_ILLEGAL_INSTRUCTION:
00084     case EXCEPTION_PRIV_INSTRUCTION:
00085         if ((handler = sighandlers[SIGILL]) != SIG_DFL)
00086         {
00087             if (handler != SIG_IGN)
00088             {
00089                 sighandlers[SIGILL] = SIG_DFL;
00090                 handler(SIGILL);
00091             }
00092             ret = EXCEPTION_CONTINUE_EXECUTION;
00093         }
00094         break;
00095     }
00096     return ret;
00097 }
00098 

Generated on Sat May 26 2012 04:35:26 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.