unxsysc.inc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 Marco van de Voort
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY;without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. (*
  12. function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
  13. {NOT IMPLEMENTED YET UNDER BSD}
  14. begin // perhaps it is better to implement the hack from solaris then this msg
  15. HALT;
  16. END;
  17. if (pointer(func)=nil) or (sp=nil) then
  18. begin
  19. Lfpseterrno(EsysEInval);
  20. exit(-1);
  21. end;
  22. asm
  23. { Insert the argument onto the new stack. }
  24. movl sp,%ecx
  25. subl $8,%ecx
  26. movl args,%eax
  27. movl %eax,4(%ecx)
  28. { Save the function pointer as the zeroth argument.
  29. It will be popped off in the child in the ebx frobbing below. }
  30. movl func,%eax
  31. movl %eax,0(%ecx)
  32. { Do the system call }
  33. pushl %ebx
  34. pushl %ebx
  35. // movl flags,%ebx
  36. movl $251,%eax
  37. int $0x80
  38. popl %ebx
  39. popl %ebx
  40. test %eax,%eax
  41. jnz .Lclone_end
  42. { We're in the new thread }
  43. subl %ebp,%ebp { terminate the stack frame }
  44. call *%ebx
  45. { exit process }
  46. movl %eax,%ebx
  47. movl $1,%eax
  48. int $0x80
  49. .Lclone_end:
  50. movl %eax,__RESULT
  51. end;
  52. end;
  53. *)
  54. Function fpfStatFS (Fd: cint; Info:pstatfs):cint;
  55. begin
  56. fpfstatfs:=do_SysCall(SysCall_nr_fstatfs,fd,TSysParam(info))
  57. end;
  58. Function fpStatFS (Path:pchar; Info:pstatfs):cint;
  59. begin
  60. fpstatfs:=do_SysCall(SysCall_nr_statfs,TSysParam(path),TSysParam(Info))
  61. end;
  62. Function fpfsync (fd : cint) : cint;
  63. begin
  64. fpfsync:=do_SysCall(syscall_nr_fsync, fd);
  65. end;
  66. Function fpFlock (fd,mode : longint) : cint;
  67. begin
  68. fpFlock:=do_syscall(syscall_nr_flock,fd,mode);
  69. end;
  70. // needs oldfpccall;
  71. Function intAssignPipe(var pipe_in,pipe_out:longint;var errn:cint):cint; oldfpccall;
  72. {
  73. Sets up a pair of file variables, which act as a pipe. The first one can
  74. be read from, the second one can be written to.
  75. If the operation was unsuccesful, linuxerror is set.
  76. }
  77. begin
  78. asm
  79. mov $42,%eax
  80. int $0x80
  81. jb .Lerror
  82. mov pipe_in,%ebx
  83. mov %eax,(%ebx)
  84. mov pipe_out,%ebx
  85. mov $0,%eax
  86. mov %edx,(%ebx)
  87. mov %eax,%ebx
  88. jmp .Lexit
  89. .Lerror:
  90. mov %eax,%ebx
  91. mov $-1,%eax
  92. .Lexit:
  93. mov Errn,%edx
  94. mov %ebx,(%edx)
  95. end;
  96. end;
  97. function MUnMap (P : Pointer; Size : size_t) : cint;
  98. begin
  99. MUnMap:=do_syscall(syscall_nr_munmap,longint(P),Size);
  100. end;