summaryrefslogtreecommitdiff
path: root/libguile/_scm.h
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-05-28 11:09:31 +0200
committerLudovic Courtès <ludo@gnu.org>2010-05-28 17:02:13 +0200
commit405a79ca7ff12ec81e4963c51be4729ebd6cc922 (patch)
tree3b92fbf3bdb0f9d89f4956f927b9982914253a4f /libguile/_scm.h
parent04186f2006bba79ffd7097f3664919078dc4d656 (diff)
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.
Diffstat (limited to 'libguile/_scm.h')
-rw-r--r--libguile/_scm.h30
1 files changed, 30 insertions, 0 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 <errno.h>
#include <verify.h>
+#include <alignof.h>
#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 */