Skip to content

Commit

Permalink
libthr _get_curthread i386: 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 gs segment.
Otherwise gcc complains if we tell it we are reading memory offset 0x8.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45829
  • Loading branch information
rlibby committed Jul 3, 2024
1 parent 657b127 commit 7b1c770
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/libthr/arch/i386/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("movl %%gs:%1, %0" : "=r" (thr)
: "m" (*(volatile u_int *)offsetof(struct tcb, tcb_thread)));
__asm __volatile("movl %%gs:%c1, %0" : "=r" (thr)
: "i" (offsetof(struct tcb, tcb_thread)));
return (thr);
}

Expand Down

0 comments on commit 7b1c770

Please sign in to comment.