From 78e143b13c668c07c3b0cd4103606967dddef710 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 14 Sep 2009 03:09:03 -0500 Subject: [PATCH] vm: fix indentation in Joe's changes --- vm/cpu-ppc.hpp | 10 +++---- vm/cpu-x86.hpp | 12 ++++----- vm/float_bits.hpp | 8 +++--- vm/layouts.hpp | 10 +++---- vm/os-freebsd-x86.32.hpp | 37 +++++++++++++++----------- vm/os-freebsd-x86.64.hpp | 21 ++++++++------- vm/os-macosx-ppc.hpp | 10 +++---- vm/os-macosx-x86.32.hpp | 10 +++---- vm/os-macosx-x86.64.hpp | 16 +++++------ vm/os-netbsd.hpp | 2 -- vm/os-windows-nt.cpp | 57 ++++++++++++++++++++-------------------- 11 files changed, 100 insertions(+), 93 deletions(-) diff --git a/vm/cpu-ppc.hpp b/vm/cpu-ppc.hpp index db02a72959..2124e03350 100644 --- a/vm/cpu-ppc.hpp +++ b/vm/cpu-ppc.hpp @@ -67,15 +67,15 @@ inline static unsigned int fpu_status(unsigned int status) 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; } diff --git a/vm/cpu-x86.hpp b/vm/cpu-x86.hpp index 7054f90735..4a37a17889 100644 --- a/vm/cpu-x86.hpp +++ b/vm/cpu-x86.hpp @@ -53,17 +53,17 @@ inline static bool tail_call_site_p(cell return_address) 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; } diff --git a/vm/float_bits.hpp b/vm/float_bits.hpp index 000bd49482..73a04639ee 100644 --- a/vm/float_bits.hpp +++ b/vm/float_bits.hpp @@ -5,8 +5,8 @@ namespace factor representations and vice versa */ union double_bits_pun { - double x; - u64 y; + double x; + u64 y; }; inline static u64 double_bits(double x) @@ -24,8 +24,8 @@ inline static double bits_double(u64 y) } union float_bits_pun { - float x; - u32 y; + float x; + u32 y; }; inline static u32 float_bits(float x) diff --git a/vm/layouts.hpp b/vm/layouts.hpp index a14c234aaa..dceb9a208a 100644 --- a/vm/layouts.hpp +++ b/vm/layouts.hpp @@ -70,11 +70,11 @@ inline static cell align8(cell a) /* 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) diff --git a/vm/os-freebsd-x86.32.hpp b/vm/os-freebsd-x86.32.hpp index 800b343dfd..a0888e1f5b 100644 --- a/vm/os-freebsd-x86.32.hpp +++ b/vm/os-freebsd-x86.32.hpp @@ -13,26 +13,33 @@ inline static void *ucontext_stack_pointer(void *uap) 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; } } diff --git a/vm/os-freebsd-x86.64.hpp b/vm/os-freebsd-x86.64.hpp index b2dd096137..6200a0f5f3 100644 --- a/vm/os-freebsd-x86.64.hpp +++ b/vm/os-freebsd-x86.64.hpp @@ -13,20 +13,23 @@ inline static void *ucontext_stack_pointer(void *uap) 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; } } diff --git a/vm/os-macosx-ppc.hpp b/vm/os-macosx-ppc.hpp index 31a1e22882..338e3e812f 100644 --- a/vm/os-macosx-ppc.hpp +++ b/vm/os-macosx-ppc.hpp @@ -54,27 +54,27 @@ Modified for Factor by Slava Pestov */ 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)); } } diff --git a/vm/os-macosx-x86.32.hpp b/vm/os-macosx-x86.32.hpp index 01ad28df4f..89906cd9a4 100644 --- a/vm/os-macosx-x86.32.hpp +++ b/vm/os-macosx-x86.32.hpp @@ -54,14 +54,14 @@ Modified for Factor by Slava Pestov */ 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) @@ -77,7 +77,7 @@ inline static void mach_clear_fpu_status(i386_float_state_t *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)); } } diff --git a/vm/os-macosx-x86.64.hpp b/vm/os-macosx-x86.64.hpp index f56ada23fd..fd6db4d68c 100644 --- a/vm/os-macosx-x86.64.hpp +++ b/vm/os-macosx-x86.64.hpp @@ -52,30 +52,30 @@ Modified for Factor by Slava Pestov and Daniel Ehrenberg */ 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)); } } diff --git a/vm/os-netbsd.hpp b/vm/os-netbsd.hpp index 635361e3e4..d45b2ac163 100644 --- a/vm/os-netbsd.hpp +++ b/vm/os-netbsd.hpp @@ -5,6 +5,4 @@ namespace factor #define UAP_PROGRAM_COUNTER(uap) _UC_MACHINE_PC((ucontext_t *)uap) -#define DIRECTORY_P(file) ((file)->d_type == DT_DIR) - } diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index c2b4e2af9e..017a96bb7c 100644 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -21,40 +21,39 @@ FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe) 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)