From 405a79ca7ff12ec81e4963c51be4729ebd6cc922 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 28 May 2010 11:09:31 +0200 Subject: [PATCH] Add `scm_t_aligned_cell' internal type. * libguile/_scm.h (struct scm_aligned_cell)[__GNUC__]: New type. (union scm_aligned_cell)[!__GNUC__]: New type. (scm_t_aligned_cell): New type. * libguile/vm.c (vm_dispatch_hook): Use it. --- libguile/_scm.h | 30 ++++++++++++++++++++++++++++++ libguile/vm.c | 6 +----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/libguile/_scm.h b/libguile/_scm.h index 3bb78b466..f18b3a875 100644 --- a/libguile/_scm.h +++ b/libguile/_scm.h @@ -63,6 +63,7 @@ #include #include +#include #include "libguile/__scm.h" /* Include headers for those files central to the implementation. The @@ -192,6 +193,35 @@ #define SCM_OBJCODE_COOKIE \ "GOOF-" SCM_OBJCODE_MACHINE_VERSION_STRING "---" + +/* Cells have to be 8-byte aligned. Use `scm_t_aligned_cell' when not + allocating on the heap to have this guarantee. This is similar to the + `SCM_ALIGNED' macro but provides an option likely to work with compilers + other than GCC. */ + +#ifdef __GNUC__ + +struct scm_aligned_cell +{ + scm_t_cell cell __attribute__ ((__aligned__ (8))); +}; + +typedef struct scm_aligned_cell scm_t_aligned_cell; + +#else /* !__GNUC__ */ + +union scm_aligned_cell +{ + double alignment; + scm_t_cell cell; +}; + +typedef union scm_aligned_cell scm_t_aligned_cell; + +#endif /* !__GNUC__ */ + +/* Make sure we get the right alignment. */ +verify (alignof (scm_t_aligned_cell) >= 8); #endif /* SCM__SCM_H */ diff --git a/libguile/vm.c b/libguile/vm.c index e036b63e1..972abf847 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -190,11 +190,7 @@ vm_dispatch_hook (SCM vm, int hook_num) struct scm_vm *vp; SCM hook; struct scm_frame c_frame; - union - { - double alignment; - scm_t_cell cell; - } frame; + scm_t_aligned_cell frame; SCM args[1]; vp = SCM_VM_DATA (vm); -- 2.20.1