Browse Source

* fixed i386/linux rtl compilation and functionality when compiled
without regcall

git-svn-id: trunk@11024 -

Jonas Maebe 17 years ago
parent
commit
f00beea41c
5 changed files with 36 additions and 12 deletions
  1. 19 8
      rtl/i386/i386.inc
  2. 4 0
      rtl/i386/mathu.inc
  3. 10 1
      rtl/i386/strings.inc
  4. 2 2
      rtl/inc/system.inc
  5. 1 1
      rtl/linux/sysos.inc

+ 19 - 8
rtl/i386/i386.inc

@@ -94,7 +94,7 @@ function mmx_support : boolean;
        mmx_support:=false;
        mmx_support:=false;
   end;
   end;
 
 
-{$ifndef FPC_SYSTEM_HAS_MOVE}
+{$if not defined(FPC_SYSTEM_HAS_MOVE) and defined(REGCALL) }
 {$define USE_FASTMOVE}
 {$define USE_FASTMOVE}
 {$i fastmove.inc}
 {$i fastmove.inc}
 {$endif FPC_SYSTEM_HAS_MOVE}
 {$endif FPC_SYSTEM_HAS_MOVE}
@@ -200,6 +200,10 @@ end;
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 Procedure FillChar(var x;count:SizeInt;value:byte);assembler;
 Procedure FillChar(var x;count:SizeInt;value:byte);assembler;
+{$ifndef regcall}
+var
+  saveedi: longint;
+{$endif}
 asm
 asm
         {A push is prefered over a local variable because a local
         {A push is prefered over a local variable because a local
          variable causes the compiler to generate a stackframe.}
          variable causes the compiler to generate a stackframe.}
@@ -210,6 +214,7 @@ asm
         movzbl  %cl,%eax
         movzbl  %cl,%eax
         movl    %edx,%ecx
         movl    %edx,%ecx
 {$else}
 {$else}
+        movl    %edi, saveedi
         movl    x,%edi
         movl    x,%edi
         movl    count,%ecx
         movl    count,%ecx
         movzbl  value,%eax
         movzbl  value,%eax
@@ -232,6 +237,8 @@ asm
 .LFillEnd:
 .LFillEnd:
 {$ifdef REGCALL}
 {$ifdef REGCALL}
         pop %edi
         pop %edi
+{$else}
+        movl   saveedi,%edi
 {$endif}
 {$endif}
 end;
 end;
 {$endif FPC_SYSTEM_HAS_FILLCHAR}
 {$endif FPC_SYSTEM_HAS_FILLCHAR}
@@ -665,9 +672,13 @@ procedure fpc_shortstr_to_shortstr(out res:shortstring; const sstr: shortstring)
         movl    %edi,saveedi
         movl    %edi,saveedi
         movl    %esi,saveesi
         movl    %esi,saveesi
         cld
         cld
-        movl    %eax,%edi
-        movl    %ecx,%esi
+        movl    res,%edi
+        movl    sstr,%esi
+{$ifdef regcall}
         movl    %edx,%ecx
         movl    %edx,%ecx
+{$else regcall}
+        movl    res+4,%ecx
+{$endif regcall}
         xorl    %eax,%eax
         xorl    %eax,%eax
         lodsb
         lodsb
         cmpl    %ecx,%eax
         cmpl    %ecx,%eax
@@ -999,7 +1010,7 @@ asm
 {$ifdef REGCALL}
 {$ifdef REGCALL}
         movl    saveres,%edi
         movl    saveres,%edi
 {$else}
 {$else}
-        movl    __RESULT,%edi
+        movl    res,%edi
 {$endif}
 {$endif}
         addb    $255,%cl
         addb    $255,%cl
         movb    %cl,(%edi)
         movb    %cl,(%edi)
@@ -1080,7 +1091,7 @@ end;
                                  Str()
                                  Str()
 ****************************************************************************}
 ****************************************************************************}
 
 
-{$ifdef disabled}
+{$if defined(disabled) and defined(regcall) }
 {$define FPC_SYSTEM_HAS_INT_STR_LONGWORD}
 {$define FPC_SYSTEM_HAS_INT_STR_LONGWORD}
 {$define FPC_SYSTEM_HAS_INT_STR_LONGINT}
 {$define FPC_SYSTEM_HAS_INT_STR_LONGINT}
 
 
@@ -1301,7 +1312,7 @@ asm
 {$else}
 {$else}
         movl    Target,%ecx
         movl    Target,%ecx
         movl    NewValue,%edx
         movl    NewValue,%edx
-        movl    Comparand,%eax
+        movl    Comperand,%eax
 {$endif}
 {$endif}
         lock
         lock
         cmpxchgl   %edx, (%ecx)
         cmpxchgl   %edx, (%ecx)
@@ -1420,7 +1431,7 @@ procedure fpc_cpucodeinit;
   end;
   end;
 
 
 
 
-{$ifndef darwin}
+{$if not defined(darwin) and defined(regcall) }
 { darwin requires that the stack is aligned to 16 bytes when calling another function }
 { darwin requires that the stack is aligned to 16 bytes when calling another function }
 
 
 {$define FPC_SYSTEM_HAS_ANSISTR_DECR_REF}
 {$define FPC_SYSTEM_HAS_ANSISTR_DECR_REF}
@@ -1496,7 +1507,7 @@ asm
 // [442] end;
 // [442] end;
 end;
 end;
 
 
-{$endif darwin}
+{$endif ndef darwin and defined(regcall) }
 
 
 {$ifndef FPC_SYSTEM_HAS_MEM_BARRIER}
 {$ifndef FPC_SYSTEM_HAS_MEM_BARRIER}
 {$define FPC_SYSTEM_HAS_MEM_BARRIER}
 {$define FPC_SYSTEM_HAS_MEM_BARRIER}

+ 4 - 0
rtl/i386/mathu.inc

@@ -28,6 +28,10 @@ procedure sincos(theta : float;out sinus,cosinus : float);assembler;
   asm
   asm
     fldt theta
     fldt theta
     fsincos
     fsincos
+{$ifndef regcall}
+    movl  sinus, %eax
+    movl  cosinus, %edx
+{$endif}
     fstpt (%edx)
     fstpt (%edx)
     fstpt (%eax)
     fstpt (%eax)
     fwait
     fwait

+ 10 - 1
rtl/i386/strings.inc

@@ -524,10 +524,15 @@ end;
 {$define FPC_UNIT_HAS_STRRSCAN}
 {$define FPC_UNIT_HAS_STRRSCAN}
 function strrscan(p : pchar;c : char) : pchar;assembler;
 function strrscan(p : pchar;c : char) : pchar;assembler;
 var
 var
-  saveeax,saveedi : longint;
+  {$ifdef regcall}
+  saveeax,
+  {$endif}
+  saveedi : longint;
 asm
 asm
         movl    %edi,saveedi
         movl    %edi,saveedi
+{$ifdef regcall}
         movl    %eax,saveeax
         movl    %eax,saveeax
+{$endif regcall}
         movl    p,%edi
         movl    p,%edi
         xorl    %eax,%eax
         xorl    %eax,%eax
         orl     %edi,%edi
         orl     %edi,%edi
@@ -539,7 +544,11 @@ asm
         scasb
         scasb
         not     %ecx
         not     %ecx
         movb    c,%al
         movb    c,%al
+{$ifdef regcall}
         movl    saveeax,%edi
         movl    saveeax,%edi
+{$else}
+        movl    p,%edi
+{$endif}
         addl    %ecx,%edi
         addl    %ecx,%edi
         decl    %edi
         decl    %edi
         std
         std

+ 2 - 2
rtl/inc/system.inc

@@ -666,7 +666,7 @@ begin
 end;
 end;
 
 
 
 
-function fpc_safecallcheck(res : hresult) : hresult;[public,alias:'FPC_SAFECALLCHECK']; compilerproc;
+function fpc_safecallcheck(res : hresult) : hresult;[public,alias:'FPC_SAFECALLCHECK']; compilerproc; register;
 begin
 begin
   if res<0 then
   if res<0 then
     begin
     begin
@@ -884,7 +884,7 @@ begin
 end;
 end;
 
 
 
 
-Procedure HandleErrorAddrFrame (Errno : longint;addr,frame : Pointer);[public,alias:'FPC_BREAK_ERROR'];
+Procedure HandleErrorAddrFrame (Errno : longint;addr,frame : Pointer);[public,alias:'FPC_BREAK_ERROR']; register;
 begin
 begin
   If pointer(ErrorProc)<>Nil then
   If pointer(ErrorProc)<>Nil then
     ErrorProc(Errno,addr,frame);
     ErrorProc(Errno,addr,frame);

+ 1 - 1
rtl/linux/sysos.inc

@@ -30,7 +30,7 @@ begin
  geterrno:=geterrnolocation^;
  geterrno:=geterrnolocation^;
 end;
 end;
 
 
-procedure seterrno(err:libcint); [public, alias: 'FPC_SYS_SETERRNO'];
+procedure seterrno(err:libcint); [public, alias: 'FPC_SYS_SETERRNO']; register;
 begin
 begin
   geterrnolocation^:=err;
   geterrnolocation^:=err;
 end;
 end;