summaryrefslogtreecommitdiff
path: root/src/objcodes.c
diff options
context:
space:
mode:
authorLudovic Courtes <ludovic.courtes@laas.fr>2005-06-24 17:25:36 +0000
committerLudovic Courtès <ludo@gnu.org>2008-04-25 19:09:30 +0200
commit6208295910a6fab78228b8255ed56ccd089bd5f0 (patch)
tree25ff4536767cd202bb8db18759dc3049e99d097b /src/objcodes.c
parent135b32ee84567a7d704fdc1f6b86997bfd970eb9 (diff)
downloadguile-6208295910a6fab78228b8255ed56ccd089bd5f0.tar.gz
Removed a few more deprecated function calls; documented closures.
* src/Makefile.am (.c.x): Fixed the rule. * src/envs.c: Use `scm_hash_get_handle ()' instead of `scm_sym2ovcell_soft ()' and `scm_hash_create_handle_x ()' instead of `scm_intern_symbol ()'. * src/objcodes.c (bytecode->objcode): Don't use `SCM_VALIDATE_INUM', use `SCM_VALIDATE_NUMBER' instead. (make_objcode_by_mmap): Check whether the file is smaller than the magic cookies; check whether the magic cookies are there. * src/frames.c (frame-local-ref): Likewise, but use `SCM_MAKE_VALIDATE'. (frame-local-set!): Likewise. * src/instructions.c (opcode->instruction): Likewise. * src/programs.c (program-external-set!): New function. * src/guile-disasm.in: New file. * src/Makefile.am: Produce `guile-disasm'. * doc/guile-vm.texi: Documented `external-ref', `external-set', `local-ref' and `local-set'. * module/system/vm/disasm.scm (disassemble-bytecode): Fixed the way `load-program' is represented. git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-1
Diffstat (limited to 'src/objcodes.c')
-rw-r--r--src/objcodes.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/objcodes.c b/src/objcodes.c
index 0e494b77a..8903bd338 100644
--- a/src/objcodes.c
+++ b/src/objcodes.c
@@ -82,10 +82,15 @@ make_objcode_by_mmap (int fd)
struct scm_objcode *p;
ret = fstat (fd, &st);
- if (ret < 0) SCM_SYSERROR;
+ if ((ret < 0) || (st.st_size <= strlen (OBJCODE_COOKIE)))
+ SCM_SYSERROR;
addr = mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (addr == MAP_FAILED) SCM_SYSERROR;
+ if (addr == MAP_FAILED)
+ SCM_SYSERROR;
+
+ if (memcmp (addr, OBJCODE_COOKIE, strlen (OBJCODE_COOKIE)))
+ SCM_SYSERROR;
p = scm_gc_malloc (sizeof (struct scm_objcode), "objcode");
p->size = st.st_size;
@@ -179,8 +184,8 @@ SCM_DEFINE (scm_bytecode_to_objcode, "bytecode->objcode", 3, 0, 0,
if (scm_u8vector_p (bytecode) != SCM_BOOL_T)
scm_wrong_type_arg (FUNC_NAME, 1, bytecode);
- SCM_VALIDATE_INUM (2, nlocs);
- SCM_VALIDATE_INUM (3, nexts);
+ SCM_VALIDATE_NUMBER (2, nlocs);
+ SCM_VALIDATE_NUMBER (3, nexts);
c_bytecode = scm_u8vector_elements (bytecode, &handle, &size, &increment);
assert (increment == 1);
@@ -191,8 +196,8 @@ SCM_DEFINE (scm_bytecode_to_objcode, "bytecode->objcode", 3, 0, 0,
base = SCM_OBJCODE_BASE (objcode);
memcpy (base, OBJCODE_COOKIE, 8);
- base[8] = SCM_I_INUM (nlocs);
- base[9] = SCM_I_INUM (nexts);
+ base[8] = scm_to_uint8 (nlocs);
+ base[9] = scm_to_uint8 (nexts);
memcpy (base + 10, c_bytecode, size - 10);