diff options
author | Andy Wingo <wingo@pobox.com> | 2010-11-18 22:30:27 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-11-19 15:22:43 +0100 |
commit | 3d27ef4bd312750f8edca81f09644eab21a3d8e0 (patch) | |
tree | 74f9b5a8c6419e5b2c14bd7df069e7b8c621fa62 | |
parent | f0c56cadfda6f8e9691d5e12cbd1778f36bfde2a (diff) | |
download | guile-3d27ef4bd312750f8edca81f09644eab21a3d8e0.tar.gz |
fix a number of assumptions that a pointer could fit into a long
* libguile/debug.c:
* libguile/eval.c:
* libguile/frames.c:
* libguile/objcodes.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/read.c:
* libguile/struct.c:
* libguile/vm.c: Fix a number of instances in which we assumed we could
fit a pointer into a long.
-rw-r--r-- | libguile/debug.c | 2 | ||||
-rw-r--r-- | libguile/eval.c | 2 | ||||
-rw-r--r-- | libguile/frames.c | 21 | ||||
-rw-r--r-- | libguile/objcodes.c | 11 | ||||
-rw-r--r-- | libguile/print.c | 6 | ||||
-rw-r--r-- | libguile/programs.c | 2 | ||||
-rw-r--r-- | libguile/read.c | 2 | ||||
-rw-r--r-- | libguile/struct.c | 3 | ||||
-rw-r--r-- | libguile/vm.c | 6 |
9 files changed, 28 insertions, 27 deletions
diff --git a/libguile/debug.c b/libguile/debug.c index dd65de45c..e059a3135 100644 --- a/libguile/debug.c +++ b/libguile/debug.c @@ -82,7 +82,7 @@ scm_t_option scm_debug_opts[] = { for anyone!) or a whoppin' 1280 KB on 64-bit arches. */ { SCM_OPTION_INTEGER, "stack", 160000, "Stack size limit (measured in words; 0 = no check)." }, - { SCM_OPTION_SCM, "show-file-name", (unsigned long)SCM_BOOL_T, + { SCM_OPTION_SCM, "show-file-name", (scm_t_bits)SCM_BOOL_T, "Show file names and line numbers " "in backtraces when not `#f'. A value of `base' " "displays only base names, while `#t' displays full names."}, diff --git a/libguile/eval.c b/libguile/eval.c index 293612ed8..414645fca 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -1009,7 +1009,7 @@ boot_closure_print (SCM closure, SCM port, scm_print_state *pstate) { SCM args; scm_puts ("#<boot-closure ", port); - scm_uintprint ((unsigned long)SCM2PTR (closure), 16, port); + scm_uintprint ((scm_t_bits)SCM2PTR (closure), 16, port); scm_putc (' ', port); args = scm_make_list (scm_from_int (BOOT_CLOSURE_NUM_REQUIRED_ARGS (closure)), scm_from_locale_symbol ("_")); diff --git a/libguile/frames.c b/libguile/frames.c index 67ddd1a17..2f870843b 100644 --- a/libguile/frames.c +++ b/libguile/frames.c @@ -209,7 +209,7 @@ SCM_DEFINE (scm_frame_address, "frame-address", 1, 0, 0, #define FUNC_NAME s_scm_frame_address { SCM_VALIDATE_VM_FRAME (1, frame); - return scm_from_ulong ((unsigned long) SCM_VM_FRAME_FP (frame)); + return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_FRAME_FP (frame)); } #undef FUNC_NAME @@ -220,7 +220,7 @@ SCM_DEFINE (scm_frame_stack_pointer, "frame-stack-pointer", 1, 0, 0, { SCM_VALIDATE_VM_FRAME (1, frame); - return scm_from_ulong ((unsigned long) SCM_VM_FRAME_SP (frame)); + return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_FRAME_SP (frame)); } #undef FUNC_NAME @@ -234,9 +234,8 @@ SCM_DEFINE (scm_frame_instruction_pointer, "frame-instruction-pointer", 1, 0, 0, SCM_VALIDATE_VM_FRAME (1, frame); c_objcode = SCM_PROGRAM_DATA (scm_frame_procedure (frame)); - return scm_from_ulong ((unsigned long) - (SCM_VM_FRAME_IP (frame) - - SCM_C_OBJCODE_BASE (c_objcode))); + return scm_from_unsigned_integer ((SCM_VM_FRAME_IP (frame) + - SCM_C_OBJCODE_BASE (c_objcode))); } #undef FUNC_NAME @@ -246,9 +245,9 @@ SCM_DEFINE (scm_frame_return_address, "frame-return-address", 1, 0, 0, #define FUNC_NAME s_scm_frame_return_address { SCM_VALIDATE_VM_FRAME (1, frame); - return scm_from_ulong ((unsigned long) - (SCM_FRAME_RETURN_ADDRESS - (SCM_VM_FRAME_FP (frame)))); + return scm_from_unsigned_integer ((scm_t_bits) + (SCM_FRAME_RETURN_ADDRESS + (SCM_VM_FRAME_FP (frame)))); } #undef FUNC_NAME @@ -258,9 +257,9 @@ SCM_DEFINE (scm_frame_mv_return_address, "frame-mv-return-address", 1, 0, 0, #define FUNC_NAME s_scm_frame_mv_return_address { SCM_VALIDATE_VM_FRAME (1, frame); - return scm_from_ulong ((unsigned long) - (SCM_FRAME_MV_RETURN_ADDRESS - (SCM_VM_FRAME_FP (frame)))); + return scm_from_unsigned_integer ((scm_t_bits) + (SCM_FRAME_MV_RETURN_ADDRESS + (SCM_VM_FRAME_FP (frame)))); } #undef FUNC_NAME diff --git a/libguile/objcodes.c b/libguile/objcodes.c index f54e79bd6..5f3079c87 100644 --- a/libguile/objcodes.c +++ b/libguile/objcodes.c @@ -123,11 +123,12 @@ scm_c_make_objcode_slice (SCM parent, const scm_t_uint8 *ptr) if (ptr < parent_base || ptr >= (parent_base + parent_data->len + parent_data->metalen - sizeof (struct scm_objcode))) - scm_misc_error (FUNC_NAME, "offset out of bounds (~a vs ~a + ~a + ~a)", - scm_list_4 (scm_from_ulong ((unsigned long) ptr), - scm_from_ulong ((unsigned long) parent_base), - scm_from_uint32 (parent_data->len), - scm_from_uint32 (parent_data->metalen))); + scm_misc_error + (FUNC_NAME, "offset out of bounds (~a vs ~a + ~a + ~a)", + scm_list_4 (scm_from_unsigned_integer ((scm_t_bits) ptr), + scm_from_unsigned_integer ((scm_t_bits) parent_base), + scm_from_uint32 (parent_data->len), + scm_from_uint32 (parent_data->metalen))); /* Make sure bytecode for the objcode-meta is suitable aligned. Failing to do so leads to SIGBUS/SIGSEGV on some arches (e.g., SPARC). */ diff --git a/libguile/print.c b/libguile/print.c index 8c807bbaf..f62378f46 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -89,11 +89,11 @@ static const char *iflagnames[] = SCM_SYMBOL (sym_reader, "reader"); scm_t_option scm_print_opts[] = { - { SCM_OPTION_SCM, "highlight-prefix", (unsigned long)SCM_BOOL_F, + { SCM_OPTION_SCM, "highlight-prefix", (scm_t_bits)SCM_BOOL_F, "The string to print before highlighted values." }, - { SCM_OPTION_SCM, "highlight-suffix", (unsigned long)SCM_BOOL_F, + { SCM_OPTION_SCM, "highlight-suffix", (scm_t_bits)SCM_BOOL_F, "The string to print after highlighted values." }, - { SCM_OPTION_SCM, "quote-keywordish-symbols", (unsigned long)SCM_BOOL_F, + { SCM_OPTION_SCM, "quote-keywordish-symbols", (scm_t_bits)SCM_BOOL_F, "How to print symbols that have a colon as their first or last character. " "The value '#f' does not quote the colons; '#t' quotes them; " "'reader' quotes them when the reader option 'keywords' is not '#f'." diff --git a/libguile/programs.c b/libguile/programs.c index 4404f832a..8b769a576 100644 --- a/libguile/programs.c +++ b/libguile/programs.c @@ -131,7 +131,7 @@ SCM_DEFINE (scm_program_base, "program-base", 1, 0, 0, SCM_VALIDATE_PROGRAM (1, program); c_objcode = SCM_PROGRAM_DATA (program); - return scm_from_ulong ((unsigned long) SCM_C_OBJCODE_BASE (c_objcode)); + return scm_from_unsigned_integer ((scm_t_bits) SCM_C_OBJCODE_BASE (c_objcode)); } #undef FUNC_NAME diff --git a/libguile/read.c b/libguile/read.c index 52ec20d9a..18047d80d 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -69,7 +69,7 @@ scm_t_option scm_read_opts[] = { "Record positions of source code expressions." }, { SCM_OPTION_BOOLEAN, "case-insensitive", 0, "Convert symbols to lower case."}, - { SCM_OPTION_SCM, "keywords", (unsigned long) SCM_BOOL_F, + { SCM_OPTION_SCM, "keywords", (scm_t_bits) SCM_BOOL_F, "Style of keyword recognition: #f, 'prefix or 'postfix."}, { SCM_OPTION_BOOLEAN, "r6rs-hex-escapes", 0, "Use R6RS variable-length character and string hex escapes."}, diff --git a/libguile/struct.c b/libguile/struct.c index c784f59bb..e5ecc1aaf 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -926,7 +926,8 @@ SCM_DEFINE (scm_struct_vtable_tag, "struct-vtable-tag", 1, 0, 0, #define FUNC_NAME s_scm_struct_vtable_tag { SCM_VALIDATE_VTABLE (1, handle); - return scm_from_ulong (((unsigned long)SCM_STRUCT_DATA (handle)) >> 3); + return scm_from_unsigned_integer + (((scm_t_bits)SCM_STRUCT_DATA (handle)) >> 3); } #undef FUNC_NAME diff --git a/libguile/vm.c b/libguile/vm.c index e1a90e127..c08b084e6 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -606,7 +606,7 @@ SCM_DEFINE (scm_vm_ip, "vm:ip", 1, 0, 0, #define FUNC_NAME s_scm_vm_ip { SCM_VALIDATE_VM (1, vm); - return scm_from_ulong ((unsigned long) SCM_VM_DATA (vm)->ip); + return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_DATA (vm)->ip); } #undef FUNC_NAME @@ -616,7 +616,7 @@ SCM_DEFINE (scm_vm_sp, "vm:sp", 1, 0, 0, #define FUNC_NAME s_scm_vm_sp { SCM_VALIDATE_VM (1, vm); - return scm_from_ulong ((unsigned long) SCM_VM_DATA (vm)->sp); + return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_DATA (vm)->sp); } #undef FUNC_NAME @@ -626,7 +626,7 @@ SCM_DEFINE (scm_vm_fp, "vm:fp", 1, 0, 0, #define FUNC_NAME s_scm_vm_fp { SCM_VALIDATE_VM (1, vm); - return scm_from_ulong ((unsigned long) SCM_VM_DATA (vm)->fp); + return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_DATA (vm)->fp); } #undef FUNC_NAME |