pipe.c 803 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include <errno.h>
  11. #include <unistd.h>
  12. #include <syscall.h>
  13. int pipe(int *fd)
  14. {
  15. long __res, __res2;
  16. __asm__ __volatile__ (
  17. "mov %2, r3;"
  18. "mov %3, r4;"
  19. "trapa %4;"
  20. "mov r1, %1;"
  21. : "=z" (__res),
  22. "=r" ((long) __res2)
  23. : "r" ((long) __NR_pipe),
  24. "r" ((long) fd),
  25. "i" (__SH_SYSCALL_TRAP_BASE + 3)
  26. : "cc", "memory", "r1", "r3", "r4");
  27. if ((unsigned long)(__res) >= (unsigned long)(-125)) {
  28. int __err = -(__res);
  29. errno = __err;
  30. return(-1);
  31. }
  32. fd[0] = __res;
  33. fd[1] = __res2;
  34. return(0);
  35. }
  36. libc_hidden_def(pipe)