Skip to content

Commit

Permalink
Bring back the DarwinSigReturn hack for pre-Mojave systems
Browse files Browse the repository at this point in the history
  • Loading branch information
xrme committed Nov 23, 2018
1 parent 8fa7fdf commit d12381c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
13 changes: 12 additions & 1 deletion lisp-kernel/platform-darwinx8632.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ typedef ucontext_t ExceptionInformation;
/* xp accessors, sigreturn stuff */
#define DARWIN_USE_PSEUDO_SIGRETURN 1

extern void darwin_sigreturn(ExceptionInformation *, unsigned);
extern natural os_major_version;

#define DarwinSigReturn(context) do { \
if (os_major_version < 18) { /* Mojave */ \
darwin_sigreturn(context, 0x1e); \
Bug(context,"sigreturn returned"); \
} \
} while (0)


#define xpGPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__ss)))
#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
Expand All @@ -62,7 +73,7 @@ typedef ucontext_t ExceptionInformation;
#define SIGNUM_FOR_INTN_TRAP SIGSEGV /* Not really, but our Mach handler fakes that */
#define IS_MAYBE_INT_TRAP(info,xp) ((UC_MCONTEXT(xp)->__es.__trapno == 0xd) && (((UC_MCONTEXT(xp)->__es.__err)&7)==2))
#define IS_PAGE_FAULT(info,xp) (UC_MCONTEXT(xp)->__es.__trapno == 0xe)
#define SIGRETURN(context)
#define SIGRETURN(context) DarwinSigReturn(context)

#include <mach/mach.h>
#include <mach/mach_error.h>
Expand Down
14 changes: 11 additions & 3 deletions lisp-kernel/platform-darwinx8664.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,19 @@ typedef ucontext_t ExceptionInformation;
#define REG_RIP 16
#define REG_RFL 17

extern void darwin_sigreturn(ExceptionInformation *,unsigned);

/* xp accessors, sigreturn stuff */
#define DARWIN_USE_PSEUDO_SIGRETURN 1

extern void darwin_sigreturn(ExceptionInformation *, unsigned);
extern natural os_major_version;

#define DarwinSigReturn(context) do { \
if (os_major_version < 18) { /* Mojave */ \
darwin_sigreturn(context, 0x1e); \
Bug(context,"sigreturn returned"); \
} \
} while (0)

#define xpGPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__ss)))
#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
Expand All @@ -71,7 +79,7 @@ extern void darwin_sigreturn(ExceptionInformation *,unsigned);
#define SIGNUM_FOR_INTN_TRAP SIGSEGV /* Not really, but our Mach handler fakes that */
#define IS_MAYBE_INT_TRAP(info,xp) ((UC_MCONTEXT(xp)->__es.__trapno == 0xd) && (((UC_MCONTEXT(xp)->__es.__err)&7)==2))
#define IS_PAGE_FAULT(info,xp) (UC_MCONTEXT(xp)->__es.__trapno == 0xe)
#define SIGRETURN(context)
#define SIGRETURN(context) DarwinSigReturn(context)

#include <mach/mach.h>
#include <mach/mach_error.h>
Expand Down
2 changes: 1 addition & 1 deletion lisp-kernel/pmcl-kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ terminate_lisp()
#endif

#ifdef DARWIN
#define min_os_version "8.0" /* aka Tiger */
#define min_os_version "13.0" /* Mavericks */
#endif
#ifdef LINUX
#ifdef PPC
Expand Down
8 changes: 8 additions & 0 deletions lisp-kernel/x86-asmutils32.s
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ _exportfn(C(freebsd_sigreturn))
_endfn
__endif

__ifdef(`DARWIN')
_exportfn(C(darwin_sigreturn))
__(movl $0xb8,%eax) /* SYS_sigreturn */
__(int $0x80)
__(ret) /* shouldn't return */
_endfn
__endif

_exportfn(C(get_vector_registers))
__(ret)
_endfn
Expand Down
11 changes: 10 additions & 1 deletion lisp-kernel/x86-asmutils64.s
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,16 @@ _endfn

_exportfn(C(put_vector_registers))
_endfn


__ifdef(`DARWIN')
_exportfn(C(darwin_sigreturn))
.globl C(sigreturn)
__(movl $0x20000b8,%eax)
__(syscall)
__(ret)
_endfn
__endif

__ifdef(`WIN_64')
/* %rcx = CONTEXT, %rdx = tcr, %r8 = old_valence. This pretty
much has to be uninterruptible */
Expand Down

0 comments on commit d12381c

Please sign in to comment.