pipe.c 793 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. 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 #0x13;"
  21. "mov r1, %1;"
  22. : "=z" (__res),
  23. "=r" ((long) __res2)
  24. : "r" ((long) __NR_pipe),
  25. "r" ((long) fd)
  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)