pipe.c 827 B

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