|
@@ -199,14 +199,12 @@ type
|
|
{$ifdef cpui386}
|
|
{$ifdef cpui386}
|
|
{$define clone_implemented}
|
|
{$define clone_implemented}
|
|
{$endif}
|
|
{$endif}
|
|
-{$ifdef cpum68k}
|
|
|
|
- {$define clone_implemented}
|
|
|
|
-{$endif}
|
|
|
|
|
|
|
|
{$ifdef clone_implemented}
|
|
{$ifdef clone_implemented}
|
|
function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; {$ifdef FPC_USE_LIBC} cdecl; external name 'clone'; {$endif}
|
|
function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; {$ifdef FPC_USE_LIBC} cdecl; external name 'clone'; {$endif}
|
|
{$endif}
|
|
{$endif}
|
|
|
|
|
|
|
|
+{$if defined(cpui386) or defined(cpux86_64)}
|
|
const
|
|
const
|
|
MODIFY_LDT_CONTENTS_DATA = 0;
|
|
MODIFY_LDT_CONTENTS_DATA = 0;
|
|
MODIFY_LDT_CONTENTS_STACK = 1;
|
|
MODIFY_LDT_CONTENTS_STACK = 1;
|
|
@@ -234,6 +232,10 @@ type
|
|
TUser_Desc = user_desc;
|
|
TUser_Desc = user_desc;
|
|
PUser_Desc = ^user_desc;
|
|
PUser_Desc = ^user_desc;
|
|
|
|
|
|
|
|
+function modify_ldt(func:cint;p:pointer;bytecount:culong):cint;
|
|
|
|
+{$endif cpui386 or cpux86_64}
|
|
|
|
+
|
|
|
|
+procedure sched_yield; {$ifdef FPC_USE_LIBC} cdecl; external name 'sched_yield'; {$endif}
|
|
|
|
|
|
type
|
|
type
|
|
EPoll_Data = record
|
|
EPoll_Data = record
|
|
@@ -349,9 +351,12 @@ function fdatasync (fd: cint): cint; {$ifdef FPC_USE_LIBC} cdecl; external name
|
|
implementation
|
|
implementation
|
|
|
|
|
|
|
|
|
|
-{$ifndef FPC_USE_LIBC}
|
|
|
|
|
|
+{$if not defined(FPC_USE_LIBC) or defined(cpui386) or defined(cpux86_64)}
|
|
|
|
+{ needed for modify_ldt on x86 }
|
|
Uses Syscall;
|
|
Uses Syscall;
|
|
|
|
+{$endif not defined(FPC_USE_LIBC) or defined(cpui386) or defined(cpux86_64)}
|
|
|
|
|
|
|
|
+{$ifndef FPC_USE_LIBC}
|
|
function Sysinfo(Info: PSysinfo): cInt;
|
|
function Sysinfo(Info: PSysinfo): cInt;
|
|
begin
|
|
begin
|
|
Sysinfo := do_SysCall(SysCall_nr_Sysinfo, TSysParam(info));
|
|
Sysinfo := do_SysCall(SysCall_nr_Sysinfo, TSysParam(info));
|
|
@@ -380,7 +385,7 @@ begin
|
|
{ Do the system call }
|
|
{ Do the system call }
|
|
pushl %ebx
|
|
pushl %ebx
|
|
movl flags,%ebx
|
|
movl flags,%ebx
|
|
- movl SysCall_nr_clone,%eax
|
|
|
|
|
|
+ movl syscall_nr_clone,%eax
|
|
int $0x80
|
|
int $0x80
|
|
popl %ebx
|
|
popl %ebx
|
|
test %eax,%eax
|
|
test %eax,%eax
|
|
@@ -391,52 +396,21 @@ begin
|
|
call *%ebx
|
|
call *%ebx
|
|
{ exit process }
|
|
{ exit process }
|
|
movl %eax,%ebx
|
|
movl %eax,%ebx
|
|
- movl $1,%eax
|
|
|
|
|
|
+ movl syscall_nr_exit,%eax
|
|
int $0x80
|
|
int $0x80
|
|
|
|
|
|
.Lclone_end:
|
|
.Lclone_end:
|
|
movl %eax,__RESULT
|
|
movl %eax,__RESULT
|
|
end;
|
|
end;
|
|
{$endif cpui386}
|
|
{$endif cpui386}
|
|
-{$ifdef cpum68k}
|
|
|
|
- { No yet translated, my m68k assembler is too weak for such things PM }
|
|
|
|
-(*
|
|
|
|
- asm
|
|
|
|
- { Insert the argument onto the new stack. }
|
|
|
|
- movl sp,%ecx
|
|
|
|
- subl $8,%ecx
|
|
|
|
- movl args,%eax
|
|
|
|
- movl %eax,4(%ecx)
|
|
|
|
-
|
|
|
|
- { Save the function pointer as the zeroth argument.
|
|
|
|
- It will be popped off in the child in the ebx frobbing below. }
|
|
|
|
- movl func,%eax
|
|
|
|
- movl %eax,0(%ecx)
|
|
|
|
-
|
|
|
|
- { Do the system call }
|
|
|
|
- pushl %ebx
|
|
|
|
- movl flags,%ebx
|
|
|
|
- movl SysCall_nr_clone,%eax
|
|
|
|
- int $0x80
|
|
|
|
- popl %ebx
|
|
|
|
- test %eax,%eax
|
|
|
|
- jnz .Lclone_end
|
|
|
|
|
|
+end;
|
|
|
|
+{$endif}
|
|
|
|
|
|
- { We're in the new thread }
|
|
|
|
- subl %ebp,%ebp { terminate the stack frame }
|
|
|
|
- call *%ebx
|
|
|
|
- { exit process }
|
|
|
|
- movl %eax,%ebx
|
|
|
|
- movl $1,%eax
|
|
|
|
- int $0x80
|
|
|
|
|
|
+procedure sched_yield;
|
|
|
|
|
|
-.Lclone_end:
|
|
|
|
- movl %eax,__RESULT
|
|
|
|
- end;
|
|
|
|
- *)
|
|
|
|
-{$endif cpum68k}
|
|
|
|
|
|
+begin
|
|
|
|
+ do_syscall(syscall_nr_sched_yield);
|
|
end;
|
|
end;
|
|
-{$endif}
|
|
|
|
|
|
|
|
function epoll_create(size: cint): cint;
|
|
function epoll_create(size: cint): cint;
|
|
begin
|
|
begin
|
|
@@ -579,6 +553,17 @@ end;
|
|
|
|
|
|
{$endif} // non-libc
|
|
{$endif} // non-libc
|
|
|
|
|
|
|
|
+{$if defined(cpui386) or defined(cpux86_64)}
|
|
|
|
+{ does not exist as a wrapper in glibc, and exists only for x86 }
|
|
|
|
+function modify_ldt(func:cint;p:pointer;bytecount:culong):cint;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ modify_ldt:=do_syscall(syscall_nr_modify_ldt,Tsysparam(func),
|
|
|
|
+ Tsysparam(p),
|
|
|
|
+ Tsysparam(bytecount));
|
|
|
|
+end;
|
|
|
|
+{$endif}
|
|
|
|
+
|
|
{ FUTEX_OP is a macro, doesn't exist in libC as function}
|
|
{ FUTEX_OP is a macro, doesn't exist in libC as function}
|
|
function FUTEX_OP(op, oparg, cmp, cmparg: cint): cint; {$ifdef SYSTEMINLINE}inline;{$endif}
|
|
function FUTEX_OP(op, oparg, cmp, cmparg: cint): cint; {$ifdef SYSTEMINLINE}inline;{$endif}
|
|
begin
|
|
begin
|