From 15ea12f9158b5859e4b8d7a1fd55e10daaf09e27 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Tue, 1 Jan 2008 04:24:36 -0500 Subject: [PATCH] cleanup of the C files to make all ikptr->int casts ikptr->long int --- scheme/ikarus.intel-assembler.ss | 174 ++++++--- scheme/last-revision | 2 +- src/cpu_has_sse2.s | 2 + src/ikarus-collect.c | 131 +++---- src/ikarus-data.h | 36 +- src/ikarus-enter.s | 13 +- src/ikarus-exec.c | 12 +- src/ikarus-fasl.c | 43 +-- src/ikarus-numerics.c | 591 ++++++++++++++++--------------- src/ikarus-print.c | 26 +- src/ikarus-runtime.c | 67 ++-- src/ikarus-symbol-table.c | 6 +- src/ikarus-verify-integrity.c | 4 +- 13 files changed, 609 insertions(+), 498 deletions(-) diff --git a/scheme/ikarus.intel-assembler.ss b/scheme/ikarus.intel-assembler.ss index 9bdcbe8..6956f34 100644 --- a/scheme/ikarus.intel-assembler.ss +++ b/scheme/ikarus.intel-assembler.ss @@ -35,46 +35,47 @@ (fold convert-instruction '() ls))) (define register-mapping - '([%eax 32 0] - [%ecx 32 1] - [%edx 32 2] - [%ebx 32 3] - [%esp 32 4] - [%ebp 32 5] - [%esi 32 6] - [%edi 32 7] - [%r8 64 0] - [%r9 64 1] - [%r10 64 2] - [%r11 64 3] - [%r12 64 4] - [%r13 64 5] - [%r14 64 6] - [%r15 64 7] - [%al 8 0] - [%cl 8 1] - [%dl 8 2] - [%bl 8 3] - [%ah 8 4] - [%ch 8 5] - [%dh 8 6] - [%bh 8 7] - [/0 0 0] - [/1 0 1] - [/2 0 2] - [/3 0 3] - [/4 0 4] - [/5 0 5] - [/6 0 6] - [/7 0 7] - [xmm0 xmm 0] - [xmm1 xmm 1] - [xmm2 xmm 2] - [xmm3 xmm 3] - [xmm4 xmm 4] - [xmm5 xmm 5] - [xmm6 xmm 6] - [xmm7 xmm 7] + ;;; reg cls idx REX.R + '([%eax 32 0 #f] + [%ecx 32 1 #f] + [%edx 32 2 #f] + [%ebx 32 3 #f] + [%esp 32 4 #f] + [%ebp 32 5 #f] + [%esi 32 6 #f] + [%edi 32 7 #f] + [%r8 32 0 #t] + [%r9 32 1 #t] + [%r10 32 2 #t] + [%r11 32 3 #t] + [%r12 32 4 #t] + [%r13 32 5 #t] + [%r14 32 6 #t] + [%r15 32 7 #t] + [%al 8 0 #f] + [%cl 8 1 #f] + [%dl 8 2 #f] + [%bl 8 3 #f] + [%ah 8 4 #f] + [%ch 8 5 #f] + [%dh 8 6 #f] + [%bh 8 7 #f] + [/0 0 0 #f] + [/1 0 1 #f] + [/2 0 2 #f] + [/3 0 3 #f] + [/4 0 4 #f] + [/5 0 5 #f] + [/6 0 6 #f] + [/7 0 7 #f] + [xmm0 xmm 0 #f] + [xmm1 xmm 1 #f] + [xmm2 xmm 2 #f] + [xmm3 xmm 3 #f] + [xmm4 xmm 4 #f] + [xmm5 xmm 5 #f] + [xmm6 xmm 6 #f] + [xmm7 xmm 7 #f] )) (define register-index @@ -108,6 +109,12 @@ (lambda (x) (assq x register-mapping))) +(define reg-requires-REX? + (lambda (x) + (cond + [(assq x register-mapping) => cadddr] + [else (error 'reg-required-REX? "not a reg" x)]))) + (define-syntax with-args (syntax-rules (lambda) [(_ x (lambda (a0 a1) b b* ...)) @@ -371,18 +378,93 @@ (module () (define who 'assembler) +(define (REX.R bits ac) + (cons (fxlogor #b01000000 bits) ac)) + +(define (REX+r r ac) + (cond + [(reg-requires-REX? r) (REX.R #b001 ac)] + [else ac])) + +(define (REX+RM r rm ac) + (define (C n ac) + (printf "CASE ~s\n" n) + (let f ([ac ac] [i 30]) + (unless (or (null? ac) (= i 0)) + (if (number? (car ac)) + (printf " #x~x" (car ac)) + (printf " ~s" (car ac))) + (f (cdr ac) (- i 1)))) + (newline) + ac) + (cond + [(mem? rm) + (if (reg-requires-REX? r) + (with-args rm + (lambda (a0 a1) + (cond + [(and (imm? a0) (reg32? a1)) + (if (reg-requires-REX? a1) + (C 0 (REX.R #b101 ac)) + (C 1 (REX.R #b100 ac)))] + [(and (imm? a1) (reg32? a0)) + (if (reg-requires-REX? a0) + (C 2 (REX.R #b101 ac)) + (C 3 (REX.R #b100 ac)))] + [(and (reg32? a0) (reg32? a1)) + (if (or (reg-requires-REX? a0) (reg-requires-REX? a1)) + (error 'REX+RM "unhandled4" a0 a1) + (error 'REX+RM "unhandleda" a1))] + [(and (imm? a0) (imm? a1)) + (error 'REX+RM "unhandledb" a1)] + [else (die 'REX+RM "unhandled" a0 a1)]))) + (with-args rm + (lambda (a0 a1) + (cond + [(and (imm? a0) (reg32? a1)) + (if (reg-requires-REX? a1) + (C 4 (REX.R #b001 ac)) + ac)] + [(and (imm? a1) (reg32? a0)) + (if (reg-requires-REX? a0) + (C 5 (REX.R #b001 ac)) + ac)] + [(and (reg32? a0) (reg32? a1)) + (if (reg-requires-REX? a0) + (if (reg-requires-REX? a1) + (error 'REX+RM "unhandled x1" a0 a1) + (C 6 (REX.R #b010 ac))) + (if (reg-requires-REX? a1) + (error 'REX+RM "unhandled x3" a0 a1) + ac))] + [(and (imm? a0) (imm? a1)) ac] + [else (die 'REX+RM "unhandled" a0 a1)]))))] + [(reg? rm) + (if (reg-requires-REX? r) + (if (reg-requires-REX? rm) + (C 7 (REX.R #b101 ac)) + (C 8 (REX.R #b100 ac))) + (if (reg-requires-REX? rm) + (C 9 (REX.R #b001 ac)) + ac))] + [else (die 'REX+RM "unhandled" rm)])) + + + (define (CR c r ac) - (CODE+r c r ac)) + (REX+r r (CODE+r c r ac))) (define (CR* c r rm ac) - (CODE c (RM r rm ac))) + (REX+RM r rm (CODE c (RM r rm ac)))) (define (CCR* c0 c1 r rm ac) - (CODE c0 (CODE c1 (RM r rm ac)))) + (REX+RM r rm (CODE c0 (CODE c1 (RM r rm ac))))) (define (CCR c0 c1 r ac) - (CODE c0 (CODE+r c1 r ac))) + (REX+r r (CODE c0 (CODE+r c1 r ac)))) +(define (CCCR* c0 c1 c2 r rm ac) + (REX+RM r rm (CODE c0 (CODE c1 (CODE c2 (RM r rm ac)))))) + + (define (CCI32 c0 c1 i32 ac) (CODE c0 (CODE c1 (IMM32 i32 ac)))) -(define (CCCR* c0 c1 c2 r rm ac) - (CODE c0 (CODE c1 (CODE c2 (RM r rm ac))))) (add-instructions instr ac [(ret) (CODE #xC3 ac)] diff --git a/scheme/last-revision b/scheme/last-revision index 47e9cd4..afdf0ce 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1302 +1303 diff --git a/src/cpu_has_sse2.s b/src/cpu_has_sse2.s index f8e31b8..fd1a18b 100644 --- a/src/cpu_has_sse2.s +++ b/src/cpu_has_sse2.s @@ -25,11 +25,13 @@ _cpu_has_sse2: # callee-save registers are $ebx, %esi, %edi, %esp, $ebp # cpuid modifies %eax, %ebx, %ecx, %edx # only %ebx needs to be saved/restored +# push %rbx push %ebx movl $1, %eax cpuid movl %edx, %eax sarl $26, %eax andl $1, %eax +# pop %rbx pop %ebx ret diff --git a/src/ikarus-collect.c b/src/ikarus-collect.c index 61550a4..41735d9 100644 --- a/src/ikarus-collect.c +++ b/src/ikarus-collect.c @@ -377,8 +377,8 @@ ik_collect(int mem_req, ikpcb* pcb){ #endif { /* ACCOUNTING */ - int bytes = ((int)pcb->allocation_pointer) - - ((int)pcb->heap_base); + long int bytes = ((long int)pcb->allocation_pointer) - + ((long int)pcb->heap_base); add_to_collect_count(pcb, bytes); } @@ -502,14 +502,14 @@ ik_collect(int mem_req, ikpcb* pcb){ old_heap_pages = 0; } - int free_space = - ((unsigned int)pcb->allocation_redline) - - ((unsigned int)pcb->allocation_pointer); + long int free_space = + ((unsigned long int)pcb->allocation_redline) - + ((unsigned long int)pcb->allocation_pointer); if((free_space <= mem_req) || (pcb->heap_size < IK_HEAPSIZE)){ #ifndef NDEBUG fprintf(stderr, "REQ=%d, got %d\n", mem_req, free_space); #endif - int memsize = (mem_req > IK_HEAPSIZE) ? mem_req : IK_HEAPSIZE; + long int memsize = (mem_req > IK_HEAPSIZE) ? mem_req : IK_HEAPSIZE; memsize = align_to_next_page(memsize); ik_munmap_from_segment( pcb->heap_base, @@ -939,27 +939,27 @@ add_code_entry(gc_t* gc, ikptr entry){ 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); + fprintf(stderr, "collecting stack from 0x%016lx .. 0x%016lx\n", + (long int) top, (long int) end); } while(top < end){ if(DEBUG_STACK){ - fprintf(stderr, "collecting frame at 0x%08x: ", (int) top); + fprintf(stderr, "collecting frame at 0x%016lx: ", (long int) top); } ikptr rp = ref(top, 0); - int rp_offset = unfix(ref(rp, disp_frame_offset)); + long int rp_offset = unfix(ref(rp, disp_frame_offset)); if(DEBUG_STACK){ - fprintf(stderr, "rp_offset=%d\n", rp_offset); + fprintf(stderr, "rp_offset=%ld\n", rp_offset); } if(rp_offset <= 0){ - fprintf(stderr, "invalid rp_offset %d\n", rp_offset); + fprintf(stderr, "invalid rp_offset %ld\n", rp_offset); exit(-1); } /* since the return point is alive, we need to find the code * object containing it and mark it live as well. the rp is * updated to reflect the new code object. */ - int code_offset = rp_offset - disp_frame_offset; + long int code_offset = rp_offset - disp_frame_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; @@ -999,18 +999,18 @@ static void collect_stack(gc_t* gc, ikptr top, ikptr end){ * there is no live mask in this case, instead all values in the * frame are live. */ - int framesize = (int) ref(rp, disp_frame_size); + long int framesize = (long int) ref(rp, disp_frame_size); if(DEBUG_STACK){ - fprintf(stderr, "fs=%d\n", framesize); + fprintf(stderr, "fs=%ld\n", framesize); } if(framesize < 0){ - fprintf(stderr, "invalid frame size %d\n", framesize); + fprintf(stderr, "invalid frame size %ld\n", framesize); exit(-1); } else if(framesize == 0){ - framesize = (int)ref(top, wordsize); + framesize = (long int)ref(top, wordsize); if(framesize <= 0){ - fprintf(stderr, "invalid redirected framesize=%d\n", framesize); + fprintf(stderr, "invalid redirected framesize=%ld\n", framesize); exit(-1); } ikptr base = top + framesize - wordsize; @@ -1020,12 +1020,12 @@ static void collect_stack(gc_t* gc, ikptr top, ikptr end){ base -= wordsize; } } else { - int frame_cells = framesize >> fx_shift; - int bytes_in_mask = (frame_cells+7) >> 3; + long int frame_cells = framesize >> fx_shift; + long int bytes_in_mask = (frame_cells+7) >> 3; char* mask = rp + disp_frame_size - bytes_in_mask; ikptr* fp = (ikptr*)(top + framesize); - int i; + long int i; for(i=0; i 1024){ - fprintf(stderr, "large closure size=0x%08x\n", size); + fprintf(stderr, "large closure size=0x%016lx\n", size); } - int asize = align(size); + long int asize = align(size); 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); @@ -1179,9 +1179,9 @@ add_object_proc(gc_t* gc, ikptr x) if(is_fixnum(fst)){ /* real vector */ //fprintf(stderr, "X=0x%08x, FST=0x%08x\n", (int)x, (int)fst); - int size = (int)fst; + long int size = (long int)fst; assert(size >= 0); - int memreq = align(size + disp_vector_data); + long int memreq = align(size + disp_vector_data); if(memreq >= pagesize){ if((t & large_object_mask) == large_object_tag){ enqueue_large_ptr(x-vector_tag, size+disp_vector_data, gc); @@ -1223,7 +1223,7 @@ add_object_proc(gc_t* gc, ikptr x) } else if(tagof(fst) == rtd_tag){ /* struct / record */ - int size = (int) ref(fst, off_rtd_length); + long int size = (long int) ref(fst, off_rtd_length); if(size & ((1< memreq = n * object_alignment + 8 @@ -1231,7 +1231,7 @@ add_object_proc(gc_t* gc, ikptr x) ikptr y = gc_alloc_new_ptr(size+wordsize, gc) + vector_tag; ref(y, -vector_tag) = fst; { - int i; + long int i; ikptr p = y+disp_record_data-vector_tag; ikptr q = x+disp_record_data-vector_tag; ref(p, 0) = ref(q, 0); @@ -1249,7 +1249,7 @@ add_object_proc(gc_t* gc, ikptr x) ikptr y = gc_alloc_new_ptr(size+(2*wordsize), gc) + vector_tag; ref(y, -vector_tag) = fst; { - int i; + long int i; 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); @@ -1311,7 +1311,7 @@ add_object_proc(gc_t* gc, ikptr x) ref(x, wordsize-vector_tag) = y; return y; } - else if((((int)fst) & port_mask) == port_tag){ + else if((((long int)fst) & port_mask) == port_tag){ ikptr y = gc_alloc_new_ptr(port_size, gc) + vector_tag; ref(y, -vector_tag) = fst; int i; @@ -1330,9 +1330,9 @@ add_object_proc(gc_t* gc, ikptr x) ref(x, wordsize-vector_tag) = new; return new; } - else if((((int)fst) & bignum_mask) == bignum_tag){ - int len = ((unsigned int)fst) >> bignum_length_shift; - int memreq = align(disp_bignum_data + len*wordsize); + else if((((long int)fst) & bignum_mask) == bignum_tag){ + long int len = ((unsigned long int)fst) >> bignum_length_shift; + long int memreq = align(disp_bignum_data + len*wordsize); ikptr new = gc_alloc_new_data(memreq, gc) + vector_tag; memcpy(new-vector_tag, x-vector_tag, memreq); ref(x, -vector_tag) = forward_ptr; @@ -1351,15 +1351,16 @@ add_object_proc(gc_t* gc, ikptr x) return y; } else { - fprintf(stderr, "unhandled vector with fst=0x%08x\n", (int)fst); + fprintf(stderr, "unhandled vector with fst=0x%016lx\n", + (long int)fst); assert(0); exit(-1); } } else if(tag == string_tag){ if(is_fixnum(fst)){ - int strlen = unfix(fst); - int memreq = align(strlen*string_char_size + disp_string_data); + long int strlen = unfix(fst); + long int memreq = align(strlen*string_char_size + disp_string_data); ikptr new_str = gc_alloc_new_data(memreq, gc) + string_tag; ref(new_str, off_string_length) = fst; memcpy(new_str+off_string_data, @@ -1373,14 +1374,14 @@ add_object_proc(gc_t* gc, ikptr x) return new_str; } else { - fprintf(stderr, "unhandled string 0x%08x with fst=0x%08x\n", - (int)x, (int)fst); + fprintf(stderr, "unhandled string 0x%016lx with fst=0x%016lx\n", + (long int)x, (long int)fst); exit(-1); } } else if(tag == bytevector_tag){ - int len = unfix(fst); - int memreq = align(len + disp_bytevector_data + 1); + long int len = unfix(fst); + long int memreq = align(len + disp_bytevector_data + 1); ikptr new_bv = gc_alloc_new_data(memreq, gc) + bytevector_tag; ref(new_bv, off_bytevector_length) = fst; memcpy(new_bv+off_bytevector_data, @@ -1401,14 +1402,14 @@ relocate_new_code(ikptr x, gc_t* gc){ 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); + long int relocsize = (long int)ref(relocvector, off_vector_length); 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; - int code_off = r >> 2; + long int r = unfix(ref(p, 0)); + long int tag = r & 3; + long int code_off = r >> 2; if(tag == 0){ /* undisplaced pointer */ #ifndef NDEBUG @@ -1422,7 +1423,7 @@ relocate_new_code(ikptr x, gc_t* gc){ } else if(tag == 2){ /* displaced pointer */ - int obj_off = unfix(ref(p, wordsize)); + long int obj_off = unfix(ref(p, wordsize)); ikptr old_object = ref(p, 2*wordsize); ikptr new_object = add_object(gc, old_object, "reloc2"); ref(code, code_off) = new_object + obj_off; @@ -1430,7 +1431,7 @@ relocate_new_code(ikptr x, gc_t* gc){ } else if(tag == 3){ /* displaced relative pointer */ - int obj_off = unfix(ref(p, wordsize)); + long int obj_off = unfix(ref(p, wordsize)); ikptr obj = ref(p, 2*wordsize); #ifndef NDEBUG //fprintf(stderr, "obj=0x%08x, obj_off=0x%08x\n", (int)obj, @@ -1439,7 +1440,7 @@ relocate_new_code(ikptr x, gc_t* gc){ obj = add_object(gc, obj, "reloc3"); ikptr displaced_object = obj + obj_off; ikptr next_word = code + code_off + wordsize; - ikptr relative_distance = displaced_object - (int)next_word; + ikptr relative_distance = displaced_object - (long int)next_word; ref(next_word, -wordsize) = relative_distance; p += (3*wordsize); } @@ -1448,7 +1449,7 @@ relocate_new_code(ikptr x, gc_t* gc){ p += (2 * wordsize); } else { - fprintf(stderr, "invalid rtag %d in 0x%08x\n", tag, r); + fprintf(stderr, "invalid rtag %ld in 0x%016lx\n", tag, r); exit(-1); } } @@ -1665,9 +1666,9 @@ static void fix_weak_pointers(gc_t* gc){ unsigned int* segment_vec = gc->segment_vector; ikpcb* pcb = gc->pcb; - int lo_idx = page_index(pcb->memory_base); - int hi_idx = page_index(pcb->memory_end); - int i = lo_idx; + long int lo_idx = page_index(pcb->memory_base); + long int hi_idx = page_index(pcb->memory_end); + long int i = lo_idx; int collect_gen = gc->collect_gen; while(i < hi_idx){ unsigned int t = segment_vec[i]; @@ -1721,7 +1722,7 @@ static unsigned int cleanup_mask[generation_count] = { static void -scan_dirty_pointers_page(gc_t* gc, int page_idx, int mask){ +scan_dirty_pointers_page(gc_t* gc, long int page_idx, int mask){ unsigned int* segment_vec = gc->segment_vector; unsigned int* dirty_vec = gc->pcb->dirty_vector; unsigned int t = segment_vec[page_idx]; @@ -1760,7 +1761,7 @@ 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){ +scan_dirty_code_page(gc_t* gc, long int page_idx, unsigned int mask){ ikptr p = (ikptr)(page_idx << pageshift); ikptr start = p; ikptr q = p + pagesize; @@ -1775,15 +1776,15 @@ scan_dirty_code_page(gc_t* gc, int page_idx, unsigned int mask){ p = q; } else { - int j = ((int)p - (int)start) / cardsize; - int code_size = unfix(ref(p, disp_code_code_size)); + long int j = ((long int)p - (long int)start) / cardsize; + long int code_size = unfix(ref(p, disp_code_code_size)); relocate_new_code(p, gc); segment_vec = gc->segment_vector; ikptr rvec = ref(p, disp_code_reloc_vector); - int len = (int)ref(rvec, off_vector_length); + long int len = (long int)ref(rvec, off_vector_length); assert(len >= 0); - int i; - unsigned int code_d = segment_vec[page_index(rvec)]; + long int i; + unsigned long int code_d = segment_vec[page_index(rvec)]; for(i=0; isegment_vector; 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; + long int lo_idx = page_index(memory_base); + long int hi_idx = page_index(memory_end); + long int i = lo_idx; while(i < hi_idx){ unsigned int t = segment_vec[i]; if(t & dealloc_mask){ diff --git a/src/ikarus-data.h b/src/ikarus-data.h index e648d3b..bd77624 100644 --- a/src/ikarus-data.h +++ b/src/ikarus-data.h @@ -92,6 +92,7 @@ inthash(int key) { #define generation_count 5 /* generations 0 (nursery), 1, 2, 3, 4 */ typedef char* ikptr; +typedef int ikchar; void ik_error(ikptr args); @@ -238,29 +239,25 @@ ikptr ik_safe_alloc(ikpcb* pcb, int size); #define IK_FX_MASK 3 #define fx_shift 2 #define fx_mask 3 -#define unfix(x) (((int)(x)) >> fx_shift) -#define fix(x) ((ikptr)((x) << fx_shift)) -#define is_fixnum(x) ((((int)(x)) & fx_mask) == 0) +#define unfix(x) (((long int)(x)) >> fx_shift) +#define fix(x) ((ikptr)(((long int)(x)) << fx_shift)) +#define is_fixnum(x) ((((long int)(x)) & fx_mask) == 0) #define IK_FIXNUMP(x) \ ((((int)(x)) & IK_FX_MASK) == 0) -#define REF(x,n) \ - (((ikptr*)(((char*)(x)) + ((int)(n))))[0]) - #define ref(x,n) \ - (((ikptr*)(((char*)(x)) + ((int)(n))))[0]) + (((ikptr*)(((char*)(x)) + ((long int)(n))))[0]) -#define IK_MASK(x,m) (((int)(x)) & ((int)(m))) +#define IK_MASK(x,m) (((long int)(x)) & ((long int)(m))) #define IK_PTAG(x) (((int)(x)) & 7) -#define tagof(x) (((int)(x)) & 7) +#define tagof(x) (((long int)(x)) & 7) #define IK_STAG(x) REF(x, -IK_PTAG(x)) #define immediate_tag 7 #define IK_UNFIX(x) (((int)(x)) >> IK_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)) @@ -282,9 +279,11 @@ ikptr ik_safe_alloc(ikpcb* pcb, int size); #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) ((ikptr)(((x) << IK_CHAR_SHIFT) | IK_CHAR_TAG)) +#define int_to_scheme_char(x) \ + ((ikptr)((((unsigned long int)(x)) << IK_CHAR_SHIFT) | IK_CHAR_TAG)) #define IK_PAIR_SIZE 8 #define pair_size 8 +#define pair_mask 7 #define pair_tag 1 #define disp_car 0 #define disp_cdr 4 @@ -299,6 +298,7 @@ ikptr ik_safe_alloc(ikpcb* pcb, int size); #define IK_HEAPSIZE (1024 * 4096) /* 4 MB */ #define IK_PAIRP(x) (IK_PTAG(x) == IK_PAIR_TAG) #define IK_CHARP(x) (IK_MASK(x,IK_CHAR_MASK) == IK_CHAR_TAG) +#define is_char(x) (IK_MASK(x,IK_CHAR_MASK) == IK_CHAR_TAG) #define IK_STRING_TAG 6 #define string_tag 6 #define disp_string_length 0 @@ -311,8 +311,9 @@ ikptr 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) \ - (((ikptr*)(((ikptr)(x)) + off_string_data))[i] = ((ikptr)(c))) -#define integer_to_char(x) ((ikptr)((((int)(x)) << IK_CHAR_SHIFT) + IK_CHAR_TAG)) + (((ikchar*)(((ikptr)(x)) + off_string_data))[i] = ((ikchar)(c))) +#define integer_to_char(x) \ + ((ikchar)((((int)(x)) << IK_CHAR_SHIFT) + IK_CHAR_TAG)) #define string_char_size 4 #define vector_tag 5 @@ -370,7 +371,8 @@ ikptr ik_safe_alloc(ikpcb* pcb, int size); #define off_closure_code (disp_closure_code - closure_tag) #define off_closure_data (disp_closure_data - closure_tag) -#define is_closure(x) ((((int)(x)) & closure_mask) == closure_tag) +#define is_closure(x) ((((long int)(x)) & closure_mask) == closure_tag) +#define is_pair(x) ((((long int)(x)) & pair_mask) == pair_tag) #define record_tag vector_tag @@ -408,9 +410,9 @@ ikptr ik_safe_alloc(ikpcb* pcb, int size); #define pagesize 4096 #define pageshift 12 #define align_to_next_page(x) \ - (((pagesize - 1 + (unsigned int)(x)) >> pageshift) << pageshift) + (((pagesize - 1 + (unsigned long int)(x)) >> pageshift) << pageshift) #define align_to_prev_page(x) \ - ((((unsigned int)(x)) >> pageshift) << pageshift) + ((((unsigned long int)(x)) >> pageshift) << pageshift) #define disp_frame_size -17 @@ -450,6 +452,6 @@ ikptr ik_safe_alloc(ikpcb* pcb, int size); #define disp_ratnum_unused 12 #define ik_eof_p(x) ((x) == ik_eof_object) -#define page_index(x) (((unsigned int)(x)) >> pageshift) +#define page_index(x) (((unsigned long int)(x)) >> pageshift) #endif diff --git a/src/ikarus-enter.s b/src/ikarus-enter.s index 087b43f..1b040b6 100644 --- a/src/ikarus-enter.s +++ b/src/ikarus-enter.s @@ -117,22 +117,25 @@ check_ecx: je L_one cmpl $0, %ecx je L_two - pushl $0 + push $0 L_two: - pushl $0 + push $0 L_one: - pushl $0 + push $0 L_zero: - pushl %esi # (pushl pcr) +# push %rsi # (pushl pcr) + push %esi # (pushl pcr) cmpl $0, %eax # (cmpl (int 0) eax) je L_set # (je (label Lset)) L_loop: # (label Lloop) movl (%ebx,%eax), %ecx # (movl (mem ebx eax) ecx) - pushl %ecx # (pushl ecx) +# push %rcx # (pushl ecx) + push %ecx # (pushl ecx) addl $4, %eax # (addl (int 4) eax) cmpl $0, %eax # (cmpl (int 0) eax) jne L_loop # (jne (label Lloop)) L_set: # (label Lset) +# call *%rdi # (call cpr) call *%edi # (call cpr) movl 8(%esi), %esp # (movl (pcb-ref 'frame-pointer) fpr) movl 0(%esi), %ebp # (movl (pcb-ref 'allocation-pointer) apr) diff --git a/src/ikarus-exec.c b/src/ikarus-exec.c index 346a26b..2e7ab61 100644 --- a/src/ikarus-exec.c +++ b/src/ikarus-exec.c @@ -37,9 +37,9 @@ ikptr ik_exec_code(ikpcb* pcb, ikptr code_ptr){ cont* k = (cont*)(next_k - vector_tag); ikptr top = k->top; ikptr rp = ref(top, 0); - int framesize = (int) ref(rp, disp_frame_size); + long int framesize = (long int) ref(rp, disp_frame_size); if(framesize <= 0){ - fprintf(stderr, "invalid framesize %d\n", framesize); + fprintf(stderr, "invalid framesize %ld\n", framesize); exit(-1); } if(framesize < k->size){ @@ -51,15 +51,15 @@ ikptr ik_exec_code(ikpcb* pcb, ikptr code_ptr){ k->size = framesize; k->next = vector_tag + (ikptr)nk; /* record side effect */ - unsigned int idx = ((unsigned int)(&k->next)) >> pageshift; + unsigned long int idx = ((unsigned long int)(&k->next)) >> pageshift; pcb->dirty_vector[idx] = -1; } pcb->next_k = k->next; ikptr fbase = pcb->frame_base - wordsize; ikptr new_fbase = fbase - framesize; - memmove(new_fbase + (int)argc, - fbase + (int)argc, - -(int)argc); + memmove(new_fbase + (long int)argc, + fbase + (long int)argc, + -(long int)argc); memcpy(new_fbase, top, framesize); argc = ik_asm_reenter(pcb, new_fbase, argc); next_k = pcb->next_k; diff --git a/src/ikarus-fasl.c b/src/ikarus-fasl.c index f935c76..10b4f23 100644 --- a/src/ikarus-fasl.c +++ b/src/ikarus-fasl.c @@ -126,8 +126,8 @@ void ik_fasl_load(ikpcb* pcb, char* fasl_file){ } static ikptr -alloc_code(int size, ikpcb* pcb, fasl_port* p){ - int asize = align(size); +alloc_code(long int size, ikpcb* pcb, fasl_port* p){ + long int asize = align(size); ikptr ap = p->code_ap; ikptr nap = ap + asize; if(nap <= p->code_ep){ @@ -135,9 +135,9 @@ alloc_code(int size, ikpcb* pcb, fasl_port* p){ return ap; } else if (asize < pagesize){ ikptr mem = ik_mmap_code(pagesize, 0, pcb); - int bytes_remaining = pagesize - asize; - int previous_bytes = - ((unsigned int)p->code_ep) - ((unsigned int)ap); + long int bytes_remaining = pagesize - asize; + long int previous_bytes = + ((unsigned long int)p->code_ep) - ((unsigned long int)ap); if(bytes_remaining <= previous_bytes){ return mem; } else { @@ -146,7 +146,7 @@ alloc_code(int size, ikpcb* pcb, fasl_port* p){ return mem; } } else { - int asize = align_to_next_page(size); + long int asize = align_to_next_page(size); ikptr mem = ik_mmap_code(asize, 0, pcb); return mem; } @@ -159,15 +159,15 @@ ik_relocate_code(ikptr code){ ikptr size = ref(vec, off_vector_length); ikptr data = code + disp_code_data; ikptr p = vec + off_vector_data; - ikptr q = p + (int)size; + ikptr q = p + (long int)size; while(p < q){ - int r = unfix(ref(p, 0)); + long int r = unfix(ref(p, 0)); if(r == 0){ fprintf(stderr, "unset reloc!\n"); exit(-1); } - int tag = r & 3; - int code_off = r >> 2; + long int tag = r & 3; + long int code_off = r >> 2; if(tag == 0){ /* vanilla object */ ref(data, code_off) = ref(p, wordsize); @@ -175,18 +175,18 @@ ik_relocate_code(ikptr code){ } else if(tag == 2){ /* displaced object */ - int obj_off = unfix(ref(p, wordsize)); + long int obj_off = unfix(ref(p, 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)); + long int obj_off = unfix(ref(p, wordsize)); 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; + ikptr relative_distance = displaced_object - (long int)next_word; ref(next_word, -wordsize) = relative_distance; p += (3*wordsize); } @@ -211,7 +211,7 @@ ik_relocate_code(ikptr code){ p += (2*wordsize); } else { - fprintf(stderr, "invalid reloc 0x%08x (tag=%d)\n", r, tag); + fprintf(stderr, "invalid reloc 0x%016lx (tag=%ld)\n", r, tag); exit(-1); } } @@ -325,7 +325,7 @@ static ikptr do_read(ikpcb* pcb, fasl_port* p){ fasl_read_buf(p, str+off_string_data, len); { unsigned char* pi = (unsigned char*) (str+off_string_data); - ikptr* pj = (ikptr*) (str+off_string_data); + ikchar* pj = (ikchar*) (str+off_string_data); int i = len-1; for(i=len-1; i >= 0; i--){ pj[i] = integer_to_char(pi[i]); @@ -339,15 +339,15 @@ static ikptr do_read(ikpcb* pcb, fasl_port* p){ } else if(c == 'S'){ /* string */ - int len; - fasl_read_buf(p, &len, sizeof(int)); + long int len; + fasl_read_buf(p, &len, sizeof(long int)); int size = align(len*string_char_size + disp_string_data); ikptr str = ik_unsafe_alloc(pcb, size) + string_tag; ref(str, off_string_length) = fix(len); - int i; + long int i; for(i=0; i> 2) << bignum_length_shift); ikptr x = ik_unsafe_alloc(pcb, align(len + disp_bignum_data)) + vector_tag; ref(x, -vector_tag) = (ikptr) tag; diff --git a/src/ikarus-numerics.c b/src/ikarus-numerics.c index 10bdcb9..20e03af 100644 --- a/src/ikarus-numerics.c +++ b/src/ikarus-numerics.c @@ -23,6 +23,11 @@ #include #include +#define bnfst_limb_count(x) \ + (((unsigned long int)(x)) >> bignum_length_shift) +#define bnfst_negative(x) \ + (((unsigned long int)(x)) & bignum_sign_mask) + #define most_positive_fixnum 0x1FFFFFFF #define most_negative_fixnum 0x20000000 @@ -99,7 +104,7 @@ ikrt_isbignum(ikptr x){ ikptr ikrt_positive_bn(ikptr x){ ikptr fst = ref(x, -vector_tag); - if((int)fst & bignum_sign_mask){ + if(bnfst_negative(fst)){ return false_object; } else { return true_object; @@ -108,7 +113,7 @@ ikrt_positive_bn(ikptr x){ ikptr ikrt_even_bn(ikptr x){ - int fst = (int)ref(x, wordsize-vector_tag); + long int fst = (long int)ref(x, wordsize-vector_tag); if(fst & 1){ return false_object; } else { @@ -120,9 +125,9 @@ ikrt_even_bn(ikptr x){ ikptr ikrt_fxfxplus(ikptr x, ikptr y, ikpcb* pcb){ - int n1 = unfix(x); - int n2 = unfix(y); - int r = n1 + n2; + long int n1 = unfix(x); + long int n2 = unfix(y); + long int r = n1 + n2; ikptr q = fix(r); if(r == unfix(q)){ return q; @@ -148,18 +153,19 @@ ikptr ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ if(x == 0){ return y ; } ikptr fst = ref(y, -vector_tag); - int limb_count = ((unsigned int) fst) >> bignum_length_shift; - int intx = unfix(x); + long int limb_count = bnfst_limb_count(fst); + long int intx = unfix(x); if(intx > 0){ - if((bignum_sign_mask & (int)fst) == 0){ + if(bnfst_negative(fst)){ /* positive fx + positive bn = even bigger positive */ pcb->root0 = &y; 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); + mp_limb_t 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) = (ikptr)1; ref(r, 0) = (ikptr) @@ -181,15 +187,16 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = &y; 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), - limb_count, - intx); + mp_limb_t borrow = + mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(y - vector_tag + disp_bignum_data), + limb_count, + intx); if(borrow){ - fprintf(stderr, "Error: BUG in borrow1 %d\n", borrow); + fprintf(stderr, "Error: BUG in borrow1 %ld\n", borrow); exit(-1); } - int result_size = + long int result_size = (ref(r, disp_bignum_data + (limb_count-1)*wordsize)) ? limb_count : (limb_count - 1); @@ -197,10 +204,10 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ return 0; } if(result_size == 1){ - unsigned int last = - (unsigned int) ref(r, disp_bignum_data + (result_size-1)*wordsize); + mp_limb_t last = + (mp_limb_t) ref(r, disp_bignum_data + (result_size-1)*wordsize); if(last <= most_negative_fixnum){ - return fix(-(int)last); + return fix(-(long int)last); } } ref(r, 0) = (ikptr) @@ -211,20 +218,21 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ } } else { - if((bignum_sign_mask & (int)fst) == 0){ + if(bnfst_negative(fst)){ /* negative fx + positive bn = smaller positive */ pcb->root0 = &y; 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), - limb_count, - - intx); + mp_limb_t borrow = + mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(y - vector_tag + disp_bignum_data), + limb_count, + - intx); if(borrow){ fprintf(stderr, "Error: BUG in borrow2\n"); exit(-1); } - int result_size = + long int result_size = (ref(r, disp_bignum_data + (limb_count-1)*wordsize) == 0) ? (limb_count - 1) : limb_count; @@ -232,10 +240,10 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ return 0; } if(result_size == 1){ - unsigned int last = - (unsigned int) ref(r, disp_bignum_data + (result_size-1)*wordsize); + mp_limb_t last = + (mp_limb_t) ref(r, disp_bignum_data + (result_size-1)*wordsize); if(last <= most_positive_fixnum){ - return fix((int)last); + return fix((long int)last); } } ref(r, 0) = (ikptr) @@ -248,10 +256,11 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = &y; 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); + mp_limb_t 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) = (ikptr)1; ref(r, 0) = (ikptr) @@ -275,14 +284,14 @@ ikrt_fxbnplus(ikptr x, ikptr 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; - int ysign = yfst & bignum_sign_mask; - int xlimbs = xfst >> bignum_length_shift; - int ylimbs = yfst >> bignum_length_shift; + unsigned long int xfst = (unsigned long int)ref(x, -vector_tag); + unsigned long int yfst = (unsigned long int)ref(y, -vector_tag); + long int xsign = xfst & bignum_sign_mask; + long int ysign = yfst & bignum_sign_mask; + long int xlimbs = xfst >> bignum_length_shift; + long int ylimbs = yfst >> bignum_length_shift; if(xsign == ysign){ - int n1,n2; + long int n1,n2; ikptr s1,s2; if(xlimbs > ylimbs){ n1 = xlimbs; n2 = ylimbs; s1 = x; s2 = y; @@ -294,11 +303,12 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ 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), - (mp_limb_t*) (s1-vector_tag+disp_bignum_data), - n1, - (mp_limb_t*) (s2-vector_tag+disp_bignum_data), - n2); + mp_limb_t carry = + mpn_add((mp_limb_t*) (res+disp_bignum_data), + (mp_limb_t*) (s1-vector_tag+disp_bignum_data), + n1, + (mp_limb_t*) (s2-vector_tag+disp_bignum_data), + n2); if(carry){ ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1; ref(res, 0) = (ikptr) @@ -316,8 +326,8 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ } else { ikptr s1=x, s2=y; - int n1=xlimbs, n2=ylimbs; - int result_sign = xsign; + long int n1=xlimbs, n2=ylimbs; + long int result_sign = xsign; while((xlimbs == ylimbs) && (ref(x, -vector_tag+disp_bignum_data+(xlimbs-1)*wordsize) == ref(y, -vector_tag+disp_bignum_data+(xlimbs-1)*wordsize))){ @@ -346,16 +356,17 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ 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), - (mp_limb_t*) (s1 - vector_tag + disp_bignum_data), - n1, - (mp_limb_t*) (s2 - vector_tag + disp_bignum_data), - n2); + mp_limb_t burrow = + mpn_sub((mp_limb_t*) (res + disp_bignum_data), + (mp_limb_t*) (s1 - vector_tag + disp_bignum_data), + n1, + (mp_limb_t*) (s2 - vector_tag + disp_bignum_data), + n2); if(burrow){ fprintf(stderr, "BUG: Burrow error in bnbn+\n"); exit(-1); } - int len = n1; + long int len = n1; while(ref(res, disp_bignum_data + (len-1)*wordsize) == 0){ len--; if(len == 0){ @@ -365,9 +376,9 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ if(result_sign == 0){ /* positive result */ if(len == 1){ - unsigned int fst_limb = (unsigned int) ref(res, disp_bignum_data); + mp_limb_t fst_limb = (mp_limb_t) ref(res, disp_bignum_data); if(fst_limb <= most_positive_fixnum){ - return fix((int)fst_limb); + return fix((long int)fst_limb); } } ref(res, 0) = (ikptr) @@ -378,9 +389,9 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ } else { /* negative result */ if(len == 1){ - unsigned int fst_limb = (unsigned int) ref(res, disp_bignum_data); + mp_limb_t fst_limb = (mp_limb_t) ref(res, disp_bignum_data); if(fst_limb <= most_negative_fixnum){ - return fix(-(int)fst_limb); + return fix(-(long int)fst_limb); } } ref(res, 0) = (ikptr) @@ -397,11 +408,11 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ ikptr ikrt_fxfxminus(ikptr x, ikptr y, ikpcb* pcb){ - int n1 = unfix(x); - int n2 = unfix(y); - int r = n1 - n2; + long int n1 = unfix(x); + long int n2 = unfix(y); + long int r = n1 - n2; if(r >= 0){ - if(((unsigned int)r) <= most_positive_fixnum){ + if(((unsigned long int)r) <= most_positive_fixnum){ return fix(r); } else { ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + wordsize)); @@ -429,13 +440,14 @@ ikrt_fxfxminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr ikrt_bnnegate(ikptr x, ikpcb* pcb){ ikptr fst = ref(x, -vector_tag); - int limb_count = ((unsigned int) fst) >> bignum_length_shift; + long int limb_count = bnfst_limb_count(fst); if(limb_count == 1){ - if((bignum_sign_mask & (int)fst) == 0){ + if(bnfst_negative(fst)){ /* positive bignum */ - unsigned int limb = (unsigned int) ref(x, disp_bignum_data - vector_tag); + mp_limb_t limb = + (mp_limb_t) ref(x, disp_bignum_data - vector_tag); if(limb == (most_positive_fixnum + 1)){ - return fix(-(int)limb); + return fix(-(long int)limb); } } } @@ -447,7 +459,7 @@ ikrt_bnnegate(ikptr x, ikpcb* pcb){ limb_count*wordsize); ref(bn, 0) = (ikptr) (bignum_tag | - ((1 << bignum_sign_shift) - (bignum_sign_mask & (int)fst)) | + ((1 << bignum_sign_shift) - (bignum_sign_mask & (long int)fst)) | (limb_count << bignum_length_shift)); return verify_bignum(bn+vector_tag, "bnneg"); } @@ -456,18 +468,19 @@ ikptr ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ if(x == 0){ return ikrt_bnnegate(y, pcb) ; } ikptr fst = ref(y, -vector_tag); - int limb_count = ((unsigned int) fst) >> bignum_length_shift; - int intx = unfix(x); + long int limb_count = bnfst_limb_count(fst); + long int intx = unfix(x); if(intx > 0){ - if(bignum_sign_mask & (int)fst){ + if(bnfst_negative(fst)){ /* positive fx - negative bn = positive bn */ pcb->root0 = &y; 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); + long 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) = (ikptr)1; ref(r, 0) = (ikptr) @@ -488,15 +501,16 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = &y; 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), - limb_count, - intx); + long int borrow = + mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(y - vector_tag + disp_bignum_data), + limb_count, + intx); if(borrow){ fprintf(stderr, "Error: BUG in borrow3\n"); exit(-1); } - int result_size = + long int result_size = (ref(r, disp_bignum_data + (limb_count-1)*wordsize)) ? limb_count : (limb_count - 1); @@ -504,10 +518,10 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ return 0; } if(result_size == 1){ - unsigned int last = - (unsigned int) ref(r, disp_bignum_data + (result_size-1)*wordsize); + unsigned long int last = + (unsigned long int) ref(r, disp_bignum_data + (result_size-1)*wordsize); if(last <= most_negative_fixnum){ - return fix(-(int)last); + return fix(-(long int)last); } } ref(r, 0) = (ikptr) @@ -518,20 +532,21 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ } } else { - if(bignum_sign_mask & (int)fst){ + if(bnfst_negative(fst)){ /* negative fx - negative bn = smaller positive */ pcb->root0 = &y; 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), - limb_count, - - intx); + long int borrow = + mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(y - vector_tag + disp_bignum_data), + limb_count, + - intx); if(borrow){ fprintf(stderr, "Error: BUG in borrow4\n"); exit(-1); } - int result_size = + long int result_size = (ref(r, disp_bignum_data + (limb_count-1)*wordsize) == 0) ? (limb_count - 1) : limb_count; @@ -539,10 +554,10 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ return 0; } if(result_size == 1){ - unsigned int last = - (unsigned int) ref(r, disp_bignum_data + (result_size-1)*wordsize); + unsigned long int last = + (unsigned long int) ref(r, disp_bignum_data + (result_size-1)*wordsize); if(last <= most_positive_fixnum){ - return fix((int)last); + return fix((long int)last); } } ref(r, 0) = (ikptr) @@ -555,10 +570,11 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = &y; 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); + long 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) = (ikptr)1; ref(r, 0) = (ikptr) @@ -581,18 +597,19 @@ ikptr ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ if(y == 0){ return x; } ikptr fst = ref(x, -vector_tag); - int limb_count = ((unsigned int) fst) >> bignum_length_shift; - int inty = unfix(y); + long int limb_count = bnfst_limb_count(fst); + long int inty = unfix(y); if(inty < 0){ - if((bignum_sign_mask & (int)fst) == 0){ + if(bnfst_negative(fst)){ /* - negative fx + positive bn = positive bn */ pcb->root0 = &x; 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); + long 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) = (ikptr)1; ref(r, 0) = (ikptr) @@ -613,15 +630,16 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = &x; 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), - limb_count, - -inty); + long int borrow = + mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(x - vector_tag + disp_bignum_data), + limb_count, + -inty); if(borrow){ fprintf(stderr, "Error: BUG in borrow5\n"); exit(-1); } - int result_size = + long int result_size = (ref(r, disp_bignum_data + (limb_count-1)*wordsize)) ? limb_count : (limb_count - 1); @@ -629,10 +647,10 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ return 0; } if(result_size == 1){ - unsigned int last = - (unsigned int) ref(r, disp_bignum_data + (result_size-1)*wordsize); + unsigned long int last = + (unsigned long int) ref(r, disp_bignum_data + (result_size-1)*wordsize); if(last <= most_negative_fixnum){ - return fix(-(int)last); + return fix(-(long int)last); } } ref(r, 0) = (ikptr) @@ -643,20 +661,21 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ } } else { - if((bignum_sign_mask & (int)fst) == 0){ + if((bignum_sign_mask & (long int)fst) == 0){ /* - positive fx + positive bn = smaller positive */ pcb->root0 = &x; 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), - limb_count, - inty); + long int borrow = + mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(x - vector_tag + disp_bignum_data), + limb_count, + inty); if(borrow){ fprintf(stderr, "Error: BUG in borrow6\n"); exit(-1); } - int result_size = + long int result_size = (ref(r, disp_bignum_data + (limb_count-1)*wordsize) == 0) ? (limb_count - 1) : limb_count; @@ -664,10 +683,10 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ return 0; } if(result_size == 1){ - unsigned int last = - (unsigned int) ref(r, disp_bignum_data + (result_size-1)*wordsize); + unsigned long int last = + (unsigned long int) ref(r, disp_bignum_data + (result_size-1)*wordsize); if(last <= most_positive_fixnum){ - return fix((int)last); + return fix((long int)last); } } ref(r, 0) = (ikptr) @@ -680,10 +699,11 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = &x; 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); + long 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) = (ikptr)1; ref(r, 0) = (ikptr) @@ -707,14 +727,14 @@ ikrt_bnfxminus(ikptr x, ikptr 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); - int xsign = xfst & bignum_sign_mask; - int ysign = yfst & bignum_sign_mask; - int xlimbs = xfst >> bignum_length_shift; - int ylimbs = yfst >> bignum_length_shift; + unsigned long int xfst = (unsigned long int)ref(x, -vector_tag); + unsigned long int yfst = (unsigned long int)ref(y, -vector_tag); + long int xsign = xfst & bignum_sign_mask; + long int ysign = yfst & bignum_sign_mask; + long int xlimbs = xfst >> bignum_length_shift; + long int ylimbs = yfst >> bignum_length_shift; if(xsign != ysign){ - int n1,n2; + long int n1,n2; ikptr s1,s2; if(xlimbs >= ylimbs){ n1 = xlimbs; n2 = ylimbs; s1 = x; s2 = y; @@ -757,8 +777,8 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ ylimbs = xlimbs; } ikptr s1=x, s2=y; - int n1=xlimbs, n2=ylimbs; - int result_sign = xsign; + long int n1=xlimbs, n2=ylimbs; + long int result_sign = xsign; /* |x| != |y| */ if(xlimbs <= ylimbs){ if(xlimbs == ylimbs){ @@ -780,16 +800,17 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ 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), - (mp_limb_t*) (s1 - vector_tag + disp_bignum_data), - n1, - (mp_limb_t*) (s2 - vector_tag + disp_bignum_data), - n2); + long int burrow = + mpn_sub((mp_limb_t*) (res + disp_bignum_data), + (mp_limb_t*) (s1 - vector_tag + disp_bignum_data), + n1, + (mp_limb_t*) (s2 - vector_tag + disp_bignum_data), + n2); if(burrow){ fprintf(stderr, "BUG: Burrow error in bnbn-\n"); exit(-1); } - int len = n1; + long int len = n1; while(ref(res, disp_bignum_data + (len-1)*wordsize) == 0){ len--; if(len == 0){ @@ -799,9 +820,10 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ if(result_sign == 0){ /* positive result */ if(len == 1){ - unsigned int fst_limb = (unsigned int) ref(res, disp_bignum_data); + unsigned long int fst_limb = + (unsigned long int) ref(res, disp_bignum_data); if(fst_limb <= most_positive_fixnum){ - return fix((int)fst_limb); + return fix((long int)fst_limb); } } ref(res, 0) = (ikptr) @@ -812,9 +834,10 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ } else { /* negative result */ if(len == 1){ - unsigned int fst_limb = (unsigned int) ref(res, disp_bignum_data); + unsigned long int fst_limb = + (unsigned long int) ref(res, disp_bignum_data); if(fst_limb <= most_negative_fixnum){ - return fix(-(int)fst_limb); + return fix(-(long int)fst_limb); } } ref(res, 0) = (ikptr) @@ -829,12 +852,12 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr ikrt_fxfxmult(ikptr x, ikptr y, ikpcb* pcb){ - int n1 = unfix(x); - int n2 = unfix(y); + long int n1 = unfix(x); + long int n2 = unfix(y); mp_limb_t lo = 0; mp_limb_t s1 = n1; mp_limb_t s2 = n2; - int sign = 0; + long int sign = 0; if(n1 < 0){ s1 = -n1; sign = 1 - sign; @@ -847,11 +870,11 @@ ikrt_fxfxmult(ikptr x, ikptr y, ikpcb* pcb){ if(hi == 0){ if(sign){ if(lo <= most_negative_fixnum){ - return fix(-((int)lo)); + return fix(-((long int)lo)); } } else { if(lo <= most_positive_fixnum){ - return fix((int)lo); + return fix((long int)lo); } } ikptr r = ik_safe_alloc(pcb, disp_bignum_data + wordsize); @@ -874,20 +897,20 @@ ikrt_fxfxmult(ikptr x, ikptr y, ikpcb* pcb){ } ikptr -normalize_bignum(int limbs, int sign, ikptr r){ +normalize_bignum(long int limbs, int sign, ikptr r){ while(ref(r, disp_bignum_data + (limbs-1)*wordsize) == 0){ limbs--; if(limbs == 0){ return 0;} } if(limbs == 1){ - unsigned int last = (unsigned int) ref(r, disp_bignum_data); + mp_limb_t last = (mp_limb_t) ref(r, disp_bignum_data); if(sign == 0){ if(last <= most_positive_fixnum){ - return fix((int)last); + return fix(last); } } else { if(last <= most_negative_fixnum){ - return fix(-((int)last)); + return fix(-(last)); } } } @@ -898,11 +921,11 @@ normalize_bignum(int limbs, int sign, ikptr r){ ikptr ikrt_fxbnmult(ikptr x, ikptr y, ikpcb* pcb){ - int n2 = unfix(x); + long int n2 = unfix(x); if(n2 == 0) { return 0; } mp_limb_t s2 = (n2>0) ? n2 : (- n2); ikptr fst = ref(y, -vector_tag); - int limb_count = ((unsigned int) fst) >> bignum_length_shift; + long int limb_count = bnfst_limb_count(fst); pcb->root0 = &y; ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + (limb_count+1)*wordsize)); pcb->root0 = 0; @@ -911,20 +934,20 @@ ikrt_fxbnmult(ikptr x, ikptr y, ikpcb* pcb){ limb_count, s2); ref(r, disp_bignum_data + limb_count * wordsize) = (ikptr)hi; - int sign = + long int sign = ((n2 > 0) ? - (bignum_sign_mask & (int)fst) : - ((1 << bignum_sign_shift) - (bignum_sign_mask&(int)fst))); + (bignum_sign_mask & (long int)fst) : + ((1 << bignum_sign_shift) - (bignum_sign_mask&(long int)fst))); return normalize_bignum(limb_count+1, sign, r); } 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; - int n2 = ((unsigned int)f2) >> bignum_length_shift; - int nr = n1 + n2; + long int f1 = (long int)ref(x, -vector_tag); + long int f2 = (long int)ref(y, -vector_tag); + long int n1 = bnfst_limb_count(f1); + long int n2 = bnfst_limb_count(f2); + long int nr = n1 + n2; pcb->root0 = &x; pcb->root1 = &y; ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + nr*wordsize)); @@ -944,7 +967,7 @@ ikrt_bnbnmult(ikptr x, ikptr y, ikpcb* pcb){ (mp_limb_t*)(x-vector_tag+disp_bignum_data), n1); } - int sign = + long int sign = ((bignum_sign_mask & f1) ? ((1 << bignum_sign_shift) - (bignum_sign_mask & f2)) : (bignum_sign_mask & f2)); @@ -958,22 +981,22 @@ 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){ + if(bnfst_negative(f1)){ + if(bnfst_negative(f2)){ /* both negative */ - int n1 = ((unsigned int) f1) >> bignum_length_shift; - int n2 = ((unsigned int) f2) >> bignum_length_shift; + long int n1 = ((mp_limb_t) f1) >> bignum_length_shift; + long int n2 = ((mp_limb_t) f2) >> bignum_length_shift; if(n1 < n2) { return fix(1); } else if(n1 > n2){ return fix(-1); } else { - int i; + long int i; for(i=(n1-1); i>=0; i--){ - unsigned int t1 = - (unsigned int) ref(bn1,disp_bignum_data-vector_tag+i*wordsize); - unsigned int t2 = - (unsigned int) ref(bn2,disp_bignum_data-vector_tag+i*wordsize); + mp_limb_t t1 = + (mp_limb_t) ref(bn1,disp_bignum_data-vector_tag+i*wordsize); + mp_limb_t t2 = + (mp_limb_t) ref(bn2,disp_bignum_data-vector_tag+i*wordsize); if(t1 < t2){ return fix(1); } else if(t1 > t2){ @@ -987,24 +1010,24 @@ ikrt_bnbncomp(ikptr bn1, ikptr bn2){ return fix(-1); } } else { - if(bignum_sign_mask & (int)f2){ + if(bnfst_negative(f2)){ /* n1 positive, n2 negative */ return fix(1); } else { /* both positive */ - int n1 = ((unsigned int) f1) >> bignum_length_shift; - int n2 = ((unsigned int) f2) >> bignum_length_shift; + long int n1 = ((mp_limb_t) f1) >> bignum_length_shift; + long int n2 = ((mp_limb_t) f2) >> bignum_length_shift; if(n1 < n2) { return fix(-1); } else if(n1 > n2){ return fix(1); } else { - int i; + long int i; for(i=(n1-1); i>=0; i--){ - unsigned int t1 = - (unsigned int) ref(bn1,disp_bignum_data-vector_tag+i*wordsize); - unsigned int t2 = - (unsigned int) ref(bn2,disp_bignum_data-vector_tag+i*wordsize); + mp_limb_t t1 = + (mp_limb_t) ref(bn1,disp_bignum_data-vector_tag+i*wordsize); + mp_limb_t t2 = + (mp_limb_t) ref(bn2,disp_bignum_data-vector_tag+i*wordsize); if(t1 < t2){ return fix(-1); } else if(t1 > t2){ @@ -1020,23 +1043,23 @@ ikrt_bnbncomp(ikptr bn1, ikptr bn2){ /* FIXME: Too complicated! */ ikptr ikrt_fxbnlogand(ikptr x, ikptr y, ikpcb* pcb){ - int n1 = unfix(x); + long int n1 = unfix(x); ikptr fst = ref(y, -vector_tag); if(n1 >= 0){ - if(bignum_sign_mask & (unsigned int) fst){ + if(bnfst_negative(fst)){ /* y is negative */ - return fix(n1 & (1+~(int)ref(y, disp_vector_data-vector_tag))); + return fix(n1 & (1+~(long int)ref(y, disp_vector_data-vector_tag))); } else { /* y is positive */ - return fix(n1 & (int)ref(y, disp_vector_data-vector_tag)); + return fix(n1 & (long int)ref(y, disp_vector_data-vector_tag)); } } else { if(n1 == -1){ return y; } - if(bignum_sign_mask & (unsigned int) fst){ + if(bnfst_negative(fst)){ /* y is negative */ - int len = (((unsigned int) fst) >> bignum_length_shift); - unsigned int nn = - (1+~((1+~(int)ref(y, disp_bignum_data - vector_tag)) & n1)); + long int len = bnfst_limb_count(fst); + unsigned long int nn = + (1+~((1+~(long int)ref(y, disp_bignum_data - vector_tag)) & n1)); if((len == 1) && (nn <= most_negative_fixnum)){ return fix(-nn); } @@ -1053,13 +1076,13 @@ ikrt_fxbnlogand(ikptr x, ikptr y, ikpcb* pcb){ return BN(r+vector_tag); } else { /* y is positive */ - int len = (((unsigned int) fst) >> bignum_length_shift); + long int len = bnfst_limb_count(fst); pcb->root0 = &y; ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + len * wordsize)); pcb->root0 = 0; ref(r, 0) = fst; ref(r, disp_bignum_data) = (ikptr) - (((int)ref(y, disp_bignum_data - vector_tag)) & n1); + (((long 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){ + long int n = bnfst_limb_count(fst); + if(bnfst_negative(fst)){ /* negative */ pcb->root0 = &x; 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); + mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); + mp_limb_t* rd = (mp_limb_t*)(r+disp_bignum_data); int i; for(i=0; (iroot0 = &x; 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; + ((mp_limb_t*)(r+disp_bignum_data))[n] = 1; ref(r, 0) = (ikptr) (bignum_tag | (1<root0 = &x; 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); + mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); + mp_limb_t* rd = (mp_limb_t*)(r+disp_bignum_data); int j; for(j=0; j> bignum_length_shift; - int n2 = ((unsigned int) yfst) >> bignum_length_shift; - if(bignum_sign_mask & (unsigned int) xfst){ - if(bignum_sign_mask & (unsigned int) yfst){ + long int n1 = bnfst_limb_count(xfst); + long int n2 = bnfst_limb_count(yfst); + if(bnfst_negative(xfst)){ + if(bnfst_negative(yfst)){ if(n1 >= n2){ pcb->root0 = &x; pcb->root1 = &y; 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)); - unsigned int* s2 = ((unsigned int*)(y+disp_bignum_data-vector_tag)); - unsigned int* s = ((unsigned int*)(r+disp_bignum_data)); + mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); + mp_limb_t* s2 = ((mp_limb_t*)(y+disp_bignum_data-vector_tag)); + mp_limb_t* s = ((mp_limb_t*)(r+disp_bignum_data)); bits_compliment(s1, s, n1); bits_compliment_logand(s2, s, s, n2); bits_compliment(s, s, n1); @@ -1218,7 +1240,7 @@ ikrt_bnbnlogand(ikptr x, ikptr y, ikpcb* pcb){ return ikrt_bnbnlogand(y,x,pcb); } } else { - if(bignum_sign_mask & (unsigned int) yfst){ + if(bnfst_negative(yfst)){ /* x positive, y negative */ /* the result is at most n1 words long */ pcb->root0 = &x; @@ -1226,21 +1248,21 @@ ikrt_bnbnlogand(ikptr x, ikptr y, ikpcb* pcb){ 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)); - unsigned int* s2 = ((unsigned int*)(y+disp_bignum_data-vector_tag)); - unsigned int* s = ((unsigned int*)(r+disp_bignum_data)); + mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); + mp_limb_t* s2 = ((mp_limb_t*)(y+disp_bignum_data-vector_tag)); + mp_limb_t* s = ((mp_limb_t*)(r+disp_bignum_data)); bits_compliment_logand(s2, s1, s, n1); return normalize_bignum(n1, 0, r); } else { /* both positive */ int n = (n1=0; i--){ - int l1 = - (int) ref(x, disp_bignum_data-vector_tag+i*wordsize); - int l2 = - (int) ref(y, disp_bignum_data-vector_tag+i*wordsize); - int last = l1 & l2; + long int l1 = + (long int) ref(x, disp_bignum_data-vector_tag+i*wordsize); + long int l2 = + (long int) ref(y, disp_bignum_data-vector_tag+i*wordsize); + long int last = l1 & l2; if(last){ if((i == 0) && (last < most_positive_fixnum)){ return fix(last); @@ -1255,9 +1277,9 @@ ikrt_bnbnlogand(ikptr x, ikptr y, ikpcb* pcb){ int j; for(j=0; j> m; +copy_bits_shifting_right(mp_limb_t* src, mp_limb_t* dst, int n, int m){ + mp_limb_t carry = src[0] >> m; int i; for(i=1; i> m; } @@ -1298,13 +1320,13 @@ copy_bits_shifting_left(unsigned int* src, unsigned int* dst, int n, int m){ ikptr ikrt_bignum_shift_right(ikptr x, ikptr y, ikpcb* pcb){ - int m = unfix(y); + long int m = unfix(y); 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 */ + long int n = bnfst_limb_count(fst); + long int whole_limb_shift = m >> 5; /* FIXME: 5 are the bits in 32-bit num */ int bit_shift = m & 31; - int new_limb_count = n - whole_limb_shift; - if(bignum_sign_mask & (unsigned int) fst){ + long int new_limb_count = n - whole_limb_shift; + if(bnfst_negative(fst)){ if(new_limb_count <= 0){ return fix(-1); } @@ -1313,13 +1335,13 @@ ikrt_bignum_shift_right(ikptr x, ikptr y, ikpcb* pcb){ 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), - (unsigned int*)(r+disp_bignum_data), + (mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), + (mp_limb_t*)(r+disp_bignum_data), new_limb_count, - bits_carry((unsigned int*)(x+off_bignum_data), whole_limb_shift)); + bits_carry((mp_limb_t*)(x+off_bignum_data), whole_limb_shift)); bits_compliment( - (unsigned int*)(r+disp_bignum_data), - (unsigned int*)(r+disp_bignum_data), + (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(r+disp_bignum_data), new_limb_count); return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r); } else { @@ -1327,20 +1349,20 @@ ikrt_bignum_shift_right(ikptr x, ikptr y, ikpcb* pcb){ 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), - (unsigned int*)(r+disp_bignum_data), + (mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), + (mp_limb_t*)(r+disp_bignum_data), new_limb_count, - bits_carry((unsigned int*)(x+off_bignum_data), whole_limb_shift)); + bits_carry((mp_limb_t*)(x+off_bignum_data), whole_limb_shift)); copy_bits_shifting_right( - (unsigned int*)(r+disp_bignum_data), - (unsigned int*)(r+disp_bignum_data), + (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(r+disp_bignum_data), new_limb_count, bit_shift); - *((unsigned int*)(r+disp_bignum_data+(new_limb_count-1)*wordsize)) + *((mp_limb_t*)(r+disp_bignum_data+(new_limb_count-1)*wordsize)) |= (-1 << (32 - bit_shift)); bits_compliment( - (unsigned int*)(r+disp_bignum_data), - (unsigned int*)(r+disp_bignum_data), + (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(r+disp_bignum_data), new_limb_count); return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r); fprintf(stderr, "not yet for negative bignum_shift\n"); @@ -1360,8 +1382,8 @@ ikrt_bignum_shift_right(ikptr x, ikptr y, ikpcb* pcb){ return normalize_bignum(new_limb_count, 0, r); } else { copy_bits_shifting_right( - (unsigned int*)(x+off_bignum_data+whole_limb_shift*wordsize), - (unsigned int*)(r+disp_bignum_data), + (mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), + (mp_limb_t*)(r+disp_bignum_data), new_limb_count, bit_shift); return normalize_bignum(new_limb_count, 0, r); @@ -1396,20 +1418,20 @@ ikrt_fixnum_shift_left(ikptr x, ikptr y, ikpcb* pcb){ ikptr ikrt_bignum_shift_left(ikptr x, ikptr y, ikpcb* pcb){ - int m = unfix(y); + long int m = unfix(y); 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; + long int n = bnfst_limb_count(fst); + long int whole_limb_shift = m >> 5; /* FIXME: 5 are the bits in 32-bit num */ + long int bit_shift = m & 31; if(bit_shift == 0){ - int limb_count = n + whole_limb_shift; + long int limb_count = n + whole_limb_shift; pcb->root0 = &x; 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); memcpy(s+whole_limb_shift, x+off_bignum_data, n*wordsize); - return normalize_bignum(limb_count, (unsigned int)fst & bignum_sign_mask, r); + return normalize_bignum(limb_count, bnfst_negative(fst), r); } else { int limb_count = n + whole_limb_shift + 1; pcb->root0 = &x; @@ -1422,7 +1444,7 @@ ikrt_bignum_shift_left(ikptr x, ikptr y, ikpcb* pcb){ s+whole_limb_shift, n, bit_shift); - return normalize_bignum(limb_count, (unsigned int)fst & bignum_sign_mask, r); + return normalize_bignum(limb_count, bnfst_negative(fst), r); } } @@ -1451,8 +1473,8 @@ 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; + mp_size_t xn = bnfst_limb_count(xfst); + mp_size_t yn = bnfst_limb_count(yfst); if(xn < yn){ /* quotient is zero, remainder is x */ pcb->root0 = &x; @@ -1487,21 +1509,20 @@ ikrt_bnbndivrem(ikptr x, ikptr y, ikpcb* pcb){ (mp_limb_t*)(y+off_bignum_data), yn); - if(((unsigned int) xfst) & bignum_sign_mask){ + if(bnfst_negative(xfst)){ /* x is negative => remainder is negative */ r = normalize_bignum(rn, 1 << bignum_sign_shift, r); } else { r = normalize_bignum(rn, 0, r); } - if(((unsigned int) yfst) & bignum_sign_mask){ + if(bnfst_negative(yfst)){ /* y is negative => quotient is opposite of x */ - int sign = - bignum_sign_mask - (((unsigned int)xfst) & bignum_sign_mask); + long int sign = bignum_sign_mask - bnfst_negative(xfst); q = normalize_bignum(qn, sign, q); } else { /* y is positive => quotient is same as x */ - int sign = (((unsigned int)xfst) & bignum_sign_mask); + long int sign = bnfst_negative(xfst); q = normalize_bignum(qn, sign, q); } pcb->root0 = &q; @@ -1537,7 +1558,7 @@ ikptr ikrt_bnfxdivrem(ikptr x, ikptr y, ikpcb* pcb){ int yint = unfix(y); ikptr fst = ref(x, -vector_tag); - mp_size_t s2n = ((unsigned int) fst) >> bignum_length_shift; + mp_size_t s2n = bnfst_limb_count(fst); pcb->root0 = &x; ikptr quot = ik_safe_alloc(pcb, align(s2n*wordsize + disp_bignum_data)); pcb->root0 = 0; @@ -1553,19 +1574,18 @@ ikrt_bnfxdivrem(ikptr x, ikptr y, ikpcb* pcb){ if(yint < 0){ /* y is negative => quotient is opposite of x */ - int sign = - bignum_sign_mask - (((unsigned int)fst) & bignum_sign_mask); + long int sign = bignum_sign_mask - bnfst_negative(fst); quot = normalize_bignum(s2n, sign, quot); } else { /* y is positive => quotient is same as x */ - int sign = (((unsigned int)fst) & bignum_sign_mask); + long int sign = bnfst_negative(fst); quot = normalize_bignum(s2n, sign, quot); } /* the remainder is always less than |y|, so it will always be a fixnum. (if y == most_negative_fixnum, then |remainder| will be at most most_positive_fixnum). */ - if(((unsigned int) fst) & bignum_sign_mask){ + if(bnfst_negative(fst)){ /* x is negative => remainder is negative */ rem = (ikptr) -(rv << fx_shift); } else { @@ -1586,9 +1606,9 @@ ikrt_bnfx_modulo(ikptr x, ikptr y, ikpcb* pcb){ int yint = unfix(y); mp_limb_t* s2p = (mp_limb_t*)(x+off_bignum_data); ikptr fst = ref(x, -vector_tag); - mp_size_t s2n = ((unsigned int) fst) >> bignum_length_shift; + mp_size_t s2n = bnfst_limb_count(fst); if(yint < 0){ - if(((unsigned int) fst) & bignum_sign_mask){ + if(bnfst_negative(fst)){ /* x negative, y negative */ mp_limb_t m = mpn_mod_1(s2p, s2n, -yint); return fix(-m); @@ -1598,7 +1618,7 @@ ikrt_bnfx_modulo(ikptr x, ikptr y, ikpcb* pcb){ return fix(yint+m); } } else { - if(((unsigned int) fst) & bignum_sign_mask){ + if(bnfst_negative(fst)){ /* x negative, y positive */ mp_limb_t m = mpn_mod_1(s2p, s2n, yint); return fix(yint-m); @@ -1626,10 +1646,10 @@ ikptr ikrt_bignum_length(ikptr x){ ikptr fst = ref(x, -vector_tag); mp_limb_t* sp = (mp_limb_t*)(x+off_bignum_data); - mp_size_t sn = ((unsigned int) fst) >> bignum_length_shift; + mp_size_t sn = bnfst_limb_count(fst); mp_limb_t last = sp[sn-1]; int n0 = limb_length(last); - if(((unsigned int) fst) & bignum_sign_mask){ + if(((unsigned long int) fst) & bignum_sign_mask){ /* negative */ if (last == (1<<(n0-1))){ /* single bit set in last limb */ @@ -1653,22 +1673,21 @@ ikrt_bignum_length(ikptr x){ } - 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 */ ikptr fst = ref(x, -vector_tag); - int limb_count = (((unsigned int)fst) >> bignum_length_shift); + long int limb_count = bnfst_limb_count(fst); if(limb_count <= 0){ - fprintf(stderr, "BUG: nbtostring: invalid length %d\n", limb_count); + fprintf(stderr, "BUG: nbtostring: invalid length %ld\n", limb_count); exit(-1); } - int sign_bit = bignum_sign_mask & (int) fst; - int nbsize = limb_count * sizeof(mp_limb_t); - int strsize = limb_count * max_digits_per_limb; - int mem_req = nbsize + strsize + 1; + long int sign_bit = bignum_sign_mask & (long int) fst; + long int nbsize = limb_count * sizeof(mp_limb_t); + long int strsize = limb_count * max_digits_per_limb; + long int mem_req = nbsize + strsize + 1; unsigned char* mem = malloc(mem_req); if(! mem){ fprintf(stderr, "Error allocating space for bignum\n"); @@ -1694,7 +1713,7 @@ ikrt_bignum_to_bytevector(ikptr x, ikpcb* pcb){ dest++; } { - int i = 0; + long int i = 0; while(i < bytes){ dest[i] = string_start[i] + '0'; i++; diff --git a/src/ikarus-print.c b/src/ikarus-print.c index 8189cf5..d17ea2e 100644 --- a/src/ikarus-print.c +++ b/src/ikarus-print.c @@ -33,7 +33,7 @@ void ik_print(ikptr x){ fprintf(stdout, "\n"); } -static char* char_string[128] = { +char* char_string[128] = { "#\\nul","#\\soh","#\\stx","#\\etx","#\\eot","#\\enq","#\\ack","#\\bel", "#\\bs", "#\\tab","#\\newline", "#\\vt", "#\\ff", "#\\return", "#\\so", "#\\si", @@ -57,10 +57,10 @@ static char* char_string[128] = { static void print(FILE* fh, ikptr x){ - if(IK_FIXNUMP(x)){ - fprintf(fh, "%d", IK_UNFIX(x)); + if(is_fixnum(x)){ + fprintf(fh, "%ld", unfix(x)); } - else if(x == IK_FALSE_OBJECT){ + else if(x == false_object){ fprintf(fh, "#f"); } else if(x == IK_TRUE_OBJECT){ @@ -69,8 +69,8 @@ print(FILE* fh, ikptr x){ else if(x == IK_NULL_OBJECT){ fprintf(fh, "()"); } - else if(IK_CHARP(x)){ - fprintf(fh, "%s", char_string[IK_CHAR_VAL(x)]); + else if(is_char(x)){ + fprintf(fh, "X"); } #if 0 else if(tagof(x) == symbol_tag){ @@ -98,16 +98,16 @@ print(FILE* fh, ikptr x){ else if(is_closure(x)){ fprintf(fh, "#"); } - else if(IK_PAIRP(x)){ + else if(is_pair(x)){ fprintf(fh, "("); - print(fh, REF(x, IK_OFF_CAR)); - ikptr d = REF(x, IK_OFF_CDR); - fprintf(stderr, "d=0x%08x\n", (int)d); + print(fh, ref(x, IK_OFF_CAR)); + ikptr d = ref(x, IK_OFF_CDR); + fprintf(stderr, "d=0x%016lx\n", (long int)d); while(1){ - if(IK_PAIRP(d)){ + if(is_pair(d)){ fprintf(fh, " "); - print(fh, REF(d, IK_OFF_CAR)); - d = REF(d, IK_OFF_CDR); + print(fh, ref(d, IK_OFF_CAR)); + d = ref(d, IK_OFF_CDR); } else if(d == IK_NULL_OBJECT){ fprintf(fh, ")"); diff --git a/src/ikarus-runtime.c b/src/ikarus-runtime.c index e2d9d79..93090d6 100644 --- a/src/ikarus-runtime.c +++ b/src/ikarus-runtime.c @@ -44,7 +44,7 @@ extern char **environ; #define segment_size (pagesize*pagesize/wordsize) #define segment_shift (pageshift+pageshift-wordshift) -#define segment_index(x) (((unsigned int)(x)) >> segment_shift) +#define segment_index(x) (((unsigned long int)(x)) >> segment_shift) void* ik_mmap(int size); void ik_munmap(void* mem, int size); @@ -54,11 +54,11 @@ extend_table_maybe(char*p, int size, ikpcb* pcb){ assert(size == align_to_next_page(size)); char* q = p + size; if(p < pcb->memory_base){ - int new_lo = segment_index(p); - int old_lo = segment_index(pcb->memory_base); - int hi = segment_index(pcb->memory_end); - int new_vec_size = (hi - new_lo) * pagesize; - int old_vec_size = (hi - old_lo) * pagesize; + long int new_lo = segment_index(p); + long int old_lo = segment_index(pcb->memory_base); + long int hi = segment_index(pcb->memory_end); + long int new_vec_size = (hi - new_lo) * pagesize; + long int old_vec_size = (hi - old_lo) * pagesize; unsigned char* v = ik_mmap(new_vec_size); bzero(v, new_vec_size - old_vec_size); memcpy(v+new_vec_size-old_vec_size, pcb->dirty_vector_base, old_vec_size); @@ -74,11 +74,11 @@ extend_table_maybe(char*p, int size, ikpcb* pcb){ pcb->memory_base = (char*)(new_lo * segment_size); } else if (q > pcb->memory_end){ - int lo = segment_index(pcb->memory_base); - int old_hi = segment_index(pcb->memory_end); - 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; + long int lo = segment_index(pcb->memory_base); + long int old_hi = segment_index(pcb->memory_end); + long int new_hi = segment_index(q+segment_size-1); + long int new_vec_size = (new_hi - lo) * pagesize; + long int old_vec_size = (old_hi - lo) * pagesize; 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); @@ -319,9 +319,9 @@ ikpcb* ik_make_pcb(){ hi_mem = pcb->heap_base + pcb->heap_size + pagesize; } - int lo_seg = segment_index(lo_mem); - int hi_seg = segment_index(hi_mem+segment_size-1); - int vec_size = (hi_seg - lo_seg) * pagesize; + long int lo_seg = segment_index(lo_mem); + long int hi_seg = segment_index(hi_mem+segment_size-1); + long int vec_size = (hi_seg - lo_seg) * pagesize; char* dvec = ik_mmap(vec_size); bzero(dvec, vec_size); pcb->dirty_vector_base = (unsigned int*) (dvec); @@ -378,8 +378,8 @@ void ik_delete_pcb(ikpcb* pcb){ 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); + long int i = page_index(base); + long int j = page_index(end); while(i < j){ unsigned int t = segment_vec[i]; if(t != hole_mt){ @@ -387,7 +387,7 @@ void ik_delete_pcb(ikpcb* pcb){ } i++; } - int vecsize = (segment_index(end) - segment_index(base)) * pagesize; + long int vecsize = (segment_index(end) - segment_index(base)) * pagesize; ik_munmap(pcb->dirty_vector_base, vecsize); ik_munmap(pcb->segment_vector_base, vecsize); ik_free(pcb, sizeof(ikpcb)); @@ -443,9 +443,10 @@ ik_unsafe_alloc(ikpcb* pcb, int size){ } { /* ACCOUNTING */ - int bytes = ((int)pcb->allocation_pointer) - - ((int)pcb->heap_base); - int minor = bytes + pcb->allocation_count_minor; + long int bytes = + ((long int)pcb->allocation_pointer) - + ((long int)pcb->heap_base); + long int minor = bytes + pcb->allocation_count_minor; while(minor >= most_bytes_in_minor){ minor -= most_bytes_in_minor; pcb->allocation_count_major++; @@ -492,7 +493,7 @@ void ik_stack_overflow(ikpcb* pcb){ ref(k, -vector_tag) = continuation_tag; ref(k, off_continuation_top) = pcb->frame_pointer; ref(k, off_continuation_size) = - pcb->frame_base - (int)pcb->frame_pointer - wordsize; + pcb->frame_base - (long int)pcb->frame_pointer - wordsize; ref(k, off_continuation_next) = pcb->next_k; pcb->next_k = k; @@ -700,9 +701,9 @@ ik_dump_metatable(ikpcb* pcb){ p += pagesize; s++; } - fprintf(stderr, "0x%08x + %5d pages = %s\n", - (int) start, - ((int)p-(int)start)/pagesize, + fprintf(stderr, "0x%016lx + %5ld pages = %s\n", + (long int) start, + ((long int)p-(long int)start)/pagesize, mtname(t)); } return void_object; @@ -722,9 +723,9 @@ ik_dump_dirty_vector(ikpcb* pcb){ p += pagesize; s++; } - fprintf(stderr, "0x%08x + %5d pages = 0x%08x\n", - (int) start, - ((int)p-(int)start)/pagesize, + fprintf(stderr, "0x%016lx + %5ld pages = 0x%08x\n", + (long int) start, + ((long int)p-(long int)start)/pagesize, t); } return void_object; @@ -863,8 +864,8 @@ ikrt_gmt_offset(ikptr t){ ikptr ikrt_bytes_allocated(ikpcb* pcb){ - int bytes_in_heap = ((int) pcb->allocation_pointer) - - ((int) pcb->heap_base); + int bytes_in_heap = ((long int) pcb->allocation_pointer) - + ((long int) pcb->heap_base); int bytes = bytes_in_heap + pcb->allocation_count_minor; return fix(bytes); } @@ -906,10 +907,10 @@ ikrt_getenv(ikptr bv, ikpcb* pcb){ ikptr ikrt_make_vector1(ikptr len, ikpcb* pcb){ - if(is_fixnum(len) && (((int)len) >= 0)){ - ikptr s = ik_safe_alloc(pcb, align(((int)len) + disp_vector_data)); + if(is_fixnum(len) && (((long int)len) >= 0)){ + ikptr s = ik_safe_alloc(pcb, align(((long int)len) + disp_vector_data)); ref(s, 0) = len; - memset(s+disp_vector_data, 0, (int)len); + memset(s+disp_vector_data, 0, (long int)len); return s+vector_tag; } else { return 0; @@ -981,6 +982,6 @@ ikrt_exit(ikptr status, ikpcb* pcb){ ikptr ikrt_debug(ikptr x){ - fprintf(stderr, "DEBUG 0x%08x\n", (int)x); + fprintf(stderr, "DEBUG 0x%016lx\n", (long int)x); return 0; }; diff --git a/src/ikarus-symbol-table.c b/src/ikarus-symbol-table.c index 9ae9d94..00b6c51 100644 --- a/src/ikarus-symbol-table.c +++ b/src/ikarus-symbol-table.c @@ -32,11 +32,11 @@ make_symbol_table(ikpcb* pcb){ return st; } -static int +static long int compute_hash(ikptr str){ - int len = unfix(ref(str, off_string_length)); + long int len = unfix(ref(str, off_string_length)); char* data = (char*) str + off_string_data; - int h = len; + long int h = len; char* last = data + len * string_char_size; while(data < last){ char c = *data; diff --git a/src/ikarus-verify-integrity.c b/src/ikarus-verify-integrity.c index 4d7cceb..5291ff4 100644 --- a/src/ikarus-verify-integrity.c +++ b/src/ikarus-verify-integrity.c @@ -21,9 +21,9 @@ #include #include -static int +static long int page_idx(char* x){ - unsigned int xi = (unsigned int) x; + unsigned long int xi = (unsigned long int) x; return xi >> pageshift; }