From 38265c7af552c1874b75c76818a082d2841c717b Mon Sep 17 00:00:00 2001 From: Ingo van Lil Date: Thu, 4 Jun 2009 14:33:34 +0200 Subject: 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 Signed-off-by: Mike Frysinger --- libc/sysdeps/linux/i386/__syscall_error.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libc/sysdeps/linux') 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; } -- cgit v1.2.3