summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/sh/pipe.c
diff options
context:
space:
mode:
authorDavid McCullough <davidm@snapgear.com>2001-08-06 12:46:12 +0000
committerDavid McCullough <davidm@snapgear.com>2001-08-06 12:46:12 +0000
commit6996c5c48239852d4bd398c8ee98fa1d5602cc7c (patch)
treed5f2b9699fdd9f5afa7adc9b56e95ec33900969d /libc/sysdeps/linux/sh/pipe.c
parent7b013e6b12c7b3e750078e1b43e1312e420ee13d (diff)
Fixup the pipe system call for the SH target.
The FD's are returned in registers.
Diffstat (limited to 'libc/sysdeps/linux/sh/pipe.c')
-rw-r--r--libc/sysdeps/linux/sh/pipe.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/sh/pipe.c b/libc/sysdeps/linux/sh/pipe.c
new file mode 100644
index 000000000..1fb399afc
--- /dev/null
+++ b/libc/sysdeps/linux/sh/pipe.c
@@ -0,0 +1,30 @@
+
+/* Copyright (C) 2001 Lineo, <davidm@lineo.com> */
+
+#include <unistd.h>
+#include <syscall.h>
+
+int pipe(int *fd)
+{
+ long __res, __res2;
+ __asm__ __volatile__ (
+ "mov %2, r3;"
+ "mov %3, r4;"
+ "trapa #0x13;"
+ "mov r1, %1;"
+ : "=z" (__res),
+ "=r" ((long) __res2)
+ : "r" ((long) __NR_pipe),
+ "r" ((long) fd)
+ : "cc", "memory", "r1", "r3", "r4");
+ if ((unsigned long)(__res) >= (unsigned long)(-125)) {
+ int __err = -(__res);
+ errno = __err;
+ return(-1);
+ }
+ fd[0] = __res;
+ fd[1] = __res2;
+ return(0);
+}
+
+