From 5f0f08dd183fed6aaeb576fc8f1e84848da487d4 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 11 Mar 2006 22:12:20 +0000 Subject: [PATCH] * fixed calling cdecl functions which return a large record with use_fixed_stack on i386 git-svn-id: trunk@2872 - --- compiler/i386/n386cal.pas | 12 +++++++++++- compiler/ncgutil.pas | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/compiler/i386/n386cal.pas b/compiler/i386/n386cal.pas index 084a64ec51..f7f50ed671 100644 --- a/compiler/i386/n386cal.pas +++ b/compiler/i386/n386cal.pas @@ -70,7 +70,17 @@ implementation hreg : tregister; begin if (use_fixed_stack) then - exit; + begin + { very weird: in this case the callee does a "ret $4" and the } + { caller immediately a "subl $4,%esp". Possibly this is for } + { use_fixed_stack code to be able to transparently call } + { old-style code (JM) } + dec(pop_size,pushedparasize); + if (pop_size < 0) then + exprasmlist.concat(taicpu.op_const_reg(A_SUB,S_L,-pop_size,NR_ESP)); + exit; + end; + { better than an add on all processors } if pop_size=4 then begin diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index c716b82bbe..6c3d0827de 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -1845,8 +1845,7 @@ implementation if current_procinfo.procdef.proccalloption in clearstack_pocalls then begin parasize:=0; - if not(use_fixed_stack) and - paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then + if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then inc(parasize,sizeof(aint)); end else