pipe.c 753 B

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