git: 657b1276ad4c - main - libthr _get_curthread amd64: quiet gcc -Warray-bounds

From: Ryan Libby <rlibby_at_FreeBSD.org>
Date: Wed, 03 Jul 2024 16:14:58 UTC
The branch main has been updated by rlibby:

URL: https://cgit.FreeBSD.org/src/commit/?id=657b1276ad4c2d2d92ce9d13b338349c0fa40dc3

commit 657b1276ad4c2d2d92ce9d13b338349c0fa40dc3
Author:     Ryan Libby <rlibby@FreeBSD.org>
AuthorDate: 2024-07-03 15:37:11 +0000
Commit:     Ryan Libby <rlibby@FreeBSD.org>
CommitDate: 2024-07-03 15:37:11 +0000

    libthr _get_curthread amd64: quiet gcc -Warray-bounds
    
    Use a constant input operand instead of a bogus memory reference to tell
    the compiler about offsetof(struct tcb, tcb_thread) in the fs segment.
    Otherwise gcc complains if we tell it we are reading memory offset 0x10.
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D45828
---
 lib/libthr/arch/amd64/include/pthread_md.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libthr/arch/amd64/include/pthread_md.h b/lib/libthr/arch/amd64/include/pthread_md.h
index f43578a8241a..995f35cb569c 100644
--- a/lib/libthr/arch/amd64/include/pthread_md.h
+++ b/lib/libthr/arch/amd64/include/pthread_md.h
@@ -47,8 +47,8 @@ _get_curthread(void)
 {
 	struct pthread *thr;
 
-	__asm __volatile("movq %%fs:%1, %0" : "=r" (thr)
-	    : "m" (*(volatile u_long *)offsetof(struct tcb, tcb_thread)));
+	__asm __volatile("movq %%fs:%c1, %0" : "=r" (thr)
+	    : "i" (offsetof(struct tcb, tcb_thread)));
 	return (thr);
 }