This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: Use __asm__("rsp") to get URRENT_STACK_FRAME
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Henderson <rth at twiddle dot net>
- Cc: "H.J. Lu" <hongjiu dot lu at intel dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 19 Mar 2012 15:35:38 -0700
- Subject: PATCH: Use __asm__("rsp") to get URRENT_STACK_FRAME
On Mon, Mar 19, 2012 at 3:10 PM, Richard Henderson <rth@twiddle.net> wrote:
> On 03/19/12 14:34, H.J. Lu wrote:
>> ?#define CURRENT_STACK_FRAME \
>> - ?({ char *frame; asm ("movq %%rsp, %0" : "=r" (frame)); frame; })
>> + ?({ char *frame; asm ("mov %%" RSP_LP ", %0" : "=r" (frame)); frame; })
>
> I'm pretty sure
>
> ?({ register void *esp __asm__("esp"); esp; })
>
> will work without the unneeded copy.
>
Thanks for the pointer. Here is the updated patch. OK to install?
Thanks.
--
H.J.
--
2012-03-19 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86_64/pthreaddef.h (CURRENT_STACK_FRAME): Use
register char * __asm__("rsp") to get stack frame.
diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
index 7e45be4..50587b8 100644
--- a/nptl/sysdeps/x86_64/pthreaddef.h
+++ b/nptl/sysdeps/x86_64/pthreaddef.h
@@ -41,7 +41,7 @@
/* Location of current stack frame. The frame pointer is not usable. */
#define CURRENT_STACK_FRAME \
- ({ char *frame; asm ("movq %%rsp, %0" : "=r" (frame)); frame; })
+ ({ register char *frame __asm__("rsp"); frame; })
/* XXX Until we have a better place keep the definitions here. */