Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Provide struct cpu_info *lwp_getcpu(struct lwp *) in...



details:   https://anonhg.NetBSD.org/src/rev/2a7cf1b2c55d
branches:  trunk
changeset: 337037:2a7cf1b2c55d
user:      matt <matt%NetBSD.org@localhost>
date:      Tue Mar 31 01:10:02 2015 +0000

description:
Provide struct cpu_info *lwp_getcpu(struct lwp *) inline for <machine/cpu.h>
<machine/cpu.h> is include by <sys/lwp.h> before struct lwp is defined so
it can't access members inside it.  This provides an accessor which is defined
after struct lwp is defined.

diffstat:

 sys/sys/lwp.h |  15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diffs (36 lines):

diff -r ac130d130bda -r 2a7cf1b2c55d sys/sys/lwp.h
--- a/sys/sys/lwp.h     Tue Mar 31 01:05:52 2015 +0000
+++ b/sys/sys/lwp.h     Tue Mar 31 01:10:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lwp.h,v 1.169 2014/05/16 10:05:38 rmind Exp $  */
+/*     $NetBSD: lwp.h,v 1.170 2015/03/31 01:10:02 matt Exp $   */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010
@@ -49,6 +49,9 @@
 #include <sys/resource.h>
 
 #if defined(_KERNEL)
+struct lwp;
+/* forward declare this for <machine/cpu.h> so it can get l_cpu. */
+static inline struct cpu_info *lwp_getcpu(struct lwp *);
 #include <machine/cpu.h>               /* curcpu() and cpu_info */
 #endif
 
@@ -467,6 +470,16 @@
 #endif /* ! curlwp */
 #define        curproc         (curlwp->l_proc)
 
+/*
+ * This provide a way for <machine/cpu.h> to get l_cpu for curlwp before
+ * struct lwp is defined.
+ */
+static inline struct cpu_info *
+lwp_getcpu(struct lwp *l)
+{
+       return l->l_cpu;
+}
+
 static inline bool
 CURCPU_IDLE_P(void)
 {



Home | Main Index | Thread Index | Old Index