Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Feb 2012 21:21:32 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r231983 - stable/9/lib/libthr/thread
Message-ID:  <201202212121.q1LLLW6l020376@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202212121.q1LLLW6l020376>