Browse Source

* fixed exception handling for PowerPC64
* math library is now automatically linked on non-x86 platforms when FPC_USE_LIBC is defined
* generic C system function signature adaptions for 64 bit CPUs

git-svn-id: trunk@1392 -

tom_at_work 20 years ago
parent
commit
701638138b

+ 14 - 14
rtl/inc/cgeneric.inc

@@ -21,10 +21,10 @@
 
 
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
-procedure bcopy(const source;var dest;count:cardinal); cdecl; external 'c' name 'bcopy';
+procedure bcopy(const source;var dest;count:sizeuint); cdecl; external 'c' name 'bcopy';
 
 
 { we need this separate move declaration because we can't add a "public, alias" to the above }
 { we need this separate move declaration because we can't add a "public, alias" to the above }
-procedure Move(const source;var dest;count:longint); [public, alias: 'FPC_MOVE'];{$ifdef SYSTEMINLINE}inline;{$endif}
+procedure Move(const source;var dest;count:sizeint); [public, alias: 'FPC_MOVE'];{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   if count <= 0 then
   if count <= 0 then
     exit;
     exit;
@@ -35,9 +35,9 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
-procedure memset(var x; value: byte; count: cardinal); cdecl; external 'c';
+procedure memset(var x; value: byte; count: sizeuint); cdecl; external 'c';
 
 
-Procedure FillChar(var x;count: longint;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
+Procedure FillChar(var x;count: sizeint;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   if count <= 0 then
   if count <= 0 then
     exit;
     exit;
@@ -48,7 +48,7 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_FILLBYTE}
 {$ifndef FPC_SYSTEM_HAS_FILLBYTE}
 {$define FPC_SYSTEM_HAS_FILLBYTE}
 {$define FPC_SYSTEM_HAS_FILLBYTE}
-procedure FillByte (var x;count : longint;value : byte );{$ifdef SYSTEMINLINE}inline;{$endif}
+procedure FillByte (var x;count : sizeint;value : byte );{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   if count <= 0 then
   if count <= 0 then
     exit;
     exit;
@@ -60,9 +60,9 @@ end;
 {$ifndef FPC_SYSTEM_HAS_INDEXCHAR}
 {$ifndef FPC_SYSTEM_HAS_INDEXCHAR}
 {$define FPC_SYSTEM_HAS_INDEXCHAR}
 {$define FPC_SYSTEM_HAS_INDEXCHAR}
 
 
-function memchr(const buf; b: longint; len: cardinal): pointer; cdecl; external 'c';
+function memchr(const buf; b: sizeuint; len: cardinal): pointer; cdecl; external 'c';
 
 
-function IndexChar(Const buf;len:longint;b:char):longint;
+function IndexChar(Const buf;len:sizeint;b:char):sizeint;
 var
 var
   res: pointer;
   res: pointer;
 begin
 begin
@@ -82,7 +82,7 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
 {$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
 {$define FPC_SYSTEM_HAS_INDEXBYTE}
 {$define FPC_SYSTEM_HAS_INDEXBYTE}
-function IndexByte(Const buf;len:longint;b:byte):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+function IndexByte(Const buf;len:sizeint;b:byte):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   IndexByte:=IndexChar(buf,len,char(b));
   IndexByte:=IndexChar(buf,len,char(b));
 end;
 end;
@@ -91,9 +91,9 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR}
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR}
 {$define FPC_SYSTEM_HAS_COMPARECHAR}
 {$define FPC_SYSTEM_HAS_COMPARECHAR}
-function memcmp_comparechar(Const buf1,buf2;len:cardinal):longint; cdecl; external 'c' name 'memcmp';
+function memcmp_comparechar(Const buf1,buf2;len:sizeuint):longint; cdecl; external 'c' name 'memcmp';
 
 
-function CompareChar(Const buf1,buf2;len:longint):longint;
+function CompareChar(Const buf1,buf2;len:sizeint):sizeint;
 var
 var
   res: longint;
   res: longint;
 begin
 begin
@@ -112,7 +112,7 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
 {$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
 {$define FPC_SYSTEM_HAS_COMPAREBYTE}
 {$define FPC_SYSTEM_HAS_COMPAREBYTE}
-function CompareByte(Const buf1,buf2;len:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+function CompareByte(Const buf1,buf2;len:sizeint):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   CompareByte := CompareChar(buf1,buf2,len);
   CompareByte := CompareChar(buf1,buf2,len);
 end;
 end;
@@ -121,9 +121,9 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 {$define FPC_SYSTEM_HAS_COMPARECHAR0}
 {$define FPC_SYSTEM_HAS_COMPARECHAR0}
-function strncmp_comparechar0(Const buf1,buf2;len:cardinal):longint; cdecl; external 'c' name 'strncmp';
+function strncmp_comparechar0(Const buf1,buf2;len:sizeuint):longint; cdecl; external 'c' name 'strncmp';
 
 
-function CompareChar0(Const buf1,buf2;len:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+function CompareChar0(Const buf1,buf2;len:sizeint):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   if len <= 0 then
   if len <= 0 then
     exit(0);
     exit(0);
@@ -137,7 +137,7 @@ end;
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
 
-function libc_pchar_length(p:pchar):cardinal; cdecl; external 'c' name 'strlen';
+function libc_pchar_length(p:pchar):sizeuint; cdecl; external 'c' name 'strlen';
 
 
 function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
 function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
 begin
 begin

+ 3 - 0
rtl/linux/osdefs.inc

@@ -28,6 +28,9 @@
                                 // (which is a GNU extension)
                                 // (which is a GNU extension)
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
   {$define usegetcwd}
   {$define usegetcwd}
+  {$if not defined(cpux86) and not defined(cpux86_64)}
+  {$linklib m}
+  {$endif}
 {$endif}
 {$endif}
 
 
 
 

+ 8 - 2
rtl/linux/ostypes.inc

@@ -31,10 +31,16 @@ CONST
     {$endif}
     {$endif}
 
 
    FD_MAXFDSET     = 1024;
    FD_MAXFDSET     = 1024;
-   BITSINWORD      = 8*sizeof(longint);
+   BITSINWORD      = 8*sizeof(cuLong);
    wordsinsigset   = SIG_MAXSIG DIV BITSINWORD;         // words in sigset_t
    wordsinsigset   = SIG_MAXSIG DIV BITSINWORD;         // words in sigset_t
    wordsinfdset    = FD_MAXFDSET DIV BITSINWORD;        // words in fdset_t
    wordsinfdset    = FD_MAXFDSET DIV BITSINWORD;        // words in fdset_t
-   ln2bitsinword   = 5;         { 32bit : ln(32)/ln(2)=5 }
+   {$ifdef cpu32}
+   ln2bitsinword   = 5;                                 { 32bit : ln(32)/ln(2)=5 }
+   {$else cpu32}
+   {$ifdef cpu64}
+   ln2bitsinword   = 6;                                 { 64bit : ln(64)/ln(2)=6 }
+   {$endif cpu64}
+   {$endif cpu32}
    ln2bitmask      = 1 shl ln2bitsinword - 1;
    ln2bitmask      = 1 shl ln2bitsinword - 1;
 
 
 
 

+ 9 - 6
rtl/linux/powerpc64/sighnd.inc

@@ -84,13 +84,16 @@ begin
   
   
   writeln('sigcontext^...regs = ', hexstr(ptrint(sigcontext^.regs), 16));
   writeln('sigcontext^...regs = ', hexstr(ptrint(sigcontext^.regs), 16));
   {$ENDIF}
   {$ENDIF}
+  // reenable signals
   reenable_signal(sig);
   reenable_signal(sig);
-  { give runtime error at the position where the signal was raised }
 
 
-  if res<>0 then
-    HandleErrorAddrFrame(res, pointer(SigContext^.gp_regs[PT_NIP]), pointer(SigContext^.gp_regs[PT_R1]));
-  {$IFDEF EXCDEBUG}
-  readln;
-  {$ENDIF}
+  // give runtime error at the position where the signal was raised, using the 
+  // system trampoline
+  if res<>0 then begin
+    SigContext^.gp_regs[PT_R3] := res;
+    SigContext^.gp_regs[PT_R4] := SigContext^.gp_regs[PT_NIP];
+    SigContext^.gp_regs[PT_R5] := SigContext^.gp_regs[PT_R1];
+    SigContext^.handler := ptruint(@HandleErrorAddrFrame);
+  end;
 end;
 end;
 
 

+ 1 - 1
rtl/linux/signal.inc

@@ -124,7 +124,7 @@ const
 
 
 
 
 type
 type
-  SigSet  =  array[0..wordsinsigset-1] of cint;
+  SigSet  =  array[0..wordsinsigset-1] of cuLong;
   sigset_t= SigSet;
   sigset_t= SigSet;
   PSigSet = ^SigSet;
   PSigSet = ^SigSet;
   psigset_t=psigset;
   psigset_t=psigset;

+ 2 - 2
rtl/linux/system.pp

@@ -111,8 +111,8 @@ begin
   fillchar(e,sizeof(e),#0);
   fillchar(e,sizeof(e),#0);
   { set is 1 based PM }
   { set is 1 based PM }
   dec(sig);
   dec(sig);
-  i:=sig mod 32;
-  j:=sig div 32;
+  i:=sig mod (sizeof(cuLong) * 8);
+  j:=sig div (sizeof(cuLong) * 8);
   e[j]:=1 shl i;
   e[j]:=1 shl i;
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   reenable_signal:=geterrno=0;
   reenable_signal:=geterrno=0;