diff --git a/scheme/last-revision b/scheme/last-revision index 9c113c6..4b809f8 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1275 +1276 diff --git a/src/ikarus-collect.c b/src/ikarus-collect.c index 519bf67..61550a4 100644 --- a/src/ikarus-collect.c +++ b/src/ikarus-collect.c @@ -28,7 +28,7 @@ #include #include -#define forward_ptr ((ikp)-1) +#define forward_ptr ((ikptr)-1) #define minimum_heap_size (pagesize * 1024 * 4) #define maximum_heap_size (pagesize * 1024 * 8) #define minimum_stack_size (pagesize * 128) @@ -47,17 +47,17 @@ static int htable_count = 0; #endif typedef struct qupages_t{ - ikp p; /* pointer to the scan start */ - ikp q; /* pointer to the scan end */ + ikptr p; /* pointer to the scan start */ + ikptr q; /* pointer to the scan end */ struct qupages_t* next; } qupages_t; typedef struct{ - ikp ap; - ikp aq; - ikp ep; - ikp base; + ikptr ap; + ikptr aq; + ikptr ep; + ikptr base; } meta_t; @@ -94,9 +94,9 @@ typedef struct gc_t{ unsigned int* segment_vector; int collect_gen; int collect_gen_tag; - ikp tconc_ap; - ikp tconc_ep; - ikp tconc_base; + ikptr tconc_ap; + ikptr tconc_ep; + ikptr tconc_base; ikpages* tconc_queue; } gc_t; @@ -109,7 +109,7 @@ next_gen_tag[generation_count] = { (0 << meta_dirty_shift) | 4 | new_gen_tag }; -static ikp +static ikptr meta_alloc_extending(int size, gc_t* gc, int meta_id){ int mapsize = align_to_next_page(size); if(mapsize < extension_amount[meta_id]){ @@ -118,20 +118,20 @@ meta_alloc_extending(int size, gc_t* gc, int meta_id){ meta_t* meta = &gc->meta[meta_id]; if((meta_id != meta_data) && meta->base){ qupages_t* p = ik_malloc(sizeof(qupages_t)); - ikp aq = meta->aq; - ikp ap = meta->ap; - ikp ep = meta->ep; + ikptr aq = meta->aq; + ikptr ap = meta->ap; + ikptr ep = meta->ep; p->p = aq; p->q = ap; p->next = gc->queues[meta_id]; gc->queues[meta_id] = p; - ikp x = ap; + ikptr x = ap; while(x < ep){ ref(x, 0) = 0; x += wordsize; } } - ikp mem = ik_mmap_typed( + ikptr mem = ik_mmap_typed( mapsize, meta_mt[meta_id] | gc->collect_gen_tag, gc->pcb); @@ -146,13 +146,13 @@ meta_alloc_extending(int size, gc_t* gc, int meta_id){ -static inline ikp +static inline ikptr meta_alloc(int size, gc_t* gc, int meta_id){ assert(size == align(size)); meta_t* meta = &gc->meta[meta_id]; - ikp ap = meta->ap; - ikp ep = meta->ep; - ikp nap = ap + size; + ikptr ap = meta->ap; + ikptr ep = meta->ep; + ikptr nap = ap + size; if(nap > ep){ return meta_alloc_extending(size, gc, meta_id); } else { @@ -161,16 +161,16 @@ meta_alloc(int size, gc_t* gc, int meta_id){ } } -static inline ikp +static inline ikptr gc_alloc_new_ptr(int size, gc_t* gc){ assert(size == align(size)); return meta_alloc(size, gc, meta_ptrs); } -static inline ikp +static inline ikptr gc_alloc_new_large_ptr(int size, gc_t* gc){ int memreq = align_to_next_page(size); - ikp mem = + ikptr mem = ik_mmap_typed(memreq, pointers_mt | large_object_tag | gc->collect_gen_tag, gc->pcb); @@ -186,7 +186,7 @@ gc_alloc_new_large_ptr(int size, gc_t* gc){ static inline void -enqueue_large_ptr(ikp mem, int size, gc_t* gc){ +enqueue_large_ptr(ikptr mem, int size, gc_t* gc){ int i = page_index(mem); int j = page_index(mem+size-1); while(i<=j){ @@ -202,7 +202,7 @@ enqueue_large_ptr(ikp mem, int size, gc_t* gc){ } -static inline ikp +static inline ikptr gc_alloc_new_symbol_record(gc_t* gc){ assert(symbol_record_size == align(symbol_record_size)); return meta_alloc(symbol_record_size, gc, meta_symbol); @@ -211,21 +211,21 @@ gc_alloc_new_symbol_record(gc_t* gc){ -static inline ikp +static inline ikptr gc_alloc_new_pair(gc_t* gc){ return meta_alloc(pair_size, gc, meta_pair); } -static inline ikp +static inline ikptr gc_alloc_new_weak_pair(gc_t* gc){ meta_t* meta = &gc->meta[meta_weak]; - ikp ap = meta->ap; - ikp ep = meta->ep; - ikp nap = ap + pair_size; + ikptr ap = meta->ap; + ikptr ep = meta->ep; + ikptr nap = ap + pair_size; if(nap > ep){ - ikp mem = ik_mmap_typed( + ikptr mem = ik_mmap_typed( pagesize, meta_mt[meta_weak] | gc->collect_gen_tag, gc->pcb); @@ -241,20 +241,20 @@ gc_alloc_new_weak_pair(gc_t* gc){ } } -static inline ikp +static inline ikptr gc_alloc_new_data(int size, gc_t* gc){ assert(size == align(size)); return meta_alloc(size, gc, meta_data); } -static inline ikp +static inline ikptr gc_alloc_new_code(int size, gc_t* gc){ assert(size == align(size)); if(size < pagesize){ return meta_alloc(size, gc, meta_code); } else { int memreq = align_to_next_page(size); - ikp mem = ik_mmap_code(memreq, gc->collect_gen, gc->pcb); + ikptr mem = ik_mmap_code(memreq, gc->collect_gen, gc->pcb); gc->segment_vector = gc->pcb->segment_vector; qupages_t* p = ik_malloc(sizeof(qupages_t)); p->p = mem; @@ -280,7 +280,7 @@ add_to_collect_count(ikpcb* pcb, int bytes){ static void -gc_tconc_push_extending(gc_t* gc, ikp tcbucket){ +gc_tconc_push_extending(gc_t* gc, ikptr tcbucket){ if(gc->tconc_base){ ikpages* p = ik_malloc(sizeof(ikpages)); p->base = gc->tconc_base; @@ -288,14 +288,14 @@ gc_tconc_push_extending(gc_t* gc, ikp tcbucket){ p->next = gc->tconc_queue; gc->tconc_queue = p; } - ikp ap = + ikptr ap = ik_mmap_typed(pagesize, meta_mt[meta_ptrs] | gc->collect_gen_tag, gc->pcb); add_to_collect_count(gc->pcb, pagesize); gc->segment_vector = gc->pcb->segment_vector; bzero(ap, pagesize); - ikp nap = ap + 2*wordsize; + ikptr nap = ap + 2*wordsize; gc->tconc_base = ap; gc->tconc_ap = nap; gc->tconc_ep = ap + pagesize; @@ -304,9 +304,9 @@ gc_tconc_push_extending(gc_t* gc, ikp tcbucket){ static inline void -gc_tconc_push(gc_t* gc, ikp tcbucket){ - ikp ap = gc->tconc_ap; - ikp nap = ap + 2*wordsize; +gc_tconc_push(gc_t* gc, ikptr tcbucket){ + ikptr ap = gc->tconc_ap; + ikptr nap = ap + 2*wordsize; if(nap > gc->tconc_ep){ gc_tconc_push_extending(gc, tcbucket); } else { @@ -317,14 +317,14 @@ gc_tconc_push(gc_t* gc, ikp tcbucket){ #ifndef NDEBUG -static ikp add_object_proc(gc_t* gc, ikp x, char* caller); +static ikptr add_object_proc(gc_t* gc, ikptr x, char* caller); #define add_object(gc,x,caller) add_object_proc(gc,x,caller) #else -static ikp add_object_proc(gc_t* gc, ikp x); +static ikptr add_object_proc(gc_t* gc, ikptr x); #define add_object(gc,x,caller) add_object_proc(gc,x) #endif -static void collect_stack(gc_t*, ikp top, ikp base); +static void collect_stack(gc_t*, ikptr top, ikptr base); static void collect_loop(gc_t*); static void forward_guardians(gc_t*); static void fix_weak_pointers(gc_t*); @@ -515,7 +515,7 @@ ik_collect(int mem_req, ikpcb* pcb){ pcb->heap_base, pcb->heap_size, pcb); - ikp ptr = ik_mmap_mixed(memsize+2*pagesize, pcb); + ikptr ptr = ik_mmap_mixed(memsize+2*pagesize, pcb); pcb->allocation_pointer = ptr; pcb->allocation_redline = ptr+memsize; pcb->heap_base = ptr; @@ -523,9 +523,9 @@ ik_collect(int mem_req, ikpcb* pcb){ } #ifndef NDEBUG - ikp x = pcb->allocation_pointer; + ikptr x = pcb->allocation_pointer; while(x < pcb->allocation_redline){ - ref(x, 0) = (ikp)(0x1234FFFF); + ref(x, 0) = (ikptr)(0x1234FFFF); x+=wordsize; } #endif @@ -574,7 +574,7 @@ ik_collect(int mem_req, ikpcb* pcb){ } static inline int -is_live(ikp x, gc_t* gc){ +is_live(ikptr x, gc_t* gc){ if(is_fixnum(x)){ return 1; } @@ -599,7 +599,7 @@ next_gen(int i){ } static ik_ptr_page* -move_guardian(ikp x, ik_ptr_page* dst, ik_ptr_page** cache){ +move_guardian(ikptr x, ik_ptr_page* dst, ik_ptr_page** cache){ if((dst == 0) || (dst->count == ik_ptr_page_size)){ ik_ptr_page* y = *cache; if(y){ @@ -637,9 +637,9 @@ forward_guardians_initial(gc_t* gc, int i; int n = src->count; for(i=0; iptr[i]; - ikp tc = ref(a, off_car); - ikp obj = ref(a, off_cdr); + ikptr a = src->ptr[i]; + ikptr tc = ref(a, off_car); + ikptr obj = ref(a, off_cdr); if(is_live(tc, gc)){ if(is_live(obj, gc)){ live_live = move_guardian(a, live_live, cache); @@ -681,8 +681,8 @@ forward_guardians_revive_dead(gc_t* gc, int i; int n = src->count; for(i=0; iptr[i]; - ikp obj = ref(a, off_cdr); + ikptr a = src->ptr[i]; + ikptr obj = ref(a, off_cdr); add_object(gc, obj, "guardian1"); } src = src->next; @@ -709,8 +709,8 @@ forward_guardians_process_tconcs(gc_t* gc, int i; int n = src->count; for(i=0; iptr[i]; - ikp tc = ref(a, off_car); + ikptr a = src->ptr[i]; + ikptr tc = ref(a, off_car); if(is_live(tc, gc)){ live = move_guardian(a, live, cache); } else { @@ -736,8 +736,8 @@ forward_guardians_process_tconcs(gc_t* gc, int i; int n = src->count; for(i=0; iptr[i]; - ikp tc = ref(a, off_car); + ikptr a = src->ptr[i]; + ikptr tc = ref(a, off_car); if(is_live(tc, gc)){ some_were_revived = 1; add_object(gc, ref(a, off_cdr), "guardian2"); @@ -849,11 +849,11 @@ empty_dropped_guardians(gc_t* gc){ int i; int n = src->count; for(i=0; iptr[i]; - ikp tc = ref(a, off_car); - ikp obj = ref(a, off_cdr); + ikptr a = src->ptr[i]; + ikptr tc = ref(a, off_car); + ikptr obj = ref(a, off_cdr); assert(tagof(tc) == pair_tag); - ikp d = ref(tc, off_cdr); + ikptr d = ref(tc, off_cdr); assert(tagof(d) == pair_tag); ref(d, off_car) = obj; ref(d, off_cdr) = a; @@ -889,9 +889,9 @@ empty_dropped_guardians(gc_t* gc){ static int alloc_code_count = 0; -static ikp -add_code_entry(gc_t* gc, ikp entry){ - ikp x = entry - disp_code_data; +static ikptr +add_code_entry(gc_t* gc, ikptr entry){ + ikptr x = entry - disp_code_data; if(ref(x,0) == forward_ptr){ return ref(x,wordsize) + off_code_data; } @@ -902,9 +902,9 @@ add_code_entry(gc_t* gc, ikp entry){ return entry; } int code_size = unfix(ref(x, disp_code_code_size)); - ikp reloc_vec = ref(x, disp_code_reloc_vector); - ikp freevars = ref(x, disp_code_freevars); - ikp annotation = ref(x, disp_code_annotation); + ikptr reloc_vec = ref(x, disp_code_reloc_vector); + ikptr freevars = ref(x, disp_code_freevars); + ikptr annotation = ref(x, disp_code_annotation); int required_mem = align(disp_code_data + code_size); if(required_mem >= pagesize){ int new_tag = gc->collect_gen_tag; @@ -921,7 +921,7 @@ add_code_entry(gc_t* gc, ikp entry){ gc->queues[meta_code] = p; return entry; } else { - ikp y = gc_alloc_new_code(required_mem, gc); + ikptr y = gc_alloc_new_code(required_mem, gc); ref(y, 0) = code_tag; ref(y, disp_code_code_size) = fix(code_size); ref(y, disp_code_reloc_vector) = reloc_vec; @@ -937,7 +937,7 @@ add_code_entry(gc_t* gc, ikp entry){ #define DEBUG_STACK 0 -static void collect_stack(gc_t* gc, ikp top, ikp end){ +static void collect_stack(gc_t* gc, ikptr top, ikptr end){ if(DEBUG_STACK){ fprintf(stderr, "collecting stack from 0x%08x .. 0x%08x\n", (int) top, (int) end); @@ -946,7 +946,7 @@ static void collect_stack(gc_t* gc, ikp top, ikp end){ if(DEBUG_STACK){ fprintf(stderr, "collecting frame at 0x%08x: ", (int) top); } - ikp rp = ref(top, 0); + ikptr rp = ref(top, 0); int rp_offset = unfix(ref(rp, disp_frame_offset)); if(DEBUG_STACK){ fprintf(stderr, "rp_offset=%d\n", rp_offset); @@ -960,9 +960,9 @@ static void collect_stack(gc_t* gc, ikp top, ikp end){ * updated to reflect the new code object. */ int code_offset = rp_offset - disp_frame_offset; - ikp code_entry = rp - code_offset; - ikp new_code_entry = add_code_entry(gc, code_entry); - ikp new_rp = new_code_entry + code_offset; + ikptr code_entry = rp - code_offset; + ikptr new_code_entry = add_code_entry(gc, code_entry); + ikptr new_rp = new_code_entry + code_offset; ref(top, 0) = new_rp; /* now for some livemask action. @@ -1013,18 +1013,18 @@ static void collect_stack(gc_t* gc, ikp top, ikp end){ fprintf(stderr, "invalid redirected framesize=%d\n", framesize); exit(-1); } - ikp base = top + framesize - wordsize; + ikptr base = top + framesize - wordsize; while(base > top){ - ikp new_obj = add_object(gc,ref(base,0), "frame"); + ikptr new_obj = add_object(gc,ref(base,0), "frame"); ref(base,0) = new_obj; base -= wordsize; } } else { int frame_cells = framesize >> fx_shift; int bytes_in_mask = (frame_cells+7) >> 3; - unsigned char* mask = rp + disp_frame_size - bytes_in_mask; + char* mask = rp + disp_frame_size - bytes_in_mask; - ikp* fp = (ikp*)(top + framesize); + ikptr* fp = (ikptr*)(top + framesize); int i; for(i=0; icollect_gen; while(1){ - ikp fst = ref(x, off_car); - ikp snd = ref(x, off_cdr); - ikp y; + ikptr fst = ref(x, off_car); + ikptr snd = ref(x, off_cdr); + ikptr y; if((t & type_mask) != weak_pairs_type){ y = gc_alloc_new_pair(gc) + pair_tag; } else { @@ -1084,7 +1084,7 @@ add_list(gc_t* gc, unsigned int t, ikp x, ikp* loc){ return; } else { x = snd; - loc = (ikp*)(y + off_cdr); + loc = (ikptr*)(y + off_cdr); /* don't return */ } } @@ -1107,11 +1107,11 @@ add_list(gc_t* gc, unsigned int t, ikp x, ikp* loc){ } -static ikp +static ikptr #ifndef NDEBUG -add_object_proc(gc_t* gc, ikp x, char* caller) +add_object_proc(gc_t* gc, ikptr x, char* caller) #else -add_object_proc(gc_t* gc, ikp x) +add_object_proc(gc_t* gc, ikptr x) #endif { if(is_fixnum(x)){ @@ -1122,7 +1122,7 @@ add_object_proc(gc_t* gc, ikp x) if(tag == immediate_tag){ return x; } - ikp fst = ref(x, -tag); + ikptr fst = ref(x, -tag); if(fst == forward_ptr){ /* already moved */ return ref(x, wordsize-tag); @@ -1133,14 +1133,14 @@ add_object_proc(gc_t* gc, ikp x) return x; } if(tag == pair_tag){ - ikp y; + ikptr y; add_list(gc, t, x, &y); return y; } #if 0 else if(tag == symbol_tag){ - //ikp y = gc_alloc_new_ptr(align(symbol_size),gen, gc) + symbol_tag; - ikp y = gc_alloc_new_symbol(gen, gc) + symbol_tag; + //ikptr y = gc_alloc_new_ptr(align(symbol_size),gen, gc) + symbol_tag; + ikptr y = gc_alloc_new_symbol(gen, gc) + symbol_tag; ref(y, off_symbol_string) = ref(x, off_symbol_string); ref(y, off_symbol_ustring) = ref(x, off_symbol_ustring); ref(y, off_symbol_value) = ref(x, off_symbol_value); @@ -1164,7 +1164,7 @@ add_object_proc(gc_t* gc, ikp x) fprintf(stderr, "large closure size=0x%08x\n", size); } int asize = align(size); - ikp y = gc_alloc_new_ptr(asize, gc) + closure_tag; + ikptr y = gc_alloc_new_ptr(asize, gc) + closure_tag; ref(y, asize-closure_tag-wordsize) = 0; memcpy(y-closure_tag, x-closure_tag, size); ref(y,-closure_tag) = add_code_entry(gc, ref(y,-closure_tag)); @@ -1187,7 +1187,7 @@ add_object_proc(gc_t* gc, ikp x) enqueue_large_ptr(x-vector_tag, size+disp_vector_data, gc); return x; } else { - ikp y = gc_alloc_new_large_ptr(size+disp_vector_data, gc) + ikptr y = gc_alloc_new_large_ptr(size+disp_vector_data, gc) + vector_tag; ref(y, disp_vector_length-vector_tag) = fst; ref(y, memreq-vector_tag-wordsize) = 0; @@ -1197,7 +1197,7 @@ add_object_proc(gc_t* gc, ikp x) return y; } } else { - ikp y = gc_alloc_new_ptr(memreq, gc) + vector_tag; + ikptr y = gc_alloc_new_ptr(memreq, gc) + vector_tag; ref(y, disp_vector_length-vector_tag) = fst; ref(y, memreq-vector_tag-wordsize) = 0; memcpy(y+off_vector_data, x+off_vector_data, size); @@ -1210,7 +1210,7 @@ add_object_proc(gc_t* gc, ikp x) #endif } else if(fst == symbol_record_tag){ - ikp y = gc_alloc_new_symbol_record(gc) + record_tag; + ikptr y = gc_alloc_new_symbol_record(gc) + record_tag; ref(y, -record_tag) = symbol_record_tag; ref(y, off_symbol_record_string) = ref(x, off_symbol_record_string); ref(y, off_symbol_record_ustring) = ref(x, off_symbol_record_ustring); @@ -1228,12 +1228,12 @@ add_object_proc(gc_t* gc, ikp x) /* size = n * object_alignment + 4 => memreq = n * object_alignment + 8 = (n+1) * object_alignment => aligned */ - ikp y = gc_alloc_new_ptr(size+wordsize, gc) + vector_tag; + ikptr y = gc_alloc_new_ptr(size+wordsize, gc) + vector_tag; ref(y, -vector_tag) = fst; { int i; - ikp p = y+disp_record_data-vector_tag; - ikp q = x+disp_record_data-vector_tag; + ikptr p = y+disp_record_data-vector_tag; + ikptr q = x+disp_record_data-vector_tag; ref(p, 0) = ref(q, 0); for(i=wordsize; i memreq = n * object_alignment + 4 + 4 (pad) */ - ikp y = gc_alloc_new_ptr(size+(2*wordsize), gc) + vector_tag; + ikptr y = gc_alloc_new_ptr(size+(2*wordsize), gc) + vector_tag; ref(y, -vector_tag) = fst; { int i; - ikp p = y+disp_record_data-vector_tag; - ikp q = x+disp_record_data-vector_tag; + ikptr p = y+disp_record_data-vector_tag; + ikptr q = x+disp_record_data-vector_tag; for(i=0; i 4096){ fprintf(stderr, "large cont size=0x%08x\n", size); } #endif - ikp next = ref(x, off_continuation_next); - ikp y = gc_alloc_new_ptr(continuation_size, gc) + vector_tag; + ikptr next = ref(x, off_continuation_next); + ikptr y = gc_alloc_new_ptr(continuation_size, gc) + vector_tag; ref(x, -vector_tag) = forward_ptr; ref(x, wordsize-vector_tag) = y; - ikp new_top = gc_alloc_new_data(align(size), gc); + ikptr new_top = gc_alloc_new_data(align(size), gc); memcpy(new_top, top, size); collect_stack(gc, new_top, new_top + size); ref(y, -vector_tag) = continuation_tag; ref(y, off_continuation_top) = new_top; - ref(y, off_continuation_size) = (ikp) size; + ref(y, off_continuation_size) = (ikptr) size; ref(y, off_continuation_next) = next; #if accounting continuation_count++; @@ -1294,9 +1294,9 @@ add_object_proc(gc_t* gc, ikp x) } else if(tagof(fst) == pair_tag){ /* tcbucket */ - ikp y = gc_alloc_new_ptr(tcbucket_size, gc) + vector_tag; + ikptr y = gc_alloc_new_ptr(tcbucket_size, gc) + vector_tag; ref(y,off_tcbucket_tconc) = fst; - ikp key = ref(x, off_tcbucket_key); + ikptr key = ref(x, off_tcbucket_key); ref(y,off_tcbucket_key) = key; ref(y,off_tcbucket_val) = ref(x, off_tcbucket_val); ref(y,off_tcbucket_next) = ref(x, off_tcbucket_next); @@ -1312,7 +1312,7 @@ add_object_proc(gc_t* gc, ikp x) return y; } else if((((int)fst) & port_mask) == port_tag){ - ikp y = gc_alloc_new_ptr(port_size, gc) + vector_tag; + ikptr y = gc_alloc_new_ptr(port_size, gc) + vector_tag; ref(y, -vector_tag) = fst; int i; for(i=wordsize; i> bignum_length_shift; int memreq = align(disp_bignum_data + len*wordsize); - ikp new = gc_alloc_new_data(memreq, gc) + vector_tag; + ikptr new = gc_alloc_new_data(memreq, gc) + vector_tag; memcpy(new-vector_tag, x-vector_tag, memreq); ref(x, -vector_tag) = forward_ptr; ref(x, wordsize-vector_tag) = new; return new; } else if(fst == ratnum_tag){ - ikp y = gc_alloc_new_data(ratnum_size, gc) + vector_tag; - ikp num = ref(x, disp_ratnum_num-vector_tag); - ikp den = ref(x, disp_ratnum_den-vector_tag); + ikptr y = gc_alloc_new_data(ratnum_size, gc) + vector_tag; + ikptr num = ref(x, disp_ratnum_num-vector_tag); + ikptr den = ref(x, disp_ratnum_den-vector_tag); ref(x, -vector_tag) = forward_ptr; ref(x, wordsize-vector_tag) = y; ref(y, -vector_tag) = fst; @@ -1360,7 +1360,7 @@ add_object_proc(gc_t* gc, ikp x) if(is_fixnum(fst)){ int strlen = unfix(fst); int memreq = align(strlen*string_char_size + disp_string_data); - ikp new_str = gc_alloc_new_data(memreq, gc) + string_tag; + ikptr new_str = gc_alloc_new_data(memreq, gc) + string_tag; ref(new_str, off_string_length) = fst; memcpy(new_str+off_string_data, x + off_string_data, @@ -1381,7 +1381,7 @@ add_object_proc(gc_t* gc, ikp x) else if(tag == bytevector_tag){ int len = unfix(fst); int memreq = align(len + disp_bytevector_data + 1); - ikp new_bv = gc_alloc_new_data(memreq, gc) + bytevector_tag; + ikptr new_bv = gc_alloc_new_data(memreq, gc) + bytevector_tag; ref(new_bv, off_bytevector_length) = fst; memcpy(new_bv+off_bytevector_data, x + off_bytevector_data, @@ -1395,16 +1395,16 @@ add_object_proc(gc_t* gc, ikp x) } static void -relocate_new_code(ikp x, gc_t* gc){ - ikp relocvector = ref(x, disp_code_reloc_vector); +relocate_new_code(ikptr x, gc_t* gc){ + ikptr relocvector = ref(x, disp_code_reloc_vector); relocvector = add_object(gc, relocvector, "relocvec"); ref(x, disp_code_reloc_vector) = relocvector; ref(x, disp_code_annotation) = add_object(gc, ref(x, disp_code_annotation), "annotation"); int relocsize = (int)ref(relocvector, off_vector_length); - ikp p = relocvector + off_vector_data; - ikp q = p + relocsize; - ikp code = x + disp_code_data; + ikptr p = relocvector + off_vector_data; + ikptr q = p + relocsize; + ikptr code = x + disp_code_data; while(p < q){ int r = unfix(ref(p, 0)); int tag = r & 3; @@ -1415,31 +1415,31 @@ relocate_new_code(ikp x, gc_t* gc){ // fprintf(stderr, "r=0x%08x code_off=%d reloc_size=0x%08x\n", // r, code_off, relocsize); #endif - ikp old_object = ref(p, wordsize); - ikp new_object = add_object(gc, old_object, "reloc1"); + ikptr old_object = ref(p, wordsize); + ikptr new_object = add_object(gc, old_object, "reloc1"); ref(code, code_off) = new_object; p += (2*wordsize); } else if(tag == 2){ /* displaced pointer */ int obj_off = unfix(ref(p, wordsize)); - ikp old_object = ref(p, 2*wordsize); - ikp new_object = add_object(gc, old_object, "reloc2"); + ikptr old_object = ref(p, 2*wordsize); + ikptr new_object = add_object(gc, old_object, "reloc2"); ref(code, code_off) = new_object + obj_off; p += (3 * wordsize); } else if(tag == 3){ /* displaced relative pointer */ int obj_off = unfix(ref(p, wordsize)); - ikp obj = ref(p, 2*wordsize); + ikptr obj = ref(p, 2*wordsize); #ifndef NDEBUG //fprintf(stderr, "obj=0x%08x, obj_off=0x%08x\n", (int)obj, // obj_off); #endif obj = add_object(gc, obj, "reloc3"); - ikp displaced_object = obj + obj_off; - ikp next_word = code + code_off + wordsize; - ikp relative_distance = displaced_object - (int)next_word; + ikptr displaced_object = obj + obj_off; + ikptr next_word = code + code_off + wordsize; + ikptr relative_distance = displaced_object - (int)next_word; ref(next_word, -wordsize) = relative_distance; p += (3*wordsize); } @@ -1467,8 +1467,8 @@ collect_loop(gc_t* gc){ done = 0; gc->queues[meta_pair] = 0; do{ - ikp p = qu->p; - ikp q = qu->q; + ikptr p = qu->p; + ikptr q = qu->q; while(p < q){ ref(p,0) = add_object(gc, ref(p,0), "loop"); p += (2*wordsize); @@ -1486,8 +1486,8 @@ collect_loop(gc_t* gc){ done = 0; gc->queues[meta_ptrs] = 0; do{ - ikp p = qu->p; - ikp q = qu->q; + ikptr p = qu->p; + ikptr q = qu->q; while(p < q){ ref(p,0) = add_object(gc, ref(p,0), "pending"); p += wordsize; @@ -1505,8 +1505,8 @@ collect_loop(gc_t* gc){ done = 0; gc->queues[meta_symbol] = 0; do{ - ikp p = qu->p; - ikp q = qu->q; + ikptr p = qu->p; + ikptr q = qu->q; while(p < q){ ref(p,0) = add_object(gc, ref(p,0), "symbols"); p += wordsize; @@ -1524,8 +1524,8 @@ collect_loop(gc_t* gc){ gc->queues[meta_code] = 0; done = 0; do{ - ikp p = codes->p; - ikp q = codes->q; + ikptr p = codes->p; + ikptr q = codes->q; while(p < q){ relocate_new_code(p, gc); alloc_code_count--; @@ -1540,8 +1540,8 @@ collect_loop(gc_t* gc){ {/* see if there are any remaining in the main ptr segment */ { meta_t* meta = &gc->meta[meta_pair]; - ikp p = meta->aq; - ikp q = meta->ap; + ikptr p = meta->aq; + ikptr q = meta->ap; if(p < q){ done = 0; do{ @@ -1557,8 +1557,8 @@ collect_loop(gc_t* gc){ } { meta_t* meta = &gc->meta[meta_symbol]; - ikp p = meta->aq; - ikp q = meta->ap; + ikptr p = meta->aq; + ikptr q = meta->ap; if(p < q){ done = 0; do{ @@ -1574,8 +1574,8 @@ collect_loop(gc_t* gc){ } { meta_t* meta = &gc->meta[meta_ptrs]; - ikp p = meta->aq; - ikp q = meta->ap; + ikptr p = meta->aq; + ikptr q = meta->ap; if(p < q){ done = 0; do{ @@ -1591,8 +1591,8 @@ collect_loop(gc_t* gc){ } { meta_t* meta = &gc->meta[meta_code]; - ikp p = meta->aq; - ikp q = meta->ap; + ikptr p = meta->aq; + ikptr q = meta->ap; if(p < q){ done = 0; do{ @@ -1615,8 +1615,8 @@ collect_loop(gc_t* gc){ /* FIXME: did you hear of code reuse? */ { meta_t* meta = &gc->meta[meta_pair]; - ikp p = meta->ap; - ikp q = meta->ep; + ikptr p = meta->ap; + ikptr q = meta->ep; while(p < q){ ref(p, 0) = 0; p += wordsize; @@ -1624,8 +1624,8 @@ collect_loop(gc_t* gc){ } { meta_t* meta = &gc->meta[meta_symbol]; - ikp p = meta->ap; - ikp q = meta->ep; + ikptr p = meta->ap; + ikptr q = meta->ep; while(p < q){ ref(p, 0) = 0; p += wordsize; @@ -1633,8 +1633,8 @@ collect_loop(gc_t* gc){ } { meta_t* meta = &gc->meta[meta_ptrs]; - ikp p = meta->ap; - ikp q = meta->ep; + ikptr p = meta->ap; + ikptr q = meta->ep; while(p < q){ ref(p, 0) = 0; p += wordsize; @@ -1642,8 +1642,8 @@ collect_loop(gc_t* gc){ } { meta_t* meta = &gc->meta[meta_weak]; - ikp p = meta->ap; - ikp q = meta->ep; + ikptr p = meta->ap; + ikptr q = meta->ep; while(p < q){ ref(p, 0) = 0; p += wordsize; @@ -1651,8 +1651,8 @@ collect_loop(gc_t* gc){ } { meta_t* meta = &gc->meta[meta_code]; - ikp p = meta->ap; - ikp q = meta->ep; + ikptr p = meta->ap; + ikptr q = meta->ep; while(p < q){ ref(p, 0) = 0; p += wordsize; @@ -1675,14 +1675,14 @@ fix_weak_pointers(gc_t* gc){ (weak_pairs_type|new_gen_tag)){ //int gen = t & gen_mask; if (1) { //(gen > collect_gen){ - ikp p = (ikp)(i << pageshift); - ikp q = p + pagesize; + ikptr p = (ikptr)(i << pageshift); + ikptr q = p + pagesize; while(p < q){ - ikp x = ref(p, 0); + ikptr x = ref(p, 0); if(! is_fixnum(x)){ int tag = tagof(x); if(tag != immediate_tag){ - ikp fst = ref(x, -tag); + ikptr fst = ref(x, -tag); if(fst == forward_ptr){ ref(p, 0) = ref(x, wordsize-tag); } else { @@ -1727,20 +1727,20 @@ scan_dirty_pointers_page(gc_t* gc, int page_idx, int mask){ unsigned int t = segment_vec[page_idx]; unsigned int d = dirty_vec[page_idx]; unsigned int masked_d = d & mask; - ikp p = (ikp)(page_idx << pageshift); + ikptr p = (ikptr)(page_idx << pageshift); int j; unsigned int new_d = 0; for(j=0; jsegment_vector; ref(p, 0) = y; card_d = card_d | segment_vec[page_index(y)]; @@ -1761,9 +1761,9 @@ scan_dirty_pointers_page(gc_t* gc, int page_idx, int mask){ static void scan_dirty_code_page(gc_t* gc, int page_idx, unsigned int mask){ - ikp p = (ikp)(page_idx << pageshift); - ikp start = p; - ikp q = p + pagesize; + ikptr p = (ikptr)(page_idx << pageshift); + ikptr start = p; + ikptr q = p + pagesize; unsigned int* segment_vec = gc->segment_vector; unsigned int* dirty_vec = gc->pcb->dirty_vector; //unsigned int d = dirty_vec[page_idx]; @@ -1779,13 +1779,13 @@ scan_dirty_code_page(gc_t* gc, int page_idx, unsigned int mask){ int code_size = unfix(ref(p, disp_code_code_size)); relocate_new_code(p, gc); segment_vec = gc->segment_vector; - ikp rvec = ref(p, disp_code_reloc_vector); + ikptr rvec = ref(p, disp_code_reloc_vector); int len = (int)ref(rvec, off_vector_length); assert(len >= 0); int i; unsigned int code_d = segment_vec[page_index(rvec)]; for(i=0; ipcb; int collect_gen = gc->collect_gen; unsigned int* segment_vec = pcb->segment_vector; - unsigned char* memory_base = pcb->memory_base; - unsigned char* memory_end = pcb->memory_end; + char* memory_base = pcb->memory_base; + char* memory_end = pcb->memory_end; int lo_idx = page_index(memory_base); int hi_idx = page_index(memory_end); int i = lo_idx; @@ -1877,7 +1877,7 @@ deallocate_unused_pages(gc_t* gc){ if(t & new_gen_mask){ /* do nothing yet */ } else { - ik_munmap_from_segment((unsigned char*)(i<pcb; unsigned int* segment_vec = pcb->segment_vector; - unsigned char* memory_base = pcb->memory_base; - unsigned char* memory_end = pcb->memory_end; + char* memory_base = pcb->memory_base; + char* memory_end = pcb->memory_end; int lo_idx = page_index(memory_base); int hi_idx = page_index(memory_end); int i = lo_idx; @@ -1908,19 +1908,19 @@ fix_new_pages(gc_t* gc){ } static void -add_one_tconc(ikpcb* pcb, ikp p){ - ikp tcbucket = ref(p,0); - ikp tc = ref(tcbucket, off_tcbucket_tconc); +add_one_tconc(ikpcb* pcb, ikptr p){ + ikptr tcbucket = ref(p,0); + ikptr tc = ref(tcbucket, off_tcbucket_tconc); assert(tagof(tc) == pair_tag); - ikp d = ref(tc, off_cdr); + ikptr d = ref(tc, off_cdr); assert(tagof(d) == pair_tag); - ikp new_pair = p + pair_tag; + ikptr new_pair = p + pair_tag; ref(d, off_car) = tcbucket; ref(d, off_cdr) = new_pair; ref(new_pair, off_car) = false_object; ref(new_pair, off_cdr) = false_object; ref(tc, off_cdr) = new_pair; - ref(tcbucket, -vector_tag) = (ikp)(tcbucket_size - wordsize); + ref(tcbucket, -vector_tag) = (ikptr)(tcbucket_size - wordsize); pcb->dirty_vector[page_index(tc)] = -1; pcb->dirty_vector[page_index(d)] = -1; } @@ -1932,8 +1932,8 @@ gc_add_tconcs(gc_t* gc){ } ikpcb* pcb = gc->pcb; { - ikp p = gc->tconc_base; - ikp q = gc->tconc_ap; + ikptr p = gc->tconc_base; + ikptr q = gc->tconc_ap; while(p < q){ add_one_tconc(pcb, p); p += 2*wordsize; @@ -1941,8 +1941,8 @@ gc_add_tconcs(gc_t* gc){ } ikpages* qu = gc->tconc_queue; while(qu){ - ikp p = qu->base; - ikp q = p + qu->size; + ikptr p = qu->base; + ikptr q = p + qu->size; while(p < q){ add_one_tconc(pcb, p); p += 2*wordsize; diff --git a/src/ikarus-data.h b/src/ikarus-data.h index f3c0863..ab75e1c 100644 --- a/src/ikarus-data.h +++ b/src/ikarus-data.h @@ -90,16 +90,17 @@ inthash(int key) { #define pagesize 4096 #define generation_count 5 /* generations 0 (nursery), 1, 2, 3, 4 */ -typedef unsigned char* ikp; -void ik_error(ikp args); +typedef char* ikptr; + +void ik_error(ikptr args); typedef struct ikpage{ - ikp base; + ikptr base; struct ikpage* next; } ikpage; typedef struct ikpages{ - ikp base; + ikptr base; int size; struct ikpages* next; } ikpages; @@ -111,55 +112,55 @@ typedef struct ikdl{ /* double-link */ #define ik_ptr_page_size \ - ((pagesize - sizeof(int) - sizeof(struct ik_ptr_page*))/sizeof(ikp)) + ((pagesize - sizeof(int) - sizeof(struct ik_ptr_page*))/sizeof(ikptr)) typedef struct ik_ptr_page{ int count; struct ik_ptr_page* next; - ikp ptr[ik_ptr_page_size]; + ikptr ptr[ik_ptr_page_size]; } ik_ptr_page; typedef struct ikpcb{ /* the first locations may be accessed by some */ /* compiled code to perform overflow/underflow ops */ - ikp allocation_pointer; /* offset = 0 */ - ikp allocation_redline; /* offset = 4 */ - ikp frame_pointer; /* offset = 8 */ - ikp frame_base; /* offset = 12 */ - ikp frame_redline; /* offset = 16 */ - ikp next_k; /* offset = 20 */ + ikptr allocation_pointer; /* offset = 0 */ + ikptr allocation_redline; /* offset = 4 */ + ikptr frame_pointer; /* offset = 8 */ + ikptr frame_base; /* offset = 12 */ + ikptr frame_redline; /* offset = 16 */ + ikptr next_k; /* offset = 20 */ void* system_stack; /* offset = 24 */ unsigned int* dirty_vector; /* offset = 28 */ - ikp arg_list; /* offset = 32 */ + ikptr arg_list; /* offset = 32 */ int engine_counter; /* offset = 36 */ int interrupted; /* offset = 40 */ - ikp base_rtd; /* offset = 44 */ - ikp collect_key; /* offset = 48 */ + ikptr base_rtd; /* offset = 44 */ + ikptr collect_key; /* offset = 48 */ /* the rest are not used by any scheme code */ /* they only support the runtime system (gc, etc.) */ - ikp* root0; - ikp* root1; + ikptr* root0; + ikptr* root1; unsigned int* segment_vector; - ikp weak_pairs_ap; - ikp weak_pairs_ep; - ikp heap_base; + ikptr weak_pairs_ap; + ikptr weak_pairs_ep; + ikptr heap_base; int heap_size; ikpages* heap_pages; ikpage* cached_pages; /* pages cached so that we don't map/unmap */ ikpage* uncached_pages; /* ikpages cached so that we don't malloc/free */ - ikp cached_pages_base; + ikptr cached_pages_base; int cached_pages_size; - ikp stack_base; + ikptr stack_base; int stack_size; - ikp symbol_table; - ikp gensym_table; + ikptr symbol_table; + ikptr gensym_table; ik_ptr_page* guardians[generation_count]; ik_ptr_page* guardians_dropped[generation_count]; unsigned int* dirty_vector_base; unsigned int* segment_vector_base; - unsigned char* memory_base; - unsigned char* memory_end; + char* memory_base; + char* memory_end; int collection_id; int allocation_count_minor; int allocation_count_major; @@ -181,28 +182,28 @@ void* ik_mmap_data(int size, int gen, ikpcb*); void* ik_mmap_code(int size, int gen, ikpcb*); void* ik_mmap_mixed(int size, ikpcb*); void ik_munmap(void*, int); -void ik_munmap_from_segment(unsigned char*, int, ikpcb*); +void ik_munmap_from_segment(char*, int, ikpcb*); ikpcb* ik_make_pcb(); void ik_delete_pcb(ikpcb*); void ik_free_symbol_table(ikpcb* pcb); void ik_fasl_load(ikpcb* pcb, char* filename); -void ik_relocate_code(ikp); +void ik_relocate_code(ikptr); -ikp ik_exec_code(ikpcb* pcb, ikp code_ptr); -void ik_print(ikp x); -void ik_fprint(FILE*, ikp x); +ikptr ik_exec_code(ikpcb* pcb, ikptr code_ptr); +void ik_print(ikptr x); +void ik_fprint(FILE*, ikptr x); -ikp ikrt_string_to_symbol(ikp, ikpcb*); -ikp ikrt_strings_to_gensym(ikp, ikp, ikpcb*); +ikptr ikrt_string_to_symbol(ikptr, ikpcb*); +ikptr ikrt_strings_to_gensym(ikptr, ikptr, ikpcb*); -ikp ik_cstring_to_symbol(char*, ikpcb*); +ikptr ik_cstring_to_symbol(char*, ikpcb*); -ikp ik_asm_enter(ikpcb*, ikp code_object, ikp arg); -ikp ik_asm_reenter(ikpcb*, ikp code_object, ikp val); -ikp ik_underflow_handler(ikpcb*); -ikp ik_unsafe_alloc(ikpcb* pcb, int size); -ikp ik_safe_alloc(ikpcb* pcb, int size); +ikptr ik_asm_enter(ikpcb*, ikptr code_object, ikptr arg); +ikptr ik_asm_reenter(ikpcb*, ikptr code_object, ikptr val); +ikptr ik_underflow_handler(ikpcb*); +ikptr ik_unsafe_alloc(ikpcb* pcb, int size); +ikptr ik_safe_alloc(ikpcb* pcb, int size); #define IK_FASL_HEADER "#@IK01" @@ -210,7 +211,7 @@ ikp ik_safe_alloc(ikpcb* pcb, int size); #define IK_FASL_CODE_HEADER_SIZE 12 #define code_pri_tag vector_tag -#define code_tag ((ikp)0x2F) +#define code_tag ((ikptr)0x2F) #define disp_code_code_size 4 #define disp_code_reloc_vector 8 #define disp_code_freevars 12 @@ -237,17 +238,17 @@ ikp ik_safe_alloc(ikpcb* pcb, int size); #define fx_shift 2 #define fx_mask 3 #define unfix(x) (((int)(x)) >> fx_shift) -#define fix(x) ((ikp)((x) << fx_shift)) +#define fix(x) ((ikptr)((x) << fx_shift)) #define is_fixnum(x) ((((int)(x)) & fx_mask) == 0) #define IK_FIXNUMP(x) \ ((((int)(x)) & IK_FX_MASK) == 0) #define REF(x,n) \ - (((ikp*)(((char*)(x)) + ((int)(n))))[0]) + (((ikptr*)(((char*)(x)) + ((int)(n))))[0]) #define ref(x,n) \ - (((ikp*)(((char*)(x)) + ((int)(n))))[0]) + (((ikptr*)(((char*)(x)) + ((int)(n))))[0]) #define IK_MASK(x,m) (((int)(x)) & ((int)(m))) #define IK_PTAG(x) (((int)(x)) & 7) @@ -257,30 +258,30 @@ ikp ik_safe_alloc(ikpcb* pcb, int size); #define immediate_tag 7 #define IK_UNFIX(x) (((int)(x)) >> IK_FX_SHIFT) -#define IK_FIX(x) ((ikp)((x) << IK_FX_SHIFT)) -#define fix(x) ((ikp)((x) << fx_shift)) +#define IK_FIX(x) ((ikptr)((x) << IK_FX_SHIFT)) +#define fix(x) ((ikptr)((x) << fx_shift)) #define IK_CODE_P(x) \ ((IK_PTAG(x) == IK_CODE_PRI_TAG) && (IK_STAG(x) == IK_CODE_SEC_TAG)) -#define IK_FALSE_OBJECT ((ikp)0x2F) -#define IK_TRUE_OBJECT ((ikp)0x3F) +#define IK_FALSE_OBJECT ((ikptr)0x2F) +#define IK_TRUE_OBJECT ((ikptr)0x3F) -#define false_object ((ikp)0x2F) -#define true_object ((ikp)0x3F) +#define false_object ((ikptr)0x2F) +#define true_object ((ikptr)0x3F) -#define IK_NULL_OBJECT ((ikp)0x4F) +#define IK_NULL_OBJECT ((ikptr)0x4F) -#define null_object ((ikp)0x4F) -#define void_object ((ikp)0x7F) -#define bwp_object ((ikp)0x8F) +#define null_object ((ikptr)0x4F) +#define void_object ((ikptr)0x7F) +#define bwp_object ((ikptr)0x8F) -#define unbound_object ((ikp)0x6F) +#define unbound_object ((ikptr)0x6F) #define IK_CHAR_TAG 0x0F #define IK_CHAR_MASK 0xFF #define IK_CHAR_SHIFT 8 #define IK_CHAR_VAL(x) (((int)(x)) >> IK_CHAR_SHIFT) -#define int_to_scheme_char(x) ((ikp)(((x) << IK_CHAR_SHIFT) | IK_CHAR_TAG)) +#define int_to_scheme_char(x) ((ikptr)(((x) << IK_CHAR_SHIFT) | IK_CHAR_TAG)) #define IK_PAIR_SIZE 8 #define pair_size 8 #define pair_tag 1 @@ -309,8 +310,8 @@ ikp ik_safe_alloc(ikpcb* pcb, int size); // ((((unsigned char*)(x)) + off_string_data + (int)(i))[0] = // (((int)(c)) >> IK_CHAR_SHIFT)) #define string_set(x,i,c) \ - (((ikp*)(((ikp)(x)) + off_string_data))[i] = ((ikp)(c))) -#define integer_to_char(x) ((ikp)((((int)(x)) << IK_CHAR_SHIFT) + IK_CHAR_TAG)) + (((ikptr*)(((ikptr)(x)) + off_string_data))[i] = ((ikptr)(c))) +#define integer_to_char(x) ((ikptr)((((int)(x)) << IK_CHAR_SHIFT) + IK_CHAR_TAG)) #define string_char_size 4 #define vector_tag 5 @@ -347,7 +348,7 @@ ikp ik_safe_alloc(ikpcb* pcb, int size); #define off_bytevector_length (disp_bytevector_length - bytevector_tag) #define off_bytevector_data (disp_bytevector_data - bytevector_tag) -#define symbol_record_tag ((ikp) 0x5F) +#define symbol_record_tag ((ikptr) 0x5F) #define disp_symbol_record_string 4 #define disp_symbol_record_ustring 8 #define disp_symbol_record_value 12 @@ -393,7 +394,7 @@ ikp ik_safe_alloc(ikpcb* pcb, int size); #define off_rtd_printer (disp_rtd_printer - rtd_tag) #define off_rtd_symbol (disp_rtd_symbol - rtd_tag) -#define continuation_tag ((ikp)0x1F) +#define continuation_tag ((ikptr)0x1F) #define disp_continuation_top 4 #define disp_continuation_size 8 #define disp_continuation_next 12 @@ -435,13 +436,13 @@ ikp ik_safe_alloc(ikpcb* pcb, int size); #define disp_bignum_data wordsize #define off_bignum_data (disp_bignum_data - vector_tag) -#define flonum_tag ((ikp)0x17) +#define flonum_tag ((ikptr)0x17) #define flonum_size 16 #define disp_flonum_data 8 #define off_flonum_data (disp_flonum_data - vector_tag) -#define flonum_data(x) (*((double*)(((ikp)(x))+off_flonum_data))) +#define flonum_data(x) (*((double*)(((ikptr)(x))+off_flonum_data))) -#define ratnum_tag ((ikp) 0x27) +#define ratnum_tag ((ikptr) 0x27) #define ratnum_size 16 #define disp_ratnum_num 4 #define disp_ratnum_den 8 diff --git a/src/ikarus-exec.c b/src/ikarus-exec.c index ac8959a..346a26b 100644 --- a/src/ikarus-exec.c +++ b/src/ikarus-exec.c @@ -23,20 +23,20 @@ #include typedef struct { - ikp tag; - ikp top; + ikptr tag; + ikptr top; int size; - ikp next; + ikptr next; } cont; -ikp ik_exec_code(ikpcb* pcb, ikp code_ptr){ - ikp argc = ik_asm_enter(pcb, code_ptr+off_code_data,0); - ikp next_k = pcb->next_k; +ikptr ik_exec_code(ikpcb* pcb, ikptr code_ptr){ + ikptr argc = ik_asm_enter(pcb, code_ptr+off_code_data,0); + ikptr next_k = pcb->next_k; while(next_k){ cont* k = (cont*)(next_k - vector_tag); - ikp top = k->top; - ikp rp = ref(top, 0); + ikptr top = k->top; + ikptr rp = ref(top, 0); int framesize = (int) ref(rp, disp_frame_size); if(framesize <= 0){ fprintf(stderr, "invalid framesize %d\n", framesize); @@ -49,14 +49,14 @@ ikp ik_exec_code(ikpcb* pcb, ikp code_ptr){ nk->top = top + framesize; nk->size = k->size - framesize; k->size = framesize; - k->next = vector_tag + (ikp)nk; + k->next = vector_tag + (ikptr)nk; /* record side effect */ unsigned int idx = ((unsigned int)(&k->next)) >> pageshift; pcb->dirty_vector[idx] = -1; } pcb->next_k = k->next; - ikp fbase = pcb->frame_base - wordsize; - ikp new_fbase = fbase - framesize; + ikptr fbase = pcb->frame_base - wordsize; + ikptr new_fbase = fbase - framesize; memmove(new_fbase + (int)argc, fbase + (int)argc, -(int)argc); diff --git a/src/ikarus-fasl.c b/src/ikarus-fasl.c index b1c8715..f935c76 100644 --- a/src/ikarus-fasl.c +++ b/src/ikarus-fasl.c @@ -41,13 +41,13 @@ typedef struct { char* membase; char* memp; char* memq; - ikp code_ap; - ikp code_ep; - ikp* marks; + ikptr code_ap; + ikptr code_ep; + ikptr* marks; int marks_size; } fasl_port; -static ikp ik_fasl_read(ikpcb* pcb, fasl_port* p); +static ikptr ik_fasl_read(ikpcb* pcb, fasl_port* p); void ik_fasl_load(ikpcb* pcb, char* fasl_file){ int fd = open(fasl_file, O_RDONLY); @@ -96,9 +96,9 @@ void ik_fasl_load(ikpcb* pcb, char* fasl_file){ while(p.memp < p.memq){ p.code_ap = 0; p.code_ep = 0; - ikp v = ik_fasl_read(pcb, &p); + ikptr v = ik_fasl_read(pcb, &p); if(p.marks_size){ - ik_munmap((unsigned char*) p.marks, p.marks_size*sizeof(ikp*)); + ik_munmap((unsigned char*) p.marks, p.marks_size*sizeof(ikptr*)); p.marks = 0; p.marks_size = 0; } @@ -110,7 +110,7 @@ void ik_fasl_load(ikpcb* pcb, char* fasl_file){ } close(fd); } - ikp val = ik_exec_code(pcb, v); + ikptr val = ik_exec_code(pcb, v); val = void_object; if(val != void_object){ /* this is from revision 1 @@ -125,16 +125,16 @@ void ik_fasl_load(ikpcb* pcb, char* fasl_file){ } } -static ikp +static ikptr alloc_code(int size, ikpcb* pcb, fasl_port* p){ int asize = align(size); - ikp ap = p->code_ap; - ikp nap = ap + asize; + ikptr ap = p->code_ap; + ikptr nap = ap + asize; if(nap <= p->code_ep){ p->code_ap = nap; return ap; } else if (asize < pagesize){ - ikp mem = ik_mmap_code(pagesize, 0, pcb); + ikptr mem = ik_mmap_code(pagesize, 0, pcb); int bytes_remaining = pagesize - asize; int previous_bytes = ((unsigned int)p->code_ep) - ((unsigned int)ap); @@ -147,19 +147,19 @@ alloc_code(int size, ikpcb* pcb, fasl_port* p){ } } else { int asize = align_to_next_page(size); - ikp mem = ik_mmap_code(asize, 0, pcb); + ikptr mem = ik_mmap_code(asize, 0, pcb); return mem; } } void -ik_relocate_code(ikp code){ - ikp vec = ref(code, disp_code_reloc_vector); - ikp size = ref(vec, off_vector_length); - ikp data = code + disp_code_data; - ikp p = vec + off_vector_data; - ikp q = p + (int)size; +ik_relocate_code(ikptr code){ + ikptr vec = ref(code, disp_code_reloc_vector); + ikptr size = ref(vec, off_vector_length); + ikptr data = code + disp_code_data; + ikptr p = vec + off_vector_data; + ikptr q = p + (int)size; while(p < q){ int r = unfix(ref(p, 0)); if(r == 0){ @@ -176,23 +176,23 @@ ik_relocate_code(ikp code){ else if(tag == 2){ /* displaced object */ int obj_off = unfix(ref(p, wordsize)); - ikp obj = ref(p, 2*wordsize); + ikptr obj = ref(p, 2*wordsize); ref(data, code_off) = obj + obj_off; p += (3*wordsize); } else if(tag == 3){ /* jump label */ int obj_off = unfix(ref(p, wordsize)); - ikp obj = ref(p, 2*wordsize); - ikp displaced_object = obj + obj_off; - ikp next_word = data + code_off + wordsize; - ikp relative_distance = displaced_object - (int)next_word; + ikptr obj = ref(p, 2*wordsize); + ikptr displaced_object = obj + obj_off; + ikptr next_word = data + code_off + wordsize; + ikptr relative_distance = displaced_object - (int)next_word; ref(next_word, -wordsize) = relative_distance; p += (3*wordsize); } else if(tag == 1){ /* foreign object */ - ikp str = ref(p, wordsize); + ikptr str = ref(p, wordsize); char* name; if(tagof(str) == bytevector_tag){ name = (char*) str + off_bytevector_data; @@ -241,12 +241,12 @@ static void fasl_read_buf(fasl_port* p, void* buf, int n){ typedef struct{ int code_size; int reloc_size; - ikp closure_size; + ikptr closure_size; } code_header; -static ikp do_read(ikpcb* pcb, fasl_port* p){ +static ikptr do_read(ikpcb* pcb, fasl_port* p){ char c = fasl_read_byte(p); int put_mark_index = 0; if(c == '>'){ @@ -273,18 +273,18 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ } else { /* allocate marks */ - p->marks = (ikp*)ik_mmap(pagesize*sizeof(ikp*)); - bzero(p->marks, pagesize*sizeof(ikp*)); + p->marks = (ikptr*)ik_mmap(pagesize*sizeof(ikptr*)); + bzero(p->marks, pagesize*sizeof(ikptr*)); p->marks_size = pagesize; } } if(c == 'x'){ int code_size; - ikp freevars; + ikptr freevars; fasl_read_buf(p, &code_size, sizeof(int)); - fasl_read_buf(p, &freevars, sizeof(ikp)); - ikp annotation = do_read(pcb, p); - ikp code = alloc_code(align(code_size+disp_code_data), pcb, p); + fasl_read_buf(p, &freevars, sizeof(ikptr)); + ikptr annotation = do_read(pcb, p); + ikptr code = alloc_code(align(code_size+disp_code_data), pcb, p); ref(code, 0) = code_tag; ref(code, disp_code_code_size) = fix(code_size); ref(code, disp_code_freevars) = freevars; @@ -298,7 +298,7 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ return code+vector_tag; } else if(c == 'P'){ - ikp pair = ik_unsafe_alloc(pcb, pair_size) + pair_tag; + ikptr pair = ik_unsafe_alloc(pcb, pair_size) + pair_tag; if(put_mark_index){ p->marks[put_mark_index] = pair; } @@ -308,8 +308,8 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ } else if(c == 'M'){ /* symbol */ - ikp str = do_read(pcb, p); - ikp sym = ikrt_string_to_symbol(str, pcb); + ikptr str = do_read(pcb, p); + ikptr sym = ikrt_string_to_symbol(str, pcb); if(put_mark_index){ p->marks[put_mark_index] = sym; } @@ -320,12 +320,12 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ int len; fasl_read_buf(p, &len, sizeof(int)); int size = align(len*string_char_size + disp_string_data); - ikp str = ik_unsafe_alloc(pcb, size) + string_tag; + ikptr str = ik_unsafe_alloc(pcb, size) + string_tag; ref(str, off_string_length) = fix(len); fasl_read_buf(p, str+off_string_data, len); { unsigned char* pi = (unsigned char*) (str+off_string_data); - ikp* pj = (ikp*) (str+off_string_data); + ikptr* pj = (ikptr*) (str+off_string_data); int i = len-1; for(i=len-1; i >= 0; i--){ pj[i] = integer_to_char(pi[i]); @@ -342,7 +342,7 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ int len; fasl_read_buf(p, &len, sizeof(int)); int size = align(len*string_char_size + disp_string_data); - ikp str = ik_unsafe_alloc(pcb, size) + string_tag; + ikptr str = ik_unsafe_alloc(pcb, size) + string_tag; ref(str, off_string_length) = fix(len); int i; for(i=0; imarks[put_mark_index] = vec; } @@ -373,7 +373,7 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ return vec; } else if(c == 'I'){ - ikp fixn; + ikptr fixn; fasl_read_buf(p, &fixn, sizeof(int)); return fixn; } @@ -392,25 +392,25 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ } else if(c == 'G'){ /* G is for gensym */ - ikp pretty = do_read(pcb, p); - ikp unique = do_read(pcb, p); - ikp sym = ikrt_strings_to_gensym(pretty, unique, pcb); + ikptr pretty = do_read(pcb, p); + ikptr unique = do_read(pcb, p); + ikptr sym = ikrt_strings_to_gensym(pretty, unique, pcb); if(put_mark_index){ p->marks[put_mark_index] = sym; } return sym; } else if(c == 'R'){ /* R is for RTD */ - ikp name = do_read(pcb, p); - ikp symb = do_read(pcb, p); + ikptr name = do_read(pcb, p); + ikptr symb = do_read(pcb, p); int i, n; fasl_read_buf(p, &n, sizeof(int)); - ikp fields; + ikptr fields; if(n == 0){ fields = null_object; } else { fields = ik_unsafe_alloc(pcb, n * align(pair_size)) + pair_tag; - ikp ptr = fields; + ikptr ptr = fields; for(i=0; ibase_rtd; + ikptr base_rtd = pcb->base_rtd; ref(rtd, off_rtd_rtd) = base_rtd; ref(rtd, off_rtd_name) = name; ref(rtd, off_rtd_length) = fix(n); @@ -441,11 +441,11 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ return rtd; } else if(c == 'Q'){ /* thunk */ - ikp proc = ik_unsafe_alloc(pcb, align(disp_closure_data)) + closure_tag; + ikptr proc = ik_unsafe_alloc(pcb, align(disp_closure_data)) + closure_tag; if(put_mark_index){ p->marks[put_mark_index] = proc; } - ikp code = do_read(pcb, p); + ikptr code = do_read(pcb, p); ref(proc, -closure_tag) = code + off_code_data; return proc; } @@ -460,7 +460,7 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ fprintf(stderr, "invalid index for ref %d\n", idx); exit(-1); } - ikp obj = p->marks[idx]; + ikptr obj = p->marks[idx]; if(obj){ return obj; } else { @@ -473,7 +473,7 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ int len; fasl_read_buf(p, &len, sizeof(int)); int size = align(len + disp_bytevector_data + 1); - ikp x = ik_unsafe_alloc(pcb, size) + bytevector_tag; + ikptr x = ik_unsafe_alloc(pcb, size) + bytevector_tag; ref(x, off_bytevector_length) = fix(len); fasl_read_buf(p, x+off_bytevector_data, len); x[off_bytevector_data+len] = 0; @@ -488,11 +488,11 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ fprintf(stderr, "invalid len=%d\n", len); exit(-1); } - ikp pair = ik_unsafe_alloc(pcb, pair_size * (len+1)) + pair_tag; + ikptr pair = ik_unsafe_alloc(pcb, pair_size * (len+1)) + pair_tag; if(put_mark_index){ p->marks[put_mark_index] = pair; } - int i; ikp pt = pair; + int i; ikptr pt = pair; for(i=0; imarks[put_mark_index] = pair; } - int i; ikp pt = pair; + int i; ikptr pt = pair; for(i=0; i> 2) << bignum_length_shift); - ikp x = ik_unsafe_alloc(pcb, align(len + disp_bignum_data)) + vector_tag; - ref(x, -vector_tag) = (ikp) tag; + ikptr x = ik_unsafe_alloc(pcb, align(len + disp_bignum_data)) + vector_tag; + ref(x, -vector_tag) = (ikptr) tag; fasl_read_buf(p, x+off_bignum_data, len); if(put_mark_index){ p->marks[put_mark_index] = x; @@ -566,7 +566,7 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){ } -static ikp ik_fasl_read(ikpcb* pcb, fasl_port* p){ +static ikptr ik_fasl_read(ikpcb* pcb, fasl_port* p){ /* first check the header */ char buf[IK_FASL_HEADER_LEN]; fasl_read_buf(p, buf, IK_FASL_HEADER_LEN); diff --git a/src/ikarus-flonums.c b/src/ikarus-flonums.c index d549a9e..ba36a35 100644 --- a/src/ikarus-flonums.c +++ b/src/ikarus-flonums.c @@ -23,20 +23,20 @@ #include #include -ikp -ikrt_fl_round(ikp x, ikp y){ +ikptr +ikrt_fl_round(ikptr x, ikptr y){ flonum_data(y) = round(flonum_data(x)); return y; } -ikp -ikrt_fl_exp(ikp x, ikp y){ +ikptr +ikrt_fl_exp(ikptr x, ikptr y){ flonum_data(y) = exp(flonum_data(x)); return y; } -ikp -ikrt_flfl_expt(ikp a, ikp b, ikp z){ +ikptr +ikrt_flfl_expt(ikptr a, ikptr b, ikptr z){ flonum_data(z) = exp(flonum_data(b) * log(flonum_data(a))); return z; } @@ -45,100 +45,100 @@ ikrt_flfl_expt(ikp a, ikp b, ikp z){ -ikp -ikrt_bytevector_to_flonum(ikp x, ikpcb* pcb){ +ikptr +ikrt_bytevector_to_flonum(ikptr x, ikpcb* pcb){ double v = strtod((char*)x+off_bytevector_data, NULL); - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = v; return r; } -ikp -ikrt_fl_plus(ikp x, ikp y,ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_plus(ikptr x, ikptr y,ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = flonum_data(x) + flonum_data(y); return r; } -ikp -ikrt_fl_minus(ikp x, ikp y,ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_minus(ikptr x, ikptr y,ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = flonum_data(x) - flonum_data(y); return r; } -ikp -ikrt_fl_times(ikp x, ikp y,ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_times(ikptr x, ikptr y,ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = flonum_data(x) * flonum_data(y); return r; } -ikp -ikrt_fl_div(ikp x, ikp y,ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_div(ikptr x, ikptr y,ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = flonum_data(x) / flonum_data(y); return r; } -ikp -ikrt_fl_invert(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_invert(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = 1.0 / flonum_data(x); return r; } -ikp -ikrt_fl_sin(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_sin(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = sin(flonum_data(x)); return r; } -ikp -ikrt_fl_cos(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_cos(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = cos(flonum_data(x)); return r; } -ikp -ikrt_fl_tan(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_tan(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = tan(flonum_data(x)); return r; } -ikp -ikrt_fl_asin(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_asin(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = asin(flonum_data(x)); return r; } -ikp -ikrt_fl_acos(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_acos(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = acos(flonum_data(x)); return r; } -ikp -ikrt_fl_atan(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_atan(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = atan(flonum_data(x)); return r; } @@ -146,99 +146,99 @@ ikrt_fl_atan(ikp x, ikpcb* pcb){ -ikp -ikrt_fl_sqrt(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_sqrt(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = sqrt(flonum_data(x)); return r; } -ikp -ikrt_fl_log(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fl_log(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = log(flonum_data(x)); return r; } -ikp -ikrt_fx_sin(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_sin(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = sin(unfix(x)); return r; } -ikp -ikrt_fx_cos(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_cos(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = cos(unfix(x)); return r; } -ikp -ikrt_fx_tan(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_tan(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = tan(unfix(x)); return r; } -ikp -ikrt_fx_asin(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_asin(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = asin(unfix(x)); return r; } -ikp -ikrt_fx_acos(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_acos(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = acos(unfix(x)); return r; } -ikp -ikrt_fx_atan(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_atan(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = atan(unfix(x)); return r; } -ikp -ikrt_fx_sqrt(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_sqrt(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = sqrt(unfix(x)); return r; } -ikp -ikrt_fx_log(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fx_log(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = log(unfix(x)); return r; } -ikp -ikrt_fixnum_to_flonum(ikp x, ikpcb* pcb){ - ikp r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; - ref(r, -vector_tag) = (ikp)flonum_tag; +ikptr +ikrt_fixnum_to_flonum(ikptr x, ikpcb* pcb){ + ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; + ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = unfix(x); return r; } -ikp -ikrt_fl_equal(ikp x, ikp y){ +ikptr +ikrt_fl_equal(ikptr x, ikptr y){ if(flonum_data(x) == flonum_data(y)){ return true_object; } else { @@ -246,8 +246,8 @@ ikrt_fl_equal(ikp x, ikp y){ } } -ikp -ikrt_fl_less_or_equal(ikp x, ikp y){ +ikptr +ikrt_fl_less_or_equal(ikptr x, ikptr y){ if(flonum_data(x) <= flonum_data(y)){ return true_object; } else { @@ -255,8 +255,8 @@ ikrt_fl_less_or_equal(ikp x, ikp y){ } } -ikp -ikrt_fl_less(ikp x, ikp y){ +ikptr +ikrt_fl_less(ikptr x, ikptr y){ if(flonum_data(x) < flonum_data(y)){ return true_object; } else { diff --git a/src/ikarus-io.c b/src/ikarus-io.c index 12b222d..8c15997 100644 --- a/src/ikarus-io.c +++ b/src/ikarus-io.c @@ -8,7 +8,7 @@ #include "ikarus-data.h" -ikp +ikptr ikrt_io_error(){ switch(errno){ case EBADF : return fix(-2); @@ -36,8 +36,8 @@ ikrt_io_error(){ } -ikp -ikrt_close_fd(ikp fd, ikpcb* pcb){ +ikptr +ikrt_close_fd(ikptr fd, ikpcb* pcb){ int err = close(unfix(fd)); if(err == -1){ return ikrt_io_error(); @@ -46,8 +46,8 @@ ikrt_close_fd(ikp fd, ikpcb* pcb){ } } -ikp -ikrt_open_input_fd(ikp fn, ikpcb* pcb){ +ikptr +ikrt_open_input_fd(ikptr fn, ikpcb* pcb){ int fh = open((char*)(fn+off_bytevector_data), O_RDONLY, 0); if(fh > 0){ return fix(fh); @@ -56,8 +56,8 @@ ikrt_open_input_fd(ikp fn, ikpcb* pcb){ } } -ikp -ikrt_open_output_fd(ikp fn, ikp ikopts, ikpcb* pcb){ +ikptr +ikrt_open_output_fd(ikptr fn, ikptr ikopts, ikpcb* pcb){ int opts = unfix(ikopts); int mode = 0; switch (opts){ @@ -86,8 +86,8 @@ ikrt_open_output_fd(ikp fn, ikp ikopts, ikpcb* pcb){ -ikp -ikrt_read_fd(ikp fd, ikp bv, ikp off, ikp cnt, ikpcb* pcb){ +ikptr +ikrt_read_fd(ikptr fd, ikptr bv, ikptr off, ikptr cnt, ikpcb* pcb){ ssize_t bytes = read(unfix(fd), (char*)(bv+off_bytevector_data+unfix(off)), @@ -99,8 +99,8 @@ ikrt_read_fd(ikp fd, ikp bv, ikp off, ikp cnt, ikpcb* pcb){ } } -ikp -ikrt_write_fd(ikp fd, ikp bv, ikp off, ikp cnt, ikpcb* pcb){ +ikptr +ikrt_write_fd(ikptr fd, ikptr bv, ikptr off, ikptr cnt, ikpcb* pcb){ ssize_t bytes = write(unfix(fd), (char*)(bv+off_bytevector_data+unfix(off)), diff --git a/src/ikarus-main.c b/src/ikarus-main.c index 8912c93..5d40675 100644 --- a/src/ikarus-main.c +++ b/src/ikarus-main.c @@ -158,12 +158,12 @@ int main(int argc, char** argv){ ikpcb* pcb = ik_make_pcb(); the_pcb = pcb; { /* set up arg_list */ - ikp arg_list = null_object; + ikptr arg_list = null_object; int i = argc-1; while(i > 0){ char* s = argv[i]; int n = strlen(s); - ikp str = ik_unsafe_alloc(pcb, align(n*string_char_size+disp_string_data+1)) + ikptr str = ik_unsafe_alloc(pcb, align(n*string_char_size+disp_string_data+1)) + string_tag; ref(str, off_string_length) = fix(n); { @@ -172,7 +172,7 @@ int main(int argc, char** argv){ string_set(str, i, integer_to_char(s[i])); } } - ikp p = ik_unsafe_alloc(pcb, pair_size); + ikptr p = ik_unsafe_alloc(pcb, pair_size); ref(p, disp_car) = str; ref(p, disp_cdr) = arg_list; arg_list = p+pair_tag; diff --git a/src/ikarus-numerics.c b/src/ikarus-numerics.c index eb576aa..a384c37 100644 --- a/src/ikarus-numerics.c +++ b/src/ikarus-numerics.c @@ -32,13 +32,13 @@ #ifdef NDEBUG #define verify_bignum(x,caller) (x) #else -static ikp -verify_bignum(ikp x, char* caller){ +static ikptr +verify_bignum(ikptr x, char* caller){ if(tagof(x) != vector_tag){ fprintf(stderr, "Error in (%s) invalid primary tag %p\n", caller, x); exit(-1); } - ikp fst = ref(x, -vector_tag); + ikptr fst = ref(x, -vector_tag); int limb_count = ((unsigned int) fst) >> bignum_length_shift; if(limb_count <= 0){ fprintf(stderr, @@ -84,10 +84,10 @@ verify_bignum(ikp x, char* caller){ #define BN(x) verify_bignum(x,"BN") #if 0 -ikp -ikrt_isbignum(ikp x){ +ikptr +ikrt_isbignum(ikptr x){ if(tagof(x) == vector_tag){ - ikp fst = ref(x, -vector_tag); + ikptr fst = ref(x, -vector_tag); if (bignum_tag == (bignum_mask & (int)fst)){ return true_object; } @@ -96,9 +96,9 @@ ikrt_isbignum(ikp x){ } #endif -ikp -ikrt_positive_bn(ikp x){ - ikp fst = ref(x, -vector_tag); +ikptr +ikrt_positive_bn(ikptr x){ + ikptr fst = ref(x, -vector_tag); if((int)fst & bignum_sign_mask){ return false_object; } else { @@ -106,8 +106,8 @@ ikrt_positive_bn(ikp x){ } } -ikp -ikrt_even_bn(ikp x){ +ikptr +ikrt_even_bn(ikptr x){ int fst = (int)ref(x, wordsize-vector_tag); if(fst & 1){ return false_object; @@ -118,57 +118,57 @@ ikrt_even_bn(ikp x){ -ikp -ikrt_fxfxplus(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fxfxplus(ikptr x, ikptr y, ikpcb* pcb){ int n1 = unfix(x); int n2 = unfix(y); int r = n1 + n2; - ikp q = fix(r); + ikptr q = fix(r); if(r == unfix(q)){ return q; } else { - ikp bn = ik_safe_alloc(pcb, align(disp_bignum_data + wordsize)); + ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + wordsize)); if(r > 0){ - ref(bn, 0) = (ikp)(bignum_tag | (1 << bignum_length_shift)); - ref(bn, disp_bignum_data) = (ikp)r; + ref(bn, 0) = (ikptr)(bignum_tag | (1 << bignum_length_shift)); + ref(bn, disp_bignum_data) = (ikptr)r; } else { ref(bn, 0) = - (ikp)(bignum_tag | + (ikptr)(bignum_tag | (1 << bignum_length_shift) | (1 << bignum_sign_shift)); - ref(bn, disp_bignum_data) = (ikp)-r; + ref(bn, disp_bignum_data) = (ikptr)-r; } return verify_bignum(bn+vector_tag, "fxfx+"); } } -ikp -ikrt_fxbnplus(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ if(x == 0){ return y ; } - ikp fst = ref(y, -vector_tag); + ikptr fst = ref(y, -vector_tag); int limb_count = ((unsigned int) fst) >> bignum_length_shift; int intx = unfix(x); if(intx > 0){ if((bignum_sign_mask & (int)fst) == 0){ /* positive fx + positive bn = even bigger positive */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; int carry = mpn_add_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), limb_count, intx); if(carry){ - ref(r, disp_bignum_data + limb_count*wordsize) = (ikp)1; - ref(r, 0) = (ikp) + ref(r, disp_bignum_data + limb_count*wordsize) = (ikptr)1; + ref(r, 0) = (ikptr) (((limb_count + 1) << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); return verify_bignum(r+vector_tag, "fxbn+1"); } else { - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((limb_count << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); @@ -179,7 +179,7 @@ ikrt_fxbnplus(ikp x, ikp y, ikpcb* pcb){ //fprintf(stderr, "this case 0x%08x\n", intx); /* positive fx + negative bn = smaller negative bn */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; int borrow = mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), @@ -203,7 +203,7 @@ ikrt_fxbnplus(ikp x, ikp y, ikpcb* pcb){ return fix(-(int)last); } } - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((result_size << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); @@ -214,7 +214,7 @@ ikrt_fxbnplus(ikp x, ikp y, ikpcb* pcb){ if((bignum_sign_mask & (int)fst) == 0){ /* negative fx + positive bn = smaller positive */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; int borrow = mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), @@ -238,7 +238,7 @@ ikrt_fxbnplus(ikp x, ikp y, ikpcb* pcb){ return fix((int)last); } } - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((result_size << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); @@ -246,21 +246,21 @@ ikrt_fxbnplus(ikp x, ikp y, ikpcb* pcb){ } else { /* negative fx + negative bn = larger negative */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; int carry = mpn_add_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), limb_count, -intx); if(carry){ - ref(r, disp_bignum_data + limb_count*wordsize) = (ikp)1; - ref(r, 0) = (ikp) + ref(r, disp_bignum_data + limb_count*wordsize) = (ikptr)1; + ref(r, 0) = (ikptr) (((limb_count + 1) << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); return verify_bignum(r+vector_tag, "fxbn+5"); } else { - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((limb_count << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); @@ -273,8 +273,8 @@ ikrt_fxbnplus(ikp x, ikp y, ikpcb* pcb){ -ikp -ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ unsigned int xfst = (unsigned int)ref(x, -vector_tag); unsigned int yfst = (unsigned int)ref(y, -vector_tag); int xsign = xfst & bignum_sign_mask; @@ -283,7 +283,7 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ int ylimbs = yfst >> bignum_length_shift; if(xsign == ysign){ int n1,n2; - ikp s1,s2; + ikptr s1,s2; if(xlimbs > ylimbs){ n1 = xlimbs; n2 = ylimbs; s1 = x; s2 = y; } else { @@ -291,7 +291,7 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ } pcb->root0 = &s1; pcb->root1 = &s2; - ikp res = ik_safe_alloc(pcb, align(disp_bignum_data + (n1+1)*wordsize)); + ikptr res = ik_safe_alloc(pcb, align(disp_bignum_data + (n1+1)*wordsize)); pcb->root0 = 0; pcb->root1 = 0; mp_limb_t carry = mpn_add((mp_limb_t*) (res+disp_bignum_data), @@ -300,14 +300,14 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ (mp_limb_t*) (s2-vector_tag+disp_bignum_data), n2); if(carry){ - ref(res, disp_vector_data + xlimbs*wordsize) = (ikp)1; - ref(res, 0) = (ikp) + ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1; + ref(res, 0) = (ikptr) (((n1+1) << bignum_length_shift) | xsign | bignum_tag); return verify_bignum(res+vector_tag, "bnbn+1"); } else { - ref(res, 0) = (ikp) + ref(res, 0) = (ikptr) ((n1 << bignum_length_shift) | xsign | bignum_tag); @@ -315,7 +315,7 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ } } else { - ikp s1=x, s2=y; + ikptr s1=x, s2=y; int n1=xlimbs, n2=ylimbs; int result_sign = xsign; while((xlimbs == ylimbs) && @@ -343,7 +343,7 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ /* |s1| > |s2| */ pcb->root0 = &s1; pcb->root1 = &s2; - ikp res = ik_safe_alloc(pcb, align(disp_bignum_data + n1 * wordsize)); + ikptr res = ik_safe_alloc(pcb, align(disp_bignum_data + n1 * wordsize)); pcb->root0 = 0; pcb->root1 = 0; int burrow = mpn_sub((mp_limb_t*) (res + disp_bignum_data), @@ -370,7 +370,7 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ return fix((int)fst_limb); } } - ref(res, 0) = (ikp) + ref(res, 0) = (ikptr) ((len << bignum_length_shift) | result_sign | bignum_tag); @@ -383,7 +383,7 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ return fix(-(int)fst_limb); } } - ref(res, 0) = (ikp) + ref(res, 0) = (ikptr) ((len << bignum_length_shift) | result_sign | bignum_tag); @@ -395,8 +395,8 @@ ikrt_bnbnplus(ikp x, ikp y, ikpcb* pcb){ -ikp -ikrt_fxfxminus(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fxfxminus(ikptr x, ikptr y, ikpcb* pcb){ int n1 = unfix(x); int n2 = unfix(y); int r = n1 - n2; @@ -404,31 +404,31 @@ ikrt_fxfxminus(ikp x, ikp y, ikpcb* pcb){ if(((unsigned int)r) <= most_positive_fixnum){ return fix(r); } else { - ikp bn = ik_safe_alloc(pcb, align(disp_bignum_data + wordsize)); - ref(bn, 0) = (ikp) (bignum_tag | (1 << bignum_length_shift)); - ref(bn, disp_bignum_data) = (ikp)r; + ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + wordsize)); + ref(bn, 0) = (ikptr) (bignum_tag | (1 << bignum_length_shift)); + ref(bn, disp_bignum_data) = (ikptr)r; return verify_bignum(bn+vector_tag,"fxfx-1"); } } else { - ikp fxr = fix(r); + ikptr fxr = fix(r); if(unfix(fxr) == r){ return fxr; } else { - ikp bn = ik_safe_alloc(pcb, align(disp_bignum_data + wordsize)); - ref(bn, 0) = (ikp) + ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + wordsize)); + ref(bn, 0) = (ikptr) (bignum_tag | (1 << bignum_sign_shift) | (1 << bignum_length_shift)); - ref(bn, disp_bignum_data) = (ikp)(-r); + ref(bn, disp_bignum_data) = (ikptr)(-r); return verify_bignum(bn+vector_tag, "fxfx-2"); } } } -ikp -ikrt_bnnegate(ikp x, ikpcb* pcb){ - ikp fst = ref(x, -vector_tag); +ikptr +ikrt_bnnegate(ikptr x, ikpcb* pcb){ + ikptr fst = ref(x, -vector_tag); int limb_count = ((unsigned int) fst) >> bignum_length_shift; if(limb_count == 1){ if((bignum_sign_mask & (int)fst) == 0){ @@ -440,43 +440,43 @@ ikrt_bnnegate(ikp x, ikpcb* pcb){ } } pcb->root0 = &x; - ikp bn = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); + ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); pcb->root0 = 0; memcpy(bn+disp_bignum_data, x-vector_tag+disp_bignum_data, limb_count*wordsize); - ref(bn, 0) = (ikp) + ref(bn, 0) = (ikptr) (bignum_tag | ((1 << bignum_sign_shift) - (bignum_sign_mask & (int)fst)) | (limb_count << bignum_length_shift)); return verify_bignum(bn+vector_tag, "bnneg"); } -ikp -ikrt_fxbnminus(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ if(x == 0){ return ikrt_bnnegate(y, pcb) ; } - ikp fst = ref(y, -vector_tag); + ikptr fst = ref(y, -vector_tag); int limb_count = ((unsigned int) fst) >> bignum_length_shift; int intx = unfix(x); if(intx > 0){ if(bignum_sign_mask & (int)fst){ /* positive fx - negative bn = positive bn */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; int carry = mpn_add_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), limb_count, intx); if(carry){ - ref(r, disp_bignum_data + limb_count*wordsize) = (ikp)1; - ref(r, 0) = (ikp) + ref(r, disp_bignum_data + limb_count*wordsize) = (ikptr)1; + ref(r, 0) = (ikptr) (((limb_count + 1) << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); return verify_bignum(r+vector_tag, "fxbn-1"); } else { - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((limb_count << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); @@ -486,7 +486,7 @@ ikrt_fxbnminus(ikp x, ikp y, ikpcb* pcb){ else { /* positive fx - positive bn = smaller negative bn/fx */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; int borrow = mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), @@ -510,7 +510,7 @@ ikrt_fxbnminus(ikp x, ikp y, ikpcb* pcb){ return fix(-(int)last); } } - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((result_size << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); @@ -521,7 +521,7 @@ ikrt_fxbnminus(ikp x, ikp y, ikpcb* pcb){ if(bignum_sign_mask & (int)fst){ /* negative fx - negative bn = smaller positive */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; int borrow = mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), @@ -545,7 +545,7 @@ ikrt_fxbnminus(ikp x, ikp y, ikpcb* pcb){ return fix((int)last); } } - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((result_size << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); @@ -553,21 +553,21 @@ ikrt_fxbnminus(ikp x, ikp y, ikpcb* pcb){ } else { /* negative fx - positive bn = larger negative */ pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; int carry = mpn_add_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y - vector_tag + disp_bignum_data), limb_count, -intx); if(carry){ - ref(r, disp_bignum_data + limb_count*wordsize) = (ikp)1; - ref(r, 0) = (ikp) + ref(r, disp_bignum_data + limb_count*wordsize) = (ikptr)1; + ref(r, 0) = (ikptr) (((limb_count + 1) << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); return verify_bignum(r+vector_tag, "fxbn-"); } else { - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((limb_count << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); @@ -577,31 +577,31 @@ ikrt_fxbnminus(ikp x, ikp y, ikpcb* pcb){ } } -ikp -ikrt_bnfxminus(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ if(y == 0){ return x; } - ikp fst = ref(x, -vector_tag); + ikptr fst = ref(x, -vector_tag); int limb_count = ((unsigned int) fst) >> bignum_length_shift; int inty = unfix(y); if(inty < 0){ if((bignum_sign_mask & (int)fst) == 0){ /* - negative fx + positive bn = positive bn */ pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; int carry = mpn_add_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(x - vector_tag + disp_bignum_data), limb_count, -inty); if(carry){ - ref(r, disp_bignum_data + limb_count*wordsize) = (ikp)1; - ref(r, 0) = (ikp) + ref(r, disp_bignum_data + limb_count*wordsize) = (ikptr)1; + ref(r, 0) = (ikptr) (((limb_count + 1) << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); return verify_bignum(r+vector_tag,"bnfx-"); } else { - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((limb_count << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); @@ -611,7 +611,7 @@ ikrt_bnfxminus(ikp x, ikp y, ikpcb* pcb){ else { /* - negative fx + negative bn = smaller negative bn/fx */ pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; int borrow = mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(x - vector_tag + disp_bignum_data), @@ -635,7 +635,7 @@ ikrt_bnfxminus(ikp x, ikp y, ikpcb* pcb){ return fix(-(int)last); } } - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((result_size << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); @@ -646,7 +646,7 @@ ikrt_bnfxminus(ikp x, ikp y, ikpcb* pcb){ if((bignum_sign_mask & (int)fst) == 0){ /* - positive fx + positive bn = smaller positive */ pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; int borrow = mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(x - vector_tag + disp_bignum_data), @@ -670,7 +670,7 @@ ikrt_bnfxminus(ikp x, ikp y, ikpcb* pcb){ return fix((int)last); } } - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((result_size << bignum_length_shift) | (0 << bignum_sign_shift) | bignum_tag); @@ -678,21 +678,21 @@ ikrt_bnfxminus(ikp x, ikp y, ikpcb* pcb){ } else { /* - positive fx + negative bn = larger negative */ pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; int carry = mpn_add_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(x - vector_tag + disp_bignum_data), limb_count, inty); if(carry){ - ref(r, disp_bignum_data + limb_count*wordsize) = (ikp)1; - ref(r, 0) = (ikp) + ref(r, disp_bignum_data + limb_count*wordsize) = (ikptr)1; + ref(r, 0) = (ikptr) (((limb_count + 1) << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); return verify_bignum(r+vector_tag, "bnfx-"); } else { - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) ((limb_count << bignum_length_shift) | (1 << bignum_sign_shift) | bignum_tag); @@ -704,8 +704,8 @@ ikrt_bnfxminus(ikp x, ikp y, ikpcb* pcb){ -ikp -ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ if(x == y) { return 0; } unsigned int xfst = (unsigned int)ref(x, -vector_tag); unsigned int yfst = (unsigned int)ref(y, -vector_tag); @@ -715,7 +715,7 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ int ylimbs = yfst >> bignum_length_shift; if(xsign != ysign){ int n1,n2; - ikp s1,s2; + ikptr s1,s2; if(xlimbs >= ylimbs){ n1 = xlimbs; n2 = ylimbs; s1 = x; s2 = y; } else { @@ -723,7 +723,7 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ } pcb->root0 = &s1; pcb->root0 = &s2; - ikp res = ik_safe_alloc(pcb, align(disp_bignum_data + (n1+1)*wordsize)); + ikptr res = ik_safe_alloc(pcb, align(disp_bignum_data + (n1+1)*wordsize)); pcb->root0 = 0; pcb->root0 = 0; mp_limb_t carry = mpn_add((mp_limb_t*) (res+disp_bignum_data), @@ -732,14 +732,14 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ (mp_limb_t*) (s2-vector_tag+disp_bignum_data), n2); if(carry){ - ref(res, disp_vector_data + xlimbs*wordsize) = (ikp)1; - ref(res, 0) = (ikp) + ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1; + ref(res, 0) = (ikptr) (((n1+1) << bignum_length_shift) | xsign | bignum_tag); return verify_bignum(res+vector_tag, "bnbn-"); } else { - ref(res, 0) = (ikp) + ref(res, 0) = (ikptr) ((n1 << bignum_length_shift) | xsign | bignum_tag); @@ -756,7 +756,7 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ } ylimbs = xlimbs; } - ikp s1=x, s2=y; + ikptr s1=x, s2=y; int n1=xlimbs, n2=ylimbs; int result_sign = xsign; /* |x| != |y| */ @@ -777,7 +777,7 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ /* |s1| > |s2| */ pcb->root0 = &s1; pcb->root0 = &s2; - ikp res = ik_safe_alloc(pcb, align(disp_bignum_data + n1 * wordsize)); + ikptr res = ik_safe_alloc(pcb, align(disp_bignum_data + n1 * wordsize)); pcb->root0 = 0; pcb->root0 = 0; int burrow = mpn_sub((mp_limb_t*) (res + disp_bignum_data), @@ -804,7 +804,7 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ return fix((int)fst_limb); } } - ref(res, 0) = (ikp) + ref(res, 0) = (ikptr) ((len << bignum_length_shift) | result_sign | bignum_tag); @@ -817,7 +817,7 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ return fix(-(int)fst_limb); } } - ref(res, 0) = (ikp) + ref(res, 0) = (ikptr) ((len << bignum_length_shift) | result_sign | bignum_tag); @@ -827,8 +827,8 @@ ikrt_bnbnminus(ikp x, ikp y, ikpcb* pcb){ } -ikp -ikrt_fxfxmult(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fxfxmult(ikptr x, ikptr y, ikpcb* pcb){ int n1 = unfix(x); int n2 = unfix(y); mp_limb_t lo = 0; @@ -854,27 +854,27 @@ ikrt_fxfxmult(ikp x, ikp y, ikpcb* pcb){ return fix((int)lo); } } - ikp r = ik_safe_alloc(pcb, disp_bignum_data + wordsize); - ref(r, 0) = (ikp) + ikptr r = ik_safe_alloc(pcb, disp_bignum_data + wordsize); + ref(r, 0) = (ikptr) (bignum_tag | (sign << bignum_sign_shift) | (1 << bignum_length_shift)); - ref(r, disp_bignum_data) = (ikp)lo; + ref(r, disp_bignum_data) = (ikptr)lo; return BN(r+vector_tag); } else { - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + 2*wordsize)); - ref(r, 0) = (ikp) + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + 2*wordsize)); + ref(r, 0) = (ikptr) (bignum_tag | (sign << bignum_sign_shift) | (2 << bignum_length_shift)); - ref(r, disp_bignum_data) = (ikp)lo; - ref(r, disp_bignum_data+wordsize) = (ikp)hi; + ref(r, disp_bignum_data) = (ikptr)lo; + ref(r, disp_bignum_data+wordsize) = (ikptr)hi; return BN(r+vector_tag); } } -ikp -normalize_bignum(int limbs, int sign, ikp r){ +ikptr +normalize_bignum(int limbs, int sign, ikptr r){ while(ref(r, disp_bignum_data + (limbs-1)*wordsize) == 0){ limbs--; if(limbs == 0){ return 0;} @@ -891,26 +891,26 @@ normalize_bignum(int limbs, int sign, ikp r){ } } } - ref(r, 0) = (ikp) (bignum_tag | sign | (limbs << bignum_length_shift)); + ref(r, 0) = (ikptr) (bignum_tag | sign | (limbs << bignum_length_shift)); return BN(r+vector_tag); } -ikp -ikrt_fxbnmult(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fxbnmult(ikptr x, ikptr y, ikpcb* pcb){ int n2 = unfix(x); if(n2 == 0) { return 0; } mp_limb_t s2 = (n2>0) ? n2 : (- n2); - ikp fst = ref(y, -vector_tag); + ikptr fst = ref(y, -vector_tag); int limb_count = ((unsigned int) fst) >> bignum_length_shift; pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + (limb_count+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + (limb_count+1)*wordsize)); pcb->root0 = 0; mp_limb_t hi = mpn_mul_1((mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(y-vector_tag+disp_bignum_data), limb_count, s2); - ref(r, disp_bignum_data + limb_count * wordsize) = (ikp)hi; + ref(r, disp_bignum_data + limb_count * wordsize) = (ikptr)hi; int sign = ((n2 > 0) ? (bignum_sign_mask & (int)fst) : @@ -918,8 +918,8 @@ ikrt_fxbnmult(ikp x, ikp y, ikpcb* pcb){ return normalize_bignum(limb_count+1, sign, r); } -ikp -ikrt_bnbnmult(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_bnbnmult(ikptr x, ikptr y, ikpcb* pcb){ int f1 = (int)ref(x, -vector_tag); int f2 = (int)ref(y, -vector_tag); int n1 = ((unsigned int)f1) >> bignum_length_shift; @@ -927,7 +927,7 @@ ikrt_bnbnmult(ikp x, ikp y, ikpcb* pcb){ int nr = n1 + n2; pcb->root0 = &x; pcb->root1 = &y; - ikp bn = ik_safe_alloc(pcb, align(disp_bignum_data + nr*wordsize)); + ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + nr*wordsize)); pcb->root0 = 0; pcb->root1 = 0; mp_limb_t r; @@ -954,10 +954,10 @@ ikrt_bnbnmult(ikp x, ikp y, ikpcb* pcb){ -ikp -ikrt_bnbncomp(ikp bn1, ikp bn2){ - ikp f1 = ref(bn1, -vector_tag); - ikp f2 = ref(bn2, -vector_tag); +ikptr +ikrt_bnbncomp(ikptr bn1, ikptr bn2){ + ikptr f1 = ref(bn1, -vector_tag); + ikptr f2 = ref(bn2, -vector_tag); if(bignum_sign_mask & (int)f1){ if(bignum_sign_mask & (int)f2){ /* both negative */ @@ -1018,10 +1018,10 @@ ikrt_bnbncomp(ikp bn1, ikp bn2){ } /* FIXME: Too complicated! */ -ikp -ikrt_fxbnlogand(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fxbnlogand(ikptr x, ikptr y, ikpcb* pcb){ int n1 = unfix(x); - ikp fst = ref(y, -vector_tag); + ikptr fst = ref(y, -vector_tag); if(n1 >= 0){ if(bignum_sign_mask & (unsigned int) fst){ /* y is negative */ @@ -1041,10 +1041,10 @@ ikrt_fxbnlogand(ikp x, ikp y, ikpcb* pcb){ return fix(-nn); } pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + len * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + len * wordsize)); pcb->root0 = 0; ref(r, 0) = fst; - ref(r, disp_bignum_data) = (ikp) nn; + ref(r, disp_bignum_data) = (ikptr) nn; int i; for(i=1; i> bignum_length_shift); pcb->root0 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + len * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + len * wordsize)); pcb->root0 = 0; ref(r, 0) = fst; - ref(r, disp_bignum_data) = (ikp) + ref(r, disp_bignum_data) = (ikptr) (((int)ref(y, disp_bignum_data - vector_tag)) & n1); int i; for(i=1; i> bignum_length_shift; if(bignum_sign_mask & (unsigned int) fst){ /* negative */ pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize)); pcb->root0 = 0; unsigned int* s1 = ((unsigned int*)(x+disp_bignum_data-vector_tag)); unsigned int* rd = (unsigned int*)(r+disp_bignum_data); @@ -1165,16 +1165,16 @@ ikrt_bnlognot(ikp x, ikpcb* pcb){ for(i=0; (iroot0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + (n+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + (n+1)*wordsize)); pcb->root0 = 0; bzero(r+disp_bignum_data, n*wordsize); ((unsigned int*)(r+disp_bignum_data))[n] = 1; - ref(r, 0) = (ikp) + ref(r, 0) = (ikptr) (bignum_tag | (1<root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize)); pcb->root0 = 0; unsigned int* s1 = ((unsigned int*)(x+disp_bignum_data-vector_tag)); unsigned int* rd = (unsigned int*)(r+disp_bignum_data); @@ -1182,7 +1182,7 @@ ikrt_bnlognot(ikp x, ikpcb* pcb){ for(j=0; j> bignum_length_shift; int n2 = ((unsigned int) yfst) >> bignum_length_shift; if(bignum_sign_mask & (unsigned int) xfst){ @@ -1201,7 +1201,7 @@ ikrt_bnbnlogand(ikp x, ikp y, ikpcb* pcb){ if(n1 >= n2){ pcb->root0 = &x; pcb->root1 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + n1*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n1*wordsize)); pcb->root0 = 0; pcb->root1 = 0; unsigned int* s1 = ((unsigned int*)(x+disp_bignum_data-vector_tag)); @@ -1223,7 +1223,7 @@ ikrt_bnbnlogand(ikp x, ikp y, ikpcb* pcb){ /* the result is at most n1 words long */ pcb->root0 = &x; pcb->root1 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + n1*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n1*wordsize)); pcb->root0 = 0; pcb->root1 = 0; unsigned int* s1 = ((unsigned int*)(x+disp_bignum_data-vector_tag)); @@ -1247,14 +1247,14 @@ ikrt_bnbnlogand(ikp x, ikp y, ikpcb* pcb){ } pcb->root0 = &x; pcb->root1 = &y; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data+(i+1)*wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(i+1)*wordsize)); pcb->root0 = 0; pcb->root1 = 0; - ref(r, 0) = (ikp) (bignum_tag | ((i+1)<> bignum_length_shift; int whole_limb_shift = m >> 5; /* FIXME: 5 are the bits in 32-bit num */ int bit_shift = m & 31; @@ -1310,7 +1310,7 @@ ikrt_bignum_shift_right(ikp x, ikp y, ikpcb* pcb){ } if(bit_shift == 0){ pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize)); pcb->root0 = 0; bits_compliment_with_carry( (unsigned int*)(x+off_bignum_data+whole_limb_shift*wordsize), @@ -1324,7 +1324,7 @@ ikrt_bignum_shift_right(ikp x, ikp y, ikpcb* pcb){ return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r); } else { pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize)); pcb->root0 = 0; bits_compliment_with_carry( (unsigned int*)(x+off_bignum_data+whole_limb_shift*wordsize), @@ -1351,7 +1351,7 @@ ikrt_bignum_shift_right(ikp x, ikp y, ikpcb* pcb){ return 0; } pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize)); pcb->root0 = 0; if(bit_shift == 0){ memcpy(r+disp_bignum_data, @@ -1370,13 +1370,13 @@ ikrt_bignum_shift_right(ikp x, ikp y, ikpcb* pcb){ } -ikp -ikrt_fixnum_shift_left(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_fixnum_shift_left(ikptr x, ikptr y, ikpcb* pcb){ int m = unfix(y); int n = unfix(x); int limb_count = (m >> 5) + 2; /* FIXME: 5 are the bits in 32-bit num */ int bit_shift = m & 31; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); unsigned int* s = (unsigned int*)(r+disp_bignum_data); bzero(s, limb_count * wordsize); if(n >= 0){ @@ -1394,17 +1394,17 @@ ikrt_fixnum_shift_left(ikp x, ikp y, ikpcb* pcb){ } -ikp -ikrt_bignum_shift_left(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_bignum_shift_left(ikptr x, ikptr y, ikpcb* pcb){ int m = unfix(y); - ikp fst = ref(x, -vector_tag); + ikptr fst = ref(x, -vector_tag); int n = ((unsigned int) fst) >> bignum_length_shift; int whole_limb_shift = m >> 5; /* FIXME: 5 are the bits in 32-bit num */ int bit_shift = m & 31; if(bit_shift == 0){ int limb_count = n + whole_limb_shift; pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); pcb->root0 = 0; unsigned int* s = (unsigned int*)(r+disp_bignum_data); bzero(s, whole_limb_shift*wordsize); @@ -1413,7 +1413,7 @@ ikrt_bignum_shift_left(ikp x, ikp y, ikpcb* pcb){ } else { int limb_count = n + whole_limb_shift + 1; pcb->root0 = &x; - ikp r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); + ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); pcb->root0 = 0; unsigned int* s = (unsigned int*)(r+disp_bignum_data); bzero(s, whole_limb_shift*wordsize); @@ -1447,17 +1447,17 @@ or equal to dn. The most significant limb of dp must be non-zero. The qxn operand must be zero. #endif -ikp -ikrt_bnbndivrem(ikp x, ikp y, ikpcb* pcb){ - ikp xfst = ref(x, -vector_tag); - ikp yfst = ref(y, -vector_tag); +ikptr +ikrt_bnbndivrem(ikptr x, ikptr y, ikpcb* pcb){ + ikptr xfst = ref(x, -vector_tag); + ikptr yfst = ref(y, -vector_tag); mp_size_t xn = ((unsigned int) xfst) >> bignum_length_shift; mp_size_t yn = ((unsigned int) yfst) >> bignum_length_shift; if(xn < yn){ /* quotient is zero, remainder is x */ pcb->root0 = &x; pcb->root1 = &y; - ikp rv = ik_safe_alloc(pcb, pair_size); + ikptr rv = ik_safe_alloc(pcb, pair_size); pcb->root0 = 0; pcb->root1 = 0; ref(rv, disp_car) = 0; @@ -1467,15 +1467,15 @@ ikrt_bnbndivrem(ikp x, ikp y, ikpcb* pcb){ mp_size_t qn = xn - yn + 1; mp_size_t rn = yn; /* - ikp q = ik_unsafe_alloc(pcb, align(disp_bignum_data + qn*wordsize)); - ikp r = ik_unsafe_alloc(pcb, align(disp_bignum_data + rn*wordsize)); + ikptr q = ik_unsafe_alloc(pcb, align(disp_bignum_data + qn*wordsize)); + ikptr r = ik_unsafe_alloc(pcb, align(disp_bignum_data + rn*wordsize)); */ pcb->root0 = &x; pcb->root1 = &y; - ikp q = ik_safe_alloc(pcb, + ikptr q = ik_safe_alloc(pcb, align(disp_bignum_data + qn*wordsize) + align(disp_bignum_data + rn*wordsize)); - ikp r = q + align(disp_bignum_data + qn*wordsize); + ikptr r = q + align(disp_bignum_data + qn*wordsize); pcb->root0 = 0; pcb->root1 = 0; mpn_tdiv_qr ( @@ -1506,7 +1506,7 @@ ikrt_bnbndivrem(ikp x, ikp y, ikpcb* pcb){ } pcb->root0 = &q; pcb->root1 = &r; - ikp rv = ik_safe_alloc(pcb, pair_size); + ikptr rv = ik_safe_alloc(pcb, pair_size); pcb->root0 = 0; pcb->root1 = 0; ref(rv, disp_car) = q; @@ -1533,13 +1533,13 @@ developed and written to {r1p, qxn}. Either or both s2n and qxn can be zero. For usages, qxn will be zero. #endif -ikp -ikrt_bnfxdivrem(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_bnfxdivrem(ikptr x, ikptr y, ikpcb* pcb){ int yint = unfix(y); - ikp fst = ref(x, -vector_tag); + ikptr fst = ref(x, -vector_tag); mp_size_t s2n = ((unsigned int) fst) >> bignum_length_shift; pcb->root0 = &x; - ikp quot = ik_safe_alloc(pcb, align(s2n*wordsize + disp_bignum_data)); + ikptr quot = ik_safe_alloc(pcb, align(s2n*wordsize + disp_bignum_data)); pcb->root0 = 0; mp_limb_t* s2p = (mp_limb_t*)(x+off_bignum_data); mp_limb_t rv = mpn_divrem_1( @@ -1549,7 +1549,7 @@ ikrt_bnfxdivrem(ikp x, ikp y, ikpcb* pcb){ s2n, abs(yint)); - ikp rem; + ikptr rem; if(yint < 0){ /* y is negative => quotient is opposite of x */ @@ -1567,13 +1567,13 @@ ikrt_bnfxdivrem(ikp x, ikp y, ikpcb* pcb){ then |remainder| will be at most most_positive_fixnum). */ if(((unsigned int) fst) & bignum_sign_mask){ /* x is negative => remainder is negative */ - rem = (ikp) -(rv << fx_shift); + rem = (ikptr) -(rv << fx_shift); } else { rem = fix(rv); } pcb->root0 = " pcb->root0 = &rem; - ikp p = ik_safe_alloc(pcb, pair_size); + ikptr p = ik_safe_alloc(pcb, pair_size); pcb->root0 = 0; pcb->root0 = 0; ref(p, disp_car) = quot; @@ -1581,11 +1581,11 @@ ikrt_bnfxdivrem(ikp x, ikp y, ikpcb* pcb){ return p+pair_tag; } -ikp -ikrt_bnfx_modulo(ikp x, ikp y, ikpcb* pcb){ +ikptr +ikrt_bnfx_modulo(ikptr x, ikptr y, ikpcb* pcb){ int yint = unfix(y); mp_limb_t* s2p = (mp_limb_t*)(x+off_bignum_data); - ikp fst = ref(x, -vector_tag); + ikptr fst = ref(x, -vector_tag); mp_size_t s2n = ((unsigned int) fst) >> bignum_length_shift; if(yint < 0){ if(((unsigned int) fst) & bignum_sign_mask){ @@ -1614,12 +1614,12 @@ ikrt_bnfx_modulo(ikp x, ikp y, ikpcb* pcb){ -ikp -ikrt_bignum_to_bytevector(ikp x, ikpcb* pcb){ +ikptr +ikrt_bignum_to_bytevector(ikptr x, ikpcb* pcb){ /* FIXME: avoid calling malloc, instead, use the heap pointer itself * as a buffer to hold the temporary data after ensuring that it has enough * space */ - ikp fst = ref(x, -vector_tag); + ikptr fst = ref(x, -vector_tag); int limb_count = (((unsigned int)fst) >> bignum_length_shift); if(limb_count <= 0){ fprintf(stderr, "BUG: nbtostring: invalid length %d\n", limb_count); @@ -1646,9 +1646,9 @@ ikrt_bignum_to_bytevector(ikp x, ikpcb* pcb){ string_start++; bytes--; } - ikp bv = ik_safe_alloc(pcb, align(bytes + disp_bytevector_data + (sign_bit?1:0))); + ikptr bv = ik_safe_alloc(pcb, align(bytes + disp_bytevector_data + (sign_bit?1:0))); ref(bv, 0) = fix(bytes + (sign_bit?1:0)); - ikp dest = bv + disp_bytevector_data; + ikptr dest = bv + disp_bytevector_data; if(sign_bit){ *dest = '-'; dest++; @@ -1666,8 +1666,8 @@ ikrt_bignum_to_bytevector(ikp x, ikpcb* pcb){ } -ikp -ikrt_fxrandom(ikp x){ +ikptr +ikrt_fxrandom(ikptr x){ int mask = 1; int n = unfix(x); { diff --git a/src/ikarus-print.c b/src/ikarus-print.c index 9ea5abd..8189cf5 100644 --- a/src/ikarus-print.c +++ b/src/ikarus-print.c @@ -22,13 +22,13 @@ #include #include -static void print(FILE* fh, ikp x); +static void print(FILE* fh, ikptr x); -void ik_fprint(FILE* fh, ikp x){ +void ik_fprint(FILE* fh, ikptr x){ print(fh, x); } -void ik_print(ikp x){ +void ik_print(ikptr x){ print(stdout, x); fprintf(stdout, "\n"); } @@ -56,7 +56,7 @@ static char* char_string[128] = { static void -print(FILE* fh, ikp x){ +print(FILE* fh, ikptr x){ if(IK_FIXNUMP(x)){ fprintf(fh, "%d", IK_UNFIX(x)); } @@ -74,19 +74,19 @@ print(FILE* fh, ikp x){ } #if 0 else if(tagof(x) == symbol_tag){ - ikp str = ref(x, off_symbol_string); + ikptr str = ref(x, off_symbol_string); fprintf(fh, "%s", str+off_string_data); } #endif else if(tagof(x) == vector_tag){ - ikp len = ref(x, off_vector_length); + ikptr len = ref(x, off_vector_length); if(len == 0){ fprintf(fh, "#()"); } else { fprintf(fh, "#("); - ikp data = x + off_vector_data; + ikptr data = x + off_vector_data; print(fh, ref(data, 0)); - ikp i = (ikp)wordsize; + ikptr i = (ikptr)wordsize; while(i -extern ikp ikrt_io_error(); +extern ikptr ikrt_io_error(); static int -list_length(ikp x){ +list_length(ikptr x){ int n = 0; while(tagof(x) == pair_tag){ n++; @@ -19,7 +19,7 @@ list_length(ikp x){ } static char** -list_to_vec(ikp x){ +list_to_vec(ikptr x){ int n = list_length(x); char** vec = malloc((n+1) * sizeof(char*)); if (vec == NULL) exit(-1); @@ -32,8 +32,8 @@ list_to_vec(ikp x){ return vec; } -ikp -ikrt_process(ikp rvec, ikp cmd, ikp argv, ikpcb* pcb){ +ikptr +ikrt_process(ikptr rvec, ikptr cmd, ikptr argv, ikpcb* pcb){ int infds[2]; int outfds[2]; int errfds[2]; @@ -72,8 +72,8 @@ ikrt_process(ikp rvec, ikp cmd, ikp argv, ikpcb* pcb){ } } -ikp -ikrt_waitpid(ikp pid, ikpcb* pcb){ +ikptr +ikrt_waitpid(ikptr pid, ikpcb* pcb){ int status; waitpid(unfix(pid), &status, 0); return fix(status); diff --git a/src/ikarus-runtime.c b/src/ikarus-runtime.c index ac81991..e2d9d79 100644 --- a/src/ikarus-runtime.c +++ b/src/ikarus-runtime.c @@ -50,9 +50,9 @@ void* ik_mmap(int size); void ik_munmap(void* mem, int size); static void -extend_table_maybe(unsigned char*p, int size, ikpcb* pcb){ +extend_table_maybe(char*p, int size, ikpcb* pcb){ assert(size == align_to_next_page(size)); - unsigned char* q = p + size; + char* q = p + size; if(p < pcb->memory_base){ int new_lo = segment_index(p); int old_lo = segment_index(pcb->memory_base); @@ -65,13 +65,13 @@ extend_table_maybe(unsigned char*p, int size, ikpcb* pcb){ ik_munmap(pcb->dirty_vector_base, old_vec_size); pcb->dirty_vector_base = (unsigned int*) v; pcb->dirty_vector = (unsigned int*)(v - new_lo * pagesize); - unsigned char* s = ik_mmap(new_vec_size); + char* s = ik_mmap(new_vec_size); bzero(s, new_vec_size - old_vec_size); memcpy(s+new_vec_size-old_vec_size, pcb->segment_vector_base, old_vec_size); ik_munmap(pcb->segment_vector_base, old_vec_size); pcb->segment_vector_base = (unsigned int*) s; pcb->segment_vector = (unsigned int*)(s - new_lo * pagesize); - pcb->memory_base = (unsigned char*)(new_lo * segment_size); + pcb->memory_base = (char*)(new_lo * segment_size); } else if (q > pcb->memory_end){ int lo = segment_index(pcb->memory_base); @@ -79,25 +79,25 @@ extend_table_maybe(unsigned char*p, int size, ikpcb* pcb){ int new_hi = segment_index(q+segment_size-1); int new_vec_size = (new_hi - lo) * pagesize; int old_vec_size = (old_hi - lo) * pagesize; - unsigned char* v = ik_mmap(new_vec_size); + char* v = ik_mmap(new_vec_size); memcpy(v, pcb->dirty_vector_base, old_vec_size); bzero(v+old_vec_size, new_vec_size - old_vec_size); ik_munmap(pcb->dirty_vector_base, old_vec_size); pcb->dirty_vector_base = (unsigned int*) v; pcb->dirty_vector = (unsigned int*)(v - lo * pagesize); - unsigned char* s = ik_mmap(new_vec_size); + char* s = ik_mmap(new_vec_size); memcpy(s, pcb->segment_vector_base, old_vec_size); bzero(s+old_vec_size, new_vec_size - old_vec_size); ik_munmap(pcb->segment_vector_base, old_vec_size); pcb->segment_vector_base = (unsigned int*) s; pcb->segment_vector = (unsigned int*)(s - lo * pagesize); - pcb->memory_end = (unsigned char*)(new_hi * segment_size); + pcb->memory_end = (char*)(new_hi * segment_size); } } static void -set_segment_type(unsigned char* base, int size, unsigned int type, ikpcb* pcb){ +set_segment_type(char* base, int size, unsigned int type, ikpcb* pcb){ assert(base >= pcb->memory_base); assert((base+size) <= pcb->memory_end); assert(size == align_to_next_page(size)); @@ -110,7 +110,7 @@ set_segment_type(unsigned char* base, int size, unsigned int type, ikpcb* pcb){ } void -ik_munmap_from_segment(unsigned char* base, int size, ikpcb* pcb){ +ik_munmap_from_segment(char* base, int size, ikpcb* pcb){ assert(base >= pcb->memory_base); assert((base+size) <= pcb->memory_end); assert(size == align_to_next_page(size)); @@ -147,7 +147,7 @@ ik_munmap_from_segment(unsigned char* base, int size, ikpcb* pcb){ void* ik_mmap_typed(int size, unsigned int type, ikpcb* pcb){ - unsigned char* p; + char* p; if(size == pagesize) { ikpage* s = pcb->cached_pages; if(s){ @@ -180,7 +180,7 @@ ik_mmap_data(int size, int gen, ikpcb* pcb){ void* ik_mmap_code(int size, int gen, ikpcb* pcb){ - ikp p = ik_mmap_typed(size, code_mt | gen, pcb); + ikptr p = ik_mmap_typed(size, code_mt | gen, pcb); if(size > pagesize){ set_segment_type(p+pagesize, size-pagesize, data_mt|gen, pcb); } @@ -295,7 +295,7 @@ ikpcb* ik_make_pcb(){ { /* make cache ikpage */ ikpage* p = ik_mmap(CACHE_SIZE * sizeof(ikpage)); - pcb->cached_pages_base = (ikp)p; + pcb->cached_pages_base = (ikptr)p; pcb->cached_pages_size = CACHE_SIZE * sizeof(ikpage); ikpage* q = 0; ikpage* e = p + CACHE_SIZE; @@ -309,8 +309,8 @@ ikpcb* ik_make_pcb(){ { /* compute extent of heap and stack */ - unsigned char* lo_mem; - unsigned char* hi_mem; + char* lo_mem; + char* hi_mem; if(pcb->heap_base < pcb->stack_base){ lo_mem = pcb->heap_base - pagesize; hi_mem = pcb->stack_base + pcb->stack_size + pagesize; @@ -330,8 +330,8 @@ ikpcb* ik_make_pcb(){ bzero(svec, vec_size); pcb->segment_vector_base = (unsigned int*) (svec); pcb->segment_vector = (unsigned int*) (svec - lo_seg * pagesize); - pcb->memory_base = (unsigned char*)(lo_seg * segment_size); - pcb->memory_end = (unsigned char*)(hi_seg * segment_size); + pcb->memory_base = (char*)(lo_seg * segment_size); + pcb->memory_end = (char*)(hi_seg * segment_size); set_segment_type(pcb->heap_base, pcb->heap_size, mainheap_mt, @@ -343,9 +343,9 @@ ikpcb* ik_make_pcb(){ } /* initialize base rtd */ { - ikp r = ik_unsafe_alloc(pcb, align(rtd_size)) + rtd_tag; + ikptr r = ik_unsafe_alloc(pcb, align(rtd_size)) + rtd_tag; ref(r, off_rtd_rtd) = r; - ref(r, off_rtd_length) = (ikp) (rtd_size-wordsize); + ref(r, off_rtd_length) = (ikptr) (rtd_size-wordsize); ref(r, off_rtd_name) = 0; ref(r, off_rtd_fields) = 0; ref(r, off_rtd_printer) = 0; @@ -375,15 +375,15 @@ void ik_delete_pcb(ikpcb* pcb){ } } } - unsigned char* base = pcb->memory_base; - unsigned char* end = pcb->memory_end; + char* base = pcb->memory_base; + char* end = pcb->memory_end; unsigned int* segment_vec = pcb->segment_vector; int i = page_index(base); int j = page_index(end); while(i < j){ unsigned int t = segment_vec[i]; if(t != hole_mt){ - ik_munmap((ikp)(i<allocation_pointer; - ikp ep = pcb->heap_base + pcb->heap_size; - ikp nap = ap + size; + ikptr ap = pcb->allocation_pointer; + ikptr ep = pcb->heap_base + pcb->heap_size; + ikptr nap = ap + size; if(nap < ep){ pcb->allocation_pointer = nap; return ap; } else { ik_collect(size, pcb); - ikp ap = pcb->allocation_pointer; - ikp ep = pcb->heap_base + pcb->heap_size; - ikp nap = ap + size; + ikptr ap = pcb->allocation_pointer; + ikptr ep = pcb->heap_base + pcb->heap_size; + ikptr nap = ap + size; if(nap < ep){ pcb->allocation_pointer = nap; return ap; @@ -423,12 +423,12 @@ ik_safe_alloc(ikpcb* pcb, int size){ -ikp +ikptr ik_unsafe_alloc(ikpcb* pcb, int size){ assert(size == align(size)); - ikp ap = pcb->allocation_pointer; - ikp ep = pcb->heap_base + pcb->heap_size; - ikp nap = ap + size; + ikptr ap = pcb->allocation_pointer; + ikptr ep = pcb->heap_base + pcb->heap_size; + ikptr nap = ap + size; if(nap < ep){ pcb->allocation_pointer = nap; return ap; @@ -468,7 +468,7 @@ ik_unsafe_alloc(ikpcb* pcb, int size){ -void ik_error(ikp args){ +void ik_error(ikptr args){ fprintf(stderr, "Error: "); ik_fprint(stderr, args); fprintf(stderr, "\n"); @@ -482,13 +482,13 @@ void ik_stack_overflow(ikpcb* pcb){ #endif set_segment_type(pcb->stack_base, pcb->stack_size, data_mt, pcb); - ikp frame_base = pcb->frame_base; - ikp underflow_handler = ref(frame_base, -wordsize); + ikptr frame_base = pcb->frame_base; + ikptr underflow_handler = ref(frame_base, -wordsize); #ifndef NDEBUG fprintf(stderr, "underflow_handler = 0x%08x\n", (int)underflow_handler); #endif /* capture continuation and set it as next_k */ - ikp k = ik_unsafe_alloc(pcb, align(continuation_size)) + vector_tag; + ikptr k = ik_unsafe_alloc(pcb, align(continuation_size)) + vector_tag; ref(k, -vector_tag) = continuation_tag; ref(k, off_continuation_top) = pcb->frame_pointer; ref(k, off_continuation_size) = @@ -520,7 +520,7 @@ char* ik_uuid(char* str){ static const char* uuid_chars = "!$%&/0123456789<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; static int uuid_strlen = 1; -ikp ik_uuid(ikp str){ +ikptr ik_uuid(ikptr str){ static int fd = -1; if(fd == -1){ fd = open("/dev/urandom", O_RDONLY); @@ -530,10 +530,10 @@ ikp ik_uuid(ikp str){ uuid_strlen = strlen(uuid_chars); } int n = unfix(ref(str, off_bytevector_length)); - unsigned char* data = str+off_bytevector_data; + char* data = str+off_bytevector_data; read(fd, data, n); - unsigned char* p = data; - unsigned char* q = data + n; + char* p = data; + char* q = data + n; while(p < q){ *p = uuid_chars[*p % uuid_strlen]; p++; @@ -563,8 +563,8 @@ ERRORS [EIO] An I/O error occurred while reading from or writing to the file system. */ -ikp -ikrt_file_exists(ikp filename){ +ikptr +ikrt_file_exists(ikptr filename){ char* str; if(tagof(filename) == bytevector_tag){ str = (char*)filename + off_bytevector_data; @@ -634,8 +634,8 @@ ikrt_file_exists(ikp filename){ */ -ikp -ikrt_delete_file(ikp filename){ +ikptr +ikrt_delete_file(ikptr filename){ char* str; if(tagof(filename) == bytevector_tag){ str = (char*) filename + off_bytevector_data; @@ -665,8 +665,8 @@ ikrt_delete_file(ikp filename){ -ikp -ik_system(ikp str){ +ikptr +ik_system(ikptr str){ if(tagof(str) == bytevector_tag){ return fix(system((char*)str+off_bytevector_data)); } else { @@ -686,14 +686,14 @@ mtname(unsigned int n){ return "WHAT_T"; } -ikp +ikptr ik_dump_metatable(ikpcb* pcb){ unsigned int* s = pcb->segment_vector_base; - unsigned char* p = pcb->memory_base; - unsigned char* hi = pcb->memory_end; + char* p = pcb->memory_base; + char* hi = pcb->memory_end; while(p < hi){ unsigned int t = *s & type_mask; - unsigned char* start = p; + char* start = p; p += pagesize; s++; while((p < hi) && ((*s & type_mask) == t)){ @@ -708,14 +708,14 @@ ik_dump_metatable(ikpcb* pcb){ return void_object; } -ikp +ikptr ik_dump_dirty_vector(ikpcb* pcb){ unsigned int* s = pcb->dirty_vector_base; - unsigned char* p = pcb->memory_base; - unsigned char* hi = pcb->memory_end; + char* p = pcb->memory_base; + char* hi = pcb->memory_end; while(p < hi){ unsigned int t = *s; - unsigned char* start = p; + char* start = p; p += pagesize; s++; while((p < hi) && (*s == t)){ @@ -730,12 +730,12 @@ ik_dump_dirty_vector(ikpcb* pcb){ return void_object; } -ikp -ikrt_make_code(ikp codesizeptr, ikp freevars, ikp rvec, ikpcb* pcb){ +ikptr +ikrt_make_code(ikptr codesizeptr, ikptr freevars, ikptr rvec, ikpcb* pcb){ assert((fx_mask & (int)codesizeptr) == 0); int code_size = unfix(codesizeptr); int memreq = align_to_next_page(code_size + disp_code_data); - ikp mem = ik_mmap_code(memreq, 0, pcb); + ikptr mem = ik_mmap_code(memreq, 0, pcb); bzero(mem, memreq); ref(mem, 0) = code_tag; ref(mem, disp_code_code_size) = codesizeptr; @@ -746,16 +746,16 @@ ikrt_make_code(ikp codesizeptr, ikp freevars, ikp rvec, ikpcb* pcb){ return mem+vector_tag; } -ikp -ikrt_set_code_reloc_vector(ikp code, ikp vec, ikpcb* pcb){ +ikptr +ikrt_set_code_reloc_vector(ikptr code, ikptr vec, ikpcb* pcb){ ref(code, off_code_reloc_vector) = vec; ik_relocate_code(code-vector_tag); pcb->dirty_vector[page_index(code)] = -1; return void_object; } -ikp -ikrt_set_code_annotation(ikp code, ikp annot, ikpcb* pcb){ +ikptr +ikrt_set_code_annotation(ikptr code, ikptr annot, ikpcb* pcb){ ref(code, off_code_annotation) = annot; pcb->dirty_vector[page_index(code)] = -1; return void_object; @@ -763,8 +763,8 @@ ikrt_set_code_annotation(ikp code, ikp annot, ikpcb* pcb){ -ikp -ikrt_bvftime(ikp outbv, ikp fmtbv){ +ikptr +ikrt_bvftime(ikptr outbv, ikptr fmtbv){ time_t t; struct tm* tmp; t = time(NULL); @@ -783,8 +783,8 @@ ikrt_bvftime(ikp outbv, ikp fmtbv){ return fix(rv); } -ikp -ikrt_register_guardian_pair(ikp p0, ikpcb* pcb){ +ikptr +ikrt_register_guardian_pair(ikptr p0, ikpcb* pcb){ ik_ptr_page* x = pcb->guardians[0]; if((x == NULL) || (x->count == ik_ptr_page_size)){ assert(sizeof(ik_ptr_page) == pagesize); @@ -798,9 +798,9 @@ ikrt_register_guardian_pair(ikp p0, ikpcb* pcb){ return void_object; } -ikp -ikrt_register_guardian(ikp tc, ikp obj, ikpcb* pcb){ - ikp p0 = ik_unsafe_alloc(pcb, pair_size) + pair_tag; +ikptr +ikrt_register_guardian(ikptr tc, ikptr obj, ikpcb* pcb){ + ikptr p0 = ik_unsafe_alloc(pcb, pair_size) + pair_tag; ref(p0, off_car) = tc; ref(p0, off_cdr) = obj; return ikrt_register_guardian_pair(p0, pcb); @@ -809,8 +809,8 @@ ikrt_register_guardian(ikp tc, ikp obj, ikpcb* pcb){ -ikp -ikrt_stats_now(ikp t, ikpcb* pcb){ +ikptr +ikrt_stats_now(ikptr t, ikpcb* pcb){ struct rusage r; struct timeval s; @@ -832,8 +832,8 @@ ikrt_stats_now(ikp t, ikpcb* pcb){ return void_object; } -ikp -ikrt_current_time(ikp t){ +ikptr +ikrt_current_time(ikptr t){ struct timeval s; gettimeofday(&s, 0); /* this will break in 8,727,224 years if we stay in 32-bit ptrs */ @@ -843,8 +843,8 @@ ikrt_current_time(ikp t){ return t; } -ikp -ikrt_gmt_offset(ikp t){ +ikptr +ikrt_gmt_offset(ikptr t){ time_t clock = unfix(ref(t, off_record_data + 0*wordsize)) * 1000000 + unfix(ref(t, off_record_data + 1*wordsize)); @@ -853,7 +853,7 @@ ikrt_gmt_offset(ikp t){ return fix(clock - gmtclock); /* struct tm* m = localtime(&clock); - ikp r = fix(m->tm_gmtoff); + ikptr r = fix(m->tm_gmtoff); return r; */ } @@ -861,7 +861,7 @@ ikrt_gmt_offset(ikp t){ -ikp +ikptr ikrt_bytes_allocated(ikpcb* pcb){ int bytes_in_heap = ((int) pcb->allocation_pointer) - ((int) pcb->heap_base); @@ -870,13 +870,13 @@ ikrt_bytes_allocated(ikpcb* pcb){ } -ikp +ikptr ikrt_bytes_allocated_major(ikpcb* pcb){ return fix(pcb->allocation_count_major); } -ikp +ikptr ikrt_fork(){ int pid = fork(); return fix(pid); @@ -884,19 +884,19 @@ ikrt_fork(){ -ikp -ikrt_getenv(ikp bv, ikpcb* pcb){ +ikptr +ikrt_getenv(ikptr bv, ikpcb* pcb){ char* v = getenv((char*)bv + off_bytevector_data); if(v){ int n = strlen(v); - ikp s = ik_safe_alloc(pcb, align(n+disp_bytevector_data+1)) + ikptr s = ik_safe_alloc(pcb, align(n+disp_bytevector_data+1)) + bytevector_tag; ref(s, -bytevector_tag) = fix(n); memcpy(s+off_bytevector_data, v, n+1); return s; } else { - ikp s = ik_safe_alloc(pcb, align(disp_bytevector_data+1)) + ikptr s = ik_safe_alloc(pcb, align(disp_bytevector_data+1)) + bytevector_tag; ref(s, -bytevector_tag) = fix(0); ref(s, off_bytevector_data) = 0; @@ -904,10 +904,10 @@ ikrt_getenv(ikp bv, ikpcb* pcb){ } } -ikp -ikrt_make_vector1(ikp len, ikpcb* pcb){ +ikptr +ikrt_make_vector1(ikptr len, ikpcb* pcb){ if(is_fixnum(len) && (((int)len) >= 0)){ - ikp s = ik_safe_alloc(pcb, align(((int)len) + disp_vector_data)); + ikptr s = ik_safe_alloc(pcb, align(((int)len) + disp_vector_data)); ref(s, 0) = len; memset(s+disp_vector_data, 0, (int)len); return s+vector_tag; @@ -917,11 +917,11 @@ ikrt_make_vector1(ikp len, ikpcb* pcb){ } #if 0 -ikp -ikrt_make_vector2(ikp len, ikp obj, ikpcb* pcb){ +ikptr +ikrt_make_vector2(ikptr len, ikptr obj, ikpcb* pcb){ if(is_fixnum(len) && ((len >> 31)!=0)){ pcb->root0 = &obj; - ikp s = ik_safe_alloc(pcb, align(((int)len) + disp_vector_data)); + ikptr s = ik_safe_alloc(pcb, align(((int)len) + disp_vector_data)); pcb->root0 = 0; ref(s, 0) = len; memset(s+disp_vector_data, 0, (int)len); @@ -933,8 +933,8 @@ ikrt_make_vector2(ikp len, ikp obj, ikpcb* pcb){ #endif -ikp -ikrt_setenv(ikp key, ikp val, ikp overwrite){ +ikptr +ikrt_setenv(ikptr key, ikptr val, ikptr overwrite){ fprintf(stderr, "setenv busted!\n"); exit(-1); int err = setenv((char*)key+off_bytevector_data, @@ -948,19 +948,19 @@ ikrt_setenv(ikp key, ikp val, ikp overwrite){ } -ikp +ikptr ikrt_environ(ikpcb* pcb){ fprintf(stderr, "environ busted!\n"); exit(-1); char** es = environ; int i; char* e; - ikp ac = null_object; + ikptr ac = null_object; for(i=0; (e=es[i]); i++){ int n = strlen(e); - ikp s = ik_unsafe_alloc(pcb, align(n+disp_string_data+1)) + string_tag; + ikptr s = ik_unsafe_alloc(pcb, align(n+disp_string_data+1)) + string_tag; ref(s, -string_tag) = fix(n); memcpy(s+off_string_data, e, n+1); - ikp p = ik_unsafe_alloc(pcb, pair_size) + pair_tag; + ikptr p = ik_unsafe_alloc(pcb, pair_size) + pair_tag; ref(p, off_cdr) = ac; ref(p, off_car) = s; ac = p; @@ -968,8 +968,8 @@ ikrt_environ(ikpcb* pcb){ return ac; } -ikp -ikrt_exit(ikp status, ikpcb* pcb){ +ikptr +ikrt_exit(ikptr status, ikpcb* pcb){ ik_delete_pcb(pcb); assert(total_allocated_pages == 0); if(is_fixnum(status)){ @@ -979,8 +979,8 @@ ikrt_exit(ikp status, ikpcb* pcb){ } } -ikp -ikrt_debug(ikp x){ +ikptr +ikrt_debug(ikptr x){ fprintf(stderr, "DEBUG 0x%08x\n", (int)x); return 0; }; diff --git a/src/ikarus-symbol-table.c b/src/ikarus-symbol-table.c index 3d96113..9ae9d94 100644 --- a/src/ikarus-symbol-table.c +++ b/src/ikarus-symbol-table.c @@ -22,18 +22,18 @@ #include #include -static ikp +static ikptr make_symbol_table(ikpcb* pcb){ #define NUM_OF_BUCKETS 4096 /* power of 2 */ int size = align_to_next_page(disp_vector_data + NUM_OF_BUCKETS * wordsize); - ikp st = ik_mmap_ptr(size, 0, pcb) + vector_tag; + ikptr st = ik_mmap_ptr(size, 0, pcb) + vector_tag; bzero(st-vector_tag, size); ref(st, off_vector_length) = fix(NUM_OF_BUCKETS); return st; } static int -compute_hash(ikp str){ +compute_hash(ikptr str){ int len = unfix(ref(str, off_string_length)); char* data = (char*) str + off_string_data; int h = len; @@ -51,13 +51,13 @@ compute_hash(ikp str){ return h; } -ikp -ikrt_string_hash(ikp str){ - return (ikp)(compute_hash(str) & (~ fx_mask)); +ikptr +ikrt_string_hash(ikptr str){ + return (ikptr)(compute_hash(str) & (~ fx_mask)); } -static int strings_eqp(ikp str1, ikp str2){ - ikp len = ref(str1, off_string_length); +static int strings_eqp(ikptr str1, ikptr str2){ + ikptr len = ref(str1, off_string_length); if(len == ref(str2, off_string_length)){ return (memcmp(str1+off_string_data, @@ -69,9 +69,9 @@ static int strings_eqp(ikp str1, ikp str2){ } #if 0 -static ikp -ik_make_symbol(ikp str, ikp ustr, ikpcb* pcb){ - ikp sym = ik_unsafe_alloc(pcb, symbol_size) + symbol_tag; +static ikptr +ik_make_symbol(ikptr str, ikptr ustr, ikpcb* pcb){ + ikptr sym = ik_unsafe_alloc(pcb, symbol_size) + symbol_tag; ref(sym, off_symbol_string) = str; ref(sym, off_symbol_ustring) = ustr; ref(sym, off_symbol_value) = unbound_object; @@ -84,9 +84,9 @@ ik_make_symbol(ikp str, ikp ustr, ikpcb* pcb){ } #endif -static ikp -ik_make_symbol(ikp str, ikp ustr, ikpcb* pcb){ - ikp sym = ik_unsafe_alloc(pcb, symbol_record_size) + record_tag; +static ikptr +ik_make_symbol(ikptr str, ikptr ustr, ikpcb* pcb){ + ikptr sym = ik_unsafe_alloc(pcb, symbol_record_size) + record_tag; ref(sym, -record_tag) = symbol_record_tag; ref(sym, off_symbol_record_string) = str; ref(sym, off_symbol_record_ustring) = ustr; @@ -98,21 +98,21 @@ ik_make_symbol(ikp str, ikp ustr, ikpcb* pcb){ -static ikp -intern_string(ikp str, ikp st, ikpcb* pcb){ +static ikptr +intern_string(ikptr str, ikptr st, ikpcb* pcb){ int h = compute_hash(str); int idx = h & (unfix(ref(st, off_vector_length)) - 1); - ikp bckt = ref(st, off_vector_data + idx*wordsize); - ikp b = bckt; + ikptr bckt = ref(st, off_vector_data + idx*wordsize); + ikptr b = bckt; while(b){ - ikp sym = ref(b, off_car); - ikp sym_str = ref(sym, off_symbol_record_string); + ikptr sym = ref(b, off_car); + ikptr sym_str = ref(sym, off_symbol_record_string); if(strings_eqp(sym_str, str)){ return sym; } b = ref(b, off_cdr); } - ikp sym = ik_make_symbol(str, false_object, pcb); + ikptr sym = ik_make_symbol(str, false_object, pcb); b = ik_unsafe_alloc(pcb, pair_size) + pair_tag; ref(b, off_car) = sym; ref(b, off_cdr) = bckt; @@ -121,21 +121,21 @@ intern_string(ikp str, ikp st, ikpcb* pcb){ return sym; } -static ikp -intern_unique_string(ikp str, ikp ustr, ikp st, ikpcb* pcb){ +static ikptr +intern_unique_string(ikptr str, ikptr ustr, ikptr st, ikpcb* pcb){ int h = compute_hash(ustr); int idx = h & (unfix(ref(st, off_vector_length)) - 1); - ikp bckt = ref(st, off_vector_data + idx*wordsize); - ikp b = bckt; + ikptr bckt = ref(st, off_vector_data + idx*wordsize); + ikptr b = bckt; while(b){ - ikp sym = ref(b, off_car); - ikp sym_ustr = ref(sym, off_symbol_record_ustring); + ikptr sym = ref(b, off_car); + ikptr sym_ustr = ref(sym, off_symbol_record_ustring); if(strings_eqp(sym_ustr, ustr)){ return sym; } b = ref(b, off_cdr); } - ikp sym = ik_make_symbol(str, ustr, pcb); + ikptr sym = ik_make_symbol(str, ustr, pcb); b = ik_unsafe_alloc(pcb, pair_size) + pair_tag; ref(b, off_car) = sym; ref(b, off_cdr) = bckt; @@ -144,21 +144,21 @@ intern_unique_string(ikp str, ikp ustr, ikp st, ikpcb* pcb){ return sym; } -ikp -ikrt_intern_gensym(ikp sym, ikpcb* pcb){ - ikp st = pcb->gensym_table; +ikptr +ikrt_intern_gensym(ikptr sym, ikpcb* pcb){ + ikptr st = pcb->gensym_table; if(st == 0){ st = make_symbol_table(pcb); pcb->gensym_table = st; } - ikp ustr = ref(sym, off_symbol_record_ustring); + ikptr ustr = ref(sym, off_symbol_record_ustring); int h = compute_hash(ustr); int idx = h & (unfix(ref(st, off_vector_length)) - 1); - ikp bckt = ref(st, off_vector_data + idx*wordsize); - ikp b = bckt; + ikptr bckt = ref(st, off_vector_data + idx*wordsize); + ikptr b = bckt; while(b){ - ikp sym = ref(b, off_car); - ikp sym_ustr = ref(sym, off_symbol_record_ustring); + ikptr sym = ref(b, off_car); + ikptr sym_ustr = ref(sym, off_symbol_record_ustring); if(strings_eqp(sym_ustr, ustr)){ return false_object; } @@ -175,9 +175,9 @@ ikrt_intern_gensym(ikp sym, ikpcb* pcb){ -ikp -ikrt_string_to_symbol(ikp str, ikpcb* pcb){ - ikp st = pcb->symbol_table; +ikptr +ikrt_string_to_symbol(ikptr str, ikpcb* pcb){ + ikptr st = pcb->symbol_table; if(st == 0){ st = make_symbol_table(pcb); pcb->symbol_table = st; @@ -185,14 +185,14 @@ ikrt_string_to_symbol(ikp str, ikpcb* pcb){ return intern_string(str, st, pcb); } -ikp -ik_intern_string(ikp str, ikpcb* pcb){ +ikptr +ik_intern_string(ikptr str, ikpcb* pcb){ return ikrt_string_to_symbol(str, pcb); } -ikp -ikrt_strings_to_gensym(ikp str, ikp ustr, ikpcb* pcb){ - ikp st = pcb->gensym_table; +ikptr +ikrt_strings_to_gensym(ikptr str, ikptr ustr, ikpcb* pcb){ + ikptr st = pcb->gensym_table; if(st == 0){ st = make_symbol_table(pcb); pcb->gensym_table = st; @@ -202,14 +202,14 @@ ikrt_strings_to_gensym(ikp str, ikp ustr, ikpcb* pcb){ #if 0 -ikp +ikptr ik_cstring_to_symbol(char* str, ikpcb* pcb){ int n = strlen(str); int size = n + disp_string_data + 1; - ikp s = ik_unsafe_alloc(pcb, align(size)) + string_tag; + ikptr s = ik_unsafe_alloc(pcb, align(size)) + string_tag; ref(s, off_string_length) = fix(n); memcpy(s+off_string_data, str, n+1); - ikp sym = ikrt_string_to_symbol(s, pcb); + ikptr sym = ikrt_string_to_symbol(s, pcb); return sym; } #endif diff --git a/src/ikarus-verify-integrity.c b/src/ikarus-verify-integrity.c index 5b975f6..4d7cceb 100644 --- a/src/ikarus-verify-integrity.c +++ b/src/ikarus-verify-integrity.c @@ -22,7 +22,7 @@ #include static int -page_idx(unsigned char* x){ +page_idx(char* x){ unsigned int xi = (unsigned int) x; return xi >> pageshift; } @@ -32,11 +32,11 @@ page_idx(unsigned char* x){ #ifndef NDEBUG -static int isa_fixnum(ikp x){ +static int isa_fixnum(ikptr x){ return ((fixnum_mask & (int)x) == 0); } -static int isa_vector(ikp x){ +static int isa_vector(ikptr x){ return ( (tagof(x) == vector_tag) && isa_fixnum(ref(x, -vector_tag))); } @@ -46,15 +46,15 @@ static int isa_vector(ikp x){ static void -verify_code(unsigned char* x, unsigned char* base, unsigned int* svec, unsigned int* dvec){ +verify_code(char* x, char* base, unsigned int* svec, unsigned int* dvec){ assert(ref(x, 0) == code_tag); - ikp rvec = ref(x, disp_code_reloc_vector); + ikptr rvec = ref(x, disp_code_reloc_vector); assert(isa_vector(rvec)); - ikp codesize = ref(x, disp_code_code_size); + ikptr codesize = ref(x, disp_code_code_size); codesize += 0; assert(unfix(codesize) >= 0); assert(isa_fixnum(codesize)); - ikp freevars = ref(x, disp_code_freevars); + ikptr freevars = ref(x, disp_code_freevars); freevars += 0; assert(isa_fixnum(freevars)); assert(unfix(freevars) >= 0); @@ -73,17 +73,17 @@ verify_code(unsigned char* x, unsigned char* base, unsigned int* svec, unsigned } static void -verify_object(ikp x, unsigned char* base, unsigned int* svec, unsigned int* dvec){ +verify_object(ikptr x, char* base, unsigned int* svec, unsigned int* dvec){ } -static unsigned char* -verify_code_small(unsigned char* p, unsigned int s, unsigned int d, - unsigned char* base, unsigned int* svec, unsigned int* dvec){ - ikp q = p + pagesize; +static char* +verify_code_small(char* p, int s, unsigned int d, + char* base, unsigned int* svec, unsigned int* dvec){ + ikptr q = p + pagesize; while(p < q){ - ikp fst = ref(p, 0); + ikptr fst = ref(p, 0); if(fst == code_tag){ assert(is_fixnum(ref(p, disp_code_code_size))); int code_size = unfix(ref(p, disp_code_code_size)); @@ -101,24 +101,24 @@ verify_code_small(unsigned char* p, unsigned int s, unsigned int d, return q; } -static unsigned char* -verify_code_large(unsigned char* p, unsigned int s, unsigned int d, - unsigned char* base, unsigned int* svec, unsigned int* dvec){ - ikp fst = ref(p, 0); +static char* +verify_code_large(char* p, unsigned int s, unsigned int d, + char* base, unsigned int* svec, unsigned int* dvec){ + ikptr fst = ref(p, 0); fst += 0; assert(fst == code_tag); int code_size = unfix(ref(p, disp_code_code_size)); assert(code_size >= 0); verify_code(p, base, svec, dvec); assert(align(code_size+disp_code_data) >= pagesize); - ikp end = p + code_size + disp_code_data; - return((unsigned char*)align_to_next_page(end)); + ikptr end = p + code_size + disp_code_data; + return((char*)align_to_next_page(end)); } -static unsigned char* -verify_code_page(unsigned char* p, unsigned int s, unsigned int d, - unsigned char* base, unsigned int* svec, unsigned int* dvec){ - ikp fst = ref(p, 0); +static char* +verify_code_page(char* p, unsigned int s, unsigned int d, + char* base, unsigned int* svec, unsigned int* dvec){ + ikptr fst = ref(p, 0); fst += 0; if(fst != code_tag){ fprintf(stderr, "non code object with tag %p found\n", fst); @@ -127,7 +127,7 @@ verify_code_page(unsigned char* p, unsigned int s, unsigned int d, int code_size = unfix(ref(p, disp_code_code_size)); assert(code_size >= 0); int obj_size = align(code_size + disp_code_data); - unsigned char* result; + char* result; if(obj_size <= pagesize){ result = verify_code_small(p,s,d,base,svec,dvec); } else { @@ -140,9 +140,9 @@ verify_code_page(unsigned char* p, unsigned int s, unsigned int d, -static unsigned char* -verify_pointers_page(unsigned char* p, unsigned int s, unsigned int d, - unsigned char* base, unsigned int* svec, unsigned int* dvec){ +static char* +verify_pointers_page(char* p, unsigned int s, unsigned int d, + char* base, unsigned int* svec, unsigned int* dvec){ { int i = 0; while(i < pagesize){ @@ -154,8 +154,8 @@ verify_pointers_page(unsigned char* p, unsigned int s, unsigned int d, return p+pagesize; } -static unsigned char* -verify_page(unsigned char* p, unsigned char* base, unsigned int* svec, unsigned int* dvec){ +static char* +verify_page(char* p, char* base, unsigned int* svec, unsigned int* dvec){ int idx = page_idx(p) - page_idx(base); unsigned int s = svec[idx]; unsigned int d = dvec[idx]; @@ -198,11 +198,11 @@ verify_page(unsigned char* p, unsigned char* base, unsigned int* svec, unsigned void verify_integrity(ikpcb* pcb, char* where){ fprintf(stderr, "verifying in %s...\n", where); - unsigned char* mem_base = pcb->memory_base; - unsigned char* mem_end = pcb->memory_end; + char* mem_base = pcb->memory_base; + char* mem_end = pcb->memory_end; unsigned int* seg_vec = pcb->segment_vector_base; unsigned int* dir_vec = pcb->dirty_vector_base; - unsigned char* mem = mem_base; + char* mem = mem_base; while(mem < mem_end){ mem = verify_page(mem, mem_base, seg_vec, dir_vec); } diff --git a/src/ikarus-weak-pairs.c b/src/ikarus-weak-pairs.c index 48dc90b..44d5e52 100644 --- a/src/ikarus-weak-pairs.c +++ b/src/ikarus-weak-pairs.c @@ -19,13 +19,13 @@ #include "ikarus-data.h" -ikp -ikrt_weak_cons(ikp a, ikp d, ikpcb* pcb){ - ikp ap = pcb->weak_pairs_ap; - ikp nap = ap + pair_size; - ikp p; +ikptr +ikrt_weak_cons(ikptr a, ikptr d, ikpcb* pcb){ + ikptr ap = pcb->weak_pairs_ap; + ikptr nap = ap + pair_size; + ikptr p; if(nap > pcb->weak_pairs_ep){ - ikp mem = ik_mmap_typed(pagesize, weak_pairs_mt, pcb); + ikptr mem = ik_mmap_typed(pagesize, weak_pairs_mt, pcb); pcb->weak_pairs_ap = mem + pair_size; pcb->weak_pairs_ep = mem + pagesize; p = mem + pair_tag; @@ -39,8 +39,8 @@ ikrt_weak_cons(ikp a, ikp d, ikpcb* pcb){ return p; } -ikp -ikrt_is_weak_pair(ikp x, ikpcb* pcb){ +ikptr +ikrt_is_weak_pair(ikptr x, ikpcb* pcb){ if(tagof(x) != pair_tag){ return false_object; }