Re: [PATCH] unbreak vfork on cris architecture

2011-03-21 Thread Mike Frysinger
On Mon, Mar 21, 2011 at 10:24 AM, Waldemar Brodkorb wrote:
> unfortunately the common vfork implementation, which just use
> the syscall function to interact with the kernel, does not work
> on the cris architecture. The system call vfork is special, on most
> architectures just calling syscall is not enough.
> The patch below adds the vfork implementation from klibc.
> License should be compatible.

this lacks an explanation as to why vfork is so special on cris.
different calling convention ?  different return values ?  something
else ?

your simple implementation is probably incorrect -- errno cannot be
referenced directly.
-mike
___
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc


[PATCH] unbreak vfork on cris architecture

2011-03-21 Thread Waldemar Brodkorb
unfortunately the common vfork implementation, which just use
the syscall function to interact with the kernel, does not work
on the cris architecture. The system call vfork is special, on most
architectures just calling syscall is not enough.
The patch below adds the vfork implementation from klibc.
License should be compatible.

Signed-off-by: Waldemar Brodkorb 
---
 libc/sysdeps/linux/cris/Makefile.arch |2 +-
 libc/sysdeps/linux/cris/vfork.S   |   33 +
 2 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 libc/sysdeps/linux/cris/vfork.S

diff --git a/libc/sysdeps/linux/cris/Makefile.arch 
b/libc/sysdeps/linux/cris/Makefile.arch
index 43e1912..8a682b0 100644
--- a/libc/sysdeps/linux/cris/Makefile.arch
+++ b/libc/sysdeps/linux/cris/Makefile.arch
@@ -7,7 +7,7 @@
 
 CSRC := __init_brk.c brk.c sbrk.c
 
-SSRC := setjmp.S __longjmp.S clone.S sysdep.S syscall.S
+SSRC := setjmp.S __longjmp.S clone.S sysdep.S syscall.S vfork.S
 ifeq ($(UNIFIED_SYSCALL),y)
 SSRC += __uClibc_syscall.S
 endif
diff --git a/libc/sysdeps/linux/cris/vfork.S b/libc/sysdeps/linux/cris/vfork.S
new file mode 100644
index 000..22b3d5d
--- /dev/null
+++ b/libc/sysdeps/linux/cris/vfork.S
@@ -0,0 +1,33 @@
+/*
+ * vfork.S
+ *
+ * On cris, r9 contains the syscall number (set by generated stub);
+ * r10..r13 contain arguments 0-3 per the standard calling convention.
+ * The return address is in $srp; so we just need to avoid the stack
+ * usage of the normal syscall stubs.
+ */
+
+#include 
+#include 
+
+   .section ".text","ax"
+   .balign 4
+   .globl  __vfork
+   .type   __vfork,@function
+__vfork:
+   move.d  __NR_vfork, $r9
+   break   13
+
+   cmps.w  -4096,$r10
+   blo 1f
+   neg.d   $r10,$r11
+   move.d  $r11,[errno]
+   moveq   -1,$r10
+1:
+   ret
+   nop
+
+   .size   __vfork,.-__vfork
+
+weak_alias(__vfork,vfork)
+libc_hidden_weak(vfork)
-- 
1.7.4.1

___
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc