MIPS syscall function

Daniel Jacobowitz drow at false.org
Tue May 22 12:27:03 UTC 2007


I discovered yesterday that the syscall() function on MIPS does not
set errno.  While checking the other assembly syscall implementations
I also found that pipe set errno to a bogus value.  This patch fixes it.

-- 
Daniel Jacobowitz
CodeSourcery

---
 libc/sysdeps/linux/mips/pipe.S    |   15 ++++++++++-----
 libc/sysdeps/linux/mips/syscall.S |   10 ++++++++++
 2 files changed, 20 insertions(+), 5 deletions(-)

Index: uclibc-0.9.29/libc/sysdeps/linux/mips/pipe.S
===================================================================
--- uclibc-0.9.29.orig/libc/sysdeps/linux/mips/pipe.S	2007-01-18 12:33:11.000000000 -0800
+++ uclibc-0.9.29/libc/sysdeps/linux/mips/pipe.S	2007-05-21 12:26:44.000000000 -0700
@@ -17,7 +17,16 @@
 pipe:
 	li	v0,__NR_pipe
 	syscall
-	beqz	a3, 1f
+	bnez	a3, 1f
+	sw	v0, 0(a0)
+	sw	v1, 4(a0)
+	li	v0, 0
+	j	ra
+1:
+	/* uClibc change -- start */
+	move		a0,v0		/* Pass return val to C function. */
+	/* uClibc change -- stop */
+
 #ifdef __PIC__
 	PTR_LA	t9, __syscall_error
 	jr	t9
@@ -25,10 +34,6 @@ pipe:
 	j	__syscall_error
 #endif
 1:
-	sw	v0, 0(a0)
-	sw	v1, 4(a0)
-	li	v0, 0
-	j	ra
 	.end	pipe
 	.size	pipe,.-pipe
 libc_hidden_def(pipe)
Index: uclibc-0.9.29/libc/sysdeps/linux/mips/syscall.S
===================================================================
--- uclibc-0.9.29.orig/libc/sysdeps/linux/mips/syscall.S	2007-01-18 12:33:11.000000000 -0800
+++ uclibc-0.9.29/libc/sysdeps/linux/mips/syscall.S	2007-05-21 12:28:08.000000000 -0700
@@ -60,6 +60,16 @@ syscall:
 #else
 	addiu	sp,sp,32
 #endif
+	bnez	a3, 1f
      	j ra			/* Return to caller.  */
+1:
+	move		a0,v0		/* Pass return val to C function. */
+
+#ifdef __PIC__
+	PTR_LA	t9, __syscall_error
+	jr	t9
+#else
+	j	__syscall_error
+#endif
 .end    syscall
 .size   syscall,.-syscall



More information about the uClibc mailing list