Ver código fonte

* fixed calling cdecl routines under win32 which return their result in
a structure whose address is passed by the caller (the caller is
responsible there to remove the address from the stack, unlike on
e.g. linux/i386 and darwin/i386) (mantis #9013)

git-svn-id: trunk@7667 -

Jonas Maebe 18 anos atrás
pai
commit
02adc2b6ab
1 arquivos alterados com 10 adições e 0 exclusões
  1. 10 0
      compiler/i386/n386cal.pas

+ 10 - 0
compiler/i386/n386cal.pas

@@ -81,6 +81,16 @@ implementation
             exit;
           end;
 
+        { on win32, the caller is responsible for removing the funcret     }
+        { pointer from the stack, unlike on Linux. Don't know about        }
+        { elsewhere (except Darwin, handled above), but since the default  }
+        { was "callee removes funcret pointer from stack" until now, we'll }
+        { keep that default for everyone else (ncgcal decreases popsize by }
+        { sizeof(aint) in case of ret_in_param())                          }
+        if (target_info.system = system_i386_win32) and
+            paramanager.ret_in_param(procdefinition.returndef,procdefinition.proccalloption) then
+           inc(pop_size,sizeof(aint));
+
         { better than an add on all processors }
         if pop_size=4 then
           begin