From 8e4c60ff2902363b41f4c23e686ad65c17e90196 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 26 Sep 2010 16:24:35 +0200 Subject: [PATCH] Fix argument passing in VM hooks. * libguile/vm.c (vm_dispatch_hook): Take care of FRAME's alignment explicitly so that it's correct even if the current stack frame isn't 8-byte aligned (as can be the case on i686--the SysV i386 ABI just says that the stack is word-aligned.) --- libguile/vm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libguile/vm.c b/libguile/vm.c index 7512d10ff..17ad96dd5 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -191,7 +191,7 @@ vm_dispatch_hook (SCM vm, int hook_num) struct scm_vm *vp; SCM hook; struct scm_frame c_frame; - scm_t_aligned_cell frame; + scm_t_cell *frame; SCM args[1]; int saved_trace_level; @@ -218,9 +218,14 @@ vm_dispatch_hook (SCM vm, int hook_num) c_frame.sp = vp->sp; c_frame.ip = vp->ip; c_frame.offset = 0; - frame.cell.word_0 = SCM_PACK (scm_tc7_frame); - frame.cell.word_1 = PTR2SCM (&c_frame); - args[0] = PTR2SCM (&frame); + + /* Arrange for FRAME to be 8-byte aligned, like any other cell. */ + frame = alloca (sizeof (*frame) + 8); + frame = (scm_t_cell *) ROUND_UP ((scm_t_uintptr) frame, 8UL); + + frame->word_0 = SCM_PACK (scm_tc7_frame); + frame->word_1 = PTR2SCM (&c_frame); + args[0] = PTR2SCM (frame); scm_c_run_hookn (hook, args, 1); -- 2.20.1