Module Name:    src
Committed By:   reinoud
Date:           Fri Sep  9 18:41:17 UTC 2011

Modified Files:
        src/sys/arch/usermode/dev: cpu.c
        src/sys/arch/usermode/include: thunk.h
        src/sys/arch/usermode/usermode: thunk.c

Log Message:
Streamline makecontext() calls to really only specify the number of arguments
to prevent side-effects


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/usermode/dev/cpu.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/usermode/usermode/thunk.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.41 src/sys/arch/usermode/dev/cpu.c:1.42
--- src/sys/arch/usermode/dev/cpu.c:1.41	Fri Sep  9 16:24:44 2011
+++ src/sys/arch/usermode/dev/cpu.c	Fri Sep  9 18:41:16 2011
@@ -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 <jmcne...@invisible.ca>
@@ -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

Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.30 src/sys/arch/usermode/include/thunk.h:1.31
--- src/sys/arch/usermode/include/thunk.h:1.30	Mon Sep  5 12:04:03 2011
+++ src/sys/arch/usermode/include/thunk.h	Fri Sep  9 18:41:16 2011
@@ -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 <jmcne...@invisible.ca>
@@ -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 *);

Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.34 src/sys/arch/usermode/usermode/thunk.c:1.35
--- src/sys/arch/usermode/usermode/thunk.c:1.34	Mon Sep  5 12:04:03 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Fri Sep  9 18:41:16 2011
@@ -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 <jmcne...@invisible.ca>
@@ -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

Reply via email to