Browse Source

* fixed FPC_USE_LIBC building for Linux and exception handling (mantis #13450)
- fixed a platform modifier in ipc.pp
- fixed different layout sigaction record in libc. (field order)
- fixed many bad use_libc fixes in linux. Most of these were only checked
for compilation, not linking. (e.g. futex doesn't link)

git-svn-id: trunk@18042 -

marco 14 years ago
parent
commit
2c00a2a0b3
3 changed files with 24 additions and 9 deletions
  1. 13 7
      rtl/linux/linux.pp
  2. 10 1
      rtl/linux/signal.inc
  3. 1 1
      rtl/unix/ipc.pp

+ 13 - 7
rtl/linux/linux.pp

@@ -105,14 +105,16 @@ const
 function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec;addr2:Pcint;val3:cint):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec;addr2:Pcint;val3:cint):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;timeout:Ptimespec;var addr2;val3:cint):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;timeout:Ptimespec;var addr2;val3:cint):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;var timeout:Ttimespec;var addr2;val3:cint):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;var timeout:Ttimespec;var addr2;val3:cint):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
-{$else}
-function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec;addr2:Pcint;val3:cint):cint; cdecl; external name 'futex';
-function futex(var uaddr;op,val:cint;timeout:Ptimespec;var addr2;val3:cint):cint; cdecl; external name 'futex';
-function futex(var uaddr;op,val:cint;var timeout:Ttimespec;var addr2;val3:cint):cint; cdecl; external name 'futex';
-{$endif}
+// general aliases:
 function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;timeout:Ptimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;timeout:Ptimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;var timeout:Ttimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(var uaddr;op,val:cint;var timeout:Ttimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$else}
+// futex is currently not exposed by glibc
+//function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec;addr2:Pcint;val3:cint):cint; cdecl; external name 'futex';
+//function futex(var uaddr;op,val:cint;timeout:Ptimespec;var addr2;val3:cint):cint; cdecl; external name 'futex';
+//function futex(var uaddr;op,val:cint;var timeout:Ttimespec;var addr2;val3:cint):cint; cdecl; external name 'futex';
+{$endif}
 
 
 {$ifndef FPC_USE_LIBC}
 {$ifndef FPC_USE_LIBC}
 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}
@@ -204,6 +206,7 @@ type
 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}
 
 
+{$ifndef FPC_USE_LIBC}
 {$if defined(cpui386) or defined(cpux86_64)}
 {$if defined(cpui386) or defined(cpux86_64)}
 const
 const
   MODIFY_LDT_CONTENTS_DATA       = 0;
   MODIFY_LDT_CONTENTS_DATA       = 0;
@@ -234,6 +237,7 @@ type
 
 
 function modify_ldt(func:cint;p:pointer;bytecount:culong):cint;
 function modify_ldt(func:cint;p:pointer;bytecount:culong):cint;
 {$endif cpui386 or cpux86_64}
 {$endif cpui386 or cpux86_64}
+{$endif}
 
 
 procedure sched_yield; {$ifdef FPC_USE_LIBC} cdecl; external name 'sched_yield'; {$endif}
 procedure sched_yield; {$ifdef FPC_USE_LIBC} cdecl; external name 'sched_yield'; {$endif}
 
 
@@ -532,7 +536,7 @@ end;
 {$else}
 {$else}
 
 
 {Libc case.}
 {Libc case.}
-
+(*
 function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function futex(uaddr:Pcint;op,val:cint;timeout:Ptimespec):cint;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 
 begin
 begin
@@ -550,9 +554,10 @@ function futex(var uaddr;op,val:cint;var timeout:Ttimespec):cint;{$ifdef SYSTEMI
 begin
 begin
   futex:=futex(@uaddr,op,val,@timeout,nil,0);
   futex:=futex(@uaddr,op,val,@timeout,nil,0);
 end;
 end;
-
+*)
 {$endif} // non-libc
 {$endif} // non-libc
 
 
+{$ifndef FPC_USE_LIBC}
 {$if defined(cpui386) or defined(cpux86_64)}
 {$if defined(cpui386) or defined(cpux86_64)}
 { does not exist as a wrapper in glibc, and exists only for x86 }
 { does not exist as a wrapper in glibc, and exists only for x86 }
 function modify_ldt(func:cint;p:pointer;bytecount:culong):cint;
 function modify_ldt(func:cint;p:pointer;bytecount:culong):cint;
@@ -563,6 +568,7 @@ begin
                                                Tsysparam(bytecount));
                                                Tsysparam(bytecount));
 end;
 end;
 {$endif}
 {$endif}
+{$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}

+ 10 - 1
rtl/linux/signal.inc

@@ -195,10 +195,19 @@ type
   tsigrestorerhandler = sigrestorerhandler_t;
   tsigrestorerhandler = sigrestorerhandler_t;
   
   
   psigactionrec = ^sigactionrec;
   psigactionrec = ^sigactionrec;
+
+{$ifdef FPC_USE_LIBC}  // libc order is different ?
+  sigactionrec = record
+    sa_handler: sigactionhandler_t;
+    sa_mask: sigset_t;
+    sa_flags: cint;
+    sa_restorer: sigrestorerhandler_t;
+  end;
+{$else}
   sigactionrec = record
   sigactionrec = record
     sa_handler: sigactionhandler_t;
     sa_handler: sigactionhandler_t;
     sa_flags: culong;
     sa_flags: culong;
     sa_restorer: sigrestorerhandler_t;
     sa_restorer: sigrestorerhandler_t;
     sa_mask: sigset_t;
     sa_mask: sigset_t;
   end;
   end;
-
+{$endif}

+ 1 - 1
rtl/unix/ipc.pp

@@ -551,7 +551,7 @@ Function semget(key:Tkey; nsems:cint; semflg:cint): cint; {$ifdef FPC_USE_LIBC}
 Function semop(semid:cint; sops: psembuf; nsops: cuint): cint; {$ifdef FPC_USE_LIBC} cdecl; external clib name 'semop'; {$endif}
 Function semop(semid:cint; sops: psembuf; nsops: cuint): cint; {$ifdef FPC_USE_LIBC} cdecl; external clib name 'semop'; {$endif}
 Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
 Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
 {$ifdef linux}
 {$ifdef linux}
-Function semtimedop(semid:cint; sops: psembuf; nsops: cuint; timeOut: ptimespec): cint; platform; {$ifdef FPC_USE_LIBC} cdecl; external name 'semtimedop'; {$endif}
+Function semtimedop(semid:cint; sops: psembuf; nsops: cuint; timeOut: ptimespec): cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'semtimedop'; platform; {$else} platform; {$endif}
 {$endif}
 {$endif}
 
 
 implementation
 implementation