Subject: LKMs independent of DIAGNOSTIC?
To: None <port-alpha@netbsd.org>
From: Assar Westerlund <assar@netbsd.org>
List: tech-kern
Date: 08/06/2001 16:53:53
Hi.
I tried loading an LKM into an alpha kernel build with DIAGNOSTIC.
This fails some time after loading it in a not-very-pretty way since
the layout of `struct cpu_info' is different depending on DIAGNOSTIC
(and MULTIPROCESSOR). To not have to build LKMs with the exakt same
set of defines (and no way of finding these) as the kernel, I suggest
something along the line of this patch. Any comments?
/assar
Index: alpha/cpu.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/alpha/cpu.c,v
retrieving revision 1.64
diff -u -w -r1.64 cpu.c
--- alpha/cpu.c 2001/07/13 21:34:35 1.64
+++ alpha/cpu.c 2001/08/06 14:44:13
@@ -711,3 +711,9 @@
#endif /* DDB */
#endif /* MULTIPROCESSOR */
+
+struct proc *
+_curproc(void)
+{
+ return curproc();
+}
Index: cpu.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/include/cpu.h,v
retrieving revision 1.58
diff -u -w -u -w -r1.58 cpu.h
--- cpu.h 2001/05/30 12:28:38 1.58
+++ cpu.h 2001/08/06 14:53:56
@@ -174,7 +174,12 @@
#define curcpu() (&cpu_info_primary)
#endif /* MULTIPROCESSOR */
+#ifdef LKM
+#define curproc _curproc()
+#else
#define curproc curcpu()->ci_curproc
+#endif
+
#define fpcurproc curcpu()->ci_fpcurproc
#define curpcb curcpu()->ci_curpcb