summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/bfin/clone.c
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2006-08-18 03:09:07 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2006-08-18 03:09:07 +0000
commit2ca268a71b555ca90fbea391b398c92bdf069c2a (patch)
treec1f7a1f94a85152acb065c0290bf77cc8942a00f /libc/sysdeps/linux/bfin/clone.c
parent82a12113eb5986a659796adb2ff2875dae0db452 (diff)
downloaduClibc-alpine-2ca268a71b555ca90fbea391b398c92bdf069c2a.tar.bz2
uClibc-alpine-2ca268a71b555ca90fbea391b398c92bdf069c2a.tar.xz
Merge from trunk.
Diffstat (limited to 'libc/sysdeps/linux/bfin/clone.c')
-rw-r--r--libc/sysdeps/linux/bfin/clone.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/libc/sysdeps/linux/bfin/clone.c b/libc/sysdeps/linux/bfin/clone.c
index f326f00a0..0ba1d5a4a 100644
--- a/libc/sysdeps/linux/bfin/clone.c
+++ b/libc/sysdeps/linux/bfin/clone.c
@@ -6,15 +6,18 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <asm/unistd.h>
+#include <sched.h>
+#include <errno.h>
+#include <sys/syscall.h>
int
-clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
+clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
{
register long rval = -1;
if (fn && child_stack) {
+#ifdef __BFIN_FDPIC__
__asm__ __volatile__ (
"r1 = %2;"
"r0 = %3;"
@@ -22,16 +25,43 @@ clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
"excpt 0;" /*Call sys_clone*/
"%0 = r0;"
"cc = r0 == 0;"
- "if !cc jump xxx;" /* if (rval != 0) skip to parent */
+ "if !cc jump .Lxxx;" /* if (rval != 0) skip to parent */
"r0 = %4;"
"p0 = %5;"
+ "fp = 0;"
+ "p1 = [p0];"
+ "p3 = [p0 + 4];"
+ "call (p1);" /* Call cloned function */
+ "p0 = %6;"
+ "excpt 0;" /* Call sys_exit */
+ ".Lxxx: nop;"
+ : "=d" (rval)
+ : "i" (__NR_clone), "a" (child_stack), "a" (flags), "a" (arg), "a" (fn), "i" (__NR_exit)
+ : "CC", "R0", "R1", "P0");
+#else
+ __asm__ __volatile__ (
+ "r1 = %2;"
+ "r0 = %3;"
+ "P0 = %1;"
+ "excpt 0;" /*Call sys_clone*/
+ "%0 = r0;"
+ "cc = r0 == 0;"
+ "if !cc jump .Lxxx;" /* if (rval != 0) skip to parent */
+ "r0 = %4;"
+ "p0 = %5;"
+ "fp = 0;"
"call (p0);" /* Call cloned function */
"p0 = %6;"
"excpt 0;" /* Call sys_exit */
- "xxx: nop;"
+ ".Lxxx: nop;"
: "=d" (rval)
: "i" (__NR_clone), "a" (child_stack), "a" (flags), "a" (arg), "a" (fn), "i" (__NR_exit)
: "CC", "R0", "R1", "P0");
+#endif
+
+ } else {
+ __set_errno(EINVAL);
}
+
return rval;
}