]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: x86_64: Use same code for CURRENT_STACK_FRAME and stackinfo_get_sp
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 8 Mar 2022 20:31:08 +0000 (17:31 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 31 Aug 2022 12:04:27 +0000 (09:04 -0300)
It avoids the possible warning of uninitialized 'frame' variable when
building with clang:

  ../sysdeps/nptl/jmp-unwind.c:27:42: error: variable 'frame' is
  uninitialized when used here [-Werror,-Wuninitialized]
    __pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME);

The resulting code is similar to CURRENT_STACK_FRAME.

Checked on x86_64-linux-gnu.

sysdeps/x86/nptl/pthreaddef.h
sysdeps/x86_64/stackinfo.h

index 63fdbcb27c356d243ef7877445e7ce2de5d7ce54..7df65931a34f77de258b2207ff7711d8b3b6f958 100644 (file)
@@ -42,7 +42,9 @@
 #ifdef __x86_64__
 /* The frame pointer is not usable.  */
 # define CURRENT_STACK_FRAME \
-  ({ register char *frame __asm__("rsp"); frame; })
+  ({ register void * p__ __asm__(RSP_REG); \
+     asm volatile("" : "=r" (p__)); \
+     p__; })
 #else
 # define CURRENT_STACK_FRAME   __builtin_frame_address (0)
 #endif
index 34c9d0b576cbc5572248e85bba15117281f75820..7354632132dd2a229ae6f183e42ffa14c74d0010 100644 (file)
@@ -40,7 +40,9 @@
    for which they need to act as barriers as well, hence the additional
    (unnecessary) parameters.  */
 #define stackinfo_get_sp() \
-  ({ void *p__; asm volatile ("mov %%" RSP_REG ", %0" : "=r" (p__)); p__; })
+  ({ register void * p__ __asm__(RSP_REG); \
+     asm volatile("" : "=r" (p__)); \
+     p__; })
 #define stackinfo_sub_sp(ptr) \
   ({ ptrdiff_t d__;                                            \
      asm volatile ("sub %%" RSP_REG " , %0" : "=r" (d__) : "0" (ptr)); \