pipe.c 778 B

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