unsigned int r = 0;
if (status & 0x20000000)
- r |= FP_TRAP_INVALID_OPERATION;
+ r |= FP_TRAP_INVALID_OPERATION;
if (status & 0x10000000)
- r |= FP_TRAP_OVERFLOW;
+ r |= FP_TRAP_OVERFLOW;
if (status & 0x08000000)
- r |= FP_TRAP_UNDERFLOW;
+ r |= FP_TRAP_UNDERFLOW;
if (status & 0x04000000)
- r |= FP_TRAP_ZERO_DIVIDE;
+ r |= FP_TRAP_ZERO_DIVIDE;
if (status & 0x02000000)
- r |= FP_TRAP_INEXACT;
+ r |= FP_TRAP_INEXACT;
return r;
}
inline static unsigned int fpu_status(unsigned int status)
{
unsigned int r = 0;
-
+
if (status & 0x01)
- r |= FP_TRAP_INVALID_OPERATION;
+ r |= FP_TRAP_INVALID_OPERATION;
if (status & 0x04)
- r |= FP_TRAP_ZERO_DIVIDE;
+ r |= FP_TRAP_ZERO_DIVIDE;
if (status & 0x08)
- r |= FP_TRAP_OVERFLOW;
+ r |= FP_TRAP_OVERFLOW;
if (status & 0x10)
- r |= FP_TRAP_UNDERFLOW;
+ r |= FP_TRAP_UNDERFLOW;
if (status & 0x20)
- r |= FP_TRAP_INEXACT;
+ r |= FP_TRAP_INEXACT;
return r;
}
representations and vice versa */
union double_bits_pun {
- double x;
- u64 y;
+ double x;
+ u64 y;
};
inline static u64 double_bits(double x)
}
union float_bits_pun {
- float x;
- u32 y;
+ float x;
+ u32 y;
};
inline static u32 float_bits(float x)
/* Constants used when floating-point trap exceptions are thrown */
enum
{
- FP_TRAP_INVALID_OPERATION = 1 << 0,
- FP_TRAP_OVERFLOW = 1 << 1,
- FP_TRAP_UNDERFLOW = 1 << 2,
- FP_TRAP_ZERO_DIVIDE = 1 << 3,
- FP_TRAP_INEXACT = 1 << 4,
+ FP_TRAP_INVALID_OPERATION = 1 << 0,
+ FP_TRAP_OVERFLOW = 1 << 1,
+ FP_TRAP_UNDERFLOW = 1 << 2,
+ FP_TRAP_ZERO_DIVIDE = 1 << 3,
+ FP_TRAP_INEXACT = 1 << 4,
};
inline static bool immediate_p(cell obj)
inline static unsigned int uap_fpu_status(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
- if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387) {
- struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
- return x87->sv_env.en_sw;
- } else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
- struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
- return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
- } else
- return 0;
+ if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387)
+ {
+ struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
+ return x87->sv_env.en_sw;
+ }
+ else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
+ {
+ struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
+ return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
+ }
+ else
+ return 0;
}
inline static void uap_clear_fpu_status(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
- if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_387) {
- struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
- x87->sv_env.en_sw = 0;
- } else if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
- struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
- xmm->sv_env.en_sw = 0;
- xmm->sv_env.en_mxcsr &= 0xffffffc0;
+ if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_387)
+ {
+ struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
+ x87->sv_env.en_sw = 0;
+ }
+ else if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
+ {
+ struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
+ xmm->sv_env.en_sw = 0;
+ xmm->sv_env.en_mxcsr &= 0xffffffc0;
}
}
inline static unsigned int uap_fpu_status(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
- if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
- struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
- return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
- } else
- return 0;
+ if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
+ {
+ struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
+ return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
+ }
+ else
+ return 0;
}
inline static void uap_clear_fpu_status(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
- if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
- struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
- xmm->sv_env.en_sw = 0;
- xmm->sv_env.en_mxcsr &= 0xffffffc0;
+ if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
+ {
+ struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
+ xmm->sv_env.en_sw = 0;
+ xmm->sv_env.en_mxcsr &= 0xffffffc0;
}
}
inline static unsigned int mach_fpu_status(ppc_float_state_t *float_state)
{
- return FPSCR(float_state);
+ return FPSCR(float_state);
}
inline static unsigned int uap_fpu_status(void *uap)
{
- return mach_fpu_status(UAP_FS(uap));
+ return mach_fpu_status(UAP_FS(uap));
}
inline static cell fix_stack_pointer(cell sp)
{
- return sp;
+ return sp;
}
inline static void mach_clear_fpu_status(ppc_float_state_t *float_state)
{
- FPSCR(float_state) &= 0x0007ffff;
+ FPSCR(float_state) &= 0x0007ffff;
}
inline static void uap_clear_fpu_status(void *uap)
{
- mach_clear_fpu_status(UAP_FS(uap));
+ mach_clear_fpu_status(UAP_FS(uap));
}
}
inline static unsigned int mach_fpu_status(i386_float_state_t *float_state)
{
- unsigned short x87sw;
- memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
- return MXCSR(float_state) | x87sw;
+ unsigned short x87sw;
+ memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
+ return MXCSR(float_state) | x87sw;
}
inline static unsigned int uap_fpu_status(void *uap)
{
- return mach_fpu_status(UAP_FS(uap));
+ return mach_fpu_status(UAP_FS(uap));
}
inline static cell fix_stack_pointer(cell sp)
inline static void uap_clear_fpu_status(void *uap)
{
- mach_clear_fpu_status(UAP_FS(uap));
+ mach_clear_fpu_status(UAP_FS(uap));
}
}
inline static unsigned int mach_fpu_status(x86_float_state64_t *float_state)
{
- unsigned short x87sw;
- memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
- return MXCSR(float_state) | x87sw;
+ unsigned short x87sw;
+ memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
+ return MXCSR(float_state) | x87sw;
}
inline static unsigned int uap_fpu_status(void *uap)
{
- return mach_fpu_status(UAP_FS(uap));
+ return mach_fpu_status(UAP_FS(uap));
}
inline static cell fix_stack_pointer(cell sp)
{
- return ((sp + 8) & ~15) - 8;
+ return ((sp + 8) & ~15) - 8;
}
inline static void mach_clear_fpu_status(x86_float_state64_t *float_state)
{
- MXCSR(float_state) &= 0xffffffc0;
- memset(&X87SW(float_state), 0, sizeof(X87SW(float_state)));
+ MXCSR(float_state) &= 0xffffffc0;
+ memset(&X87SW(float_state), 0, sizeof(X87SW(float_state)));
}
inline static void uap_clear_fpu_status(void *uap)
{
- mach_clear_fpu_status(UAP_FS(uap));
+ mach_clear_fpu_status(UAP_FS(uap));
}
}
#define UAP_PROGRAM_COUNTER(uap) _UC_MACHINE_PC((ucontext_t *)uap)
-#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
-
}
else
signal_callstack_top = NULL;
- switch (e->ExceptionCode) {
- case EXCEPTION_ACCESS_VIOLATION:
+ switch (e->ExceptionCode)
+ {
+ case EXCEPTION_ACCESS_VIOLATION:
signal_fault_addr = e->ExceptionInformation[1];
c->EIP = (cell)memory_signal_handler_impl;
- break;
+ break;
- case EXCEPTION_FLT_DENORMAL_OPERAND:
- case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- case EXCEPTION_FLT_INEXACT_RESULT:
- case EXCEPTION_FLT_INVALID_OPERATION:
- case EXCEPTION_FLT_OVERFLOW:
- case EXCEPTION_FLT_STACK_CHECK:
- case EXCEPTION_FLT_UNDERFLOW:
- /* XXX MxCsr is not available in CONTEXT structure on x86.32 */
- signal_fpu_status = c->FloatSave.StatusWord;
- c->FloatSave.StatusWord = 0;
- c->EIP = (cell)fp_signal_handler_impl;
- break;
-
- /* If the Widcomm bluetooth stack is installed, the BTTray.exe process
- injects code into running programs. For some reason this results in
- random SEH exceptions with this (undocumented) exception code being
- raised. The workaround seems to be ignoring this altogether, since that
- is what happens if SEH is not enabled. Don't really have any idea what
- this exception means. */
- case 0x40010006:
- break;
-
- default:
+ case EXCEPTION_FLT_DENORMAL_OPERAND:
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ case EXCEPTION_FLT_INEXACT_RESULT:
+ case EXCEPTION_FLT_INVALID_OPERATION:
+ case EXCEPTION_FLT_OVERFLOW:
+ case EXCEPTION_FLT_STACK_CHECK:
+ case EXCEPTION_FLT_UNDERFLOW:
+ /* XXX MxCsr is not available in CONTEXT structure on x86.32 */
+ signal_fpu_status = c->FloatSave.StatusWord;
+ c->FloatSave.StatusWord = 0;
+ c->EIP = (cell)fp_signal_handler_impl;
+ break;
+ case 0x40010006:
+ /* If the Widcomm bluetooth stack is installed, the BTTray.exe
+ process injects code into running programs. For some reason this
+ results in random SEH exceptions with this (undocumented)
+ exception code being raised. The workaround seems to be ignoring
+ this altogether, since that is what happens if SEH is not
+ enabled. Don't really have any idea what this exception means. */
+ break;
+ default:
signal_number = e->ExceptionCode;
c->EIP = (cell)misc_signal_handler_impl;
- break;
- }
- return EXCEPTION_CONTINUE_EXECUTION;
+ break;
+ }
+ return EXCEPTION_CONTINUE_EXECUTION;
}
void c_to_factor_toplevel(cell quot)