Loading...
sys/sigtramp.c Libc-391.4.2 Libc-320
--- Libc/Libc-391.4.2/sys/sigtramp.c
+++ Libc/Libc-320/sys/sigtramp.c
@@ -2,6 +2,8 @@
  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
  *
  * @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
@@ -24,10 +26,9 @@
  * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved
  */
 #import	"sigcatch.h"
-#import	<sys/types.h>
 #import	<signal.h>
+#import	<sys/signal.h>
 #import	<ucontext.h>
-#import	<mach/thread_status.h>
 
 /*
  * sigvec registers _sigtramp as the handler for any signal requiring
@@ -42,10 +43,10 @@
 
 /* These defn should match the kernel one */
 #define UC_TRAD			1
-#define UC_FLAVOR		30
-#if defined(__ppc__) || defined(__ppc64__)
+#ifdef __ppc__
 #define UC_TRAD64		20
 #define UC_TRAD64_VEC		25
+#define UC_FLAVOR		30
 #define UC_FLAVOR_VEC		35
 #define UC_FLAVOR64		40
 #define UC_FLAVOR64_VEC		45
@@ -62,10 +63,10 @@
 #define UC_FLAVOR64_VEC_SIZE ((PPC_THREAD_STATE64_COUNT + PPC_EXCEPTION_STATE64_COUNT + PPC_FLOAT_STATE_COUNT + PPC_VECTOR_STATE_COUNT) * sizeof(int))
 #endif
 
-#if defined(__ppc__) || defined(__ppc64__)
+#ifdef __ppc__
 /* This routine will be replaced by an assembly soon */
 static  int
-restore64_state(mcontext_t mctx, mcontext64_t mctx64, int sigstyle)
+restore64_state(mcontext_t mctx, mcontext64_t mctx64)
 {
 	if (mctx->ss.srr0 != (unsigned int)mctx64->ss.srr0)
 		return(0);	
@@ -145,11 +146,6 @@
 	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);
 
 }
@@ -162,24 +158,21 @@
 	int 			sigstyle,
 	int 			sig,
 	siginfo_t		*sinfo,
-	ucontext_t		*uctx
+	struct ucontext		*uctx
 ) {
+#ifdef __ppc__
 	int ctxstyle = UC_FLAVOR;
-#if defined(__ppc__) || defined(__ppc64__)
+#endif
 	mcontext_t mctx;
 	mcontext64_t mctx64;
-#endif
 
 #if defined(__DYNAMIC__)
         __in_sigtramp++;
 #endif
-#ifdef __i386__
+#ifndef __ppc__
 	if (sigstyle == UC_TRAD)
         	sa_handler(sig);
-	else {
-		sa_sigaction(sig, sinfo, uctx);
-	}
-#elif defined(__ppc__) || defined(__ppc64__)
+#else /* __ppc__ */
 	if ((sigstyle == UC_TRAD) || (sigstyle == UC_TRAD64) || (sigstyle == UC_TRAD64_VEC))
         	sa_handler(sig);
 
@@ -190,7 +183,7 @@
 		mctx = uctx->uc_mcontext;
 		mctx64 = (mcontext64_t)((char *)(uctx->uc_mcontext) + sizeof(struct mcontext));
 		/* restore 64bit state ? */
-		if (restore64_state(mctx, mctx64, sigstyle)) {
+		if (restore64_state(mctx, mctx64)) {
 			uctx->uc_mcontext = (void *)mctx64;
 			if (sigstyle == UC_DUAL)  {
 				uctx->uc_mcsize = UC_FLAVOR64_SIZE;
@@ -207,13 +200,19 @@
 		}
 	} else
 		ctxstyle = sigstyle;
-#endif /* __ppc__ || __ppc64__ */
+#endif /* __ppc__ */
 
 #if defined(__DYNAMIC__)
         __in_sigtramp--;
 #endif
+#ifdef __ppc__
+	{
         /* sigreturn(uctx, ctxstyle); */
 	/* syscall (SYS_SIGRETURN, uctx, ctxstyle); */
 	syscall (184, uctx, ctxstyle);
+	}
+#else
+	sigreturn(uctx);
+#endif /* __ppc__ */
 }