Module Name: src
Committed By: reinoud
Date: Mon Sep 5 19:28:32 UTC 2011
Modified Files:
src/sys/arch/usermode/dev: cpu.c
Log Message:
Restore errno just before switching to the new context and NOT after it got
back again
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/usermode/dev/cpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/usermode/dev/cpu.c
diff -u src/sys/arch/usermode/dev/cpu.c:1.31 src/sys/arch/usermode/dev/cpu.c:1.32
--- src/sys/arch/usermode/dev/cpu.c:1.31 Mon Sep 5 12:40:38 2011
+++ src/sys/arch/usermode/dev/cpu.c Mon Sep 5 19:28:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.31 2011/09/05 12:40:38 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.32 2011/09/05 19:28:32 reinoud Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <[email protected]>
@@ -29,7 +29,7 @@
#include "opt_cpu.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.31 2011/09/05 12:40:38 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.32 2011/09/05 19:28:32 reinoud Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -159,7 +159,6 @@
struct pcb *oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL;
struct pcb *newpcb = lwp_getpcb(newlwp);
struct cpu_info *ci = curcpu();
- int s;
#ifdef CPU_DEBUG
printf("cpu_switchto [%s,pid=%d,lid=%d] -> [%s,pid=%d,lid=%d]\n",
@@ -185,22 +184,19 @@
}
#endif /* !CPU_DEBUG */
- s = splsched();
-
ci->ci_stash = oldlwp;
curlwp = newlwp;
if (oldpcb) {
oldpcb->pcb_errno = thunk_geterrno();
+ thunk_seterrno(newpcb->pcb_errno);
if (thunk_swapcontext(&oldpcb->pcb_ucp, &newpcb->pcb_ucp))
panic("swapcontext failed");
} else {
+ thunk_seterrno(newpcb->pcb_errno);
if (thunk_setcontext(&newpcb->pcb_ucp))
panic("setcontext failed");
}
- thunk_seterrno(newpcb->pcb_errno);
-
- splx(s);
#ifdef CPU_DEBUG
printf("cpu_switchto: returning %p (was %p)\n", ci->ci_stash, oldlwp);