ensure the compiler does not move around thread-register-based reads

if gcc decided to move this across a conditional that checks validity
of the thread register, an invalid thread-register-based read could be
performed and raise sigsegv.
This commit is contained in:
Rich Felker 2011-08-06 20:45:30 -04:00
parent 357876052b
commit 8426a99048
2 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
static inline struct pthread *__pthread_self()
{
struct pthread *self;
__asm__ ("movl %%gs:0,%0" : "=r" (self) );
__asm__ __volatile__ ("movl %%gs:0,%0" : "=r" (self) );
return self;
}

View File

@ -1,7 +1,7 @@
static inline struct pthread *__pthread_self()
{
struct pthread *self;
__asm__ ("movq %%fs:0,%0" : "=r" (self) );
__asm__ __volatile__ ("movq %%fs:0,%0" : "=r" (self) );
return self;
}