Changeset 11864


Ignore:
Timestamp:
Mar 31, 2009, 12:14:43 AM (10 years ago)
Author:
gb
Message:

x86-exceptions.h: define xpMXCSRptr macro for Win32 (the MXCSR is buried
in there somewhere.)

lisp-debug.c: use xpMXCSRptr to find the MXCSR register on Win32.

x86-exceptions.c: Win32 uses exception codes STATUS_FLOAT_MULTIPLE_FAULTS
and STATUS_FLOAT_MULTIPLE_TRAPS for SSE2-related FP exceptions. Map these
to SIGFPE, look at the MXCSR to determine the FP exception flavor.

Location:
trunk/source/lisp-kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/lisp-debug.c

    r11624 r11864  
    875875#endif
    876876#ifdef WINDOWS
    877           0 /* XXX: get from somewhere */
     877          *(xpMXCSRptr(xp))
    878878#endif
    879879          );
  • trunk/source/lisp-kernel/x86-exceptions.c

    r11803 r11864  
    18211821}
    18221822
     1823static
     1824DWORD mxcsr_bit_to_fpe_code[] = {
     1825  EXCEPTION_FLT_INVALID_OPERATION, /* ie */
     1826  0,                            /* de */
     1827  EXCEPTION_FLT_DIVIDE_BY_ZERO, /* ze */
     1828  EXCEPTION_FLT_OVERFLOW,       /* oe */
     1829  EXCEPTION_FLT_UNDERFLOW,      /* ue */
     1830  EXCEPTION_FLT_INEXACT_RESULT  /* pe */
     1831};
     1832
     1833#ifndef STATUS_FLOAT_MULTIPLE_FAULTS
     1834#define STATUS_FLOAT_MULTIPLE_FAULTS 0xc00002b4
     1835#endif
     1836
     1837#ifndef STATUS_FLOAT_MULTIPLE_TRAPS
     1838#define  STATUS_FLOAT_MULTIPLE_TRAPS 0xc00002b5
     1839#endif
     1840
    18231841int
    1824 map_windows_exception_code_to_posix_signal(DWORD code)
     1842map_windows_exception_code_to_posix_signal(DWORD code, siginfo_t *info, ExceptionInformation *context)
    18251843{
    18261844  switch (code) {
     1845#ifdef WIN_32
     1846  case STATUS_FLOAT_MULTIPLE_FAULTS:
     1847  case STATUS_FLOAT_MULTIPLE_TRAPS:
     1848    {
     1849      int xbit, maskbit;
     1850      DWORD mxcsr = *(xpMXCSRptr(context));
     1851
     1852      for (xbit = 0, maskbit = MXCSR_IM_BIT; xbit < 6; xbit++, maskbit++) {
     1853        if ((mxcsr & (1 << xbit)) &&
     1854            !(mxcsr & (1 << maskbit))) {
     1855          info->ExceptionCode = mxcsr_bit_to_fpe_code[xbit];
     1856          break;
     1857        }
     1858      }
     1859    }
     1860    return SIGFPE;
     1861#endif
     1862     
    18271863  case EXCEPTION_ACCESS_VIOLATION:
    18281864    return SIGSEGV;
     
    18601896  wait_for_exception_lock_in_handler(tcr, context, &xframes);
    18611897
    1862   signal_number = map_windows_exception_code_to_posix_signal(code);
     1898  signal_number = map_windows_exception_code_to_posix_signal(code, info, context);
    18631899 
    18641900  if (!handle_exception(signal_number, info, context, tcr, old_valence)) {
  • trunk/source/lisp-kernel/x86-exceptions.h

    r11565 r11864  
    101101#define xpFPRvector(x) ((natural *)(&(x->ExtendedRegisters[10*16])))
    102102#define xpMMXreg(x,n)  (*((u64_t *)(&(x->FloatSave.RegisterArea[10*(n)]))))
     103#define xpMXCSRptr(x) (DWORD *)(&(x->ExtendedRegisters[24]))
    103104#endif
    104105#endif
Note: See TracChangeset for help on using the changeset viewer.