Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode Streamline makecontext() calls to really o...
details: https://anonhg.NetBSD.org/src/rev/8371d41ef10a
branches: trunk
changeset: 769431:8371d41ef10a
user: reinoud <reinoud%NetBSD.org@localhost>
date: Fri Sep 09 18:41:16 2011 +0000
description:
Streamline makecontext() calls to really only specify the number of arguments
to prevent side-effects
diffstat:
sys/arch/usermode/dev/cpu.c | 8 ++++----
sys/arch/usermode/include/thunk.h | 6 +++---
sys/arch/usermode/usermode/thunk.c | 31 ++++++++++++++++++-------------
3 files changed, 25 insertions(+), 20 deletions(-)
diffs (102 lines):
diff -r beec18d6df37 -r 8371d41ef10a sys/arch/usermode/dev/cpu.c
--- a/sys/arch/usermode/dev/cpu.c Fri Sep 09 17:48:39 2011 +0000
+++ b/sys/arch/usermode/dev/cpu.c Fri Sep 09 18:41:16 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.41 2011/09/09 16:24:44 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.42 2011/09/09 18:41:16 reinoud Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
#include "opt_hz.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.41 2011/09/09 16:24:44 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.42 2011/09/09 18:41:16 reinoud Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -327,8 +327,8 @@
pcb2->pcb_syscall_ucp.uc_flags = _UC_CPU;
pcb2->pcb_syscall_ucp.uc_link = &pcb2->pcb_userland_ucp;
pcb2->pcb_syscall_ucp.uc_stack.ss_size = 0; /* no stack move */
- thunk_makecontext_1(&pcb2->pcb_syscall_ucp, (void (*)(void)) syscall,
- NULL);
+ thunk_makecontext(&pcb2->pcb_syscall_ucp, (void (*)(void)) syscall,
+ 0, NULL, NULL);
}
void
diff -r beec18d6df37 -r 8371d41ef10a sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Fri Sep 09 17:48:39 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Fri Sep 09 18:41:16 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.30 2011/09/05 12:04:03 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.31 2011/09/09 18:41:16 reinoud Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -83,8 +83,8 @@
int thunk_getcontext(ucontext_t *);
int thunk_setcontext(const ucontext_t *);
-void thunk_makecontext(ucontext_t *, void (*)(void), int, void (*)(void *), void *);
-void thunk_makecontext_1(ucontext_t *, void *func, void *arg);
+void thunk_makecontext(ucontext_t *ucp, void (*func)(void), int nargs,
+ void (*arg1)(void *), void *arg2);
int thunk_swapcontext(ucontext_t *, ucontext_t *);
int thunk_tcgetattr(int, struct thunk_termios *);
diff -r beec18d6df37 -r 8371d41ef10a sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c Fri Sep 09 17:48:39 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c Fri Sep 09 18:41:16 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.34 2011/09/05 12:04:03 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.35 2011/09/09 18:41:16 reinoud Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.34 2011/09/05 12:04:03 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.35 2011/09/09 18:41:16 reinoud Exp $");
#endif
#include <sys/types.h>
@@ -253,18 +253,23 @@
}
void
-thunk_makecontext(ucontext_t *ucp, void (*func)(void), int argc,
- void (*arg1)(void *), void *arg2)
+thunk_makecontext(ucontext_t *ucp, void (*func)(void),
+ int nargs, void (*arg1)(void *), void *arg2)
{
-// assert(argc == 2);
-
- makecontext(ucp, func, argc, arg1, arg2);
-}
-
-void
-thunk_makecontext_1(ucontext_t *ucp, void *func, void *arg)
-{
- makecontext(ucp, func, 1, arg);
+ switch (nargs) {
+ case 0:
+ makecontext(ucp, func, 0);
+ break;
+ case 1:
+ makecontext(ucp, func, 1, arg1);
+ break;
+ case 2:
+ makecontext(ucp, func, 2, arg1, arg2);
+ break;
+ default:
+ printf("%s: nargs (%d) too big\n", __func__, nargs);
+ abort();
+ }
}
int
Home |
Main Index |
Thread Index |
Old Index