summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/i386/__syscall_error.c
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2005-07-30 01:56:45 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2005-07-30 01:56:45 +0000
commit04ab95efe9d498e9ac07a37c80b80b6f267ddcf0 (patch)
tree57ca40d5c9c1efa6025867cca1d1572a15f1eac6 /libc/sysdeps/linux/i386/__syscall_error.c
parentb87804d0362d55f8a0291595036ebfccf5b1a59f (diff)
downloaduClibc-alpine-04ab95efe9d498e9ac07a37c80b80b6f267ddcf0.tar.bz2
uClibc-alpine-04ab95efe9d498e9ac07a37c80b80b6f267ddcf0.tar.xz
More merges with main trunk.
Diffstat (limited to 'libc/sysdeps/linux/i386/__syscall_error.c')
-rw-r--r--libc/sysdeps/linux/i386/__syscall_error.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/i386/__syscall_error.c b/libc/sysdeps/linux/i386/__syscall_error.c
index de65a1f39..133500cb6 100644
--- a/libc/sysdeps/linux/i386/__syscall_error.c
+++ b/libc/sysdeps/linux/i386/__syscall_error.c
@@ -22,8 +22,25 @@
/* This routine is jumped to by all the syscall handlers, to stash
* an error number into errno. */
-int attribute_hidden __syscall_error(int err_no)
+
+/* This version uses a lot of magic and relies heavily on x86
+ * calling convention ... The advantage is that this is the same
+ * size as the previous __syscall_error() but all the .S functions
+ * need just one instruction.
+ *
+ * Local .S files have to set %eax to the negative errno value
+ * and then jump to this function. The neglected return to caller
+ * and return value of -1 is taken care of here so we don't have to
+ * worry about it in the .S functions.
+ *
+ * We have to stash the errno from %eax in a local stack var because
+ * __set_errno will prob call a function thus clobbering %eax on us.
+ */
+int attribute_hidden __syscall_error(void)
{
- __set_errno(err_no);
+ register int edx asm("%edx");
+ asm("mov %eax, %edx");
+ asm("negl %edx");
+ __set_errno(edx);
return -1;
}