Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/include Simplify some macros: if we only ev...



details:   https://anonhg.NetBSD.org/src/rev/9422ff57a490
branches:  trunk
changeset: 967960:9422ff57a490
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Dec 29 21:09:27 2019 +0000

description:
Simplify some macros: if we only ever use them on the local cpu,
there is no need to do another pointer derefernence to go via the global
address of our cpu info.
Pointed out by ad.

diffstat:

 sys/arch/sparc64/include/cpu.h |  17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diffs (37 lines):

diff -r 8a0fe43ae4c0 -r 9422ff57a490 sys/arch/sparc64/include/cpu.h
--- a/sys/arch/sparc64/include/cpu.h    Sun Dec 29 20:58:34 2019 +0000
+++ b/sys/arch/sparc64/include/cpu.h    Sun Dec 29 21:09:27 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.128 2019/12/01 15:34:45 ad Exp $ */
+/*     $NetBSD: cpu.h,v 1.129 2019/12/29 21:09:27 martin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -256,18 +256,21 @@
 extern struct cpu_info *cpus;
 extern struct pool_cache *fpstate_cache;
 
-#define        curcpu()        (((struct cpu_info *)CPUINFO_VA)->ci_self)
+/* CURCPU_INT() a local (per CPU) view of our cpu_info */
+#define        CURCPU_INT()    ((struct cpu_info *)CPUINFO_VA)
+/* in general we prefer the globaly visible pointer */
+#define        curcpu()        (CURCPU_INT()->ci_self)
 #define        cpu_number()    (curcpu()->ci_index)
 #define        CPU_IS_PRIMARY(ci)      ((ci)->ci_flags & CPUF_PRIMARY)
 
 #define CPU_INFO_ITERATOR              int __unused
 #define CPU_INFO_FOREACH(cii, ci)      ci = cpus; ci != NULL; ci = ci->ci_next
 
-#define curlwp         curcpu()->ci_curlwp
-#define fplwp          curcpu()->ci_fplwp
-#define curpcb         curcpu()->ci_cpcb
-
-#define want_ast       curcpu()->ci_want_ast
+/* these are only valid on the local cpu */
+#define curlwp         CURCPU_INT()->ci_curlwp
+#define fplwp          CURCPU_INT()->ci_fplwp
+#define curpcb         CURCPU_INT()->ci_cpcb
+#define want_ast       CURCPU_INT()->ci_want_ast
 
 /*
  * definitions of cpu-dependent requirements



Home | Main Index | Thread Index | Old Index