diff --git a/vm/alien.cpp b/vm/alien.cpp index 7bb458c8cd..6a8c334788 100755 --- a/vm/alien.cpp +++ b/vm/alien.cpp @@ -10,10 +10,12 @@ char *pinned_alien_offset(cell obj) switch(tagged(obj).type()) { case ALIEN_TYPE: - alien *ptr = untag(obj); - if(ptr->expired != F) - general_error(ERROR_EXPIRED,obj,F,NULL); - return pinned_alien_offset(ptr->alien) + ptr->displacement; + { + alien *ptr = untag(obj); + if(ptr->expired != F) + general_error(ERROR_EXPIRED,obj,F,NULL); + return pinned_alien_offset(ptr->alien) + ptr->displacement; + } case F_TYPE: return NULL; default: @@ -165,10 +167,12 @@ VM_C_API char *alien_offset(cell obj) case BYTE_ARRAY_TYPE: return untag(obj)->data(); case ALIEN_TYPE: - alien *ptr = untag(obj); - if(ptr->expired != F) - general_error(ERROR_EXPIRED,obj,F,NULL); - return alien_offset(ptr->alien) + ptr->displacement; + { + alien *ptr = untag(obj); + if(ptr->expired != F) + general_error(ERROR_EXPIRED,obj,F,NULL); + return alien_offset(ptr->alien) + ptr->displacement; + } case F_TYPE: return NULL; default: diff --git a/vm/code_block.cpp b/vm/code_block.cpp index 38a421704b..403d9c33d1 100644 --- a/vm/code_block.cpp +++ b/vm/code_block.cpp @@ -279,21 +279,27 @@ void mark_object_code_block(object *object) switch(object->h.hi_tag()) { case WORD_TYPE: - word *w = (word *)object; - if(w->code) - mark_code_block(w->code); - if(w->profiling) - mark_code_block(w->profiling); - break; + { + word *w = (word *)object; + if(w->code) + mark_code_block(w->code); + if(w->profiling) + mark_code_block(w->profiling); + break; + } case QUOTATION_TYPE: - quotation *q = (quotation *)object; - if(q->compiledp != F) - mark_code_block(q->code); - break; + { + quotation *q = (quotation *)object; + if(q->compiledp != F) + mark_code_block(q->code); + break; + } case CALLSTACK_TYPE: - callstack *stack = (callstack *)object; - iterate_callstack_object(stack,mark_stack_frame_step); - break; + { + callstack *stack = (callstack *)object; + iterate_callstack_object(stack,mark_stack_frame_step); + break; + } } } @@ -318,28 +324,32 @@ void *get_rel_symbol(array *literals, cell index) switch(tagged(symbol).type()) { case BYTE_ARRAY_TYPE: - symbol_char *name = alien_offset(symbol); - void *sym = ffi_dlsym(d,name); - - if(sym) - return sym; - else { - printf("%s\n",name); - return (void *)undefined_symbol; - } - case ARRAY_TYPE: - cell i; - array *names = untag(symbol); - for(i = 0; i < array_capacity(names); i++) - { - symbol_char *name = alien_offset(array_nth(names,i)); + symbol_char *name = alien_offset(symbol); void *sym = ffi_dlsym(d,name); if(sym) return sym; + else + { + printf("%s\n",name); + return (void *)undefined_symbol; + } + } + case ARRAY_TYPE: + { + cell i; + array *names = untag(symbol); + for(i = 0; i < array_capacity(names); i++) + { + symbol_char *name = alien_offset(array_nth(names,i)); + void *sym = ffi_dlsym(d,name); + + if(sym) + return sym; + } + return (void *)undefined_symbol; } - return (void *)undefined_symbol; default: critical_error("Bad symbol specifier",symbol); return (void *)undefined_symbol; diff --git a/vm/code_heap.cpp b/vm/code_heap.cpp index 71105dabcf..5dca29b420 100755 --- a/vm/code_heap.cpp +++ b/vm/code_heap.cpp @@ -80,20 +80,22 @@ PRIMITIVE(modify_code_heap) jit_compile_word(word.value(),data.value(),false); break; case ARRAY_TYPE: - array *compiled_data = data.as().untagged(); - cell literals = array_nth(compiled_data,0); - cell relocation = array_nth(compiled_data,1); - cell labels = array_nth(compiled_data,2); - cell code = array_nth(compiled_data,3); + { + array *compiled_data = data.as().untagged(); + cell literals = array_nth(compiled_data,0); + cell relocation = array_nth(compiled_data,1); + cell labels = array_nth(compiled_data,2); + cell code = array_nth(compiled_data,3); - code_block *compiled = add_code_block( - WORD_TYPE, - code, - labels, - relocation, - literals); + code_block *compiled = add_code_block( + WORD_TYPE, + code, + labels, + relocation, + literals); - word->code = compiled; + word->code = compiled; + } break; default: critical_error("Expected a quotation or an array",data.value()); @@ -141,25 +143,28 @@ void forward_object_xts(void) switch(tagged(obj).type()) { case WORD_TYPE: - word *w = untag(obj); + { + word *w = untag(obj); - if(w->code) - w->code = forward_xt(w->code); - if(w->profiling) - w->profiling = forward_xt(w->profiling); - + if(w->code) + w->code = forward_xt(w->code); + if(w->profiling) + w->profiling = forward_xt(w->profiling); + } break; case QUOTATION_TYPE: - quotation *quot = untag(obj); + { + quotation *quot = untag(obj); - if(quot->compiledp != F) - quot->code = forward_xt(quot->code); - + if(quot->compiledp != F) + quot->code = forward_xt(quot->code); + } break; case CALLSTACK_TYPE: - callstack *stack = untag(obj); - iterate_callstack_object(stack,forward_frame_xt); - + { + callstack *stack = untag(obj); + iterate_callstack_object(stack,forward_frame_xt); + } break; default: break; @@ -185,10 +190,12 @@ void fixup_object_xts(void) update_word_xt(obj); break; case QUOTATION_TYPE: - quotation *quot = untag(obj); - if(quot->compiledp != F) - set_quot_xt(quot,quot->code); - break; + { + quotation *quot = untag(obj); + if(quot->compiledp != F) + set_quot_xt(quot,quot->code); + break; + } default: break; } diff --git a/vm/data_gc.cpp b/vm/data_gc.cpp index 57934f92a6..e26edc9721 100755 --- a/vm/data_gc.cpp +++ b/vm/data_gc.cpp @@ -637,7 +637,7 @@ void clear_gc_stats(void) { int i; for(i = 0; i < MAX_GEN_COUNT; i++) - memset(&stats[i],0,sizeof(stats)); + memset(&stats[i],0,sizeof(gc_stats)); cards_scanned = 0; decks_scanned = 0; diff --git a/vm/debug.cpp b/vm/debug.cpp index f405282098..3cd05711ad 100755 --- a/vm/debug.cpp +++ b/vm/debug.cpp @@ -293,7 +293,7 @@ void dump_code_heap(void) while(scan) { - char *status; + const char *status; switch(scan->status) { case B_FREE: diff --git a/vm/errors.cpp b/vm/errors.cpp index 7da6980ece..f2ba355293 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -16,14 +16,14 @@ void out_of_memory(void) exit(1); } -void fatal_error(char* msg, cell tagged) +void fatal_error(const char* msg, cell tagged) { print_string("fatal_error: "); print_string(msg); print_string(": "); print_cell_hex(tagged); nl(); exit(1); } -void critical_error(char* msg, cell tagged) +void critical_error(const char* msg, cell tagged) { print_string("You have triggered a bug in Factor. Please report.\n"); print_string("critical_error: "); print_string(msg); diff --git a/vm/errors.hpp b/vm/errors.hpp index c884770a02..e5968468a5 100755 --- a/vm/errors.hpp +++ b/vm/errors.hpp @@ -23,8 +23,8 @@ enum vm_error_type }; void out_of_memory(void); -void fatal_error(char* msg, cell tagged); -void critical_error(char* msg, cell tagged); +void fatal_error(const char* msg, cell tagged); +void critical_error(const char* msg, cell tagged); PRIMITIVE(die); diff --git a/vm/inline_cache.cpp b/vm/inline_cache.cpp index ea330e863a..5d9fbf069e 100644 --- a/vm/inline_cache.cpp +++ b/vm/inline_cache.cpp @@ -49,9 +49,11 @@ static cell determine_inline_cache_type(array *cache_entries) switch(TAG(klass)) { case FIXNUM_TYPE: - fixnum type = untag_fixnum(klass); - if(type >= HEADER_TYPE) - seen_hi_tag = true; + { + fixnum type = untag_fixnum(klass); + if(type >= HEADER_TYPE) + seen_hi_tag = true; + } break; case ARRAY_TYPE: seen_tuple = true; diff --git a/vm/os-genunix.cpp b/vm/os-genunix.cpp index 1513d6840e..731527d208 100755 --- a/vm/os-genunix.cpp +++ b/vm/os-genunix.cpp @@ -31,7 +31,7 @@ const char *default_image_path(void) const char *iter = path; while(*iter) { len++; iter++; } - char *new_path = safe_malloc(PATH_MAX + SUFFIX_LEN + 1); + char *new_path = (char *)safe_malloc(PATH_MAX + SUFFIX_LEN + 1); memcpy(new_path,path,len + 1); memcpy(new_path + len,SUFFIX,SUFFIX_LEN + 1); return new_path; diff --git a/vm/os-linux.cpp b/vm/os-linux.cpp index c3e10668e7..ecc8973ebe 100644 --- a/vm/os-linux.cpp +++ b/vm/os-linux.cpp @@ -6,7 +6,7 @@ namespace factor /* Snarfed from SBCL linux-so.c. You must free() this yourself. */ const char *vm_executable_path(void) { - char *path = safe_malloc(PATH_MAX + 1); + char *path = (char *)safe_malloc(PATH_MAX + 1); int size = readlink("/proc/self/exe", path, PATH_MAX); if (size < 0)