Skip to content

Commit

Permalink
libthr _get_curthread amd64: quiet gcc -Warray-bounds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rlibby committed Jul 3, 2024
1 parent 2730f42 commit 657b127
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/libthr/arch/amd64/include/pthread_md.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 657b127

Please sign in to comment.