FreeBSD32 struct return

This commit is contained in:
herman ten brugge 2020-12-31 06:48:14 +01:00
parent 9d49883895
commit 8db839cc85

View file

@ -379,7 +379,7 @@ static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX };
returning via struct pointer. */ returning via struct pointer. */
ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align, int *regsize) ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align, int *regsize)
{ {
#ifdef TCC_TARGET_PE #if defined(TCC_TARGET_PE) || TARGETOS_FreeBSD
int size, align; int size, align;
*ret_align = 1; // Never have to re-align return values for x86 *ret_align = 1; // Never have to re-align return values for x86
*regsize = 4; *regsize = 4;
@ -501,7 +501,7 @@ ST_FUNC void gfunc_call(int nb_args)
args_size -= 4; args_size -= 4;
} }
} }
#ifndef TCC_TARGET_PE #if !defined(TCC_TARGET_PE) && !TARGETOS_FreeBSD
else if ((vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT) else if ((vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT)
args_size -= 4; args_size -= 4;
#endif #endif
@ -551,7 +551,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym)
func_sub_sp_offset = ind; func_sub_sp_offset = ind;
/* if the function returns a structure, then add an /* if the function returns a structure, then add an
implicit pointer parameter */ implicit pointer parameter */
#ifdef TCC_TARGET_PE #if defined(TCC_TARGET_PE) || TARGETOS_FreeBSD
size = type_size(&func_vt,&align); size = type_size(&func_vt,&align);
if (((func_vt.t & VT_BTYPE) == VT_STRUCT) if (((func_vt.t & VT_BTYPE) == VT_STRUCT)
&& (size > 8 || (size & (size - 1)))) { && (size > 8 || (size & (size - 1)))) {
@ -592,7 +592,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym)
/* pascal type call or fastcall ? */ /* pascal type call or fastcall ? */
if (func_call == FUNC_STDCALL || func_call == FUNC_FASTCALLW) if (func_call == FUNC_STDCALL || func_call == FUNC_FASTCALLW)
func_ret_sub = addr - 8; func_ret_sub = addr - 8;
#ifndef TCC_TARGET_PE #if !defined(TCC_TARGET_PE) && !TARGETOS_FreeBSD
else if (func_vc) else if (func_vc)
func_ret_sub = 4; func_ret_sub = 4;
#endif #endif