[uClibc]mipsel syscall stat ... argh!

Geoffrey Espin espin at idiom.com
Thu Feb 21 23:42:13 UTC 2002


> Pipe's don't work in mipsel-uclibc-busybox... (was my vfork.c bogus?)
>     # echo hi | sed -e '/hi/ho/'
>     hi
>     268476192: %m
>     #

Seems that MIPS needs its own pipe.c like SH.

Sorry, my __asm__() understanding & MIPS assembly ability are
near 0... but this cobbly-gook actually works.

This patch also includes adding _mmap.c lifted from v850 as well.

With this patch, one can now build a working mipsel-busybox with ash/vi/...

    % mipsel-linux-size  busybox.*/busybox
    text    data     bss     dec     hex filename
    1235728   28380   63748 1327856  1442f0 busybox.glibc/busybox
     740280   10600   37068  787948   c05ec busybox.uclibc/busybox

Geoff
-- 
Geoffrey Espin
espin at idiom.com
--

diff -b -Naur uClibc.orig/libc/sysdeps/linux/common/syscalls.c uClibc.new/libc/sysdeps/linux/common/syscalls.c
--- uClibc.orig/libc/sysdeps/linux/common/syscalls.c	Wed Feb 13 01:47:02 2002
+++ uClibc.new/libc/sysdeps/linux/common/syscalls.c	Thu Feb 21 14:59:28 2002
@@ -357,9 +357,9 @@
 #ifdef L_pipe
 #include <unistd.h>
 /*
- * SH has a weird register calling mechanism for pipe, see pipe.c
+ * SH & MIPS has a weird register calling mechanism for pipe, see pipe.c
  */
-#if !defined(__sh__)
+#if !defined(__sh__) && !defined(__mips__)
 _syscall1(int, pipe, int *, filedes);
 #endif
 #endif
diff -b -Naur uClibc.orig/libc/sysdeps/linux/mips/Makefile uClibc.new/libc/sysdeps/linux/mips/Makefile
--- uClibc.orig/libc/sysdeps/linux/mips/Makefile	Sat Feb 16 12:16:20 2002
+++ uClibc.new/libc/sysdeps/linux/mips/Makefile	Thu Feb 21 14:48:00 2002
@@ -33,7 +33,7 @@
 SSRC=bsd-_setjmp.S bsd-setjmp.S setjmp.S #fork.S clone.S
 SOBJS=$(patsubst %.S,%.o, $(SSRC))
 
-CSRC=__longjmp.c  brk.c vfork.c setjmp_aux.c
+CSRC=__longjmp.c  brk.c vfork.c setjmp_aux.c _mmap.c pipe.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
 
 OBJS=$(SOBJS) $(MOBJ) $(COBJS)
diff -b -Naur uClibc.orig/libc/sysdeps/linux/mips/_mmap.c uClibc.new/libc/sysdeps/linux/mips/_mmap.c
--- uClibc.orig/libc/sysdeps/linux/mips/_mmap.c	Wed Dec 31 16:00:00 1969
+++ uClibc.new/libc/sysdeps/linux/mips/_mmap.c	Thu Feb 21 14:48:00 2002
@@ -0,0 +1,9 @@
+/* Use new style mmap for v850 */
+
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+
+_syscall6 (__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot,
+	   int, flags, int, fd, __off_t, offset);
diff -b -Naur uClibc.orig/libc/sysdeps/linux/mips/pipe.c uClibc.new/libc/sysdeps/linux/mips/pipe.c
--- uClibc.orig/libc/sysdeps/linux/mips/pipe.c	Wed Dec 31 16:00:00 1969
+++ uClibc.new/libc/sysdeps/linux/mips/pipe.c	Thu Feb 21 15:03:45 2002
@@ -0,0 +1,23 @@
+/* pipe system call for Linux/MIPS */
+
+/* see uClibc's sh/pipe.c and glibc-2.2.4's mips/pipe.S */
+
+#include <errno.h>
+#include <unistd.h>
+#include <syscall.h>
+
+int pipe(int *fd)
+{
+    register long int res __asm__ ("$2"); // v0
+    register long int res2 __asm__ ("$3"); // v1
+
+    asm ("move\t$4,%2\n\t"		// $4 = a0
+	 "syscall"		/* Perform the system call.  */
+	 : "=r" (res)
+	 : "0" (__NR_pipe), "r" (fd)
+	 : "$4", "$7");
+
+	fd[0] = res;
+	fd[1] = res2;
+	return(0);
+}



More information about the uClibc mailing list