* 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 -
This commit is contained in:
tom_at_work 2005-10-15 21:24:15 +00:00
parent 810ec85e34
commit 701638138b
6 changed files with 37 additions and 25 deletions

View File

@ -21,10 +21,10 @@
{$ifndef 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 }
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
if count <= 0 then
exit;
@ -35,9 +35,9 @@ end;
{$ifndef 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
if count <= 0 then
exit;
@ -48,7 +48,7 @@ end;
{$ifndef 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
if count <= 0 then
exit;
@ -60,9 +60,9 @@ end;
{$ifndef 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
res: pointer;
begin
@ -82,7 +82,7 @@ end;
{$ifndef 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
IndexByte:=IndexChar(buf,len,char(b));
end;
@ -91,9 +91,9 @@ end;
{$ifndef 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
res: longint;
begin
@ -112,7 +112,7 @@ end;
{$ifndef 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
CompareByte := CompareChar(buf1,buf2,len);
end;
@ -121,9 +121,9 @@ end;
{$ifndef 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
if len <= 0 then
exit(0);
@ -137,7 +137,7 @@ end;
{$ifndef 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;
begin

View File

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

View File

@ -31,10 +31,16 @@ CONST
{$endif}
FD_MAXFDSET = 1024;
BITSINWORD = 8*sizeof(longint);
BITSINWORD = 8*sizeof(cuLong);
wordsinsigset = SIG_MAXSIG DIV BITSINWORD; // words in sigset_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;

View File

@ -84,13 +84,16 @@ begin
writeln('sigcontext^...regs = ', hexstr(ptrint(sigcontext^.regs), 16));
{$ENDIF}
// reenable signals
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;

View File

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

View File

@ -111,8 +111,8 @@ begin
fillchar(e,sizeof(e),#0);
{ set is 1 based PM }
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;
fpsigprocmask(SIG_UNBLOCK,@e,nil);
reenable_signal:=geterrno=0;