X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/734aad71947a79037af64f74c683f5eb36fe6065..3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff:/sys/sigtramp.c diff --git a/sys/sigtramp.c b/sys/sigtramp.c index 373d1ff..b387329 100644 --- a/sys/sigtramp.c +++ b/sys/sigtramp.c @@ -3,8 +3,6 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -26,9 +24,10 @@ * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ #import "sigcatch.h" +#import #import -#import #import +#import /* * sigvec registers _sigtramp as the handler for any signal requiring @@ -43,7 +42,7 @@ int __in_sigtramp = 0; /* These defn should match the kernel one */ #define UC_TRAD 1 -#ifdef __ppc__ +#if defined(__ppc__) || defined(__ppc64__) #define UC_TRAD64 20 #define UC_TRAD64_VEC 25 #define UC_FLAVOR 30 @@ -63,10 +62,10 @@ int __in_sigtramp = 0; #define UC_FLAVOR64_VEC_SIZE ((PPC_THREAD_STATE64_COUNT + PPC_EXCEPTION_STATE64_COUNT + PPC_FLOAT_STATE_COUNT + PPC_VECTOR_STATE_COUNT) * sizeof(int)) #endif -#ifdef __ppc__ +#if defined(__ppc__) || defined(__ppc64__) /* This routine will be replaced by an assembly soon */ static int -restore64_state(mcontext_t mctx, mcontext64_t mctx64) +restore64_state(mcontext_t mctx, mcontext64_t mctx64, int sigstyle) { if (mctx->ss.srr0 != (unsigned int)mctx64->ss.srr0) return(0); @@ -146,6 +145,11 @@ restore64_state(mcontext_t mctx, mcontext64_t mctx64) if (mctx->ss.ctr != (unsigned int)mctx64->ss.ctr) return(0); + if (bcmp(&mctx->fs, &mctx64->ss, (PPC_FLOAT_STATE_COUNT * sizeof(int)))) + return(0); + if ((sigstyle == UC_DUAL_VEC) && bcmp(&mctx->vs, &mctx64->vs, (PPC_VECTOR_STATE_COUNT * sizeof(int)))) + return(0); + return(1); } @@ -158,9 +162,9 @@ _sigtramp( int sigstyle, int sig, siginfo_t *sinfo, - struct ucontext *uctx + ucontext_t *uctx ) { -#ifdef __ppc__ +#if defined(__ppc__) || defined(__ppc64__) int ctxstyle = UC_FLAVOR; #endif mcontext_t mctx; @@ -169,10 +173,10 @@ _sigtramp( #if defined(__DYNAMIC__) __in_sigtramp++; #endif -#ifndef __ppc__ +#ifdef __i386__ if (sigstyle == UC_TRAD) sa_handler(sig); -#else /* __ppc__ */ +#elif defined(__ppc__) || defined(__ppc64__) if ((sigstyle == UC_TRAD) || (sigstyle == UC_TRAD64) || (sigstyle == UC_TRAD64_VEC)) sa_handler(sig); @@ -183,7 +187,7 @@ _sigtramp( mctx = uctx->uc_mcontext; mctx64 = (mcontext64_t)((char *)(uctx->uc_mcontext) + sizeof(struct mcontext)); /* restore 64bit state ? */ - if (restore64_state(mctx, mctx64)) { + if (restore64_state(mctx, mctx64, sigstyle)) { uctx->uc_mcontext = (void *)mctx64; if (sigstyle == UC_DUAL) { uctx->uc_mcsize = UC_FLAVOR64_SIZE; @@ -200,12 +204,12 @@ _sigtramp( } } else ctxstyle = sigstyle; -#endif /* __ppc__ */ +#endif /* __ppc__ || __ppc64__ */ #if defined(__DYNAMIC__) __in_sigtramp--; #endif -#ifdef __ppc__ +#if defined(__ppc__) || defined(__ppc64__) { /* sigreturn(uctx, ctxstyle); */ /* syscall (SYS_SIGRETURN, uctx, ctxstyle); */ @@ -213,6 +217,6 @@ _sigtramp( } #else sigreturn(uctx); -#endif /* __ppc__ */ +#endif /* __ppc__ || __ppc64__ */ }