OSDN Git Service

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