pipe.c 564 B

12345678910111213141516171819202122232425262728293031
  1. /* Copyright (C) 2001 Lineo, <davidm@lineo.com> */
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #include <syscall.h>
  5. int pipe(int *fd)
  6. {
  7. long __res, __res2;
  8. __asm__ __volatile__ (
  9. "mov %2, r3;"
  10. "mov %3, r4;"
  11. "trapa #0x13;"
  12. "mov r1, %1;"
  13. : "=z" (__res),
  14. "=r" ((long) __res2)
  15. : "r" ((long) __NR_pipe),
  16. "r" ((long) fd)
  17. : "cc", "memory", "r1", "r3", "r4");
  18. if ((unsigned long)(__res) >= (unsigned long)(-125)) {
  19. int __err = -(__res);
  20. errno = __err;
  21. return(-1);
  22. }
  23. fd[0] = __res;
  24. fd[1] = __res2;
  25. return(0);
  26. }