2
0

bsyscall.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005-2009 by Michael Van Canneyt and David Zhang
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {$ifndef generic_linux_syscalls}
  11. {$define FPC_BASEUNIX_HAS_FPPIPE}
  12. Function fppipe(var fildes : tfildes):cint;assembler;
  13. {
  14. This function puts the registers in place, does the call, and then
  15. copies back the registers as they are after the SysCall.
  16. Extracted from linux/source/arch/mips/kernel/syscall.c:
  17. * For historic reasons the pipe(2) syscall on MIPS has an unusual calling
  18. * convention. It returns results in registers $v0 / $v1 which means there
  19. * is no need for it to do verify the validity of a userspace pointer
  20. * argument. Historically that used to be expensive in Linux. These days
  21. * the performance advantage is negligible.
  22. }
  23. var
  24. tmp: pointer;
  25. asm
  26. sw $a0,tmp { if $a0 is preserved in syscall then this is not needed }
  27. li $v0,syscall_nr_pipe
  28. syscall
  29. nop
  30. beq $a3,$0,.L1
  31. nop
  32. move $a0,$v0
  33. jal fpseterrno
  34. nop
  35. b .L2
  36. li $v0,-1 { in delay slot }
  37. .L1:
  38. { the two files descriptors are now in v0 and v1 registers
  39. copying them back into fildes variable }
  40. lw $t1,tmp
  41. sw $v0,($t1)
  42. sw $v1,4($t1)
  43. .L2:
  44. end;
  45. {$endif generic_linux_syscalls}