From: dlg Date: Wed, 17 Aug 2016 11:09:01 +0000 (+0000) Subject: use a register variable to get at the curcpu pointer in %g7 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b69b316e016cc1c4a9d17118a7857c9c196be354;p=openbsd use a register variable to get at the curcpu pointer in %g7 this lets us define curcpu(), cpu_number(), etc as derefs of this variable rather than having to write asm to copy it into another register for the same derefs. this provides shorter inlined code that wastes less registers. ok kettenis@ who notes we use this these on other archs already --- diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h index d349496f189..570d5dc5152 100644 --- a/sys/arch/sparc64/include/cpu.h +++ b/sys/arch/sparc64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.88 2015/08/28 23:28:39 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.89 2016/08/17 11:09:01 dlg Exp $ */ /* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */ /* @@ -169,22 +169,12 @@ struct cpu_info { extern struct cpu_info *cpus; -#define curpcb curcpu()->ci_cpcb -#define fpproc curcpu()->ci_fpproc - #ifdef MULTIPROCESSOR -#define cpu_number() (curcpu()->ci_number) - -extern __inline struct cpu_info *curcpu(void); -extern __inline struct cpu_info * -curcpu(void) -{ - struct cpu_info *ci; +register struct cpu_info *__curcpu asm ("%g7"); - __asm volatile("mov %%g7, %0" : "=r"(ci)); - return (ci->ci_self); -} +#define curcpu() (__curcpu->ci_self) +#define cpu_number() (__curcpu->ci_number) #define CPU_IS_PRIMARY(ci) ((ci)->ci_number == 0) #define CPU_INFO_ITERATOR int @@ -200,10 +190,11 @@ void sparc64_broadcast_ipi(void (*)(void), u_int64_t, u_int64_t); void cpu_unidle(struct cpu_info *); -#else +#else /* MULTIPROCESSOR */ +#define __curcpu ((struct cpu_info *)CPUINFO_VA) +#define curcpu() __curcpu #define cpu_number() 0 -#define curcpu() ((struct cpu_info *)CPUINFO_VA) #define CPU_IS_PRIMARY(ci) 1 #define CPU_INFO_ITERATOR int @@ -214,7 +205,10 @@ void cpu_unidle(struct cpu_info *); #define cpu_unidle(ci) -#endif +#endif /* MULTIPROCESSOR */ + +#define curpcb __curcpu->ci_cpcb +#define fpproc __curcpu->ci_fpproc #define CPU_BUSY_CYCLE() do {} while (0)