Browse Source

* use and remember that C functions with complex data results use ret $4

pierre 26 years ago
parent
commit
7bf3213a01
2 changed files with 25 additions and 5 deletions
  1. 10 3
      compiler/cg386cal.pas
  2. 15 2
      compiler/cgai386.pas

+ 10 - 3
compiler/cg386cal.pas

@@ -399,7 +399,12 @@ implementation
            inlinecode^.retoffset:=gettempofsizepersistant(4);
            inlinecode^.retoffset:=gettempofsizepersistant(4);
          if ret_in_param(p^.resulttype) then
          if ret_in_param(p^.resulttype) then
            begin
            begin
-              inc(pushedparasize,4);
+              { This must not be counted for C code
+                complex return address is removed from stack
+                by function itself !   }
+{$ifdef OLD_C_STACK}
+              inc(pushedparasize,4); { lets try without it PM }
+{$endif not OLD_C_STACK}
               if inlined then
               if inlined then
                 begin
                 begin
                    emit_ref_reg(A_LEA,S_L,
                    emit_ref_reg(A_LEA,S_L,
@@ -1217,7 +1222,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.106  1999-09-27 23:44:46  peter
+  Revision 1.107  1999-10-08 15:40:47  pierre
+   * use and remember that C functions with complex data results use ret $4
+
+  Revision 1.106  1999/09/27 23:44:46  peter
     * procinfo is now a pointer
     * procinfo is now a pointer
     * support for result setting in sub procedure
     * support for result setting in sub procedure
 
 
@@ -1666,4 +1674,3 @@ end.
     * splitted cgi386
     * splitted cgi386
 
 
 }
 }
-

+ 15 - 2
compiler/cgai386.pas

@@ -3296,7 +3296,17 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
        begin
        begin
        {Routines with the poclearstack flag set use only a ret.}
        {Routines with the poclearstack flag set use only a ret.}
        { also routines with parasize=0     }
        { also routines with parasize=0     }
-         if (parasize=0) or (pocall_clearstack in aktprocsym^.definition^.proccalloptions) then
+         if (pocall_clearstack in aktprocsym^.definition^.proccalloptions) then
+           begin
+{$ifndef OLD_C_STACK}
+             { complex return values are removed from stack in C code PM }
+             if ret_in_param(aktprocsym^.definition^.retdef) then
+               exprasmlist^.concat(new(paicpu,op_const(A_RET,S_NO,4)))
+             else
+{$endif not OLD_C_STACK}
+               exprasmlist^.concat(new(paicpu,op_none(A_RET,S_NO)));
+           end
+         else if (parasize=0) then
           exprasmlist^.concat(new(paicpu,op_none(A_RET,S_NO)))
           exprasmlist^.concat(new(paicpu,op_none(A_RET,S_NO)))
          else
          else
           exprasmlist^.concat(new(paicpu,op_const(A_RET,S_NO,parasize)));
           exprasmlist^.concat(new(paicpu,op_const(A_RET,S_NO,parasize)));
@@ -3386,7 +3396,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.51  1999-10-05 22:01:52  pierre
+  Revision 1.52  1999-10-08 15:40:47  pierre
+   * use and remember that C functions with complex data results use ret $4
+
+  Revision 1.51  1999/10/05 22:01:52  pierre
    * bug exit('test') + fail for classes
    * bug exit('test') + fail for classes
 
 
   Revision 1.50  1999/09/29 11:46:18  florian
   Revision 1.50  1999/09/29 11:46:18  florian