unxsysc.inc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 Marco van de Voort
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY;without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. (*
  13. function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
  14. {NOT IMPLEMENTED YET UNDER BSD}
  15. begin // perhaps it is better to implement the hack from solaris then this msg
  16. HALT;
  17. END;
  18. if (pointer(func)=nil) or (sp=nil) then
  19. begin
  20. Lfpseterrno(EsysEInval);
  21. exit(-1);
  22. end;
  23. asm
  24. { Insert the argument onto the new stack. }
  25. movl sp,%ecx
  26. subl $8,%ecx
  27. movl args,%eax
  28. movl %eax,4(%ecx)
  29. { Save the function pointer as the zeroth argument.
  30. It will be popped off in the child in the ebx frobbing below. }
  31. movl func,%eax
  32. movl %eax,0(%ecx)
  33. { Do the system call }
  34. pushl %ebx
  35. pushl %ebx
  36. // movl flags,%ebx
  37. movl $251,%eax
  38. int $0x80
  39. popl %ebx
  40. popl %ebx
  41. test %eax,%eax
  42. jnz .Lclone_end
  43. { We're in the new thread }
  44. subl %ebp,%ebp { terminate the stack frame }
  45. call *%ebx
  46. { exit process }
  47. movl %eax,%ebx
  48. movl $1,%eax
  49. int $0x80
  50. .Lclone_end:
  51. movl %eax,__RESULT
  52. end;
  53. end;
  54. *)
  55. Function fsync (fd : cint) : cint;
  56. begin
  57. fsync:=do_syscall(syscall_nr_fsync,fd);
  58. end;
  59. Function fpFlock (fd,mode : longint) : cint;
  60. begin
  61. fpFlock:=do_syscall(syscall_nr_flock,fd,mode);
  62. end;
  63. Function fStatFS(Fd:Longint;Var Info:tstatfs):cint;
  64. {
  65. Get all information on a fileSystem, and return it in Info.
  66. Fd is the file descriptor of a file/directory on the fileSystem
  67. you wish to investigate.
  68. }
  69. begin
  70. fStatFS:=do_syscall(syscall_nr_fstatfs,fd,longint(@info));
  71. end;
  72. Function StatFS(path:pchar;Var Info:tstatfs):cint;
  73. {
  74. Get all information on a fileSystem, and return it in Info.
  75. Fd is the file descriptor of a file/directory on the fileSystem
  76. you wish to investigate.
  77. }
  78. begin
  79. StatFS:=do_syscall(syscall_nr_statfs,longint(path),longint(@info));
  80. end;
  81. // needs oldfpccall;
  82. Function intAssignPipe(var pipe_in,pipe_out:longint;var errn:cint):cint; {$ifndef ver1_0} oldfpccall;{$endif}
  83. {
  84. Sets up a pair of file variables, which act as a pipe. The first one can
  85. be read from, the second one can be written to.
  86. If the operation was unsuccesful, linuxerror is set.
  87. }
  88. begin
  89. asm
  90. mov $42,%eax
  91. int $0x80
  92. jb .Lerror
  93. mov pipe_in,%ebx
  94. mov %eax,(%ebx)
  95. mov pipe_out,%ebx
  96. mov $0,%eax
  97. mov %edx,(%ebx)
  98. mov %eax,%ebx
  99. jmp .Lexit
  100. .Lerror:
  101. mov %eax,%ebx
  102. mov $-1,%eax
  103. .Lexit:
  104. mov Errn,%edx
  105. mov %ebx,(%edx)
  106. end;
  107. end;
  108. function MUnMap (P : Pointer; Size : size_t) : cint;
  109. begin
  110. MUnMap:=do_syscall(syscall_nr_munmap,longint(P),Size);
  111. end;
  112. {
  113. $Log$
  114. Revision 1.1 2005-02-13 20:01:37 peter
  115. * include file cleanup
  116. Revision 1.8 2004/11/14 12:21:08 marco
  117. * moved some calls from unix to baseunix. Darwin untested.
  118. Revision 1.7 2004/11/03 15:00:43 marco
  119. * Pathstr eliminated
  120. Revision 1.6 2004/07/03 22:48:49 marco
  121. * small fix for 1.0.x cycling
  122. Revision 1.5 2004/04/22 16:22:10 marco
  123. * fpnice fixes
  124. Revision 1.4 2004/01/01 17:07:21 marco
  125. * few small freebsd fixes backported from debugging linux
  126. }