blob: 799f5183906f5f68cc56651533ce863cf11b2db0 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* 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
16int pipe(int *fd)
17{
18 long __res, __res2;
19 __asm__ __volatile__ (
20 "mov %2, r3;"
21 "mov %3, r4;"
22 "trapa %4;"
23 "mov r1, %1;"
24 : "=z" (__res),
25 "=r" ((long) __res2)
26 : "r" ((long) __NR_pipe),
27 "r" ((long) fd),
28 "i" (__SH_SYSCALL_TRAP_BASE + 3)
29 : "cc", "memory", "r1", "r3", "r4");
30 if ((unsigned long)(__res) >= (unsigned long)(-125)) {
31 int __err = -(__res);
32 errno = __err;
33 return(-1);
34 }
35 fd[0] = __res;
36 fd[1] = __res2;
37 return(0);
38}
39libc_hidden_def(pipe)