summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/i386
diff options
context:
space:
mode:
authorIngo van Lil <inguin@gmx.de>2009-06-04 14:33:34 +0200
committerMike Frysinger <vapier@gentoo.org>2009-07-03 15:16:17 -0400
commit38265c7af552c1874b75c76818a082d2841c717b (patch)
treec62bf55e46404d74ed352e5a53927f0820c95efd /libc/sysdeps/linux/i386
parenteed594d648dbd42235d8e63bfbd868c49712a90f (diff)
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>
Diffstat (limited to 'libc/sysdeps/linux/i386')
-rw-r--r--libc/sysdeps/linux/i386/__syscall_error.c7
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;
}