svn commit: r231983 - stable/9/lib/libthr/thread

Konstantin Belousov kib at FreeBSD.org
Tue Feb 21 21:21:32 UTC 2012


Author: kib
Date: Tue Feb 21 21:21:31 2012
New Revision: 231983
URL: http://svn.freebsd.org/changeset/base/231983

Log:
  MFC r230430:
  Use getcontextx(3) internal API instead of getcontext(2) to provide
  the signal handlers with the context information in the deferrred
  case.

Modified:
  stable/9/lib/libthr/thread/thr_sig.c
Directory Properties:
  stable/9/lib/libthr/   (props changed)

Modified: stable/9/lib/libthr/thread/thr_sig.c
==============================================================================
--- stable/9/lib/libthr/thread/thr_sig.c	Tue Feb 21 21:20:52 2012	(r231982)
+++ stable/9/lib/libthr/thread/thr_sig.c	Tue Feb 21 21:21:31 2012	(r231983)
@@ -32,6 +32,7 @@
 #include <sys/signalvar.h>
 #include <signal.h>
 #include <errno.h>
+#include <stdlib.h>
 #include <string.h>
 #include <pthread.h>
 #include "un-namespace.h"
@@ -314,16 +315,24 @@ check_cancel(struct pthread *curthread, 
 static void
 check_deferred_signal(struct pthread *curthread)
 {
-	ucontext_t uc;
+	ucontext_t *uc;
 	struct sigaction act;
 	siginfo_t info;
 
 	if (__predict_true(curthread->deferred_siginfo.si_signo == 0))
 		return;
-	getcontext(&uc);
+
+#if defined(__amd64__) || defined(__i386__)
+	uc = alloca(__getcontextx_size());
+	__fillcontextx((char *)uc);
+#else
+	ucontext_t ucv;
+	uc = &ucv;
+	getcontext(uc);
+#endif
 	if (curthread->deferred_siginfo.si_signo != 0) {
 		act = curthread->deferred_sigact;
-		uc.uc_sigmask = curthread->deferred_sigmask;
+		uc->uc_sigmask = curthread->deferred_sigmask;
 		memcpy(&info, &curthread->deferred_siginfo, sizeof(siginfo_t));
 		/* remove signal */
 		curthread->deferred_siginfo.si_signo = 0;
@@ -334,7 +343,7 @@ check_deferred_signal(struct pthread *cu
 			tact.sa_handler = SIG_DFL;
 			_sigaction(info.si_signo, &tact, NULL);
 		}
-		handle_signal(&act, info.si_signo, &info, &uc);
+		handle_signal(&act, info.si_signo, &info, uc);
 	}
 }
 


More information about the svn-src-stable-9 mailing list