浏览代码

+ cgeneric.inc: implementations of rtl routines based on libc
* system.inc: include cgeneric.inc before powerpc.inc/i386.inc/... if
FPC_USE_LIBC is defined
* powerpc.inc, i386.inc: check whether the routines they implement aren't
implemented yet in another include file (cgeneric.inc)

Jonas Maebe 22 年之前
父节点
当前提交
5439babeb5
共有 4 个文件被更改,包括 246 次插入6 次删除
  1. 45 1
      rtl/i386/i386.inc
  2. 147 0
      rtl/inc/cgeneric.inc
  3. 13 1
      rtl/inc/system.inc
  4. 41 4
      rtl/powerpc/powerpc.inc

+ 45 - 1
rtl/i386/i386.inc

@@ -31,6 +31,7 @@ asm
   ret
   ret
 end;
 end;
 
 
+{$ifndef FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
 procedure Move(const source;var dest;count:longint);assembler;
 procedure Move(const source;var dest;count:longint);assembler;
 var
 var
@@ -111,8 +112,10 @@ asm
         movl    saveedi,%edi
         movl    saveedi,%edi
         movl    saveesi,%esi
         movl    saveesi,%esi
 end;
 end;
+{$endif FPC_SYSTEM_HAS_MOVE}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 Procedure FillChar(var x;count:longint;value:byte);assembler;
 Procedure FillChar(var x;count:longint;value:byte);assembler;
 var
 var
@@ -157,8 +160,10 @@ asm
 .LFillEnd:
 .LFillEnd:
         movl    saveedi,%edi
         movl    saveedi,%edi
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FILLCHAR}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FILLWORD}
 {$define FPC_SYSTEM_HAS_FILLWORD}
 {$define FPC_SYSTEM_HAS_FILLWORD}
 procedure fillword(var x;count : longint;value : word);assembler;
 procedure fillword(var x;count : longint;value : word);assembler;
 var
 var
@@ -192,8 +197,10 @@ asm
 .LFillWordEnd:
 .LFillWordEnd:
         movl    saveedi,%edi
         movl    saveedi,%edi
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FILLWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FILLDWORD}
 {$define FPC_SYSTEM_HAS_FILLDWORD}
 {$define FPC_SYSTEM_HAS_FILLDWORD}
 procedure filldword(var x;count : longint;value : dword);assembler;
 procedure filldword(var x;count : longint;value : dword);assembler;
 var
 var
@@ -218,8 +225,10 @@ asm
 .LFillDWordEnd:
 .LFillDWordEnd:
         movl    saveedi,%edi
         movl    saveedi,%edi
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FILLDWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
 {$define FPC_SYSTEM_HAS_INDEXBYTE}
 {$define FPC_SYSTEM_HAS_INDEXBYTE}
 function IndexByte(Const buf;len:longint;b:byte):longint; assembler;
 function IndexByte(Const buf;len:longint;b:byte):longint; assembler;
 var
 var
@@ -249,8 +258,10 @@ asm
         movl    saveedi,%edi
         movl    saveedi,%edi
         movl    saveebx,%ebx
         movl    saveebx,%ebx
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FILLDWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXWORD}
 {$define FPC_SYSTEM_HAS_INDEXWORD}
 {$define FPC_SYSTEM_HAS_INDEXWORD}
 function Indexword(Const buf;len:longint;b:word):longint; assembler;
 function Indexword(Const buf;len:longint;b:word):longint; assembler;
 var
 var
@@ -280,8 +291,10 @@ asm
         movl    saveedi,%edi
         movl    saveedi,%edi
         movl    saveebx,%ebx
         movl    saveebx,%ebx
 end;
 end;
+{$endif FPC_SYSTEM_HAS_INDEXWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
 {$define FPC_SYSTEM_HAS_INDEXDWORD}
 {$define FPC_SYSTEM_HAS_INDEXDWORD}
 function IndexDWord(Const buf;len:longint;b:DWord):longint; assembler;
 function IndexDWord(Const buf;len:longint;b:DWord):longint; assembler;
 var
 var
@@ -317,8 +330,10 @@ asm
         movl    saveedi,%edi
         movl    saveedi,%edi
         movl    saveebx,%ebx
         movl    saveebx,%ebx
 end;
 end;
+{$endif FPC_SYSTEM_HAS_INDEXDWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
 {$define FPC_SYSTEM_HAS_COMPAREBYTE}
 {$define FPC_SYSTEM_HAS_COMPAREBYTE}
 function CompareByte(Const buf1,buf2;len:longint):longint; assembler;
 function CompareByte(Const buf1,buf2;len:longint):longint; assembler;
 var
 var
@@ -371,9 +386,11 @@ asm
         movl    saveedi,%edi
         movl    saveedi,%edi
         movl    saveesi,%esi
         movl    saveesi,%esi
 end;
 end;
+{$endif FPC_SYSTEM_HAS_COMPAREBYTE}
 
 
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_COMPAREWORD}
 {$define FPC_SYSTEM_HAS_COMPAREWORD}
 {$define FPC_SYSTEM_HAS_COMPAREWORD}
 function CompareWord(Const buf1,buf2;len:longint):longint; assembler;
 function CompareWord(Const buf1,buf2;len:longint):longint; assembler;
 var
 var
@@ -438,8 +455,10 @@ asm
         movl    saveesi,%esi
         movl    saveesi,%esi
         movl    saveebx,%ebx
         movl    saveebx,%ebx
 end;
 end;
+{$endif FPC_SYSTEM_HAS_COMPAREWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_COMPAREDWORD}
 {$define FPC_SYSTEM_HAS_COMPAREDWORD}
 {$define FPC_SYSTEM_HAS_COMPAREDWORD}
 function CompareDWord(Const buf1,buf2;len:longint):longint; assembler;
 function CompareDWord(Const buf1,buf2;len:longint):longint; assembler;
 var
 var
@@ -502,8 +521,10 @@ asm
         movl    saveesi,%esi
         movl    saveesi,%esi
         movl    saveebx,%ebx
         movl    saveebx,%ebx
 end;
 end;
+{$endif FPC_SYSTEM_HAS_COMPAREDWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXCHAR0}
 {$define FPC_SYSTEM_HAS_INDEXCHAR0}
 {$define FPC_SYSTEM_HAS_INDEXCHAR0}
 function IndexChar0(Const buf;len:longint;b:Char):longint; assembler;
 function IndexChar0(Const buf;len:longint;b:Char):longint; assembler;
 var
 var
@@ -542,6 +563,7 @@ asm
         movl    saveesi,%esi
         movl    saveesi,%esi
         movl    saveebx,%ebx
         movl    saveebx,%ebx
 end;
 end;
+{$endif FPC_SYSTEM_HAS_INDEXCHAR0}
 
 
 
 
 {****************************************************************************
 {****************************************************************************
@@ -874,6 +896,7 @@ end;
                                  String
                                  String
 ****************************************************************************}
 ****************************************************************************}
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
 
 
 function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
 function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
@@ -910,6 +933,7 @@ begin
   end ['ESI','EDI','EAX','ECX'];
   end ['ESI','EDI','EAX','ECX'];
 end;
 end;
 
 
+
 {$ifdef interncopy}
 {$ifdef interncopy}
 procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
 procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
 {$else}
 {$else}
@@ -951,7 +975,10 @@ begin
         popl    %eax
         popl    %eax
   end ['ESI','EDI'];
   end ['ESI','EDI'];
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
+
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
 
 
 function fpc_shortstr_concat(const s1,s2:shortstring):shortstring;{$ifdef hascompilerproc}compilerproc;{$endif}
 function fpc_shortstr_concat(const s1,s2:shortstring):shortstring;{$ifdef hascompilerproc}compilerproc;{$endif}
@@ -1009,8 +1036,10 @@ begin
         movsb
         movsb
   end ['EBX','ECX','EAX','ESI','EDI'];
   end ['EBX','ECX','EAX','ESI','EDI'];
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 
 
 {$ifdef hascompilerproc}
 {$ifdef hascompilerproc}
@@ -1090,8 +1119,10 @@ begin
   end ['EBX','ECX','EAX','ESI','EDI'];
   end ['EBX','ECX','EAX','ESI','EDI'];
 end;
 end;
 {$endif hascompilerproc}
 {$endif hascompilerproc}
+{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
 function fpc_shortstr_compare(const left,right:shortstring): longint; [public,alias:'FPC_SHORTSTR_COMPARE']; {$ifdef hascompilerproc} compilerproc; {$endif}
 function fpc_shortstr_compare(const left,right:shortstring): longint; [public,alias:'FPC_SHORTSTR_COMPARE']; {$ifdef hascompilerproc} compilerproc; {$endif}
 begin
 begin
@@ -1140,15 +1171,21 @@ begin
 .LStrCmp3:
 .LStrCmp3:
   end ['EDX','ECX','EBX','EAX','ESI','EDI'];
   end ['EDX','ECX','EBX','EAX','ESI','EDI'];
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 function fpc_pchar_to_shortstr(p:pchar):shortstring;assembler;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
 function fpc_pchar_to_shortstr(p:pchar):shortstring;assembler;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
 {$include strpas.inc}
 {$include strpas.inc}
+{$endif FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
+
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
 function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
 {$include strlen.inc}
 {$include strlen.inc}
+{$endif FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
 
 
 
 {$define FPC_SYSTEM_HAS_GET_FRAME}
 {$define FPC_SYSTEM_HAS_GET_FRAME}
@@ -1418,7 +1455,14 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.57  2004-01-02 17:22:14  jonas
+  Revision 1.58  2004-01-11 11:10:07  jonas
+    + cgeneric.inc: implementations of rtl routines based on libc
+    * system.inc: include cgeneric.inc before powerpc.inc/i386.inc/... if
+      FPC_USE_LIBC is defined
+    * powerpc.inc, i386.inc: check whether the routines they implement aren't
+      implemented yet in another include file (cgeneric.inc)
+
+  Revision 1.57  2004/01/02 17:22:14  jonas
     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit
     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit
       initialises
       initialises
     + fpu exceptions for invalid operations and division by zero enabled for
     + fpu exceptions for invalid operations and division by zero enabled for

+ 147 - 0
rtl/inc/cgeneric.inc

@@ -0,0 +1,147 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by the Free Pascal development team.
+
+    Processor independent implementation for the system unit
+    (based on libc)
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{****************************************************************************
+                               Primitives
+****************************************************************************}
+
+{$ifndef FPC_SYSTEM_HAS_MOVE}
+{$define FPC_SYSTEM_HAS_MOVE}
+procedure bcopy(const source;var dest;count:cardinal); 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}
+begin
+  if count <= 0 then
+    exit;
+  bcopy(source,dest,count);
+end;
+{$endif not FPC_SYSTEM_HAS_MOVE}
+
+
+{$ifndef FPC_SYSTEM_HAS_FILLCHAR}
+{$define FPC_SYSTEM_HAS_FILLCHAR}
+procedure memset(var x; value: byte; count: cardinal); cdecl; external 'c';
+
+Procedure FillChar(var x;count: longint;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  if count <= 0 then
+    exit;
+  memset(x,value,count);
+end;
+{$endif FPC_SYSTEM_HAS_FILLCHAR}
+
+
+{$ifndef FPC_SYSTEM_HAS_FILLBYTE}
+{$define FPC_SYSTEM_HAS_FILLBYTE}
+procedure FillByte (var x;count : longint;value : byte );{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  if count <= 0 then
+    exit;
+  FillChar (X,Count,CHR(VALUE));
+end;
+{$endif not FPC_SYSTEM_HAS_FILLBYTE}
+
+
+{$ifndef FPC_SYSTEM_HAS_INDEXCHAR}
+{$define FPC_SYSTEM_HAS_INDEXCHAR}
+
+function memchr(const buf; b: longint; len: cardinal): pointer; cdecl; external 'c';
+
+function IndexChar(Const buf;len:longint;b:char):longint;
+var
+  res: pointer;
+begin
+  if len = 0 then
+    exit(-1);
+  { simulate assembler implementations behaviour, which is expected }
+  { fpc_pchar_to_ansistr in astrings.inc (interpret values < 0 as   }
+  { unsigned)                                                       }
+  res := memchr(buf,longint(b),cardinal(len));
+  if (res <> nil) then
+    IndexChar := longint(res-@buf)
+  else
+    IndexChar := -1;
+end;
+{$endif not FPC_SYSTEM_HAS_INDEXCHAR}
+
+
+{$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
+{$define FPC_SYSTEM_HAS_INDEXBYTE}
+function IndexByte(Const buf;len:longint;b:byte):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  IndexByte:=IndexChar(buf,len,char(b));
+end;
+{$endif not FPC_SYSTEM_HAS_INDEXBYTE}
+
+
+{$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 CompareChar(Const buf1,buf2;len:longint):longint;
+var
+  res: longint;
+begin
+  if len <= 0 then
+    exit(0);
+  res := memcmp_comparechar(buf1,buf2,len);
+  if res < 0 then
+    CompareChar := -1
+  else if res > 0 then
+    CompareChar := 1
+  else
+    CompareChar := 0;
+end;
+{$endif not FPC_SYSTEM_HAS_COMPARECHAR}
+
+
+{$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
+{$define FPC_SYSTEM_HAS_COMPAREBYTE}
+function CompareByte(Const buf1,buf2;len:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  CompareByte := CompareChar(buf1,buf2,len);
+end;
+{$endif not FPC_SYSTEM_HAS_COMPAREBYTE}
+
+
+{$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 CompareChar0(Const buf1,buf2;len:longint):longint;
+begin
+  if len <= 0 then
+    exit(0);
+  strncmp_comparechar0(buf1,buf2,len);
+end;
+
+{$endif not FPC_SYSTEM_HAS_COMPARECHAR0}
+
+
+{
+  $Log$
+  Revision 1.1  2004-01-11 11:10:07  jonas
+    + cgeneric.inc: implementations of rtl routines based on libc
+    * system.inc: include cgeneric.inc before powerpc.inc/i386.inc/... if
+      FPC_USE_LIBC is defined
+    * powerpc.inc, i386.inc: check whether the routines they implement aren't
+      implemented yet in another include file (cgeneric.inc)
+
+
+}

+ 13 - 1
rtl/inc/system.inc

@@ -81,6 +81,11 @@ Procedure Rewrite(var f : TypedFile); [INTERNPROC: In_Rewrite_TypedFile];
                     Include processor specific routines
                     Include processor specific routines
 ****************************************************************************}
 ****************************************************************************}
 
 
+{$ifdef FPC_USE_LIBC}
+{ prefer libc implementations over our own, as they're most likely faster }
+{$i libcproc.inc}
+{$endif FPC_USE_LIBC}
+
 {$ifdef cpui386}
 {$ifdef cpui386}
   {$ifdef SYSPROCDEFINED}
   {$ifdef SYSPROCDEFINED}
     {$Error Can't determine processor type !}
     {$Error Can't determine processor type !}
@@ -859,7 +864,14 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.49  2004-01-02 17:21:50  jonas
+  Revision 1.50  2004-01-11 11:10:07  jonas
+    + cgeneric.inc: implementations of rtl routines based on libc
+    * system.inc: include cgeneric.inc before powerpc.inc/i386.inc/... if
+      FPC_USE_LIBC is defined
+    * powerpc.inc, i386.inc: check whether the routines they implement aren't
+      implemented yet in another include file (cgeneric.inc)
+
+  Revision 1.49  2004/01/02 17:21:50  jonas
     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit
     + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit
       initialises
       initialises
     + fpu exceptions for invalid operations and division by zero enabled for
     + fpu exceptions for invalid operations and division by zero enabled for

+ 41 - 4
rtl/powerpc/powerpc.inc

@@ -210,8 +210,8 @@ end;
                                 Move / Fill
                                 Move / Fill
 ****************************************************************************}
 ****************************************************************************}
 
 
+{$ifndef FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
-
 procedure Move(const source;var dest;count:longint);[public, alias: 'FPC_MOVE'];assembler;
 procedure Move(const source;var dest;count:longint);[public, alias: 'FPC_MOVE'];assembler;
 asm
 asm
           {  count <= 0 ?  }
           {  count <= 0 ?  }
@@ -433,8 +433,10 @@ asm
           bdnz    .LMoveBytesLoop
           bdnz    .LMoveBytesLoop
 .LMoveDone:
 .LMoveDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_MOVE}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 
 
 Procedure FillChar(var x;count:longint;value:byte);assembler;
 Procedure FillChar(var x;count:longint;value:byte);assembler;
@@ -569,8 +571,10 @@ asm
         bdnz      .LFillCharVerySmallLoop
         bdnz      .LFillCharVerySmallLoop
 .LFillCharDone:
 .LFillCharDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FILLCHAR}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FILLDWORD}
 {$define FPC_SYSTEM_HAS_FILLDWORD}
 {$define FPC_SYSTEM_HAS_FILLDWORD}
 procedure filldword(var x;count : longint;value : dword);
 procedure filldword(var x;count : longint;value : dword);
 assembler;
 assembler;
@@ -589,8 +593,10 @@ asm
                 bdnz    .LFillDWordLoop
                 bdnz    .LFillDWordLoop
 .LFillDWordEnd:
 .LFillDWordEnd:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FILLDWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
 {$define FPC_SYSTEM_HAS_INDEXBYTE}
 {$define FPC_SYSTEM_HAS_INDEXBYTE}
 function IndexByte(const buf;len:longint;b:byte):longint; assembler;
 function IndexByte(const buf;len:longint;b:byte):longint; assembler;
 { input: r3 = buf, r4 = len, r5 = b                   }
 { input: r3 = buf, r4 = len, r5 = b                   }
@@ -614,8 +620,10 @@ asm
                 sub     r3,r10,r0
                 sub     r3,r10,r0
 .LIndexByteDone:
 .LIndexByteDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_INDEXBYTE}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXWORD}
 {$define FPC_SYSTEM_HAS_INDEXWORD}
 {$define FPC_SYSTEM_HAS_INDEXWORD}
 function IndexWord(const buf;len:longint;b:word):longint; assembler;
 function IndexWord(const buf;len:longint;b:word):longint; assembler;
 { input: r3 = buf, r4 = len, r5 = b                   }
 { input: r3 = buf, r4 = len, r5 = b                   }
@@ -640,8 +648,10 @@ asm
                 srawi   r3,r3,1
                 srawi   r3,r3,1
 .LIndexWordDone:
 .LIndexWordDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_INDEXWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
 {$define FPC_SYSTEM_HAS_INDEXDWORD}
 {$define FPC_SYSTEM_HAS_INDEXDWORD}
 function IndexDWord(const buf;len:longint;b:DWord):longint; assembler;
 function IndexDWord(const buf;len:longint;b:DWord):longint; assembler;
 { input: r3 = buf, r4 = len, r5 = b                   }
 { input: r3 = buf, r4 = len, r5 = b                   }
@@ -666,7 +676,10 @@ asm
                 srawi   r3,r3,2
                 srawi   r3,r3,2
 .LIndexDWordDone:
 .LIndexDWordDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_INDEXDWORD}
+
 
 
+{$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
 {$define FPC_SYSTEM_HAS_COMPAREBYTE}
 {$define FPC_SYSTEM_HAS_COMPAREBYTE}
 function CompareByte(const buf1,buf2;len:longint):longint; assembler;
 function CompareByte(const buf1,buf2;len:longint):longint; assembler;
 { input: r3 = buf1, r4 = buf2, r5 = len                           }
 { input: r3 = buf1, r4 = buf2, r5 = len                           }
@@ -692,7 +705,10 @@ asm
         bdnzt   cr0*4+eq, .LCompByteLoop
         bdnzt   cr0*4+eq, .LCompByteLoop
 .LCompByteDone:
 .LCompByteDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_COMPAREBYTE}
 
 
+
+{$ifndef FPC_SYSTEM_HAS_COMPAREWORD}
 {$define FPC_SYSTEM_HAS_COMPAREWORD}
 {$define FPC_SYSTEM_HAS_COMPAREWORD}
 function CompareWord(const buf1,buf2;len:longint):longint; assembler;
 function CompareWord(const buf1,buf2;len:longint):longint; assembler;
 { input: r3 = buf1, r4 = buf2, r5 = len                           }
 { input: r3 = buf1, r4 = buf2, r5 = len                           }
@@ -718,8 +734,10 @@ asm
         bdnzt   cr0*4+eq, .LCompWordLoop
         bdnzt   cr0*4+eq, .LCompWordLoop
 .LCompWordDone:
 .LCompWordDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_COMPAREWORD}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_COMPAREDWORD}
 {$define FPC_SYSTEM_HAS_COMPAREDWORD}
 {$define FPC_SYSTEM_HAS_COMPAREDWORD}
 function CompareDWord(const buf1,buf2;len:longint):longint; assembler;
 function CompareDWord(const buf1,buf2;len:longint):longint; assembler;
 { input: r3 = buf1, r4 = buf2, r5 = len                           }
 { input: r3 = buf1, r4 = buf2, r5 = len                           }
@@ -745,7 +763,10 @@ asm
         bdnzt   cr0*4+eq, .LCompDWordLoop
         bdnzt   cr0*4+eq, .LCompDWordLoop
 .LCompDWordDone:
 .LCompDWordDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_COMPAREDWORD}
+
 
 
+{$ifndef FPC_SYSTEM_HAS_INDEXCHAR0}
 {$define FPC_SYSTEM_HAS_INDEXCHAR0}
 {$define FPC_SYSTEM_HAS_INDEXCHAR0}
 function IndexChar0(const buf;len:longint;b:Char):longint; assembler;
 function IndexChar0(const buf;len:longint;b:Char):longint; assembler;
 { input: r3 = buf, r4 = len, r5 = b                         }
 { input: r3 = buf, r4 = len, r5 = b                         }
@@ -772,13 +793,15 @@ asm
         sub     r3,r9,r0
         sub     r3,r9,r0
 .LIndexChar0Done:
 .LIndexChar0Done:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_INDEXCHAR0}
 
 
 
 
 {****************************************************************************
 {****************************************************************************
                                  String
                                  String
 ****************************************************************************}
 ****************************************************************************}
 
 
-{$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COPY}
+{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
+{$define FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
 function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; compilerproc;
 function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; compilerproc;
 assembler;
 assembler;
 { input: r3: pointer to result, r4: len, r5: sstr }
 { input: r3: pointer to result, r4: len, r5: sstr }
@@ -807,7 +830,6 @@ asm
 end;
 end;
 
 
 
 
-{$define FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
 {$ifdef interncopy}
 {$ifdef interncopy}
 procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
 procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
 {$else}
 {$else}
@@ -838,8 +860,10 @@ asm
         bdnz    .LShortStrCopyLoop2
         bdnz    .LShortStrCopyLoop2
 .LShortStrCopyDone2:
 .LShortStrCopyDone2:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 
 
 procedure fpc_shortstr_append_shortstr(var s1: shortstring; const s2: shortstring); compilerproc;
 procedure fpc_shortstr_append_shortstr(var s1: shortstring; const s2: shortstring); compilerproc;
@@ -881,6 +905,7 @@ asm
       bdnz    .LShortStrAppendLoop
       bdnz    .LShortStrAppendLoop
 .LShortStrAppendDone:
 .LShortStrAppendDone:
 end;
 end;
+{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
 
 
 (*
 (*
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
@@ -942,15 +967,20 @@ LShortStrCompareDone:
 end;
 end;
 *)
 *)
 
 
+
+{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 function fpc_pchar_to_shortstr(p:pchar):shortstring;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
 function fpc_pchar_to_shortstr(p:pchar):shortstring;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
 assembler;
 assembler;
 {$include strpas.inc}
 {$include strpas.inc}
+{$endif FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
 function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
 {$include strlen.inc}
 {$include strlen.inc}
+{$endif FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
 
 
 
 {$define FPC_SYSTEM_HAS_GET_FRAME}
 {$define FPC_SYSTEM_HAS_GET_FRAME}
@@ -1061,7 +1091,14 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.64  2004-01-10 00:16:20  jonas
+  Revision 1.65  2004-01-11 11:10:07  jonas
+    + cgeneric.inc: implementations of rtl routines based on libc
+    * system.inc: include cgeneric.inc before powerpc.inc/i386.inc/... if
+      FPC_USE_LIBC is defined
+    * powerpc.inc, i386.inc: check whether the routines they implement aren't
+      implemented yet in another include file (cgeneric.inc)
+
+  Revision 1.64  2004/01/10 00:16:20  jonas
     * fixed mtfsb0 instruction for assembler reader/writer
     * fixed mtfsb0 instruction for assembler reader/writer
     * fixed initialisation of fpscr register to avoid spurious SIGPFE's
     * fixed initialisation of fpscr register to avoid spurious SIGPFE's
       (uses mtfsb0 instruction, so added extra define in options.pas to avoid
       (uses mtfsb0 instruction, so added extra define in options.pas to avoid