From 66e9cd6415804cf9b0835072692ea8334952ec73 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Tue, 1 Jan 2008 21:42:52 -0500 Subject: [PATCH] ikarus now compiles cleanly (but still unrunnable) in 64-bit mode. --- scheme/last-revision | 2 +- src/ikarus-collect.c | 2 +- src/ikarus-data.h | 2 +- src/ikarus-exec.c | 6 +- src/ikarus-fasl.c | 12 +-- src/ikarus-flonums.c | 2 +- src/ikarus-numerics.c | 186 +++++++++++++++++----------------- src/ikarus-runtime.c | 5 +- src/ikarus-symbol-table.c | 8 +- src/ikarus-verify-integrity.c | 8 +- 10 files changed, 119 insertions(+), 114 deletions(-) diff --git a/scheme/last-revision b/scheme/last-revision index 7ff75c7..fb814da 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1305 +1307 diff --git a/src/ikarus-collect.c b/src/ikarus-collect.c index c713397..8686fdc 100644 --- a/src/ikarus-collect.c +++ b/src/ikarus-collect.c @@ -834,7 +834,7 @@ forward_guardians(gc_t* gc){ collect_loop(gc); while(cache){ ik_ptr_page* next = cache->next; - ik_munmap((ikptr)cache, sizeof(ik_ptr_page)); + ik_munmap((ikptr)(long)cache, sizeof(ik_ptr_page)); cache = next; } } diff --git a/src/ikarus-data.h b/src/ikarus-data.h index 1d81334..864f27d 100644 --- a/src/ikarus-data.h +++ b/src/ikarus-data.h @@ -312,7 +312,7 @@ 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) \ - (((ikchar*)(((ikptr)(x)) + off_string_data))[i] = ((ikchar)(c))) + (((ikchar*)(((long)(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 diff --git a/src/ikarus-exec.c b/src/ikarus-exec.c index 2ce12b9..a07ad07 100644 --- a/src/ikarus-exec.c +++ b/src/ikarus-exec.c @@ -57,10 +57,10 @@ ikptr ik_exec_code(ikpcb* pcb, ikptr code_ptr){ pcb->next_k = k->next; ikptr fbase = pcb->frame_base - wordsize; ikptr new_fbase = fbase - framesize; - memmove((char*)new_fbase + argc, - (char*)fbase + argc, + memmove((char*)(long)new_fbase + argc, + (char*)(long)fbase + argc, -argc); - memcpy((char*)new_fbase, (char*)top, framesize); + memcpy((char*)(long)new_fbase, (char*)(long)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 b6b41bc..f3fb9ba 100644 --- a/src/ikarus-fasl.c +++ b/src/ikarus-fasl.c @@ -98,7 +98,7 @@ void ik_fasl_load(ikpcb* pcb, char* fasl_file){ p.code_ep = 0; ikptr v = ik_fasl_read(pcb, &p); if(p.marks_size){ - ik_munmap((ikptr) p.marks, p.marks_size*sizeof(ikptr*)); + ik_munmap((ikptr)(long)p.marks, p.marks_size*sizeof(ikptr*)); p.marks = 0; p.marks_size = 0; } @@ -195,7 +195,7 @@ ik_relocate_code(ikptr code){ ikptr str = ref(p, wordsize); char* name; if(tagof(str) == bytevector_tag){ - name = (char*) str + off_bytevector_data; + name = (char*)(long) str + off_bytevector_data; } else { fprintf(stderr, "foreign name is not a bytevector\n"); exit(-1); @@ -207,7 +207,7 @@ ik_relocate_code(ikptr code){ fprintf(stderr, "failed to find foreign name %s: %s\n", name, err); exit(-1); } - ref(data,code_off) = (ikptr)sym; + ref(data,code_off) = (ikptr)(long)sym; p += (2*wordsize); } else { @@ -273,7 +273,7 @@ static ikptr do_read(ikpcb* pcb, fasl_port* p){ } else { /* allocate marks */ - p->marks = (ikptr*)ik_mmap(pagesize*sizeof(ikptr*)); + p->marks = (ikptr*)(long)ik_mmap(pagesize*sizeof(ikptr*)); bzero(p->marks, pagesize*sizeof(ikptr*)); p->marks_size = pagesize; } @@ -289,7 +289,7 @@ static ikptr do_read(ikpcb* pcb, fasl_port* p){ ref(code, disp_code_code_size) = fix(code_size); ref(code, disp_code_freevars) = freevars; ref(code, disp_code_annotation) = annotation; - fasl_read_buf(p, (void*)code+disp_code_data, code_size); + fasl_read_buf(p, (void*)(long)code+disp_code_data, code_size); if(put_mark_index){ p->marks[put_mark_index] = code+vector_tag; } @@ -322,7 +322,7 @@ static ikptr do_read(ikpcb* pcb, fasl_port* p){ 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); - fasl_read_buf(p, (char*)str+off_string_data, len); + fasl_read_buf(p, (char*)(long)str+off_string_data, len); { unsigned char* pi = (unsigned char*)(long)(str+off_string_data); ikchar* pj = (ikchar*)(long)(str+off_string_data); diff --git a/src/ikarus-flonums.c b/src/ikarus-flonums.c index ba36a35..e3c318c 100644 --- a/src/ikarus-flonums.c +++ b/src/ikarus-flonums.c @@ -47,7 +47,7 @@ ikrt_flfl_expt(ikptr a, ikptr b, ikptr z){ ikptr ikrt_bytevector_to_flonum(ikptr x, ikpcb* pcb){ - double v = strtod((char*)x+off_bytevector_data, NULL); + double v = strtod((char*)(long)x+off_bytevector_data, NULL); ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag; ref(r, -vector_tag) = (ikptr)flonum_tag; flonum_data(r) = v; diff --git a/src/ikarus-numerics.c b/src/ikarus-numerics.c index 1431200..bb8392b 100644 --- a/src/ikarus-numerics.c +++ b/src/ikarus-numerics.c @@ -162,8 +162,8 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; mp_limb_t carry = - mpn_add_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, intx); if(carry){ @@ -188,8 +188,8 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; mp_limb_t borrow = - mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, intx); if(borrow){ @@ -224,8 +224,8 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; mp_limb_t borrow = - mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, - intx); if(borrow){ @@ -257,8 +257,8 @@ ikrt_fxbnplus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; mp_limb_t carry = - mpn_add_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, -intx); if(carry){ @@ -304,10 +304,10 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ 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), + mpn_add((mp_limb_t*)(long)(res+disp_bignum_data), + (mp_limb_t*)(long)(s1-vector_tag+disp_bignum_data), n1, - (mp_limb_t*) (s2-vector_tag+disp_bignum_data), + (mp_limb_t*)(long)(s2-vector_tag+disp_bignum_data), n2); if(carry){ ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1; @@ -357,10 +357,10 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = 0; pcb->root1 = 0; mp_limb_t burrow = - mpn_sub((mp_limb_t*) (res + disp_bignum_data), - (mp_limb_t*) (s1 - vector_tag + disp_bignum_data), + mpn_sub((mp_limb_t*)(long)(res + disp_bignum_data), + (mp_limb_t*)(long)(s1 - vector_tag + disp_bignum_data), n1, - (mp_limb_t*) (s2 - vector_tag + disp_bignum_data), + (mp_limb_t*)(long)(s2 - vector_tag + disp_bignum_data), n2); if(burrow){ fprintf(stderr, "BUG: Burrow error in bnbn+\n"); @@ -454,8 +454,8 @@ ikrt_bnnegate(ikptr x, ikpcb* pcb){ pcb->root0 = &x; ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); pcb->root0 = 0; - memcpy((char*)bn+disp_bignum_data, - (char*)x-vector_tag+disp_bignum_data, + memcpy((char*)(long)bn+disp_bignum_data, + (char*)(long)x-vector_tag+disp_bignum_data, limb_count*wordsize); ref(bn, 0) = (ikptr) (bignum_tag | @@ -477,8 +477,8 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; long int carry = - mpn_add_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, intx); if(carry){ @@ -502,8 +502,8 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; long int borrow = - mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, intx); if(borrow){ @@ -538,8 +538,8 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; long int borrow = - mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, - intx); if(borrow){ @@ -571,8 +571,8 @@ ikrt_fxbnminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; long int carry = - mpn_add_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y - vector_tag + disp_bignum_data), + mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data), limb_count, -intx); if(carry){ @@ -606,8 +606,8 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; long int carry = - mpn_add_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(x - vector_tag + disp_bignum_data), + mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data), limb_count, -inty); if(carry){ @@ -631,8 +631,8 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; long int borrow = - mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(x - vector_tag + disp_bignum_data), + mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data), limb_count, -inty); if(borrow){ @@ -667,8 +667,8 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize)); pcb->root0 = 0; long int borrow = - mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(x - vector_tag + disp_bignum_data), + mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data), limb_count, inty); if(borrow){ @@ -700,8 +700,8 @@ ikrt_bnfxminus(ikptr x, ikptr y, ikpcb* pcb){ ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize)); pcb->root0 = 0; long int carry = - mpn_add_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(x - vector_tag + disp_bignum_data), + mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data), limb_count, inty); if(carry){ @@ -746,11 +746,12 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ 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), - (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*)(long)(res+disp_bignum_data), + (mp_limb_t*)(long)(s1-vector_tag+disp_bignum_data), + n1, + (mp_limb_t*)(long)(s2-vector_tag+disp_bignum_data), + n2); if(carry){ ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1; ref(res, 0) = (ikptr) @@ -801,10 +802,10 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = 0; pcb->root0 = 0; long int burrow = - mpn_sub((mp_limb_t*) (res + disp_bignum_data), - (mp_limb_t*) (s1 - vector_tag + disp_bignum_data), + mpn_sub((mp_limb_t*)(long)(res + disp_bignum_data), + (mp_limb_t*)(long)(s1 - vector_tag + disp_bignum_data), n1, - (mp_limb_t*) (s2 - vector_tag + disp_bignum_data), + (mp_limb_t*)(long)(s2 - vector_tag + disp_bignum_data), n2); if(burrow){ fprintf(stderr, "BUG: Burrow error in bnbn-\n"); @@ -929,8 +930,8 @@ ikrt_fxbnmult(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; - mp_limb_t hi = mpn_mul_1((mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(y-vector_tag+disp_bignum_data), + mp_limb_t hi = mpn_mul_1((mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(y-vector_tag+disp_bignum_data), limb_count, s2); ref(r, disp_bignum_data + limb_count * wordsize) = (ikptr)hi; @@ -955,16 +956,16 @@ ikrt_bnbnmult(ikptr x, ikptr y, ikpcb* pcb){ pcb->root1 = 0; mp_limb_t r; if(n1 >= n2){ - r = mpn_mul((mp_limb_t*)(bn+disp_bignum_data), - (mp_limb_t*)(x-vector_tag+disp_bignum_data), + r = mpn_mul((mp_limb_t*)(long)(bn+disp_bignum_data), + (mp_limb_t*)(long)(x-vector_tag+disp_bignum_data), n1, - (mp_limb_t*)(y-vector_tag+disp_bignum_data), + (mp_limb_t*)(long)(y-vector_tag+disp_bignum_data), n2); } else { - r = mpn_mul((mp_limb_t*)(bn+disp_bignum_data), - (mp_limb_t*)(y-vector_tag+disp_bignum_data), + r = mpn_mul((mp_limb_t*)(long)(bn+disp_bignum_data), + (mp_limb_t*)(long)(y-vector_tag+disp_bignum_data), n2, - (mp_limb_t*)(x-vector_tag+disp_bignum_data), + (mp_limb_t*)(long)(x-vector_tag+disp_bignum_data), n1); } long int sign = @@ -1169,8 +1170,8 @@ ikrt_bnlognot(ikptr x, ikpcb* pcb){ pcb->root0 = &x; ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize)); pcb->root0 = 0; - mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); - mp_limb_t* rd = (mp_limb_t*)(r+disp_bignum_data); + mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag); + mp_limb_t* rd = (mp_limb_t*)(long)(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((char*)r+disp_bignum_data, n*wordsize); - ((mp_limb_t*)(r+disp_bignum_data))[n] = 1; + bzero((char*)(long)r+disp_bignum_data, n*wordsize); + ((mp_limb_t*)(long)(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; - mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); - mp_limb_t* rd = (mp_limb_t*)(r+disp_bignum_data); + mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag); + mp_limb_t* rd = (mp_limb_t*)(long)(r+disp_bignum_data); int j; for(j=0; jroot0 = 0; pcb->root1 = 0; - 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)); + mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag); + mp_limb_t* s2 = (mp_limb_t*)(long)(y+disp_bignum_data-vector_tag); + mp_limb_t* s = (mp_limb_t*)(long)(r+disp_bignum_data); bits_compliment(s1, s, n1); bits_compliment_logand(s2, s, s, n2); bits_compliment(s, s, n1); @@ -1248,9 +1249,9 @@ 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; - 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)); + mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag); + mp_limb_t* s2 = (mp_limb_t*)(long)(y+disp_bignum_data-vector_tag); + mp_limb_t* s = (mp_limb_t*)(long)(r+disp_bignum_data); bits_compliment_logand(s2, s1, s, n1); return normalize_bignum(n1, 0, r); } else { @@ -1335,13 +1336,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( - (mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), - (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(long)(x+off_bignum_data+whole_limb_shift*wordsize), + (mp_limb_t*)(long)(r+disp_bignum_data), new_limb_count, - bits_carry((mp_limb_t*)(x+off_bignum_data), whole_limb_shift)); + bits_carry((mp_limb_t*)(long)(x+off_bignum_data), whole_limb_shift)); bits_compliment( - (mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(r+disp_bignum_data), new_limb_count); return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r); } else { @@ -1349,20 +1350,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( - (mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), - (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(long)(x+off_bignum_data+whole_limb_shift*wordsize), + (mp_limb_t*)(long)(r+disp_bignum_data), new_limb_count, - bits_carry((mp_limb_t*)(x+off_bignum_data), whole_limb_shift)); + bits_carry((mp_limb_t*)(long)(x+off_bignum_data), whole_limb_shift)); copy_bits_shifting_right( - (mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(r+disp_bignum_data), new_limb_count, bit_shift); *((mp_limb_t*)(r+disp_bignum_data+(new_limb_count-1)*wordsize)) |= (-1 << (32 - bit_shift)); bits_compliment( - (mp_limb_t*)(r+disp_bignum_data), - (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(long)(r+disp_bignum_data), + (mp_limb_t*)(long)(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"); @@ -1376,14 +1377,14 @@ 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; if(bit_shift == 0){ - memcpy((char*)r+disp_bignum_data, - (char*)x+off_bignum_data+whole_limb_shift*wordsize, + memcpy((char*)(long)r+disp_bignum_data, + (char*)(long)x+off_bignum_data+whole_limb_shift*wordsize, new_limb_count * wordsize); return normalize_bignum(new_limb_count, 0, r); } else { copy_bits_shifting_right( - (mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), - (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(long)(x+off_bignum_data+whole_limb_shift*wordsize), + (mp_limb_t*)(long)(r+disp_bignum_data), new_limb_count, bit_shift); return normalize_bignum(new_limb_count, 0, r); @@ -1399,7 +1400,7 @@ ikrt_fixnum_shift_left(ikptr x, ikptr y, ikpcb* pcb){ int limb_count = (m >> 5) + 2; /* FIXME: 5 are the bits in 32-bit num */ int bit_shift = m & 31; ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); - unsigned int* s = (unsigned int*)(r+disp_bignum_data); + unsigned int* s = (unsigned int*)(long)(r+disp_bignum_data); bzero(s, limb_count * wordsize); if(n >= 0){ if(bit_shift){ @@ -1428,19 +1429,20 @@ ikrt_bignum_shift_left(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; - unsigned int* s = (unsigned int*)(r+disp_bignum_data); + unsigned int* s = (unsigned int*)(long)(r+disp_bignum_data); bzero(s, whole_limb_shift*wordsize); - memcpy((char*)s+whole_limb_shift, (char*)x+off_bignum_data, n*wordsize); + memcpy((char*)(long)s+whole_limb_shift, + (char*)(long)x+off_bignum_data, n*wordsize); return normalize_bignum(limb_count, bnfst_negative(fst), r); } else { int limb_count = n + whole_limb_shift + 1; 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); + unsigned int* s = (unsigned int*)(long)(r+disp_bignum_data); bzero(s, whole_limb_shift*wordsize); copy_bits_shifting_left( - (unsigned int*)(x+off_bignum_data), + (unsigned int*)(long)(x+off_bignum_data), s+whole_limb_shift, n, bit_shift); @@ -1501,12 +1503,12 @@ ikrt_bnbndivrem(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = 0; pcb->root1 = 0; mpn_tdiv_qr ( - (mp_limb_t*)(q+disp_bignum_data), - (mp_limb_t*)(r+disp_bignum_data), + (mp_limb_t*)(long)(q+disp_bignum_data), + (mp_limb_t*)(long)(r+disp_bignum_data), 0, - (mp_limb_t*)(x+off_bignum_data), + (mp_limb_t*)(long)(x+off_bignum_data), xn, - (mp_limb_t*)(y+off_bignum_data), + (mp_limb_t*)(long)(y+off_bignum_data), yn); if(bnfst_negative(xfst)){ @@ -1562,9 +1564,9 @@ ikrt_bnfxdivrem(ikptr x, ikptr y, ikpcb* pcb){ pcb->root0 = &x; 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* s2p = (mp_limb_t*)(long)(x+off_bignum_data); mp_limb_t rv = mpn_divrem_1( - (mp_limb_t*)(quot+disp_bignum_data), + (mp_limb_t*)(long)(quot+disp_bignum_data), 0, s2p, s2n, @@ -1604,7 +1606,7 @@ ikrt_bnfxdivrem(ikptr x, ikptr 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); + mp_limb_t* s2p = (mp_limb_t*)(long)(x+off_bignum_data); ikptr fst = ref(x, -vector_tag); mp_size_t s2n = bnfst_limb_count(fst); if(yint < 0){ @@ -1645,7 +1647,7 @@ limb_length(unsigned int n){ ikptr ikrt_bignum_length(ikptr x){ ikptr fst = ref(x, -vector_tag); - mp_limb_t* sp = (mp_limb_t*)(x+off_bignum_data); + mp_limb_t* sp = (mp_limb_t*)(long)(x+off_bignum_data); mp_size_t sn = bnfst_limb_count(fst); mp_limb_t last = sp[sn-1]; int n0 = limb_length(last); @@ -1693,7 +1695,9 @@ ikrt_bignum_to_bytevector(ikptr x, ikpcb* pcb){ fprintf(stderr, "Error allocating space for bignum\n"); exit(-1); } - memcpy((char*)mem, (char*)x - vector_tag + disp_bignum_data, nbsize); + memcpy((char*)(long)mem, + (char*)(long)x - vector_tag + disp_bignum_data, + nbsize); mp_size_t bytes = mpn_get_str(mem+nbsize, /* output string */ 10, /* base */ diff --git a/src/ikarus-runtime.c b/src/ikarus-runtime.c index ce044d4..2c840b0 100644 --- a/src/ikarus-runtime.c +++ b/src/ikarus-runtime.c @@ -64,7 +64,7 @@ extend_table_maybe(ikptr p, int size, ikpcb* pcb){ memcpy((char*)(long)(v+new_vec_size-old_vec_size), (char*)(long)pcb->dirty_vector_base, old_vec_size); - ik_munmap((ikptr)pcb->dirty_vector_base, old_vec_size); + ik_munmap((ikptr)(long)pcb->dirty_vector_base, old_vec_size); pcb->dirty_vector_base = (unsigned int*)(long)v; pcb->dirty_vector = (v - new_lo * pagesize); ikptr s = ik_mmap(new_vec_size); @@ -916,7 +916,8 @@ ikrt_getenv(ikptr bv, ikpcb* pcb){ ikptr ikrt_make_vector1(ikptr len, ikpcb* pcb){ - if(is_fixnum(len) && (((long int)len) >= 0)){ + int intlen = (int)len; + if(is_fixnum(len) && (intlen >= 0)){ ikptr s = ik_safe_alloc(pcb, align(len + disp_vector_data)); ref(s, 0) = len; memset((char*)(long)(s+disp_vector_data), 0, len); diff --git a/src/ikarus-symbol-table.c b/src/ikarus-symbol-table.c index ac6f266..813e9b9 100644 --- a/src/ikarus-symbol-table.c +++ b/src/ikarus-symbol-table.c @@ -27,7 +27,7 @@ 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); ikptr st = ik_mmap_ptr(size, 0, pcb) + vector_tag; - bzero((char*)st-vector_tag, size); + bzero((char*)(long)st-vector_tag, size); ref(st, off_vector_length) = fix(NUM_OF_BUCKETS); return st; } @@ -35,7 +35,7 @@ make_symbol_table(ikpcb* pcb){ static long int compute_hash(ikptr str){ long int len = unfix(ref(str, off_string_length)); - char* data = (char*) str + off_string_data; + char* data = (char*)(long) str + off_string_data; long int h = len; char* last = data + len * string_char_size; while(data < last){ @@ -60,8 +60,8 @@ static int strings_eqp(ikptr str1, ikptr str2){ ikptr len = ref(str1, off_string_length); if(len == ref(str2, off_string_length)){ return - (memcmp((char*)str1+off_string_data, - (char*)str2+off_string_data, + (memcmp((char*)(long)str1+off_string_data, + (char*)(long)str2+off_string_data, unfix(len) * string_char_size) == 0); } diff --git a/src/ikarus-verify-integrity.c b/src/ikarus-verify-integrity.c index 45bfeee..bcaf75d 100644 --- a/src/ikarus-verify-integrity.c +++ b/src/ikarus-verify-integrity.c @@ -59,7 +59,7 @@ verify_code(char* x, char* base, unsigned int* svec, unsigned int* dvec){ assert(isa_fixnum(freevars)); assert(unfix(freevars) >= 0); - unsigned int rs = svec[page_idx((void*)rvec) - page_idx(base)]; + unsigned int rs = svec[page_idx((void*)(long)rvec) - page_idx(base)]; unsigned int cs = svec[page_idx(x) - page_idx(base)]; int cgen = cs&gen_mask; int rgen = rs&gen_mask; @@ -122,7 +122,7 @@ verify_code_page(char* p, unsigned int s, unsigned int d, fst += 0; if(fst != code_tag){ fprintf(stderr, "non code object with tag %p found\n", - (void*)fst); + (void*)(long)fst); exit(-1); } int code_size = unfix(ref(p, disp_code_code_size)); @@ -199,8 +199,8 @@ verify_page(char* p, char* base, unsigned int* svec, unsigned int* dvec){ void verify_integrity(ikpcb* pcb, char* where){ fprintf(stderr, "verifying in %s...\n", where); - char* mem_base = (char*)pcb->memory_base; - char* mem_end = (char*)pcb->memory_end; + char* mem_base = (char*)(long)pcb->memory_base; + char* mem_end = (char*)(long)pcb->memory_end; unsigned int* seg_vec = pcb->segment_vector_base; unsigned int* dir_vec = pcb->dirty_vector_base; char* mem = mem_base;