Selaa lähdekoodia

* SYSTEMINLINE define that will add inline directives for small
functions and wrappers. This will be defined automaticly when
the compiler defines the HASINLINE directive

peter 23 vuotta sitten
vanhempi
commit
c3af3cda9b
4 muutettua tiedostoa jossa 103 lisäystä ja 78 poistoa
  1. 13 8
      rtl/i386/i386.inc
  2. 15 10
      rtl/inc/generic.inc
  3. 33 29
      rtl/inc/system.inc
  4. 42 31
      rtl/inc/systemh.inc

+ 13 - 8
rtl/i386/i386.inc

@@ -954,14 +954,14 @@ end;
 
 
 {$define FPC_SYSTEM_HAS_GET_FRAME}
-function get_frame:longint;assembler;
+function get_frame:longint;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 asm
         movl    %ebp,%eax
 end ['EAX'];
 
 
 {$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
-function get_caller_addr(framebp:longint):longint;assembler;
+function get_caller_addr(framebp:longint):longint;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 asm
         movl    framebp,%eax
         orl     %eax,%eax
@@ -972,7 +972,7 @@ end ['EAX'];
 
 
 {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
-function get_caller_frame(framebp:longint):longint;assembler;
+function get_caller_frame(framebp:longint):longint;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 asm
         movl    framebp,%eax
         orl     %eax,%eax
@@ -987,7 +987,7 @@ end ['EAX'];
 ****************************************************************************}
 
 {$define FPC_SYSTEM_HAS_ABS_LONGINT}
-function abs(l:longint):longint; assembler;[internconst:in_const_abs];
+function abs(l:longint):longint; assembler;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_abs];
 asm
         movl    l,%eax
         cltd
@@ -997,7 +997,7 @@ end ['EAX','EDX'];
 
 
 {$define FPC_SYSTEM_HAS_ODD_LONGINT}
-function odd(l:longint):boolean;assembler;[internconst:in_const_odd];
+function odd(l:longint):boolean;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
 asm
        movl     l,%eax
        andl     $1,%eax
@@ -1006,7 +1006,7 @@ end ['EAX'];
 
 
 {$define FPC_SYSTEM_HAS_SQR_LONGINT}
-function sqr(l:longint):longint;assembler;[internconst:in_const_sqr];
+function sqr(l:longint):longint;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
 asm
         mov     l,%eax
         imull   %eax,%eax
@@ -1014,7 +1014,7 @@ end ['EAX'];
 
 
 {$define FPC_SYSTEM_HAS_SPTR}
-Function Sptr : Longint;assembler;
+Function Sptr : Longint;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 asm
         movl    %esp,%eax
 end;
@@ -1176,7 +1176,12 @@ procedure inclocked(var l : longint);assembler;
 
 {
   $Log$
-  Revision 1.26  2002-07-26 15:45:33  florian
+  Revision 1.27  2002-08-19 19:34:02  peter
+    * SYSTEMINLINE define that will add inline directives for small
+      functions and wrappers. This will be defined automaticly when
+      the compiler defines the HASINLINE directive
+
+  Revision 1.26  2002/07/26 15:45:33  florian
     * changed multi threading define: it's MT instead of MTRTL
 
   Revision 1.25  2002/07/06 20:31:59  carl

+ 15 - 10
rtl/inc/generic.inc

@@ -761,7 +761,7 @@ end;
 ****************************************************************************}
 
 {$ifndef FPC_SYSTEM_HAS_ABS_LONGINT}
-function abs(l:longint):longint;[internconst:in_const_abs];
+function abs(l:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_abs];
 begin
    if l<0 then
      abs:=-l
@@ -773,7 +773,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_ODD_LONGINT}
 
-function odd(l:longint):boolean;[internconst:in_const_odd];
+function odd(l:longint):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
 begin
    odd:=boolean(l and 1);
 end;
@@ -782,7 +782,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_ODD_CARDINAL}
 
-function odd(l:cardinal):boolean;[internconst:in_const_odd];
+function odd(l:cardinal):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
 begin
    odd:=boolean(l and 1);
 end;
@@ -792,7 +792,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_ODD_INT64}
 
-function odd(l:int64):boolean;[internconst:in_const_odd];
+function odd(l:int64):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
 begin
    odd:=boolean(longint(l) and 1);
 end;
@@ -801,7 +801,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_ODD_QWORD}
 
-function odd(l:qword):boolean;[internconst:in_const_odd];
+function odd(l:qword):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
 begin
    odd:=boolean(longint(l) and 1);
 end;
@@ -810,7 +810,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_SQR_LONGINT}
 
-function sqr(l:longint):longint;[internconst:in_const_sqr];
+function sqr(l:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
 begin
    sqr:=l*l;
 end;
@@ -820,7 +820,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_ABS_INT64}
 
-function abs(l: Int64): Int64;[internconst:in_const_abs];
+function abs(l: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_abs];
 begin
   if l < 0 then
     abs := -l
@@ -833,7 +833,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_SQR_INT64}
 
-function sqr(l: Int64): Int64;[internconst:in_const_sqr];
+function sqr(l: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
 begin
   sqr := l*l;
 end;
@@ -843,7 +843,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_SQR_QWORD}
 
-function sqr(l: QWord): QWord;[internconst:in_const_sqr];
+function sqr(l: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
 begin
   sqr := l*l;
 end;
@@ -946,7 +946,12 @@ end;
 
 {
   $Log$
-  Revision 1.31  2002-07-29 21:28:16  florian
+  Revision 1.32  2002-08-19 19:34:02  peter
+    * SYSTEMINLINE define that will add inline directives for small
+      functions and wrappers. This will be defined automaticly when
+      the compiler defines the HASINLINE directive
+
+  Revision 1.31  2002/07/29 21:28:16  florian
     * several fixes to get further with linux/ppc system unit compilation
 
   Revision 1.30  2002/07/29 09:23:11  jonas

+ 33 - 29
rtl/inc/system.inc

@@ -137,6 +137,17 @@ Procedure Rewrite(var f : TypedFile); [INTERNPROC: In_Rewrite_TypedFile];
   {$define SYSPROCDEFINED}
 {$endif iA64}
 
+
+procedure fillchar(var x;count : longint;value : boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  fillchar(x,count,byte(value));
+end;
+
+procedure fillchar(var x;count : longint;value : char);{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  fillchar(x,count,byte(value));
+end;
+
 { Include generic pascal only routines which are not defined in the processor
   specific include file }
 {$I generic.inc}
@@ -157,42 +168,42 @@ Procedure Rewrite(var f : TypedFile); [INTERNPROC: In_Rewrite_TypedFile];
                                Math Routines
 ****************************************************************************}
 
-function Hi(b : byte): byte;
+function Hi(b : byte): byte;{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
    Hi := b shr 4
 end;
 
-function Lo(b : byte): byte;
+function Lo(b : byte): byte;{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
    Lo := b and $0f
 end;
 
-Function swap (X : Word) : Word;[internconst:in_const_swap_word];
+Function swap (X : Word) : Word;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_swap_word];
 Begin
   swap:=(X and $ff) shl 8 + (X shr 8)
 End;
 
-Function Swap (X : Integer) : Integer;[internconst:in_const_swap_word];
+Function Swap (X : Integer) : Integer;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_swap_word];
 Begin
   swap:=(X and $ff) shl 8 + (X shr 8)
 End;
 
-Function swap (X : Longint) : Longint;[internconst:in_const_swap_long];
+Function swap (X : Longint) : Longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_swap_long];
 Begin
   Swap:=(X and $ffff) shl 16 + (X shr 16)
 End;
 
-Function Swap (X : Cardinal) : Cardinal;[internconst:in_const_swap_long];
+Function Swap (X : Cardinal) : Cardinal;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_swap_long];
 Begin
   Swap:=(X and $ffff) shl 16 + (X shr 16)
 End;
 
-Function Swap (X : QWord) : QWord;
+Function Swap (X : QWord) : QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Swap:=(X and $ffffffff) shl 32 + (X shr 32);
 End;
 
-Function swap (X : Int64) : Int64;
+Function swap (X : Int64) : Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Swap:=(X and $ffffffff) shl 32 + (X shr 32);
 End;
@@ -343,28 +354,26 @@ begin
 end;
 
 
-
-
 {****************************************************************************
                             Memory Management
 ****************************************************************************}
 
-Function Ptr(sel,off : Longint) : farpointer;[internconst:in_const_ptr];
+Function Ptr(sel,off : Longint) : farpointer;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_ptr];
 Begin
   ptr:=farpointer((sel shl 4)+off);
 End;
 
-Function CSeg : Word;
+Function CSeg : Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Cseg:=0;
 End;
 
-Function DSeg : Word;
+Function DSeg : Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Dseg:=0;
 End;
 
-Function SSeg : Word;
+Function SSeg : Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Sseg:=0;
 End;
@@ -427,24 +436,14 @@ begin
    end;
 end;
 
-Function IOResult:Word;
+
+Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   IOResult:=InOutRes;
   InOutRes:=0;
 End;
 
 
-procedure fillchar(var x;count : longint;value : boolean);
-begin
-  fillchar(x,count,byte(value));
-end;
-
-
-procedure fillchar(var x;count : longint;value : char);
-begin
-  fillchar(x,count,byte(value));
-end;
-
 {*****************************************************************************
                          Stack check code
 *****************************************************************************}
@@ -626,13 +625,13 @@ begin
 end;
 
 
-Procedure RunError;
+Procedure RunError;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   RunError (0);
 End;
 
 
-Procedure Halt;
+Procedure Halt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Halt(0);
 End;
@@ -757,7 +756,12 @@ end;
 
 {
   $Log$
-  Revision 1.32  2002-07-28 20:43:48  florian
+  Revision 1.33  2002-08-19 19:34:02  peter
+    * SYSTEMINLINE define that will add inline directives for small
+      functions and wrappers. This will be defined automaticly when
+      the compiler defines the HASINLINE directive
+
+  Revision 1.32  2002/07/28 20:43:48  florian
     * several fixes for linux/powerpc
     * several fixes to MT
 

+ 42 - 31
rtl/inc/systemh.inc

@@ -22,6 +22,12 @@
 {$I-,Q-,H-,R-,V-}
 {$mode objfpc}
 
+{ Using inlining for small system functions/wrappers }
+{$ifdef HASINLINE}
+  {$inline on}
+  {$define SYSTEMINLINE}
+{$endif}
+
 { don't use FPU registervariables on the i386 }
 {$ifdef i386}
   {$maxfpuregisters 0}
@@ -260,8 +266,8 @@ Var
 ****************************************************************************}
 
 Procedure Move(const source;var dest;count:Longint);
-Procedure FillChar(Var x;count:Longint;Value:Boolean);
-Procedure FillChar(Var x;count:Longint;Value:Char);
+Procedure FillChar(Var x;count:Longint;Value:Boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
+Procedure FillChar(Var x;count:Longint;Value:Char);{$ifdef SYSTEMINLINE}inline;{$endif}
 Procedure FillChar(Var x;count:Longint;Value:Byte);
 procedure FillByte(var x;count:longint;value:byte);
 Procedure FillWord(Var x;count:Longint;Value:Word);
@@ -287,37 +293,37 @@ Function  lo(w:Word):byte;
 Function  lo(l:Longint):Word;
 Function  lo(l:DWord):Word;
 Function  lo(i:Integer):byte;
-Function  lo(B: Byte):Byte;
+Function  lo(B: Byte):Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function  hi(w:Word):byte;
 Function  hi(i:Integer):byte;
 Function  hi(l:Longint):Word;
-Function  hi(b : Byte) : Byte;
+Function  hi(b : Byte) : Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function  hi(l: DWord): Word;
-Function  Swap (X:Word):Word;
-Function  Swap (X:Integer):Integer;
-Function  Swap (X:Cardinal):Cardinal;
-Function  Swap (X:LongInt):LongInt;
 Function  lo(q : QWord) : DWord;
 Function  lo(i : Int64) : DWord;
 Function  hi(q : QWord) : DWord;
 Function  hi(i : Int64) : DWord;
-Function  Swap (X:QWord):QWord;
-Function  Swap (X:Int64):Int64;
+Function  Swap (X:Word):Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Swap (X:Integer):Integer;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Swap (X:Cardinal):Cardinal;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Swap (X:LongInt):LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Swap (X:QWord):QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Swap (X:Int64):Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 Function  Random(l:cardinal):cardinal;
 Function  Random(l:longint):longint;
 Function  Random: extended;
 Procedure Randomize;
 
-Function abs(l:Longint):Longint;
-Function abs(l:Int64):Int64;
-Function sqr(l:Longint):Longint;
-Function sqr(l:Int64):Int64;
-Function sqr(l:QWord):QWord;
-Function odd(l:Longint):Boolean;
-Function odd(l:Cardinal):Boolean;
-Function odd(l:Int64):Boolean;
-Function odd(l:QWord):Boolean;
+Function abs(l:Longint):Longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function abs(l:Int64):Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function sqr(l:Longint):Longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function sqr(l:Int64):Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function sqr(l:QWord):QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function odd(l:Longint):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function odd(l:Cardinal):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function odd(l:Int64):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function odd(l:QWord):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { float math routines }
 {$I mathh.inc}
@@ -326,10 +332,10 @@ Function odd(l:QWord):Boolean;
                          Addr/Pointer Handling
 ****************************************************************************}
 
-Function  ptr(sel,off:Longint):farpointer;
-Function  Cseg:Word;
-Function  Dseg:Word;
-Function  Sseg:Word;
+Function  ptr(sel,off:Longint):farpointer;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Cseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Dseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function  Sseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 {****************************************************************************
                       PChar and String Handling
@@ -504,12 +510,12 @@ Procedure getdir(drivenr:byte;Var dir:ansistring);
 *****************************************************************************}
 
 { os independent calls to allow backtraces }
-function get_frame:longint;
-function get_caller_addr(framebp:longint):longint;
-function get_caller_frame(framebp:longint):longint;
+function get_frame:longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+function get_caller_addr(framebp:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
+function get_caller_frame(framebp:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
 
-Function IOResult:Word;
-Function Sptr:Longint;
+Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Sptr:Longint;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 
 {*****************************************************************************
@@ -520,10 +526,10 @@ Function  Paramcount:Longint;
 Function  ParamStr(l:Longint):string;
 Procedure Dump_Stack(var f : text;bp:Longint);
 Procedure RunError(w:Word);
-Procedure RunError;
+Procedure RunError;{$ifdef SYSTEMINLINE}inline;{$endif}
 Procedure halt(errnum:byte);
 Procedure AddExitProc(Proc:TProcedure);
-Procedure halt;
+Procedure halt;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 
 {*****************************************************************************
@@ -581,7 +587,12 @@ const
 
 {
   $Log$
-  Revision 1.51  2002-08-06 20:53:38  michael
+  Revision 1.52  2002-08-19 19:34:02  peter
+    * SYSTEMINLINE define that will add inline directives for small
+      functions and wrappers. This will be defined automaticly when
+      the compiler defines the HASINLINE directive
+
+  Revision 1.51  2002/08/06 20:53:38  michael
     + Added support for octal strings (using &)
 
   Revision 1.50  2002/07/26 22:46:06  florian