diff options
author | Ingo van Lil <inguin@gmx.de> | 2009-06-04 14:33:34 +0200 |
---|---|---|
committer | Austin Foxley <austinf@cetoncorp.com> | 2009-07-09 01:34:24 -0700 |
commit | 73591018c44e785d08d7636e02c671c4c5b56f97 (patch) | |
tree | 00118714c8cbe2c723e3c0e8b4a889429504ae7a | |
parent | 31e58445346a84c24d15178c0d52b8df3a63c6b4 (diff) | |
download | uClibc-alpine-73591018c44e785d08d7636e02c671c4c5b56f97.tar.bz2 uClibc-alpine-73591018c44e785d08d7636e02c671c4c5b56f97.tar.xz |
i386: store errno value before using __set_errno()
The __syscall_error() function stores the errno value in the edx register
before invoking the __set_errno() macro. When using the pthread library
this macro calls thread_self() to determine the errno location, which might
clobber the edx register. The errno value must be stored in a "real"
variable so the compiler can take care of saving/restoring it if necessary.
Signed-off-by: Ingo van Lil <inguin@gmx.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
-rw-r--r-- | libc/sysdeps/linux/i386/__syscall_error.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libc/sysdeps/linux/i386/__syscall_error.c b/libc/sysdeps/linux/i386/__syscall_error.c index 7509d4409..36946bc6d 100644 --- a/libc/sysdeps/linux/i386/__syscall_error.c +++ b/libc/sysdeps/linux/i386/__syscall_error.c @@ -28,9 +28,8 @@ int __syscall_error(void) attribute_hidden; int __syscall_error(void) { - register int edx __asm__ ("%edx"); - __asm__ ("mov %eax, %edx\n\t" - "negl %edx"); - __set_errno (edx); + register int eax __asm__ ("%eax"); + int _errno = -eax; + __set_errno (_errno); return -1; } |