pipe.c 512 B

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