Changeset 13638


Ignore:
Timestamp:
Apr 18, 2010, 10:58:15 AM (9 years ago)
Author:
gb
Message:

Move more PPC exception stuff, x86 exception stuff to platform heeaders.
Introduce OS headers; so far, just signal constants. Include the applicable
os-*.h in platform-*.h.
Ensure that Makefiles have constants.h, os*.h in CHEADERS.
Will try to smoke-test & fix typos before sleeping.

Location:
trunk/source/lisp-kernel
Files:
5 added
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/Threads.h

    r13431 r13638  
    235235
    236236
    237 #if defined(SIGRTMIN) && !defined(SOLARIS)
    238 #define SIG_SUSPEND_THREAD (SIGRTMIN+6)
    239 #else
    240 #define SIG_SUSPEND_THREAD SIGUSR2
    241 #endif
    242 
    243 
    244 #ifdef DARWIN
    245 #define SIG_KILL_THREAD SIGEMT
    246 #endif
    247 
    248 #if defined(LINUX) && defined(SIGRTMIN)
    249 #define SIG_KILL_THREAD (SIGRTMIN+7)
    250 #endif
    251 
    252 #ifdef SOLARIS
    253 #define SIG_KILL_THREAD SIGRTMIN
    254 #endif
    255 
    256 #ifdef FREEBSD
    257 #define SIG_KILL_THREAD (SIGTHR+5)
    258 #endif
    259 
    260237
    261238extern int thread_suspend_signal, thread_kill_signal;
  • trunk/source/lisp-kernel/darwinppc/Makefile

    r13607 r13638  
    5151CHEADERS = area.h bits.h ppc-constants.h lisp-errors.h gc.h lisp.h \
    5252        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    53         Threads.h lisptypes.h ppc-constants32.h ppc-exceptions.h $(PLATFORM_H)
     53        Threads.h lisptypes.h ppc-constants32.h ppc-exceptions.h \
     54        $(PLATFORM_H) constants.h os-darwin.h
    5455
    5556# Subprims linked into the kernel ?
  • trunk/source/lisp-kernel/darwinppc64/Makefile

    r13607 r13638  
    5959CHEADERS = area.h bits.h ppc-constants.h lisp-errors.h gc.h lisp.h \
    6060        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    61         Threads.h lisptypes.h ppc-constants64.h ppc-exceptions.h $(PLATFORM_H)
     61        Threads.h lisptypes.h ppc-constants64.h ppc-exceptions.h \
     62        $(PLATFORM_H) constants.h os-darwin.h
    6263
    6364# Subprims linked into the kernel ?
  • trunk/source/lisp-kernel/darwinx8632/Makefile

    r13628 r13638  
    5353CHEADERS = area.h bits.h x86-constants.h lisp-errors.h gc.h lisp.h \
    5454        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    55         Threads.h lisptypes.h x86-constants32.h x86-exceptions.h $(PLATFORM_H) \
    56         constants.h
     55        Threads.h lisptypes.h x86-constants32.h x86-exceptions.h \
     56        $(PLATFORM_H) constants.h os-darwin.h
    5757
    5858# Subprims linked into the kernel ?
  • trunk/source/lisp-kernel/darwinx8664/Makefile

    r13628 r13638  
    7676CHEADERS = area.h bits.h x86-constants.h lisp-errors.h gc.h lisp.h \
    7777        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    78         Threads.h lisptypes.h x86-constants64.h x86-exceptions.h $(PLATFORM_H) \
    79         constants.h
     78        Threads.h lisptypes.h x86-constants64.h x86-exceptions.h \
     79        $(PLATFORM_H) constants.h os-darwin.h
    8080
    8181# Subprims linked into the kernel ?
  • trunk/source/lisp-kernel/linuxppc/Makefile

    r13602 r13638  
    7272CHEADERS = area.h bits.h ppc-constants.h lisp-errors.h gc.h lisp.h \
    7373        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    74         Threads.h ppc-constants32.h ppc-exceptions.h $(PLATFORM_H)
     74        Threads.h ppc-constants32.h ppc-exceptions.h $(PLATFORM_H) \
     75        constants.h os-linux.h
    7576
    7677# Subprims linked into the kernel ?
  • trunk/source/lisp-kernel/linuxppc64/Makefile

    r13602 r13638  
    6060CHEADERS = area.h bits.h ppc-constants.h lisp-errors.h gc.h lisp.h \
    6161        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    62         Threads.h ppc-constants64.h ppc-exceptions.h $(PLATFORM_H)
     62        Threads.h ppc-constants64.h ppc-exceptions.h $(PLATFORM_H) \
     63        constants.h os-linux.h
    6364
    6465# Subprims linked into the kernel ?
  • trunk/source/lisp-kernel/linuxx8632/Makefile

    r13625 r13638  
    5959CHEADERS = area.h bits.h x86-constants.h lisp-errors.h gc.h lisp.h \
    6060        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    61         Threads.h x86-constants32.h x86-exceptions.h lisptypes.h $(PLATFORM_H)
     61        Threads.h x86-constants32.h x86-exceptions.h lisptypes.h \
     62        $(PLATFORM_H) constants.h os-linux.h
    6263
    6364
  • trunk/source/lisp-kernel/linuxx8664/Makefile

    r13625 r13638  
    5959CHEADERS = area.h bits.h x86-constants.h lisp-errors.h gc.h lisp.h \
    6060        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    61         Threads.h x86-constants64.h x86-exceptions.h lisptypes.h $(PLATFORM_H)
     61        Threads.h x86-constants64.h x86-exceptions.h lisptypes.h \
     62        $(PLATFORM_H) constants.h os-linux.h
    6263
    6364
  • trunk/source/lisp-kernel/platform-darwinppc.h

    r13637 r13638  
    6868#define SIGRETURN(context)
    6969
     70#include "os-darwin.h"
  • trunk/source/lisp-kernel/platform-darwinppc64.h

    r13637 r13638  
    6868*/
    6969#define SIGRETURN(context)
     70
     71#include "os-darwin.h"
  • trunk/source/lisp-kernel/platform-darwinx8632.h

    r13627 r13638  
    3636#include "lisptypes.h"
    3737#include "x86-constants32.h"
     38
     39
     40/* xp accessors, sigreturn stuff */
     41#define DARWIN_USE_PSEUDO_SIGRETURN 1
     42#define DarwinSigReturn(context) do {\
     43    darwin_sigreturn(context);\
     44    Bug(context,"sigreturn returned");\
     45  } while (0)
     46
     47#define xpGPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__ss)))
     48#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     49#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     50#define xpPC(x) (xpGPR(x,Iip))
     51#define eflags_register(xp) xpGPR(xp,Iflags)
     52#define xpFPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__fs.__fpu_xmm0)))
     53#define xpMMXvector(x) (&(UC_MCONTEXT(x)->__fs.__fpu_stmm0))
     54/* Note that this yields only the lower half of the MMX reg on x8632 */
     55#define xpMMXreg(x,n) *(natural *)&(xpMMXvector(x)[n])
     56
     57#define SIGNUM_FOR_INTN_TRAP SIGSEGV /* Not really, but our Mach handler fakes that */
     58#define IS_MAYBE_INT_TRAP(info,xp) ((UC_MCONTEXT(xp)->__es.__trapno == 0xd) && (((UC_MCONTEXT(xp)->__es.__err)&7)==2))
     59#define IS_PAGE_FAULT(info,xp) (UC_MCONTEXT(xp)->__es.__trapno == 0xe)
     60/* The x86 version of sigreturn just needs the context argument; the
     61   hidden, magic "flavor" argument that sigtramp uses is ignored. */
     62#define SIGRETURN(context) DarwinSigReturn(context)
     63
     64#include <mach/mach.h>
     65#include <mach/mach_error.h>
     66#include <mach/machine/thread_state.h>
     67#include <mach/machine/thread_status.h>
     68
     69pthread_mutex_t *mach_exception_lock;
     70
     71#include "os-darwin.h"
  • trunk/source/lisp-kernel/platform-darwinx8664.h

    r13627 r13638  
    3737#include "lisptypes.h"
    3838#include "x86-constants64.h"
     39
     40/* xp accessors, sigreturn stuff */
     41#define DARWIN_USE_PSEUDO_SIGRETURN 1
     42#define DarwinSigReturn(context) do {\
     43    darwin_sigreturn(context);\
     44    Bug(context,"sigreturn returned");\
     45  } while (0)
     46
     47#define xpGPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__ss)))
     48#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     49#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     50#define xpPC(x) (xpGPR(x,Iip))
     51#define eflags_register(xp) xpGPR(xp,Iflags)
     52#define xpFPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__fs.__fpu_xmm0)))
     53#define xpMMXvector(x) (&(UC_MCONTEXT(x)->__fs.__fpu_stmm0))
     54/* Note that this yields only the lower half of the MMX reg on x8632 */
     55#define xpMMXreg(x,n) *(natural *)&(xpMMXvector(x)[n])
     56#define SIGNUM_FOR_INTN_TRAP SIGSEGV /* Not really, but our Mach handler fakes that */
     57#define IS_MAYBE_INT_TRAP(info,xp) ((UC_MCONTEXT(xp)->__es.__trapno == 0xd) && (((UC_MCONTEXT(xp)->__es.__err)&7)==2))
     58#define IS_PAGE_FAULT(info,xp) (UC_MCONTEXT(xp)->__es.__trapno == 0xe)
     59/* The x86 version of sigreturn just needs the context argument; the
     60   hidden, magic "flavor" argument that sigtramp uses is ignored. */
     61#define SIGRETURN(context) DarwinSigReturn(context)
     62
     63#include <mach/mach.h>
     64#include <mach/mach_error.h>
     65#include <mach/machine/thread_state.h>
     66#include <mach/machine/thread_status.h>
     67
     68pthread_mutex_t *mach_exception_lock;
     69
     70#include "os-darwin.h"
  • trunk/source/lisp-kernel/platform-freebsdx8632.h

    r13627 r13638  
    3131#include "lisptypes.h"
    3232#include "x86-constants32.h"
     33
     34#include <machine/fpu.h>
     35#define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext)))
     36#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     37#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     38#define eflags_register(xp) xpGPR(xp,Iflags)
     39#define xpPC(x) xpGPR(x,Iip)
     40#define xpMMXreg(x,n) *((natural *)(&(((struct ccl_savexmm *)(&(x)->uc_mcontext.mc_fpstate))->sv_fp[n])))
     41#define xpXMMregs(x)(&(((struct ccl_savexmm *)(&(x)->uc_mcontext.mc_fpstate))->sv_xmm[0]))
     42extern void freebsd_sigreturn(ExceptionInformation *);
     43#define SIGNUM_FOR_INTN_TRAP SIGBUS
     44#define IS_MAYBE_INT_TRAP(info,xp) ((xp->uc_mcontext.mc_trapno == T_PROTFLT) && ((xp->uc_mcontext.mc_err & 7) == 2))
     45#define IS_PAGE_FAULT(info,xp) (xp->uc_mcontext.mc_trapno == T_PAGEFLT)
     46#define SIGRETURN(context) freebsd_sigreturn(context)
     47
     48#include "os-freebsd.h"
  • trunk/source/lisp-kernel/platform-freebsdx8664.h

    r13627 r13638  
    3030#include "lisptypes.h"
    3131#include "x86-constants64.h"
     32
     33#include <machine/fpu.h>
     34#define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext)))
     35#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     36#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     37#define eflags_register(xp) xpGPR(xp,Iflags)
     38#define xpPC(x) xpGPR(x,Iip)
     39#define xpMMXreg(x,n) *((natural *)(&(((struct savefpu *)(&(x)->uc_mcontext.mc_fpstate))->sv_fp[n])))
     40#define xpXMMregs(x)(&(((struct savefpu *)(&(x)->uc_mcontext.mc_fpstate))->sv_xmm[0]))
     41extern void freebsd_sigreturn(ExceptionInformation *);
     42#define SIGNUM_FOR_INTN_TRAP SIGBUS
     43#define IS_MAYBE_INT_TRAP(info,xp) ((xp->uc_mcontext.mc_trapno == T_PROTFLT) && ((xp->uc_mcontext.mc_err & 7) == 2))
     44#define IS_PAGE_FAULT(info,xp) (xp->uc_mcontext.mc_trapno == T_PAGEFLT)
     45#define SIGRETURN(context) freebsd_sigreturn(context)
     46
     47#include "os-freebsd.h"
  • trunk/source/lisp-kernel/platform-linuxppc.h

    r13637 r13638  
    5959#define DarwinSigReturn(context)
    6060#define SIGRETURN(context)
     61
     62#include "os-linux.h"
  • trunk/source/lisp-kernel/platform-linuxppc64.h

    r13637 r13638  
    5858#define DarwinSigReturn(context)
    5959#define SIGRETURN(context)
     60
     61#include "os-linux.h"
  • trunk/source/lisp-kernel/platform-linuxx8632.h

    r13627 r13638  
    3131#include "lisptypes.h"
    3232#include "x86-constants32.h"
     33
     34/* xp accessors */
     35#define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext.gregs)))
     36#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     37#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     38#define xpPC(x) (xpGPR(x,Iip))
     39#define xpMMXreg(x,n)  *((natural *)(&((x)->uc_mcontext.fpregs->_st[n])))
     40#define eflags_register(xp) xpGPR(xp,Iflags)
     41#define SIGNUM_FOR_INTN_TRAP SIGSEGV
     42#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
     43#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
     44#define SIGRETURN(context)
     45
     46#include "os-linux.h"
  • trunk/source/lisp-kernel/platform-linuxx8664.h

    r13627 r13638  
    3030#include "lisptypes.h"
    3131#include "x86-constants64.h"
     32
     33/* xp accessors */
     34#define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext.gregs)))
     35#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     36#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     37#define xpPC(x) (xpGPR(x,Iip))
     38#define xpMMXreg(x,n)  *((natural *)(&((x)->uc_mcontext.fpregs->_st[n])))
     39#define eflags_register(xp) xpGPR(xp,Iflags)
     40#define SIGNUM_FOR_INTN_TRAP SIGSEGV
     41#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
     42#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
     43#define SIGRETURN(context)
     44
     45#include "os-linux.h"
  • trunk/source/lisp-kernel/platform-solarisx64.h

    r13627 r13638  
    3030#include "lisptypes.h"
    3131#include "x86-constants64.h"
     32
     33#define xpGPRvector(x) ((x)->uc_mcontext.gregs)
     34#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     35#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     36#define xpPC(x) xpGPR(x,Iip)
     37#define eflags_register(xp) xpGPR(xp,Iflags)
     38#define xpXMMregs(x)(&((x)->uc_mcontext.fpregs.fp_reg_set.fpchip_state.xmm[0]))
     39#define SIGNUM_FOR_INTN_TRAP SIGSEGV
     40#ifdef X8664
     41#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
     42#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
     43#else
     44#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,TRAPNO)==0xd)&&((xpGPR(xp,ERR)&7)==2))
     45#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,TRAPNO)==0xe)
     46#endif
     47#define SIGRETURN(context) setcontext(context)
     48
     49#include "os-solaris.h"
  • trunk/source/lisp-kernel/platform-solarisx86.h

    r13627 r13638  
    3030#include "lisptypes.h"
    3131#include "x86-constants32.h"
     32
     33#define xpGPRvector(x) ((x)->uc_mcontext.gregs)
     34#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     35#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
     36#define xpPC(x) xpGPR(x,Iip)
     37#define eflags_register(xp) xpGPR(xp,Iflags)
     38#define xpXMMregs(x)(&((x)->uc_mcontext.fpregs.fp_reg_set.fpchip_state.xmm[0]))
     39#define xpMMXreg(x,n)*(natural *)(&(((struct fnsave_state *)(&(((x)->uc_mcontext.fpregs))))->f_st[n]))
     40#define SIGNUM_FOR_INTN_TRAP SIGSEGV
     41#ifdef X8664
     42#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
     43#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
     44#else
     45#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,TRAPNO)==0xd)&&((xpGPR(xp,ERR)&7)==2))
     46#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,TRAPNO)==0xe)
     47#endif
     48#define SIGRETURN(context) setcontext(context)
     49
     50#include "os-solaris.h"
  • trunk/source/lisp-kernel/platform-win32.h

    r13627 r13638  
    3232#include "lisptypes.h"
    3333#include "x86-constants32.h"
     34
     35#define xpGPRvector(x) ((DWORD *)(&(x)->Edi))
     36#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     37#define xpPC(x) xpGPR(x,Iip)
     38#define eflags_register(xp) xp->EFlags
     39#define xpFPRvector(x) ((natural *)(&(x->ExtendedRegisters[10*16])))
     40#define xpMMXreg(x,n)  (*((u64_t *)(&(x->FloatSave.RegisterArea[10*(n)]))))
     41#define xpMXCSRptr(x) (DWORD *)(&(x->ExtendedRegisters[24]))
     42
     43#ifdef SOLARIS
     44#define SIGNUM_FOR_INTN_TRAP SIGSEGV
     45#ifdef X8664
     46#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
     47#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
     48#else
     49#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,TRAPNO)==0xd)&&((xpGPR(xp,ERR)&7)==2))
     50#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,TRAPNO)==0xe)
     51#endif
     52#define SIGRETURN(context) setcontext(context)
     53#endif
     54
     55#include "os-windows.h"
  • trunk/source/lisp-kernel/platform-win64.h

    r13627 r13638  
    3333#include "lisptypes.h"
    3434#include "x86-constants64.h"
     35
     36#define xpGPRvector(x) ((DWORD64 *)(&(x)->Rax))
     37#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
     38#define xpPC(x) xpGPR(x,Iip)
     39#define eflags_register(xp) xp->EFlags
     40#define xpMXCSRptr(x) (DWORD *)(&(x->MxCsr))
     41
     42#ifdef SOLARIS
     43#define SIGNUM_FOR_INTN_TRAP SIGSEGV
     44#ifdef X8664
     45#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
     46#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
     47#else
     48#define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,TRAPNO)==0xd)&&((xpGPR(xp,ERR)&7)==2))
     49#define IS_PAGE_FAULT(info,xp) (xpGPR(xp,TRAPNO)==0xe)
     50#endif
     51#define SIGRETURN(context) setcontext(context)
     52#endif
     53
     54#include "os-windows.h"
  • trunk/source/lisp-kernel/solarisx64/Makefile

    r13605 r13638  
    6060CHEADERS = area.h bits.h x86-constants.h lisp-errors.h gc.h lisp.h \
    6161        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    62         Threads.h x86-constants64.h x86-exceptions.h lisptypes.h $(PLATFORM_H)
     62        Threads.h x86-constants64.h x86-exceptions.h lisptypes.h \
     63        $(PLATFORM_H) constants.h os-solaris.h
    6364
    6465
  • trunk/source/lisp-kernel/solarisx86/Makefile

    r13605 r13638  
    5959CHEADERS = area.h bits.h x86-constants.h lisp-errors.h gc.h lisp.h \
    6060        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    61         Threads.h x86-constants32.h x86-exceptions.h lisptypes.h $(PLATFORM_H)
     61        Threads.h x86-constants32.h x86-exceptions.h lisptypes.h \
     62        $(PLATFORM_H) constants.h os-solaris.h
    6263
    6364
  • trunk/source/lisp-kernel/win32/Makefile

    r13609 r13638  
    7575        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    7676        Threads.h x86-constants32.h x86-exceptions.h lisptypes.h \
    77         $(PLATFORM_H)
     77        $(PLATFORM_H) constsnts.h os-windows.h
    7878
    7979
  • trunk/source/lisp-kernel/win64/Makefile

    r13612 r13638  
    7474        lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
    7575        Threads.h x86-constants64.h x86-exceptions.h lisptypes.h \
    76         $(PLATFORM_H)
     76        $(PLATFORM_H) constants.h os-windows.h
    7777
    7878
  • trunk/source/lisp-kernel/x86-exceptions.h

    r13206 r13638  
    1919
    2020typedef u8_t opcode, *pc;
    21 
    22 #ifdef LINUX
    23 #define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext.gregs)))
    24 #define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
    25 #define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
    26 #define xpPC(x) (xpGPR(x,Iip))
    27 #define xpMMXreg(x,n)  *((natural *)(&((x)->uc_mcontext.fpregs->_st[n])))
    28 #define eflags_register(xp) xpGPR(xp,Iflags)
    29 #endif
    30 
    31 #ifdef DARWIN
    32 #define DARWIN_USE_PSEUDO_SIGRETURN 1
    33 #include <sys/syscall.h>
    34 #define DarwinSigReturn(context) do {\
    35     darwin_sigreturn(context);\
    36     Bug(context,"sigreturn returned");\
    37   } while (0)
    38 
    39 #define xpGPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__ss)))
    40 #define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
    41 #define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
    42 #define xpPC(x) (xpGPR(x,Iip))
    43 #define eflags_register(xp) xpGPR(xp,Iflags)
    44 #define xpFPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__fs.__fpu_xmm0)))
    45 #define xpMMXvector(x) (&(UC_MCONTEXT(x)->__fs.__fpu_stmm0))
    46 /* Note that this yields only the lower half of the MMX reg on x8632 */
    47 #define xpMMXreg(x,n) *(natural *)&(xpMMXvector(x)[n])
    48 
    49 #include <mach/mach.h>
    50 #include <mach/mach_error.h>
    51 #include <mach/machine/thread_state.h>
    52 #include <mach/machine/thread_status.h>
    53 
    54 pthread_mutex_t *mach_exception_lock;
    55 
    56 #endif
    57 
    58 #ifdef FREEBSD
    59 #ifdef X8664
    60 #include <machine/fpu.h>
    61 #else
    62 #include "freebsdx8632/fpu.h"
    63 #endif
    64 #define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext)))
    65 #define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
    66 #define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
    67 #define eflags_register(xp) xpGPR(xp,Iflags)
    68 #define xpPC(x) xpGPR(x,Iip)
    69 #ifdef X8664
    70 #define xpMMXreg(x,n) *((natural *)(&(((struct savefpu *)(&(x)->uc_mcontext.mc_fpstate))->sv_fp[n])))
    71 #define xpXMMregs(x)(&(((struct savefpu *)(&(x)->uc_mcontext.mc_fpstate))->sv_xmm[0]))
    72 #else
    73 #define xpMMXreg(x,n) *((natural *)(&(((struct ccl_savexmm *)(&(x)->uc_mcontext.mc_fpstate))->sv_fp[n])))
    74 #define xpXMMregs(x)(&(((struct ccl_savexmm *)(&(x)->uc_mcontext.mc_fpstate))->sv_xmm[0]))
    75 #endif
    76 #endif
    77 
    78 #ifdef SOLARIS
    79 #define xpGPRvector(x) ((x)->uc_mcontext.gregs)
    80 #define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
    81 #define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
    82 #define xpPC(x) xpGPR(x,Iip)
    83 #define eflags_register(xp) xpGPR(xp,Iflags)
    84 #define xpXMMregs(x)(&((x)->uc_mcontext.fpregs.fp_reg_set.fpchip_state.xmm[0]))
    85 #ifdef X8632
    86 #define xpMMXreg(x,n)*(natural *)(&(((struct fnsave_state *)(&(((x)->uc_mcontext.fpregs))))->f_st[n]))
    87 #endif
    88 #endif
    89 
    90 #ifdef WINDOWS
    91 #ifdef X8664
    92 #define xpGPRvector(x) ((DWORD64 *)(&(x)->Rax))
    93 #define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
    94 #define xpPC(x) xpGPR(x,Iip)
    95 #define eflags_register(xp) xp->EFlags
    96 #define xpMXCSRptr(x) (DWORD *)(&(x->MxCsr))
    97 #else
    98 #define xpGPRvector(x) ((DWORD *)(&(x)->Edi))
    99 #define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
    100 #define xpPC(x) xpGPR(x,Iip)
    101 #define eflags_register(xp) xp->EFlags
    102 #define xpFPRvector(x) ((natural *)(&(x->ExtendedRegisters[10*16])))
    103 #define xpMMXreg(x,n)  (*((u64_t *)(&(x->FloatSave.RegisterArea[10*(n)]))))
    104 #define xpMXCSRptr(x) (DWORD *)(&(x->ExtendedRegisters[24]))
    105 #endif
    106 #endif
    107 
    108 #ifdef DARWIN
    109 #define SIGNAL_FOR_PROCESS_INTERRUPT SIGUSR1
    110 #endif
    111 #ifdef LINUX
    112 #define SIGNAL_FOR_PROCESS_INTERRUPT SIGPWR
    113 #endif
    114 #ifdef FREEBSD
    115 #define SIGNAL_FOR_PROCESS_INTERRUPT SIGEMT
    116 #endif
    117 #ifdef SOLARIS
    118 #define SIGNAL_FOR_PROCESS_INTERRUPT SIGUSR1
    119 #endif
    120 #ifdef WINDOWS
    121 #define SIGNAL_FOR_PROCESS_INTERRUPT SIGINT
    122 #ifndef SIGBUS
    123 #define SIGBUS 10
    124 #endif
    125 #ifndef CONTEXT_ALL
    126 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
    127 #endif
    128 #endif
    129 
    130 
    13121
    13222void switch_to_foreign_stack(void*, ...);
     
    17060} alloc_instruction_id;
    17161
    172 #ifdef LINUX
    173 #define SIGNUM_FOR_INTN_TRAP SIGSEGV
    174 #define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
    175 #define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
    176 #define SIGRETURN(context)
    177 #endif
    17862
    179 #ifdef FREEBSD
    180 extern void freebsd_sigreturn(ExceptionInformation *);
    181 #define SIGNUM_FOR_INTN_TRAP SIGBUS
    182 #define IS_MAYBE_INT_TRAP(info,xp) ((xp->uc_mcontext.mc_trapno == T_PROTFLT) && ((xp->uc_mcontext.mc_err & 7) == 2))
    183 #define IS_PAGE_FAULT(info,xp) (xp->uc_mcontext.mc_trapno == T_PAGEFLT)
    184 #define SIGRETURN(context) freebsd_sigreturn(context)
    185 #endif
    18663
    187 #ifdef DARWIN
    188 #define SIGNUM_FOR_INTN_TRAP SIGSEGV /* Not really, but our Mach handler fakes that */
    189 #define IS_MAYBE_INT_TRAP(info,xp) ((UC_MCONTEXT(xp)->__es.__trapno == 0xd) && (((UC_MCONTEXT(xp)->__es.__err)&7)==2))
    190 #define IS_PAGE_FAULT(info,xp) (UC_MCONTEXT(xp)->__es.__trapno == 0xe)
    191 /* The x86 version of sigreturn just needs the context argument; the
    192    hidden, magic "flavor" argument that sigtramp uses is ignored. */
    193 #define SIGRETURN(context) DarwinSigReturn(context)
    194 #endif
    19564
    196 #ifdef SOLARIS
    197 #define SIGNUM_FOR_INTN_TRAP SIGSEGV
    198 #ifdef X8664
    199 #define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,REG_TRAPNO)==0xd)&&((xpGPR(xp,REG_ERR)&7)==2))
    200 #define IS_PAGE_FAULT(info,xp) (xpGPR(xp,REG_TRAPNO)==0xe)
    201 #else
    202 #define IS_MAYBE_INT_TRAP(info,xp) ((xpGPR(xp,TRAPNO)==0xd)&&((xpGPR(xp,ERR)&7)==2))
    203 #define IS_PAGE_FAULT(info,xp) (xpGPR(xp,TRAPNO)==0xe)
    204 #endif
    205 #define SIGRETURN(context) setcontext(context)
    206 #endif
    207 
    208 #ifdef WINDOWS
    209 #define SIGNUM_FOR_INTN_TRAP SIGSEGV /* Also fake */
    210 #define IS_MAYBE_INT_TRAP(info,xp) \
    211   ((info->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) &&       \
    212    (info->ExceptionInformation[0]==0) &&                       \
    213    (info->ExceptionInformation[1]==(ULONG_PTR)(-1L)))
    214 #define IS_PAGE_FAULT(info,xp) (1)
    215 #define SIGRETURN(context)      /* for now */
    216 #endif
    21765
    21866/* Please go away. */
     
    25098extern void set_mxcsr(natural);
    25199
    252 #ifdef WINDOWS
    253 typedef struct {
    254   HANDLE h;
    255   OVERLAPPED *o;
    256 } pending_io;
    257 #endif
    258 
    259100#ifdef X8632
    260101/* The 32-bit immediate value in the instruction
Note: See TracChangeset for help on using the changeset viewer.