ikarus now compiles cleanly (but still unrunnable) in 64-bit mode.

This commit is contained in:
Abdulaziz Ghuloum 2008-01-01 21:42:52 -05:00
parent e0909d76fe
commit 66e9cd6415
10 changed files with 119 additions and 114 deletions

View File

@ -1 +1 @@
1305 1307

View File

@ -834,7 +834,7 @@ forward_guardians(gc_t* gc){
collect_loop(gc); collect_loop(gc);
while(cache){ while(cache){
ik_ptr_page* next = cache->next; 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; cache = next;
} }
} }

View File

@ -312,7 +312,7 @@ ikptr ik_safe_alloc(ikpcb* pcb, int size);
// ((((unsigned char*)(x)) + off_string_data + (int)(i))[0] = // ((((unsigned char*)(x)) + off_string_data + (int)(i))[0] =
// (((int)(c)) >> IK_CHAR_SHIFT)) // (((int)(c)) >> IK_CHAR_SHIFT))
#define string_set(x,i,c) \ #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) \ #define integer_to_char(x) \
((ikchar)((((int)(x)) << IK_CHAR_SHIFT) + IK_CHAR_TAG)) ((ikchar)((((int)(x)) << IK_CHAR_SHIFT) + IK_CHAR_TAG))
#define string_char_size 4 #define string_char_size 4

View File

@ -57,10 +57,10 @@ ikptr ik_exec_code(ikpcb* pcb, ikptr code_ptr){
pcb->next_k = k->next; pcb->next_k = k->next;
ikptr fbase = pcb->frame_base - wordsize; ikptr fbase = pcb->frame_base - wordsize;
ikptr new_fbase = fbase - framesize; ikptr new_fbase = fbase - framesize;
memmove((char*)new_fbase + argc, memmove((char*)(long)new_fbase + argc,
(char*)fbase + argc, (char*)(long)fbase + argc,
-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); argc = ik_asm_reenter(pcb, new_fbase, argc);
next_k = pcb->next_k; next_k = pcb->next_k;
} }

View File

@ -98,7 +98,7 @@ void ik_fasl_load(ikpcb* pcb, char* fasl_file){
p.code_ep = 0; p.code_ep = 0;
ikptr v = ik_fasl_read(pcb, &p); ikptr v = ik_fasl_read(pcb, &p);
if(p.marks_size){ 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 = 0;
p.marks_size = 0; p.marks_size = 0;
} }
@ -195,7 +195,7 @@ ik_relocate_code(ikptr code){
ikptr str = ref(p, wordsize); ikptr str = ref(p, wordsize);
char* name; char* name;
if(tagof(str) == bytevector_tag){ if(tagof(str) == bytevector_tag){
name = (char*) str + off_bytevector_data; name = (char*)(long) str + off_bytevector_data;
} else { } else {
fprintf(stderr, "foreign name is not a bytevector\n"); fprintf(stderr, "foreign name is not a bytevector\n");
exit(-1); exit(-1);
@ -207,7 +207,7 @@ ik_relocate_code(ikptr code){
fprintf(stderr, "failed to find foreign name %s: %s\n", name, err); fprintf(stderr, "failed to find foreign name %s: %s\n", name, err);
exit(-1); exit(-1);
} }
ref(data,code_off) = (ikptr)sym; ref(data,code_off) = (ikptr)(long)sym;
p += (2*wordsize); p += (2*wordsize);
} }
else { else {
@ -273,7 +273,7 @@ static ikptr do_read(ikpcb* pcb, fasl_port* p){
} }
else { else {
/* allocate marks */ /* 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*)); bzero(p->marks, pagesize*sizeof(ikptr*));
p->marks_size = pagesize; 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_code_size) = fix(code_size);
ref(code, disp_code_freevars) = freevars; ref(code, disp_code_freevars) = freevars;
ref(code, disp_code_annotation) = annotation; 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){ if(put_mark_index){
p->marks[put_mark_index] = code+vector_tag; 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); int size = align(len*string_char_size + disp_string_data);
ikptr str = ik_unsafe_alloc(pcb, size) + string_tag; ikptr str = ik_unsafe_alloc(pcb, size) + string_tag;
ref(str, off_string_length) = fix(len); 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); unsigned char* pi = (unsigned char*)(long)(str+off_string_data);
ikchar* pj = (ikchar*)(long)(str+off_string_data); ikchar* pj = (ikchar*)(long)(str+off_string_data);

View File

@ -47,7 +47,7 @@ ikrt_flfl_expt(ikptr a, ikptr b, ikptr z){
ikptr ikptr
ikrt_bytevector_to_flonum(ikptr x, ikpcb* pcb){ 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; ikptr r = ik_unsafe_alloc(pcb, flonum_size) + vector_tag;
ref(r, -vector_tag) = (ikptr)flonum_tag; ref(r, -vector_tag) = (ikptr)flonum_tag;
flonum_data(r) = v; flonum_data(r) = v;

View File

@ -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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t carry = mp_limb_t carry =
mpn_add_1((mp_limb_t*)(r+disp_bignum_data), mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
intx); intx);
if(carry){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t borrow = mp_limb_t borrow =
mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
intx); intx);
if(borrow){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t borrow = mp_limb_t borrow =
mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
- intx); - intx);
if(borrow){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t carry = mp_limb_t carry =
mpn_add_1((mp_limb_t*)(r+disp_bignum_data), mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
-intx); -intx);
if(carry){ if(carry){
@ -304,10 +304,10 @@ ikrt_bnbnplus(ikptr x, ikptr y, ikpcb* pcb){
pcb->root0 = 0; pcb->root0 = 0;
pcb->root1 = 0; pcb->root1 = 0;
mp_limb_t carry = mp_limb_t carry =
mpn_add((mp_limb_t*) (res+disp_bignum_data), mpn_add((mp_limb_t*)(long)(res+disp_bignum_data),
(mp_limb_t*) (s1-vector_tag+disp_bignum_data), (mp_limb_t*)(long)(s1-vector_tag+disp_bignum_data),
n1, n1,
(mp_limb_t*) (s2-vector_tag+disp_bignum_data), (mp_limb_t*)(long)(s2-vector_tag+disp_bignum_data),
n2); n2);
if(carry){ if(carry){
ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1; 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->root0 = 0;
pcb->root1 = 0; pcb->root1 = 0;
mp_limb_t burrow = mp_limb_t burrow =
mpn_sub((mp_limb_t*) (res + disp_bignum_data), mpn_sub((mp_limb_t*)(long)(res + disp_bignum_data),
(mp_limb_t*) (s1 - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(s1 - vector_tag + disp_bignum_data),
n1, n1,
(mp_limb_t*) (s2 - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(s2 - vector_tag + disp_bignum_data),
n2); n2);
if(burrow){ if(burrow){
fprintf(stderr, "BUG: Burrow error in bnbn+\n"); fprintf(stderr, "BUG: Burrow error in bnbn+\n");
@ -454,8 +454,8 @@ ikrt_bnnegate(ikptr x, ikpcb* pcb){
pcb->root0 = &x; pcb->root0 = &x;
ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); ikptr bn = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize));
pcb->root0 = 0; pcb->root0 = 0;
memcpy((char*)bn+disp_bignum_data, memcpy((char*)(long)bn+disp_bignum_data,
(char*)x-vector_tag+disp_bignum_data, (char*)(long)x-vector_tag+disp_bignum_data,
limb_count*wordsize); limb_count*wordsize);
ref(bn, 0) = (ikptr) ref(bn, 0) = (ikptr)
(bignum_tag | (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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int carry = long int carry =
mpn_add_1((mp_limb_t*)(r+disp_bignum_data), mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
intx); intx);
if(carry){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int borrow = long int borrow =
mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
intx); intx);
if(borrow){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int borrow = long int borrow =
mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
- intx); - intx);
if(borrow){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int carry = long int carry =
mpn_add_1((mp_limb_t*)(r+disp_bignum_data), mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(y - vector_tag + disp_bignum_data),
limb_count, limb_count,
-intx); -intx);
if(carry){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int carry = long int carry =
mpn_add_1((mp_limb_t*)(r+disp_bignum_data), mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(x - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data),
limb_count, limb_count,
-inty); -inty);
if(carry){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int borrow = long int borrow =
mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(x - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data),
limb_count, limb_count,
-inty); -inty);
if(borrow){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+limb_count*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int borrow = long int borrow =
mpn_sub_1((mp_limb_t*)(r+disp_bignum_data), mpn_sub_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(x - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data),
limb_count, limb_count,
inty); inty);
if(borrow){ 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data+(limb_count+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
long int carry = long int carry =
mpn_add_1((mp_limb_t*)(r+disp_bignum_data), mpn_add_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(x - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(x - vector_tag + disp_bignum_data),
limb_count, limb_count,
inty); inty);
if(carry){ 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)); ikptr res = ik_safe_alloc(pcb, align(disp_bignum_data + (n1+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t carry = mpn_add((mp_limb_t*) (res+disp_bignum_data), mp_limb_t carry =
(mp_limb_t*) (s1-vector_tag+disp_bignum_data), mpn_add((mp_limb_t*)(long)(res+disp_bignum_data),
n1, (mp_limb_t*)(long)(s1-vector_tag+disp_bignum_data),
(mp_limb_t*) (s2-vector_tag+disp_bignum_data), n1,
n2); (mp_limb_t*)(long)(s2-vector_tag+disp_bignum_data),
n2);
if(carry){ if(carry){
ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1; ref(res, disp_vector_data + xlimbs*wordsize) = (ikptr)1;
ref(res, 0) = (ikptr) ref(res, 0) = (ikptr)
@ -801,10 +802,10 @@ ikrt_bnbnminus(ikptr x, ikptr y, ikpcb* pcb){
pcb->root0 = 0; pcb->root0 = 0;
pcb->root0 = 0; pcb->root0 = 0;
long int burrow = long int burrow =
mpn_sub((mp_limb_t*) (res + disp_bignum_data), mpn_sub((mp_limb_t*)(long)(res + disp_bignum_data),
(mp_limb_t*) (s1 - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(s1 - vector_tag + disp_bignum_data),
n1, n1,
(mp_limb_t*) (s2 - vector_tag + disp_bignum_data), (mp_limb_t*)(long)(s2 - vector_tag + disp_bignum_data),
n2); n2);
if(burrow){ if(burrow){
fprintf(stderr, "BUG: Burrow error in bnbn-\n"); fprintf(stderr, "BUG: Burrow error in bnbn-\n");
@ -929,8 +930,8 @@ ikrt_fxbnmult(ikptr x, ikptr y, ikpcb* pcb){
pcb->root0 = &y; pcb->root0 = &y;
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + (limb_count+1)*wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + (limb_count+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t hi = mpn_mul_1((mp_limb_t*)(r+disp_bignum_data), mp_limb_t hi = mpn_mul_1((mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(y-vector_tag+disp_bignum_data), (mp_limb_t*)(long)(y-vector_tag+disp_bignum_data),
limb_count, limb_count,
s2); s2);
ref(r, disp_bignum_data + limb_count * wordsize) = (ikptr)hi; 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; pcb->root1 = 0;
mp_limb_t r; mp_limb_t r;
if(n1 >= n2){ if(n1 >= n2){
r = mpn_mul((mp_limb_t*)(bn+disp_bignum_data), r = mpn_mul((mp_limb_t*)(long)(bn+disp_bignum_data),
(mp_limb_t*)(x-vector_tag+disp_bignum_data), (mp_limb_t*)(long)(x-vector_tag+disp_bignum_data),
n1, n1,
(mp_limb_t*)(y-vector_tag+disp_bignum_data), (mp_limb_t*)(long)(y-vector_tag+disp_bignum_data),
n2); n2);
} else { } else {
r = mpn_mul((mp_limb_t*)(bn+disp_bignum_data), r = mpn_mul((mp_limb_t*)(long)(bn+disp_bignum_data),
(mp_limb_t*)(y-vector_tag+disp_bignum_data), (mp_limb_t*)(long)(y-vector_tag+disp_bignum_data),
n2, n2,
(mp_limb_t*)(x-vector_tag+disp_bignum_data), (mp_limb_t*)(long)(x-vector_tag+disp_bignum_data),
n1); n1);
} }
long int sign = long int sign =
@ -1169,8 +1170,8 @@ ikrt_bnlognot(ikptr x, ikpcb* pcb){
pcb->root0 = &x; pcb->root0 = &x;
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag);
mp_limb_t* rd = (mp_limb_t*)(r+disp_bignum_data); mp_limb_t* rd = (mp_limb_t*)(long)(r+disp_bignum_data);
int i; int i;
for(i=0; (i<n) && (s1[i] == 0); i++) { for(i=0; (i<n) && (s1[i] == 0); i++) {
rd[i] = -1; rd[i] = -1;
@ -1183,14 +1184,14 @@ ikrt_bnlognot(ikptr x, ikpcb* pcb){
} else { } else {
/* positive */ /* positive */
long int i; long int i;
mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag);
for(i=0; (i<n) && (s1[i] == -1); i++) {/*nothing*/} for(i=0; (i<n) && (s1[i] == -1); i++) {/*nothing*/}
if(i==n){ if(i==n){
pcb->root0 = &x; pcb->root0 = &x;
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + (n+1)*wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + (n+1)*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
bzero((char*)r+disp_bignum_data, n*wordsize); bzero((char*)(long)r+disp_bignum_data, n*wordsize);
((mp_limb_t*)(r+disp_bignum_data))[n] = 1; ((mp_limb_t*)(long)(r+disp_bignum_data))[n] = 1;
ref(r, 0) = (ikptr) ref(r, 0) = (ikptr)
(bignum_tag | (1<<bignum_sign_shift) | ((n+1) << bignum_length_shift)); (bignum_tag | (1<<bignum_sign_shift) | ((n+1) << bignum_length_shift));
return r+vector_tag; return r+vector_tag;
@ -1198,8 +1199,8 @@ ikrt_bnlognot(ikptr x, ikpcb* pcb){
pcb->root0 = &x; pcb->root0 = &x;
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag);
mp_limb_t* rd = (mp_limb_t*)(r+disp_bignum_data); mp_limb_t* rd = (mp_limb_t*)(long)(r+disp_bignum_data);
int j; int j;
for(j=0; j<i; j++){ rd[j] = 0; } for(j=0; j<i; j++){ rd[j] = 0; }
rd[i] = s1[i] + 1; rd[i] = s1[i] + 1;
@ -1226,9 +1227,9 @@ ikrt_bnbnlogand(ikptr x, ikptr y, ikpcb* pcb){
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n1*wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n1*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
pcb->root1 = 0; pcb->root1 = 0;
mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag);
mp_limb_t* s2 = ((mp_limb_t*)(y+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*)(r+disp_bignum_data)); mp_limb_t* s = (mp_limb_t*)(long)(r+disp_bignum_data);
bits_compliment(s1, s, n1); bits_compliment(s1, s, n1);
bits_compliment_logand(s2, s, s, n2); bits_compliment_logand(s2, s, s, n2);
bits_compliment(s, s, n1); 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + n1*wordsize));
pcb->root0 = 0; pcb->root0 = 0;
pcb->root1 = 0; pcb->root1 = 0;
mp_limb_t* s1 = ((mp_limb_t*)(x+disp_bignum_data-vector_tag)); mp_limb_t* s1 = (mp_limb_t*)(long)(x+disp_bignum_data-vector_tag);
mp_limb_t* s2 = ((mp_limb_t*)(y+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*)(r+disp_bignum_data)); mp_limb_t* s = (mp_limb_t*)(long)(r+disp_bignum_data);
bits_compliment_logand(s2, s1, s, n1); bits_compliment_logand(s2, s1, s, n1);
return normalize_bignum(n1, 0, r); return normalize_bignum(n1, 0, r);
} else { } 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize));
pcb->root0 = 0; pcb->root0 = 0;
bits_compliment_with_carry( bits_compliment_with_carry(
(mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), (mp_limb_t*)(long)(x+off_bignum_data+whole_limb_shift*wordsize),
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
new_limb_count, 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( bits_compliment(
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
new_limb_count); new_limb_count);
return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r); return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r);
} else { } 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize));
pcb->root0 = 0; pcb->root0 = 0;
bits_compliment_with_carry( bits_compliment_with_carry(
(mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), (mp_limb_t*)(long)(x+off_bignum_data+whole_limb_shift*wordsize),
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
new_limb_count, 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( copy_bits_shifting_right(
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
new_limb_count, new_limb_count,
bit_shift); bit_shift);
*((mp_limb_t*)(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)); |= (-1 << (32 - bit_shift));
bits_compliment( bits_compliment(
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
new_limb_count); new_limb_count);
return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r); return normalize_bignum(new_limb_count, 1 << bignum_sign_shift, r);
fprintf(stderr, "not yet for negative bignum_shift\n"); 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)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + new_limb_count * wordsize));
pcb->root0 = 0; pcb->root0 = 0;
if(bit_shift == 0){ if(bit_shift == 0){
memcpy((char*)r+disp_bignum_data, memcpy((char*)(long)r+disp_bignum_data,
(char*)x+off_bignum_data+whole_limb_shift*wordsize, (char*)(long)x+off_bignum_data+whole_limb_shift*wordsize,
new_limb_count * wordsize); new_limb_count * wordsize);
return normalize_bignum(new_limb_count, 0, r); return normalize_bignum(new_limb_count, 0, r);
} else { } else {
copy_bits_shifting_right( copy_bits_shifting_right(
(mp_limb_t*)(x+off_bignum_data+whole_limb_shift*wordsize), (mp_limb_t*)(long)(x+off_bignum_data+whole_limb_shift*wordsize),
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
new_limb_count, new_limb_count,
bit_shift); bit_shift);
return normalize_bignum(new_limb_count, 0, r); 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 limb_count = (m >> 5) + 2; /* FIXME: 5 are the bits in 32-bit num */
int bit_shift = m & 31; int bit_shift = m & 31;
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize));
unsigned int* s = (unsigned int*)(r+disp_bignum_data); unsigned int* s = (unsigned int*)(long)(r+disp_bignum_data);
bzero(s, limb_count * wordsize); bzero(s, limb_count * wordsize);
if(n >= 0){ if(n >= 0){
if(bit_shift){ if(bit_shift){
@ -1428,19 +1429,20 @@ ikrt_bignum_shift_left(ikptr x, ikptr y, ikpcb* pcb){
pcb->root0 = &x; pcb->root0 = &x;
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize));
pcb->root0 = 0; 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); 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); return normalize_bignum(limb_count, bnfst_negative(fst), r);
} else { } else {
int limb_count = n + whole_limb_shift + 1; int limb_count = n + whole_limb_shift + 1;
pcb->root0 = &x; pcb->root0 = &x;
ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize)); ikptr r = ik_safe_alloc(pcb, align(disp_bignum_data + limb_count * wordsize));
pcb->root0 = 0; 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); bzero(s, whole_limb_shift*wordsize);
copy_bits_shifting_left( copy_bits_shifting_left(
(unsigned int*)(x+off_bignum_data), (unsigned int*)(long)(x+off_bignum_data),
s+whole_limb_shift, s+whole_limb_shift,
n, n,
bit_shift); bit_shift);
@ -1501,12 +1503,12 @@ ikrt_bnbndivrem(ikptr x, ikptr y, ikpcb* pcb){
pcb->root0 = 0; pcb->root0 = 0;
pcb->root1 = 0; pcb->root1 = 0;
mpn_tdiv_qr ( mpn_tdiv_qr (
(mp_limb_t*)(q+disp_bignum_data), (mp_limb_t*)(long)(q+disp_bignum_data),
(mp_limb_t*)(r+disp_bignum_data), (mp_limb_t*)(long)(r+disp_bignum_data),
0, 0,
(mp_limb_t*)(x+off_bignum_data), (mp_limb_t*)(long)(x+off_bignum_data),
xn, xn,
(mp_limb_t*)(y+off_bignum_data), (mp_limb_t*)(long)(y+off_bignum_data),
yn); yn);
if(bnfst_negative(xfst)){ if(bnfst_negative(xfst)){
@ -1562,9 +1564,9 @@ ikrt_bnfxdivrem(ikptr x, ikptr y, ikpcb* pcb){
pcb->root0 = &x; pcb->root0 = &x;
ikptr quot = ik_safe_alloc(pcb, align(s2n*wordsize + disp_bignum_data)); ikptr quot = ik_safe_alloc(pcb, align(s2n*wordsize + disp_bignum_data));
pcb->root0 = 0; 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 rv = mpn_divrem_1(
(mp_limb_t*)(quot+disp_bignum_data), (mp_limb_t*)(long)(quot+disp_bignum_data),
0, 0,
s2p, s2p,
s2n, s2n,
@ -1604,7 +1606,7 @@ ikrt_bnfxdivrem(ikptr x, ikptr y, ikpcb* pcb){
ikptr ikptr
ikrt_bnfx_modulo(ikptr x, ikptr y, ikpcb* pcb){ ikrt_bnfx_modulo(ikptr x, ikptr y, ikpcb* pcb){
int yint = unfix(y); 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); ikptr fst = ref(x, -vector_tag);
mp_size_t s2n = bnfst_limb_count(fst); mp_size_t s2n = bnfst_limb_count(fst);
if(yint < 0){ if(yint < 0){
@ -1645,7 +1647,7 @@ limb_length(unsigned int n){
ikptr ikptr
ikrt_bignum_length(ikptr x){ ikrt_bignum_length(ikptr x){
ikptr fst = ref(x, -vector_tag); 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_size_t sn = bnfst_limb_count(fst);
mp_limb_t last = sp[sn-1]; mp_limb_t last = sp[sn-1];
int n0 = limb_length(last); 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"); fprintf(stderr, "Error allocating space for bignum\n");
exit(-1); 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 = mp_size_t bytes =
mpn_get_str(mem+nbsize, /* output string */ mpn_get_str(mem+nbsize, /* output string */
10, /* base */ 10, /* base */

View File

@ -64,7 +64,7 @@ extend_table_maybe(ikptr p, int size, ikpcb* pcb){
memcpy((char*)(long)(v+new_vec_size-old_vec_size), memcpy((char*)(long)(v+new_vec_size-old_vec_size),
(char*)(long)pcb->dirty_vector_base, (char*)(long)pcb->dirty_vector_base,
old_vec_size); 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_base = (unsigned int*)(long)v;
pcb->dirty_vector = (v - new_lo * pagesize); pcb->dirty_vector = (v - new_lo * pagesize);
ikptr s = ik_mmap(new_vec_size); ikptr s = ik_mmap(new_vec_size);
@ -916,7 +916,8 @@ ikrt_getenv(ikptr bv, ikpcb* pcb){
ikptr ikptr
ikrt_make_vector1(ikptr len, ikpcb* pcb){ 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)); ikptr s = ik_safe_alloc(pcb, align(len + disp_vector_data));
ref(s, 0) = len; ref(s, 0) = len;
memset((char*)(long)(s+disp_vector_data), 0, len); memset((char*)(long)(s+disp_vector_data), 0, len);

View File

@ -27,7 +27,7 @@ make_symbol_table(ikpcb* pcb){
#define NUM_OF_BUCKETS 4096 /* power of 2 */ #define NUM_OF_BUCKETS 4096 /* power of 2 */
int size = align_to_next_page(disp_vector_data + NUM_OF_BUCKETS * wordsize); int size = align_to_next_page(disp_vector_data + NUM_OF_BUCKETS * wordsize);
ikptr st = ik_mmap_ptr(size, 0, pcb) + vector_tag; 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); ref(st, off_vector_length) = fix(NUM_OF_BUCKETS);
return st; return st;
} }
@ -35,7 +35,7 @@ make_symbol_table(ikpcb* pcb){
static long int static long int
compute_hash(ikptr str){ compute_hash(ikptr str){
long int len = unfix(ref(str, off_string_length)); 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; long int h = len;
char* last = data + len * string_char_size; char* last = data + len * string_char_size;
while(data < last){ while(data < last){
@ -60,8 +60,8 @@ static int strings_eqp(ikptr str1, ikptr str2){
ikptr len = ref(str1, off_string_length); ikptr len = ref(str1, off_string_length);
if(len == ref(str2, off_string_length)){ if(len == ref(str2, off_string_length)){
return return
(memcmp((char*)str1+off_string_data, (memcmp((char*)(long)str1+off_string_data,
(char*)str2+off_string_data, (char*)(long)str2+off_string_data,
unfix(len) * string_char_size) unfix(len) * string_char_size)
== 0); == 0);
} }

View File

@ -59,7 +59,7 @@ verify_code(char* x, char* base, unsigned int* svec, unsigned int* dvec){
assert(isa_fixnum(freevars)); assert(isa_fixnum(freevars));
assert(unfix(freevars) >= 0); 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)]; unsigned int cs = svec[page_idx(x) - page_idx(base)];
int cgen = cs&gen_mask; int cgen = cs&gen_mask;
int rgen = rs&gen_mask; int rgen = rs&gen_mask;
@ -122,7 +122,7 @@ verify_code_page(char* p, unsigned int s, unsigned int d,
fst += 0; fst += 0;
if(fst != code_tag){ if(fst != code_tag){
fprintf(stderr, "non code object with tag %p found\n", fprintf(stderr, "non code object with tag %p found\n",
(void*)fst); (void*)(long)fst);
exit(-1); exit(-1);
} }
int code_size = unfix(ref(p, disp_code_code_size)); 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 void
verify_integrity(ikpcb* pcb, char* where){ verify_integrity(ikpcb* pcb, char* where){
fprintf(stderr, "verifying in %s...\n", where); fprintf(stderr, "verifying in %s...\n", where);
char* mem_base = (char*)pcb->memory_base; char* mem_base = (char*)(long)pcb->memory_base;
char* mem_end = (char*)pcb->memory_end; char* mem_end = (char*)(long)pcb->memory_end;
unsigned int* seg_vec = pcb->segment_vector_base; unsigned int* seg_vec = pcb->segment_vector_base;
unsigned int* dir_vec = pcb->dirty_vector_base; unsigned int* dir_vec = pcb->dirty_vector_base;
char* mem = mem_base; char* mem = mem_base;