syscall.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Marco van de Voort
  4. Syscall functions for i386 *BSD.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. These functions are the same over all three BSDs, except that some have a
  18. 32-bit Errno, and some a 16-bit}
  19. {$ifdef FPC_USE_SYSCALL}
  20. {$ifdef NetBSD}
  21. {$UNDEF ErrnoWord}
  22. {$endif}
  23. {$ifdef FreeBSD}
  24. {$DEFINE ErrnoWord}
  25. {$endif}
  26. procedure actualsyscall; assembler; {inline requires a dummy push IIRC}
  27. asm
  28. int $0x80
  29. jb .LErrorcode
  30. ret
  31. .LErrorcode:
  32. {$ifdef ErrnoWord}
  33. movw %ax,Errno
  34. {$else}
  35. movl %eax,Errno
  36. {$endif}
  37. mov $-1,%eax
  38. end;
  39. function FpSysCall(sysnr:TSysParam):TSysResult; {$ifndef VER1_0} oldfpccall;{$endif} assembler; [public,alias:'FPC_DOSYS0'];
  40. asm
  41. movl sysnr,%eax
  42. call actualsyscall
  43. end;
  44. function FpSysCall(sysnr,param1:TSysParam):TSysResult; {$ifndef VER1_0} oldfpccall;{$endif} assembler;[public,alias:'FPC_DOSYS1'];
  45. asm
  46. movl sysnr,%eax
  47. pushl Param1
  48. call actualsyscall
  49. addl $4,%esp
  50. end;
  51. function FpSysCall(sysnr,param1:integer):TSysResult; {$ifndef VER1_0} oldfpccall;{$endif}assembler;[public,alias:'FPC_DOSYS1w'];
  52. asm
  53. movl sysnr,%eax
  54. pushw Param1
  55. call actualsyscall
  56. add $2,%esp
  57. end;
  58. function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; {$ifndef VER1_0} oldfpccall;{$endif}assembler; [public,alias:'FPC_DOSYS2'];
  59. asm
  60. movl sysnr,%eax
  61. pushl param2
  62. pushl Param1
  63. call actualsyscall
  64. addl $8,%esp
  65. end;
  66. function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; {$ifndef VER1_0} oldfpccall;{$endif}assembler;[public,alias:'FPC_DOSYS3'];
  67. asm
  68. movl sysnr,%eax
  69. pushl param3
  70. pushl param2
  71. pushl Param1
  72. call actualsyscall
  73. addl $12,%esp
  74. end;
  75. function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult;{$ifndef VER1_0} oldfpccall;{$endif} assembler;[public,alias:'FPC_DOSYS4'];
  76. asm
  77. movl sysnr,%eax
  78. pushl param4
  79. pushl param3
  80. pushl param2
  81. pushl Param1
  82. call actualsyscall
  83. addl $16,%esp
  84. end;
  85. function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult;{$ifndef VER1_0} oldfpccall;{$endif} assembler;[public,alias:'FPC_DOSYS5'];
  86. asm
  87. movl sysnr,%eax
  88. pushl param5
  89. pushl param4
  90. pushl param3
  91. pushl param2
  92. pushl Param1
  93. call actualsyscall
  94. addl $20,%esp
  95. end;
  96. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):int64; {$ifndef VER1_0} oldfpccall;{$endif} assembler;[public,alias:'FPC_DOSYS6'];
  97. asm
  98. movl sysnr,%eax
  99. pushl param6
  100. pushl param5
  101. pushl param4
  102. pushl param3
  103. pushl param2
  104. pushl Param1
  105. call actualsyscall
  106. addl $24,%esp
  107. end;
  108. function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:TSysParam):int64;{$ifndef VER1_0} oldfpccall;{$endif} assembler; [public,alias:'FPC_DOSYS7'];
  109. asm
  110. movl sysnr,%eax
  111. pushl param7
  112. pushl param6
  113. pushl param5
  114. pushl param4
  115. pushl param3
  116. pushl param2
  117. pushl Param1
  118. call actualsyscall
  119. addl $28,%esp
  120. end;
  121. {$endif}
  122. {
  123. $Log$
  124. Revision 1.10 2003-12-30 12:26:21 marco
  125. * FPC_USE_LIBC
  126. }