summaryrefslogtreecommitdiff
path: root/libguile/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/vm.c')
-rw-r--r--libguile/vm.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/libguile/vm.c b/libguile/vm.c
index 41eacd79f..527598b86 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -220,44 +220,33 @@ static SCM sym_vm_run;
static SCM sym_vm_error;
static SCM sym_debug;
-static SCM make_u8vector (const scm_t_uint8 *bytes, size_t len)
-{
- scm_t_uint8 *new_bytes = scm_gc_malloc (len, "make-u8vector");
- memcpy (new_bytes, bytes, len);
- return scm_take_u8vector (new_bytes, len);
-}
-
-/* Dummy structure to guarantee 32-bit alignment. */
-struct t_32bit_aligned
-{
- scm_t_int32 dummy;
- scm_t_uint8 bytes[18];
-};
-
static SCM
really_make_boot_program (long nargs)
{
SCM u8vec;
- struct t_32bit_aligned bytes =
- {
- .dummy = 0,
- .bytes = { 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- scm_op_mv_call, 0, 0, 1,
- scm_op_make_int8_1, scm_op_halt }
- };
-
+ /* Make sure "bytes" is 64-bit aligned. */
+ scm_t_uint8 text[] = { scm_op_mv_call, 0, 0, 1,
+ scm_op_make_int8_1,
+ scm_op_halt };
+ struct scm_objcode *bp;
SCM ret;
- /* Set length in current endianness, no meta. */
- ((scm_t_uint32 *) bytes.bytes)[1] = 6;
-
if (SCM_UNLIKELY (nargs > 255 || nargs < 0))
abort ();
- bytes.bytes[13] = (scm_byte_t) nargs;
-
- u8vec = make_u8vector (bytes.bytes, sizeof (bytes.bytes));
+ text[1] = (scm_t_uint8)nargs;
+
+ bp = scm_gc_malloc (sizeof (struct scm_objcode) + sizeof (text),
+ "make-u8vector");
+ memcpy (bp->base, text, sizeof (text));
+ bp->nargs = 0;
+ bp->nrest = 0;
+ bp->nlocs = 0;
+ bp->len = sizeof(text);
+ bp->metalen = 0;
+ bp->unused = 0;
+
+ u8vec = scm_take_u8vector ((scm_t_uint8*)bp,
+ sizeof (struct scm_objcode) + sizeof (text));
ret = scm_make_program (scm_bytecode_to_objcode (u8vec),
SCM_BOOL_F, SCM_BOOL_F);
SCM_SET_SMOB_FLAGS (ret, SCM_F_PROGRAM_IS_BOOT);