ntdll: Rename i386 CPU trap codes to avoid collision with system headers.

This commit is contained in:
Robert Millan 2006-02-03 12:30:55 +01:00 committed by Alexandre Julliard
parent 16cc1858d0
commit 62af0706ff
2 changed files with 87 additions and 94 deletions

View File

@ -411,35 +411,6 @@ typedef ucontext_t SIGCONTEXT;
#endif /* svr4 || SCO_DS */
/* exception code definitions (already defined by FreeBSD/NetBSD) */
#if !defined(__FreeBSD__) && !defined(__NetBSD__) /* FIXME: other BSDs? */
#define T_DIVIDE 0 /* Division by zero exception */
#define T_TRCTRAP 1 /* Single-step exception */
#define T_NMI 2 /* NMI interrupt */
#define T_BPTFLT 3 /* Breakpoint exception */
#define T_OFLOW 4 /* Overflow exception */
#define T_BOUND 5 /* Bound range exception */
#define T_PRIVINFLT 6 /* Invalid opcode exception */
#define T_DNA 7 /* Device not available exception */
#define T_DOUBLEFLT 8 /* Double fault exception */
#define T_FPOPFLT 9 /* Coprocessor segment overrun */
#define T_TSSFLT 10 /* Invalid TSS exception */
#define T_SEGNPFLT 11 /* Segment not present exception */
#define T_STKFLT 12 /* Stack fault */
#define T_PROTFLT 13 /* General protection fault */
#define T_PAGEFLT 14 /* Page fault */
#define T_RESERVED 15 /* Unknown exception */
#define T_ARITHTRAP 16 /* Floating point exception */
#define T_ALIGNFLT 17 /* Alignment check exception */
#define T_MCHK 18 /* Machine check exception */
#define T_CACHEFLT 19 /* Cache flush exception */
#endif
#if defined(__NetBSD__)
#define T_MCHK 19 /* Machine check exception */
#endif
#define T_UNKNOWN (-1) /* Unknown fault (TRAP_sig not defined) */
#include "wine/exception.h"
#include "wine/debug.h"
@ -454,6 +425,30 @@ static wine_signal_handler handlers[256];
extern void DECLSPEC_NORETURN __wine_call_from_32_restore_regs( const CONTEXT *context );
enum i386_trap_code
{
TRAP_x86_UNKNOWN = -1, /* Unknown fault (TRAP_sig not defined) */
TRAP_x86_DIVIDE = 0, /* Division by zero exception */
TRAP_x86_TRCTRAP = 1, /* Single-step exception */
TRAP_x86_NMI = 2, /* NMI interrupt */
TRAP_x86_BPTFLT = 3, /* Breakpoint exception */
TRAP_x86_OFLOW = 4, /* Overflow exception */
TRAP_x86_BOUND = 5, /* Bound range exception */
TRAP_x86_PRIVINFLT = 6, /* Invalid opcode exception */
TRAP_x86_DNA = 7, /* Device not available exception */
TRAP_x86_DOUBLEFLT = 8, /* Double fault exception */
TRAP_x86_FPOPFLT = 9, /* Coprocessor segment overrun */
TRAP_x86_TSSFLT = 10, /* Invalid TSS exception */
TRAP_x86_SEGNPFLT = 11, /* Segment not present exception */
TRAP_x86_STKFLT = 12, /* Stack fault */
TRAP_x86_PROTFLT = 13, /* General protection fault */
TRAP_x86_PAGEFLT = 14, /* Page fault */
TRAP_x86_ARITHTRAP = 16, /* Floating point exception */
TRAP_x86_ALIGNFLT = 17, /* Alignment check exception */
TRAP_x86_MCHK = 18, /* Machine check exception */
TRAP_x86_CACHEFLT = 19 /* Cache flush exception */
};
/***********************************************************************
* dispatch_signal
@ -470,12 +465,12 @@ inline static int dispatch_signal(unsigned int sig)
*
* Get the trap code for a signal.
*/
static inline int get_trap_code( const SIGCONTEXT *sigcontext )
static inline enum i386_trap_code get_trap_code( const SIGCONTEXT *sigcontext )
{
#ifdef TRAP_sig
return TRAP_sig(sigcontext);
#else
return T_UNKNOWN; /* unknown trap code */
return TRAP_x86_UNKNOWN; /* unknown trap code */
#endif
}
@ -1149,21 +1144,21 @@ static HANDLER_DEF(segv_handler)
switch(get_trap_code(HANDLER_CONTEXT))
{
case T_OFLOW: /* Overflow exception */
case TRAP_x86_OFLOW: /* Overflow exception */
rec->ExceptionCode = EXCEPTION_INT_OVERFLOW;
break;
case T_BOUND: /* Bound range exception */
case TRAP_x86_BOUND: /* Bound range exception */
rec->ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
break;
case T_PRIVINFLT: /* Invalid opcode exception */
case TRAP_x86_PRIVINFLT: /* Invalid opcode exception */
rec->ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
break;
case T_STKFLT: /* Stack fault */
case TRAP_x86_STKFLT: /* Stack fault */
rec->ExceptionCode = EXCEPTION_STACK_OVERFLOW;
break;
case T_SEGNPFLT: /* Segment not present exception */
case T_PROTFLT: /* General protection fault */
case T_UNKNOWN: /* Unknown fault code */
case TRAP_x86_SEGNPFLT: /* Segment not present exception */
case TRAP_x86_PROTFLT: /* General protection fault */
case TRAP_x86_UNKNOWN: /* Unknown fault code */
if (!get_error_code(HANDLER_CONTEXT) && is_privileged_instr( get_exception_context(rec) ))
rec->ExceptionCode = EXCEPTION_PRIV_INSTRUCTION;
else
@ -1176,7 +1171,7 @@ static HANDLER_DEF(segv_handler)
rec->ExceptionInformation[1] = (err & 7) == 4 ? (err & ~7) : 0xffffffff;
}
break;
case T_PAGEFLT: /* Page fault */
case TRAP_x86_PAGEFLT: /* Page fault */
rec->ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
#ifdef FAULT_ADDRESS
rec->NumberParameters = 2;
@ -1184,21 +1179,18 @@ static HANDLER_DEF(segv_handler)
rec->ExceptionInformation[1] = (ULONG_PTR)FAULT_ADDRESS;
#endif
break;
case T_ALIGNFLT: /* Alignment check exception */
case TRAP_x86_ALIGNFLT: /* Alignment check exception */
rec->ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
break;
default:
ERR( "Got unexpected trap %d\n", get_trap_code(HANDLER_CONTEXT) );
/* fall through */
case T_NMI: /* NMI interrupt */
case T_DNA: /* Device not available exception */
case T_DOUBLEFLT: /* Double fault exception */
case T_TSSFLT: /* Invalid TSS exception */
case T_RESERVED: /* Unknown exception */
case T_MCHK: /* Machine check exception */
#ifdef T_CACHEFLT
case T_CACHEFLT: /* Cache flush exception */
#endif
case TRAP_x86_NMI: /* NMI interrupt */
case TRAP_x86_DNA: /* Device not available exception */
case TRAP_x86_DOUBLEFLT: /* Double fault exception */
case TRAP_x86_TSSFLT: /* Invalid TSS exception */
case TRAP_x86_MCHK: /* Machine check exception */
case TRAP_x86_CACHEFLT: /* Cache flush exception */
rec->ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
break;
}
@ -1216,10 +1208,10 @@ static HANDLER_DEF(trap_handler)
switch(get_trap_code(HANDLER_CONTEXT))
{
case T_TRCTRAP: /* Single-step exception */
case TRAP_x86_TRCTRAP: /* Single-step exception */
rec->ExceptionCode = EXCEPTION_SINGLE_STEP;
break;
case T_BPTFLT: /* Breakpoint exception */
case TRAP_x86_BPTFLT: /* Breakpoint exception */
rec->ExceptionAddress = (char *)rec->ExceptionAddress - 1; /* back up over the int3 instruction */
/* fall through */
default:
@ -1244,14 +1236,14 @@ static HANDLER_DEF(fpe_handler)
switch(get_trap_code(HANDLER_CONTEXT))
{
case T_DIVIDE: /* Division by zero exception */
case TRAP_x86_DIVIDE: /* Division by zero exception */
rec->ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
break;
case T_FPOPFLT: /* Coprocessor segment overrun */
case TRAP_x86_FPOPFLT: /* Coprocessor segment overrun */
rec->ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
break;
case T_ARITHTRAP: /* Floating point exception */
case T_UNKNOWN: /* Unknown fault code */
case TRAP_x86_ARITHTRAP: /* Floating point exception */
case TRAP_x86_UNKNOWN: /* Unknown fault code */
rec->ExceptionCode = get_fpu_code( context );
break;
default:
@ -1491,10 +1483,10 @@ void __wine_enter_vm86( CONTEXT *context )
case VM86_TRAP: /* return due to DOS-debugger request */
switch(VM86_ARG(res))
{
case T_TRCTRAP: /* Single-step exception, single step flag is cleared by raise_trap_exception */
case TRAP_x86_TRCTRAP: /* Single-step exception, single step flag is cleared by raise_trap_exception */
rec.ExceptionCode = EXCEPTION_SINGLE_STEP;
break;
case T_BPTFLT: /* Breakpoint exception */
case TRAP_x86_BPTFLT: /* Breakpoint exception */
rec.ExceptionAddress = (char *)rec.ExceptionAddress - 1; /* back up over the int3 instruction */
/* fall through */
default:

View File

@ -93,27 +93,29 @@ typedef struct ucontext SIGCONTEXT;
#endif /* linux */
#define T_UNKNOWN (-1) /* Unknown fault (TRAP_sig not defined) */
#define T_DIVIDE 0 /* Division by zero exception */
#define T_TRCTRAP 1 /* Single-step exception */
#define T_NMI 2 /* NMI interrupt */
#define T_BPTFLT 3 /* Breakpoint exception */
#define T_OFLOW 4 /* Overflow exception */
#define T_BOUND 5 /* Bound range exception */
#define T_PRIVINFLT 6 /* Invalid opcode exception */
#define T_DNA 7 /* Device not available exception */
#define T_DOUBLEFLT 8 /* Double fault exception */
#define T_FPOPFLT 9 /* Coprocessor segment overrun */
#define T_TSSFLT 10 /* Invalid TSS exception */
#define T_SEGNPFLT 11 /* Segment not present exception */
#define T_STKFLT 12 /* Stack fault */
#define T_PROTFLT 13 /* General protection fault */
#define T_PAGEFLT 14 /* Page fault */
#define T_RESERVED 15 /* Unknown exception */
#define T_ARITHTRAP 16 /* Floating point exception */
#define T_ALIGNFLT 17 /* Alignment check exception */
#define T_MCHK 18 /* Machine check exception */
#define T_CACHEFLT 19 /* Cache flush exception */
enum i386_trap_code
{
TRAP_x86_UNKNOWN = -1, /* Unknown fault (TRAP_sig not defined) */
TRAP_x86_DIVIDE = 0, /* Division by zero exception */
TRAP_x86_TRCTRAP = 1, /* Single-step exception */
TRAP_x86_NMI = 2, /* NMI interrupt */
TRAP_x86_BPTFLT = 3, /* Breakpoint exception */
TRAP_x86_OFLOW = 4, /* Overflow exception */
TRAP_x86_BOUND = 5, /* Bound range exception */
TRAP_x86_PRIVINFLT = 6, /* Invalid opcode exception */
TRAP_x86_DNA = 7, /* Device not available exception */
TRAP_x86_DOUBLEFLT = 8, /* Double fault exception */
TRAP_x86_FPOPFLT = 9, /* Coprocessor segment overrun */
TRAP_x86_TSSFLT = 10, /* Invalid TSS exception */
TRAP_x86_SEGNPFLT = 11, /* Segment not present exception */
TRAP_x86_STKFLT = 12, /* Stack fault */
TRAP_x86_PROTFLT = 13, /* General protection fault */
TRAP_x86_PAGEFLT = 14, /* Page fault */
TRAP_x86_ARITHTRAP = 16, /* Floating point exception */
TRAP_x86_ALIGNFLT = 17, /* Alignment check exception */
TRAP_x86_MCHK = 18, /* Machine check exception */
TRAP_x86_CACHEFLT = 19 /* Cache flush exception */
};
typedef int (*wine_signal_handler)(unsigned int sig);
@ -226,25 +228,25 @@ static HANDLER_DEF(segv_handler)
switch(TRAP_sig(HANDLER_CONTEXT))
{
case T_OFLOW: /* Overflow exception */
case TRAP_x86_OFLOW: /* Overflow exception */
rec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
break;
case T_BOUND: /* Bound range exception */
case TRAP_x86_BOUND: /* Bound range exception */
rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
break;
case T_PRIVINFLT: /* Invalid opcode exception */
case TRAP_x86_PRIVINFLT: /* Invalid opcode exception */
rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
break;
case T_STKFLT: /* Stack fault */
case TRAP_x86_STKFLT: /* Stack fault */
rec.ExceptionCode = EXCEPTION_STACK_OVERFLOW;
break;
case T_SEGNPFLT: /* Segment not present exception */
case T_PROTFLT: /* General protection fault */
case T_UNKNOWN: /* Unknown fault code */
case TRAP_x86_SEGNPFLT: /* Segment not present exception */
case TRAP_x86_PROTFLT: /* General protection fault */
case TRAP_x86_UNKNOWN: /* Unknown fault code */
rec.ExceptionCode = ERROR_sig(HANDLER_CONTEXT) ? EXCEPTION_ACCESS_VIOLATION
: EXCEPTION_PRIV_INSTRUCTION;
break;
case T_PAGEFLT: /* Page fault */
case TRAP_x86_PAGEFLT: /* Page fault */
rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
#ifdef FAULT_ADDRESS
rec.NumberParameters = 2;
@ -252,19 +254,18 @@ static HANDLER_DEF(segv_handler)
rec.ExceptionInformation[1] = (ULONG_PTR)FAULT_ADDRESS;
#endif
break;
case T_ALIGNFLT: /* Alignment check exception */
case TRAP_x86_ALIGNFLT: /* Alignment check exception */
rec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
break;
default:
ERR( "Got unexpected trap %ld\n", TRAP_sig(HANDLER_CONTEXT) );
/* fall through */
case T_NMI: /* NMI interrupt */
case T_DNA: /* Device not available exception */
case T_DOUBLEFLT: /* Double fault exception */
case T_TSSFLT: /* Invalid TSS exception */
case T_RESERVED: /* Unknown exception */
case T_MCHK: /* Machine check exception */
case T_CACHEFLT: /* Cache flush exception */
case TRAP_x86_NMI: /* NMI interrupt */
case TRAP_x86_DNA: /* Device not available exception */
case TRAP_x86_DOUBLEFLT: /* Double fault exception */
case TRAP_x86_TSSFLT: /* Invalid TSS exception */
case TRAP_x86_MCHK: /* Machine check exception */
case TRAP_x86_CACHEFLT: /* Cache flush exception */
rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
break;
}