summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2011-07-07 09:25:16 +0000
committerguenther <guenther@openbsd.org>2011-07-07 09:25:16 +0000
commit4fa1fab639e37e79ffab5b1b65db3b7c8af65cf6 (patch)
tree7608e9ee4be919a414a6371c739d42dd4bda8f1c
parentsync (diff)
downloadwireguard-openbsd-4fa1fab639e37e79ffab5b1b65db3b7c8af65cf6.tar.xz
wireguard-openbsd-4fa1fab639e37e79ffab5b1b65db3b7c8af65cf6.zip
When context switching, if the 'new' thread is the same as the 'old'
thread, then the save and restore of errno, FPU, and regs is unnecessary and can be skipped. "looks reasonable" marc@
-rw-r--r--lib/libpthread/uthread/uthread_kern.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libpthread/uthread/uthread_kern.c b/lib/libpthread/uthread/uthread_kern.c
index fabb2088cd8..dab360b40fe 100644
--- a/lib/libpthread/uthread/uthread_kern.c
+++ b/lib/libpthread/uthread/uthread_kern.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_kern.c,v 1.37 2011/01/25 22:55:14 stsp Exp $ */
+/* $OpenBSD: uthread_kern.c,v 1.38 2011/07/07 09:25:16 guenther Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -467,6 +467,13 @@ _thread_kern_sched(struct sigcontext * scp)
curthread->slice_usec = 0;
}
+ /*
+ * If we're 'switching' to the current thread,
+ * then don't bother with the save/restore
+ */
+ if (curthread == old_thread_run)
+ goto after_switch;
+
/* Restore errno. */
errno = curthread->error;
@@ -487,6 +494,8 @@ _thread_kern_sched(struct sigcontext * scp)
*/
curthread = _get_curthread();
+ after_switch:
+
/* Allow signals again. */
_queue_signals = 0;