2
$Id: unixsysc.inc,v 1.7 2004/03/04 13:10:30 olle Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 2000 by Marco van de Voort
5
member of the Free Pascal development team.
7
See the file COPYING.FPC, included in this distribution,
8
for details about the copyright.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY;without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
**********************************************************************}
17
function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
18
{NOT IMPLEMENTED YET UNDER BSD}
19
begin // perhaps it is better to implement the hack from solaris then this msg
23
if (pointer(func)=nil) or (sp=nil) then
25
Lfpseterrno(EsysEInval);
29
{ Insert the argument onto the new stack. }
35
{ Save the function pointer as the zeroth argument.
36
It will be popped off in the child in the ebx frobbing below. }
40
{ Do the system call }
51
{ We're in the new thread }
52
subl %ebp,%ebp { terminate the stack frame }
65
{$ifndef FPC_USE_LIBC}
66
Function fsync (fd : cint) : cint;
69
fsync:=do_syscall(syscall_nr_fsync,fd);
72
Function Flock (fd,mode : longint) : cint;
75
Flock:=do_syscall(syscall_nr_flock,fd,mode);
78
Function fStatFS(Fd:Longint;Var Info:tstatfs):cint;
80
Get all information on a fileSystem, and return it in Info.
81
Fd is the file descriptor of a file/directory on the fileSystem
82
you wish to investigate.
86
fStatFS:=do_syscall(syscall_nr_fstatfs,fd,longint(@info));
89
Function StatFS(path:pchar;Var Info:tstatfs):cint;
91
Get all information on a fileSystem, and return it in Info.
92
Fd is the file descriptor of a file/directory on the fileSystem
93
you wish to investigate.
97
StatFS:=do_syscall(syscall_nr_statfs,longint(path),longint(@info));
101
Function intAssignPipe(var pipe_in,pipe_out:longint;var errn:cint):cint; {$ifndef ver1_0} oldfpccall;{$endif}
103
Sets up a pair of file variables, which act as a pipe. The first one can
104
be read from, the second one can be written to.
105
If the operation was unsuccesful, linuxerror is set.
132
Function PClose(Var F:text) :cint;
138
do_syscall(syscall_nr_close,Textrec(F).Handle);
139
{ closed our side, Now wait for the other - this appears to be needed ?? }
140
pl:=@(textrec(f).userdata[2]);
141
fpwaitpid(pl^,@res,0);
145
Function PClose(Var F:file) : cint;
151
do_syscall(syscall_nr_close,filerec(F).Handle);
152
{ closed our side, Now wait for the other - this appears to be needed ?? }
153
pl:=@(filerec(f).userdata[2]);
154
fpwaitpid(pl^,@res,0);
158
function MUnMap (P : Pointer; Size : size_t) : cint;
161
MUnMap:=do_syscall(syscall_nr_munmap,longint(P),Size);
165
Function PClose(Var F:file) : cint;
171
fpclose(filerec(F).Handle);
172
{ closed our side, Now wait for the other - this appears to be needed ?? }
173
pl:=@(filerec(f).userdata[2]);
174
fpwaitpid(pl^,@res,0);
178
Function PClose(Var F:text) :cint;
184
fpclose(Textrec(F).Handle);
185
{ closed our side, Now wait for the other - this appears to be needed ?? }
186
pl:=@(textrec(f).userdata[2]);
187
fpwaitpid(pl^,@res,0);
192
// can't have oldfpccall here, linux doesn't need it.
193
Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
195
Sets up a pair of file variables, which act as a pipe. The first one can
196
be read from, the second one can be written to.
197
If the operation was unsuccesful, linuxerror is set.
202
{$ifdef FPC_USE_LIBC}
203
fdis : array[0..1] of cint;
206
{$ifndef FPC_USE_LIBC}
207
ret:=intAssignPipe(pipe_in,pipe_out,errn);
222
function intClone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; {$ifndef ver1_0} oldfpccall; {$endif}
225
var lerrno : Longint;
233
movl 12(%ebp), %esi // get stack addr
235
movl 20(%ebp), %eax // get __arg
238
movl 8(%ebp), %eax // get __fn
242
mov syscall_nr_rfork, %eax
243
int $0x80 // call actualsyscall
251
call halt // Does not return
269
function Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
273
intclone(tclonefunc(func),sp,flags,args);
279
$Log: unixsysc.inc,v $
280
Revision 1.7 2004/03/04 13:10:30 olle
281
+ added comment to ETXTBSY
282
* changed i386 -> cpui386, m68k -> cpum68k
284
Revision 1.6 2004/01/04 15:55:47 marco
287
Revision 1.5 2004/01/04 01:11:28 marco
288
* a new qod port of the freebsd rtl. To be refined in the coming days.
290
Revision 1.18 2004/01/01 17:07:21 marco
291
* few small freebsd fixes backported from debugging linux
293
Revision 1.17 2003/12/30 12:32:30 marco
294
*** empty log message ***
296
Revision 1.16 2003/11/19 17:11:40 marco
299
Revision 1.15 2003/11/19 10:12:02 marco
302
Revision 1.14 2003/11/17 10:05:51 marco
303
* threads for FreeBSD. Not working tho
305
Revision 1.13 2003/11/14 16:21:59 marco
306
* linuxerror elimination
308
Revision 1.12 2003/11/09 12:00:16 marco
311
Revision 1.11 2003/09/20 12:38:29 marco
312
* FCL now compiles for FreeBSD with new 1.1. Now Linux.
314
Revision 1.10 2003/09/15 20:08:49 marco
315
* small fixes. FreeBSD now cycles
317
Revision 1.9 2003/09/15 07:09:58 marco
318
* small fixes, round 1
320
Revision 1.8 2003/09/14 20:15:01 marco
321
* Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
323
Revision 1.7 2003/01/05 19:02:29 marco
324
* Should now work with baseunx. (gmake all works)
326
Revision 1.6 2002/10/18 12:19:59 marco
327
* Fixes to get the generic *BSD RTL compiling again + fixes for thread
328
support. Still problems left in fexpand. (inoutres?) Therefore fixed
329
sysposix not yet commited
331
Revision 1.5 2002/09/07 16:01:18 peter
332
* old logs removed and tabs fixed
334
Revision 1.4 2002/05/06 09:35:09 marco
335
* Some stuff from 1.0.x ported