From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 2DC1A38582A7; Wed, 31 Aug 2022 12:06:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DC1A38582A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661947572; bh=yTYAKLrZJi9ARBfzVQlsKra7cOPuRcmk9PKfSW4FAHA=; h=From:To:Subject:Date:From; b=COLyrqHfYucCgyqls9yWGqROMZAg6kIeA95mrddYJjNUItKQInRu2jwoCPE3TkQSy o8fUfq0JD28Q/UjTgoVLYsYttdghfiV9n9GhaTdWP4GbjSZ2Dt4stR0zB4EWiqgkw5 wSxVqX/C6uyovCvGJqy9LWuyKDuUhEQQfr9VPJas= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] nptl: x86_64: Use same code for CURRENT_STACK_FRAME and stackinfo_get_sp X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/master X-Git-Oldrev: c7509d49c4e8fa494120c5ead21338559dad16f5 X-Git-Newrev: 8cd559cf5afe3894f92c2be6f972e1a4e38c56ca Message-Id: <20220831120612.2DC1A38582A7@sourceware.org> Date: Wed, 31 Aug 2022 12:06:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8cd559cf5afe3894f92c2be6f972e1a4e38c56ca commit 8cd559cf5afe3894f92c2be6f972e1a4e38c56ca Author: Adhemerval Zanella Date: Tue Mar 8 17:31:08 2022 -0300 nptl: x86_64: Use same code for CURRENT_STACK_FRAME and stackinfo_get_sp 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. Diff: --- sysdeps/x86/nptl/pthreaddef.h | 4 +++- sysdeps/x86_64/stackinfo.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sysdeps/x86/nptl/pthreaddef.h b/sysdeps/x86/nptl/pthreaddef.h index 63fdbcb27c..7df65931a3 100644 --- a/sysdeps/x86/nptl/pthreaddef.h +++ b/sysdeps/x86/nptl/pthreaddef.h @@ -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 diff --git a/sysdeps/x86_64/stackinfo.h b/sysdeps/x86_64/stackinfo.h index 34c9d0b576..7354632132 100644 --- a/sysdeps/x86_64/stackinfo.h +++ b/sysdeps/x86_64/stackinfo.h @@ -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)); \