pipe.c 661 B

123456789101112131415161718192021222324252627282930
  1. /* pipe system call for Linux/MIPS */
  2. /*
  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. /*see uClibc's sh/pipe.c and glibc-2.2.4's mips/pipe.S */
  8. #include <errno.h>
  9. #include <unistd.h>
  10. #include <syscall.h>
  11. libc_hidden_proto(pipe)
  12. int pipe(int *fd)
  13. {
  14. register long int res __asm__ ("$2"); // v0
  15. register long int res2 __asm__ ("$3"); // v1
  16. asm ("move\t$4,%2\n\t" // $4 = a0
  17. "syscall" /* Perform the system call. */
  18. : "=r" (res)
  19. : "0" (__NR_pipe), "r" (fd)
  20. : "$4", "$7");
  21. fd[0] = res;
  22. fd[1] = res2;
  23. return(0);
  24. }
  25. libc_hidden_def(pipe)