From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH 11/34] xen/arm: Introduce __builtin_stack_pointer Date: Tue, 25 Mar 2014 16:55:18 +0000 Message-ID: <1395766541-23979-12-git-send-email-julien.grall@linaro.org> References: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WSUeF-00005f-10 for xen-devel@lists.xenproject.org; Tue, 25 Mar 2014 16:56:23 +0000 Received: by mail-ee0-f49.google.com with SMTP id c41so685351eek.36 for ; Tue, 25 Mar 2014 09:56:10 -0700 (PDT) In-Reply-To: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org Clang doesn't support named register. Introduce __builtin_stack_pointer to be able to use named register with gcc. In file included from arm32/asm-offsets.c:10: In file included from xen/xen/include/xen/sched.h:18: In file included from xen/xen/include/xen/smp.h:4: In file included from xen/xen/include/asm/smp.h:8: xen/xen/include/asm/current.h:31:33: error: variable 'sp' is uninitialized when used here [-Werror,-Wuninitialized] return (struct cpu_info *)((sp & ~(STACK_SIZE - 1)) + STACK_SIZE - sizeof(struct cpu_info)); ^~ xen/xen/include/asm/current.h:30:30: note: initialize the variable 'sp' to silence this warning register unsigned long sp asm ("sp"); ^ = 0 Signed-off-by: Julien Grall Cc: Ian Campbell Cc: Stefano Stabellini Cc: Tim Deegan --- xen/include/asm-arm/current.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-arm/current.h b/xen/include/asm-arm/current.h index 65c0cdf..0d4a8c0 100644 --- a/xen/include/asm-arm/current.h +++ b/xen/include/asm-arm/current.h @@ -25,10 +25,23 @@ struct cpu_info { unsigned int pad; }; +#ifdef __clang__ +#define __builtin_stack_pointer() ({ \ + unsigned long current_sp; \ + asm ("mov %0, sp" : "=r" (current_sp)); \ + current_sp; \ +}) +#else +#define __builtin_stack_pointer() ({ \ + register unsigned long current_sp asm ("sp"); \ + current_sp; \ +}) +#endif + static inline struct cpu_info *get_cpu_info(void) { - register unsigned long sp asm ("sp"); - return (struct cpu_info *)((sp & ~(STACK_SIZE - 1)) + STACK_SIZE - sizeof(struct cpu_info)); + return (struct cpu_info *)((__builtin_stack_pointer() & ~(STACK_SIZE - 1)) + + STACK_SIZE - sizeof(struct cpu_info)); } #define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs) -- 1.7.10.4