1 /*
2 * pipe syscall for uClibc sh
3 *
4 * Copyright (C) 2001 Lineo, <davidm@lineo.com>
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6 *
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 */
9
10 #include <errno.h>
11 #include <unistd.h>
12 #include <syscall.h>
13
14
pipe(int * fd)15 int pipe(int *fd)
16 {
17 long __res, __res2;
18 __asm__ __volatile__ (
19 "mov %2, r3;"
20 "mov %3, r4;"
21 "trapa %4;"
22 "mov r1, %1;"
23 : "=z" (__res),
24 "=r" ((long) __res2)
25 : "r" ((long) __NR_pipe),
26 "r" ((long) fd),
27 "i" (__SH_SYSCALL_TRAP_BASE + 3)
28 : "cc", "memory", "r1", "r3", "r4");
29 if ((unsigned long)(__res) >= (unsigned long)(-125)) {
30 int __err = -(__res);
31 errno = __err;
32 return(-1);
33 }
34 fd[0] = __res;
35 fd[1] = __res2;
36 return(0);
37 }
38 libc_hidden_def(pipe)
39