Bläddra i källkod

--- Merging r15602 into '.':
U rtl/unix/oscdeclh.inc
U rtl/unix/bunxh.inc
U rtl/bsd/bunxsysc.inc
C rtl/freebsd/sysnr.inc
U rtl/linux/bunxsysc.inc
U rtl/linux/linux.pp
--- Merging r15605 into '.':
G rtl/unix/oscdeclh.inc
--- Merging r15620 into '.':
G rtl/unix/oscdeclh.inc
--- Merging r15838 into '.':
G rtl/linux/linux.pp
Summary of conflicts:
Text conflicts: 1

# revisions: 15602,15605,15620,15838
------------------------------------------------------------------------
r15602 | daniel | 2010-07-18 23:53:26 +0200 (Sun, 18 Jul 2010) | 5 lines
Changed paths:
M /trunk/rtl/bsd/bunxsysc.inc
M /trunk/rtl/freebsd/sysnr.inc
M /trunk/rtl/linux/bunxsysc.inc
M /trunk/rtl/linux/linux.pp
M /trunk/rtl/unix/bunxh.inc
M /trunk/rtl/unix/oscdeclh.inc

+ Add modify_ldt to linux unit
+ Add sched_yield to linux unit
- Remove clone for m68k from linux unit (unimplemented assembler section)
+ Add fpsigtimedwait to baseunix unit

------------------------------------------------------------------------
------------------------------------------------------------------------
r15605 | jonas | 2010-07-19 00:07:33 +0200 (Mon, 19 Jul 2010) | 2 lines
Changed paths:
M /trunk/rtl/unix/oscdeclh.inc

- disabled fpsigtimedwait for darwin because it doesn't exist there

------------------------------------------------------------------------
------------------------------------------------------------------------
r15620 | jonas | 2010-07-20 22:54:04 +0200 (Tue, 20 Jul 2010) | 3 lines
Changed paths:
M /trunk/rtl/unix/oscdeclh.inc

- disabled FpSigTimedWait also for haiku (based on patch by
Olivier Coursiere, mantis #16996)

------------------------------------------------------------------------
------------------------------------------------------------------------
r15838 | jonas | 2010-08-17 23:34:09 +0200 (Tue, 17 Aug 2010) | 5 lines
Changed paths:
M /trunk/rtl/linux/linux.pp

- disabled modify_ldt for non-x86 platforms, since it does not exist there
(mantis #17100)
* also use a syscall to call modify_ldt when FPC_USE_LIBC is defined,
because it's not exported as a function from libc

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@17618 -

marco 14 år sedan
förälder
incheckning
9e321bd8ea
5 ändrade filer med 59 tillägg och 46 borttagningar
  1. 10 0
      rtl/bsd/bunxsysc.inc
  2. 13 0
      rtl/linux/bunxsysc.inc
  3. 27 42
      rtl/linux/linux.pp
  4. 5 4
      rtl/unix/bunxh.inc
  5. 4 0
      rtl/unix/oscdeclh.inc

+ 10 - 0
rtl/bsd/bunxsysc.inc

@@ -50,6 +50,16 @@ begin
   FPsigsuspend:= do_syscall(syscall_nr_sigsuspend,TSysParam(@sigmask));
 end;
 
+function fpsigtimedwait(const sigset:TSigSet;info:Psiginfo;timeout:Ptimespec):cint;
+
+begin
+  FpSigTimedWait:=do_syscall(syscall_nr_sigtimedwait,
+                             Tsysparam(@sigset),
+                             Tsysparam(info),
+                             Tsysparam(timeout));
+end;
+
+
 Type // implementation side for now. Should move to BSD unit.
   ITimerVal= Record
               It_Interval,

+ 13 - 0
rtl/linux/bunxsysc.inc

@@ -50,6 +50,19 @@ begin
   fpsigsuspend:= do_syscall(syscall_nr_rt_sigsuspend,TSysParam(@sigmask),TSysParam(8));
 end;
 
+function fpsigtimedwait(const sigset:TSigSet;info:Psiginfo;timeout:Ptimespec):cint;
+
+begin
+  {Sizeof(Tsigset)=16 for Free Pascal, but the Linux kernel has a different idea,
+   it wants a Tsigset of 8 bytes. So we have to hardcode :( }
+  FpSigTimedWait:=do_syscall(syscall_nr_rt_sigtimedwait,
+                             Tsysparam(@sigset),
+                             Tsysparam(info),
+                             Tsysparam(timeout),
+                             Tsysparam(8 {sizeof(Tsigset)}));
+end;
+
+
 Type
   ITimerVal= Record
               It_Interval,

+ 27 - 42
rtl/linux/linux.pp

@@ -199,14 +199,12 @@ type
 {$ifdef cpui386}
   {$define clone_implemented}
 {$endif}
-{$ifdef cpum68k}
-  {$define clone_implemented}
-{$endif}
 
 {$ifdef clone_implemented}
 function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; {$ifdef FPC_USE_LIBC} cdecl; external name 'clone'; {$endif}
 {$endif}
 
+{$if defined(cpui386) or defined(cpux86_64)}
 const
   MODIFY_LDT_CONTENTS_DATA       = 0;
   MODIFY_LDT_CONTENTS_STACK      = 1;
@@ -234,6 +232,10 @@ type
   TUser_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
   EPoll_Data = record
@@ -349,9 +351,12 @@ function fdatasync (fd: cint): cint; {$ifdef FPC_USE_LIBC} cdecl; external name
 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;
+{$endif not defined(FPC_USE_LIBC) or defined(cpui386) or defined(cpux86_64)}
 
+{$ifndef FPC_USE_LIBC}
 function Sysinfo(Info: PSysinfo): cInt;
 begin
   Sysinfo := do_SysCall(SysCall_nr_Sysinfo, TSysParam(info));
@@ -380,7 +385,7 @@ begin
         { Do the system call }
         pushl   %ebx
         movl    flags,%ebx
-        movl    SysCall_nr_clone,%eax
+        movl    syscall_nr_clone,%eax
         int     $0x80
         popl    %ebx
         test    %eax,%eax
@@ -391,52 +396,21 @@ begin
         call    *%ebx
         { exit process }
         movl    %eax,%ebx
-        movl    $1,%eax
+        movl    syscall_nr_exit,%eax
         int     $0x80
 
 .Lclone_end:
         movl    %eax,__RESULT
   end;
 {$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;
-{$endif}
 
 function epoll_create(size: cint): cint;
 begin
@@ -579,6 +553,17 @@ end;
 
 {$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}
 function FUTEX_OP(op, oparg, cmp, cmparg: cint): cint; {$ifdef SYSTEMINLINE}inline;{$endif}
 begin

+ 5 - 4
rtl/unix/bunxh.inc

@@ -20,10 +20,11 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
 
 // if you are looking for macro definitions or non C template overloaded versions, they are moved to bunxovlh.inc
 
-    Function  FpSigProcMask(how : cInt; nset : pSigSet; oset : pSigSet): cInt; external name 'FPC_SYSC_SIGPROCMASK';
-    Function  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt; external name 'FPC_SYSC_SIGPROCMASK';
-    Function  FpSigPending (var nset : TSigSet): cInt;
-    Function  FpSigSuspend (Const sigmask : TSigSet): cInt;
+    Function  FpSigProcMask  (how : cInt; nset : pSigSet; oset : pSigSet): cInt; external name 'FPC_SYSC_SIGPROCMASK';
+    Function  FpSigProcMask  (how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt; external name 'FPC_SYSC_SIGPROCMASK';
+    Function  FpSigPending   (var nset : TSigSet): cInt;
+    Function  FpSigSuspend   (Const sigmask : TSigSet): cInt;
+    Function  FpSigTimedWait (Const sigset : TSigSet; info : Psiginfo; timeout:Ptimespec): cInt;
 
     Function  FpUmask      (cmask : TMode): TMode;
     Function  FpLink       (existing : pChar; newone : pChar): cInt;

+ 4 - 0
rtl/unix/oscdeclh.inc

@@ -65,6 +65,10 @@ const
     Function  FpGetcwd  (path:pChar; siz:TSize):pChar; cdecl;  external clib name 'getcwd';
     function  FPSigProcMask(how:cint;nset : psigset;oset : psigset):cint;cdecl; external clib name 'sigprocmask';
     function  FPSigProcMask(how:cint;const nset : sigset;var oset : sigset):cint;cdecl; external clib name 'sigprocmask';
+{$if not defined(darwin) and not defined(haiku)}
+    Function  FpSigTimedWait (Const sigset : TSigSet; info : Psiginfo; timeout:Ptimespec): cInt; cdecl; external clib name 'sigtimedwait';
+    Function  FpSigTimedWait (Const sigset : TSigSet; info : Psiginfo; var timeout:Ttimespec): cInt; cdecl; external clib name 'sigtimedwait';
+{$endif}
     function  FpTime       (tloc:ptime_t): time_t; cdecl; external clib name 'time';
     Function  FpTime       (var tloc : Time_t): Time_t; cdecl; external clib name 'time';
     function  FpTimes	(var buffer : tms): TClock; cdecl; external clib name 'times';