be careful around 1L and friends
This commit is contained in:
parent
99dafc9172
commit
c52dda489b
4
C/alloc.c
Normal file → Executable file
4
C/alloc.c
Normal file → Executable file
@ -821,7 +821,7 @@ ExtendWorkSpace(Int s, int fixed_allocation)
|
|||||||
Yap_PrologMode = ExtendStackMode;
|
Yap_PrologMode = ExtendStackMode;
|
||||||
|
|
||||||
#if DEBUG_WIN32_ALLOC
|
#if DEBUG_WIN32_ALLOC
|
||||||
fprintf(stderr,"trying: %p--%x %d\n",b, s, fixed_allocation);
|
fprintf(stderr,"trying: %p (" Int_FORMAT "K) %d\n",b, s/1024, fixed_allocation);
|
||||||
#endif
|
#endif
|
||||||
if (fixed_allocation) {
|
if (fixed_allocation) {
|
||||||
b = VirtualAlloc(b, s, MEM_RESERVE, PAGE_NOACCESS);
|
b = VirtualAlloc(b, s, MEM_RESERVE, PAGE_NOACCESS);
|
||||||
@ -840,7 +840,7 @@ ExtendWorkSpace(Int s, int fixed_allocation)
|
|||||||
NULL, GetLastError(),
|
NULL, GetLastError(),
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 256,
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 256,
|
||||||
NULL);
|
NULL);
|
||||||
fprintf(stderr,"NOT OK1: %p--%p %s\n",b, brk, msg);
|
fprintf(stderr,"NOT OK1: %p %p %s\n", brk, b, msg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
6
C/arith1.c
Normal file → Executable file
6
C/arith1.c
Normal file → Executable file
@ -150,7 +150,7 @@ msb(Int inp) /* calculate the most significant bit for an integer */
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (off) {
|
while (off) {
|
||||||
Int limit = 1L << (off);
|
Int limit = ((CELL)1) << (off);
|
||||||
if (inp >= limit) {
|
if (inp >= limit) {
|
||||||
out += off;
|
out += off;
|
||||||
inp >>= off;
|
inp >>= off;
|
||||||
@ -179,7 +179,7 @@ lsb(Int inp) /* calculate the least significant bit for an integer */
|
|||||||
if (!(inp & 0xffL)) {inp >>= 8; out += 8;}
|
if (!(inp & 0xffL)) {inp >>= 8; out += 8;}
|
||||||
if (!(inp & 0xfL)) {inp >>= 4; out += 4;}
|
if (!(inp & 0xfL)) {inp >>= 4; out += 4;}
|
||||||
if (!(inp & 0x3L)) {inp >>= 2; out += 2;}
|
if (!(inp & 0x3L)) {inp >>= 2; out += 2;}
|
||||||
if (!(inp & 0x1L)) out++;
|
if (!(inp & ((CELL)0x1))) out++;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ static Int
|
|||||||
popcount(Int inp) /* calculate the least significant bit for an integer */
|
popcount(Int inp) /* calculate the least significant bit for an integer */
|
||||||
{
|
{
|
||||||
/* the obvious solution: do it by using binary search */
|
/* the obvious solution: do it by using binary search */
|
||||||
Int c = 0, j = 0, m = 1L;
|
Int c = 0, j = 0, m = ((CELL)1);
|
||||||
|
|
||||||
if (inp < 0) {
|
if (inp < 0) {
|
||||||
return Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, MkIntegerTerm(inp),
|
return Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, MkIntegerTerm(inp),
|
||||||
|
6
C/arith2.c
Normal file → Executable file
6
C/arith2.c
Normal file → Executable file
@ -542,12 +542,12 @@ ipow(Int x, Int p)
|
|||||||
{
|
{
|
||||||
Int r;
|
Int r;
|
||||||
|
|
||||||
if (p == 0) return 1L;
|
if (p == 0) return ((CELL)1);
|
||||||
if (x == 0 && p > 0) return 0L;
|
if (x == 0 && p > 0) return 0L;
|
||||||
if(p < 0)
|
if(p < 0)
|
||||||
return (-p % 2) ? x : 1L;
|
return (-p % 2) ? x : ((CELL)1);
|
||||||
|
|
||||||
r = 1L;
|
r = ((CELL)1);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(p & 1) {
|
if(p & 1) {
|
||||||
if (mul_overflow((r*x), r, x)) {
|
if (mul_overflow((r*x), r, x)) {
|
||||||
|
25
C/compiler.c
25
C/compiler.c
@ -565,7 +565,7 @@ compile_sf_term(Term t, int argno, int level)
|
|||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "illegal argument of soft functor";
|
Yap_ErrorMessage = "illegal argument of soft functor";
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c_var(t, -argno, arity, level, cglobs);
|
c_var(t, -argno, arity, level, cglobs);
|
||||||
@ -592,7 +592,7 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
|||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "exceed maximum arity of compiled goal";
|
Yap_ErrorMessage = "exceed maximum arity of compiled goal";
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||||
}
|
}
|
||||||
if (Arity > cglobs->max_args)
|
if (Arity > cglobs->max_args)
|
||||||
cglobs->max_args = Arity;
|
cglobs->max_args = Arity;
|
||||||
@ -2247,14 +2247,10 @@ static CELL *
|
|||||||
init_bvarray(int nperm, compiler_struct *cglobs)
|
init_bvarray(int nperm, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
CELL *vinfo = NULL;
|
CELL *vinfo = NULL;
|
||||||
unsigned int i;
|
size_t sz = sizeof(CELL)*(1+nperm/(8*sizeof(CELL)));
|
||||||
CELL *vptr;
|
vinfo = (CELL *)Yap_AllocCMem(sz, &cglobs->cint);
|
||||||
|
memset((void *)vinfo, 0, sz);
|
||||||
vptr = vinfo = (CELL *)Yap_AllocCMem(sizeof(CELL)*(1+nperm/(8*sizeof(CELL))), &cglobs->cint);
|
return vinfo;
|
||||||
for (i = 0; i <= nperm/(8*sizeof(CELL)); i++) {
|
|
||||||
*vptr++ = (CELL)(0L);
|
|
||||||
}
|
|
||||||
return(vinfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2273,15 +2269,16 @@ clear_bvarray(int var, CELL *bvarray
|
|||||||
var -= max;
|
var -= max;
|
||||||
}
|
}
|
||||||
/* now put a 0 on it, from now on the variable is initialised */
|
/* now put a 0 on it, from now on the variable is initialised */
|
||||||
nbit = (1L << var);
|
nbit = ((CELL)1 << var);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (*bvarray & nbit) {
|
if (*bvarray & nbit) {
|
||||||
/* someone had already marked this variable: complain */
|
/* someone had already marked this variable: complain */
|
||||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "compiler internal error: variable initialised twice";
|
Yap_ErrorMessage = "compiler internal error: variable initialised twice";
|
||||||
|
fprintf(stderr," vsc: compiling7\n");
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||||
}
|
}
|
||||||
cglobs->pbvars++;
|
cglobs->pbvars++;
|
||||||
#endif
|
#endif
|
||||||
@ -2322,7 +2319,7 @@ push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
|
|||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "Too many embedded disjunctions";
|
Yap_ErrorMessage = "Too many embedded disjunctions";
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||||
}
|
}
|
||||||
/* the label instruction */
|
/* the label instruction */
|
||||||
bvstack[bvindex].lab = label;
|
bvstack[bvindex].lab = label;
|
||||||
@ -2345,7 +2342,7 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
|||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "No embedding in disjunctions";
|
Yap_ErrorMessage = "No embedding in disjunctions";
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||||
}
|
}
|
||||||
env_size = (bvstack[bvindex-1].pc)->rnd1;
|
env_size = (bvstack[bvindex-1].pc)->rnd1;
|
||||||
size = env_size/(8*sizeof(CELL));
|
size = env_size/(8*sizeof(CELL));
|
||||||
|
4
C/dbase.c
Normal file → Executable file
4
C/dbase.c
Normal file → Executable file
@ -304,14 +304,14 @@ static void create_hash_table(DBProp p, Int hint) {
|
|||||||
if (hint < p->NOfEntries)
|
if (hint < p->NOfEntries)
|
||||||
hint = p->NOfEntries;
|
hint = p->NOfEntries;
|
||||||
while (off) {
|
while (off) {
|
||||||
Int limit = 1L << (off);
|
Int limit = ((CELL)1) << (off);
|
||||||
if (inp >= limit) {
|
if (inp >= limit) {
|
||||||
out += off;
|
out += off;
|
||||||
inp >>= off;
|
inp >>= off;
|
||||||
}
|
}
|
||||||
off >>= 1;
|
off >>= 1;
|
||||||
}
|
}
|
||||||
if ((size = 1L << out) < hint)
|
if ((size = ((CELL)1) << out) < hint)
|
||||||
hint <<= 1;
|
hint <<= 1;
|
||||||
/* clean up the table */
|
/* clean up the table */
|
||||||
pt = tbl = (hash_db_entry *)AllocDBSpace(hint*sizeof(hash_db_entry));
|
pt = tbl = (hash_db_entry *)AllocDBSpace(hint*sizeof(hash_db_entry));
|
||||||
|
@ -1507,7 +1507,7 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
|
|||||||
pvbmap += tsize/(sizeof(CELL)*8);
|
pvbmap += tsize/(sizeof(CELL)*8);
|
||||||
bmap = *pvbmap;
|
bmap = *pvbmap;
|
||||||
} else {
|
} else {
|
||||||
bmap = -1L;
|
bmap = ((CELL)-1);
|
||||||
}
|
}
|
||||||
bmap = (Int)(((CELL)bmap) << currv);
|
bmap = (Int)(((CELL)bmap) << currv);
|
||||||
}
|
}
|
||||||
@ -1518,7 +1518,7 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
|
|||||||
pvbmap--;
|
pvbmap--;
|
||||||
bmap = *pvbmap;
|
bmap = *pvbmap;
|
||||||
} else {
|
} else {
|
||||||
bmap = -1L;
|
bmap = ((CELL)-1);
|
||||||
}
|
}
|
||||||
currv = 0;
|
currv = 0;
|
||||||
}
|
}
|
||||||
@ -2734,7 +2734,7 @@ sweep_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
|
|||||||
pvbmap += tsize/(sizeof(CELL)*8);
|
pvbmap += tsize/(sizeof(CELL)*8);
|
||||||
bmap = *pvbmap;
|
bmap = *pvbmap;
|
||||||
} else {
|
} else {
|
||||||
bmap = -1L;
|
bmap = ((CELL)-1);
|
||||||
}
|
}
|
||||||
bmap = (Int)(((CELL)bmap) << currv);
|
bmap = (Int)(((CELL)bmap) << currv);
|
||||||
}
|
}
|
||||||
@ -2745,7 +2745,7 @@ sweep_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
|
|||||||
pvbmap--;
|
pvbmap--;
|
||||||
bmap = *pvbmap;
|
bmap = *pvbmap;
|
||||||
} else {
|
} else {
|
||||||
bmap = -1L;
|
bmap = ((CELL)-1);
|
||||||
}
|
}
|
||||||
currv = 0;
|
currv = 0;
|
||||||
}
|
}
|
||||||
|
@ -3980,7 +3980,7 @@ p_in_range2(void) {
|
|||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_max_tagged_integer(void) {
|
p_max_tagged_integer(void) {
|
||||||
return Yap_unify(ARG1, MkIntTerm(MAX_ABS_INT-1L));
|
return Yap_unify(ARG1, MkIntTerm(MAX_ABS_INT-((CELL)1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
|
0
H/compile.h
Normal file → Executable file
0
H/compile.h
Normal file → Executable file
Reference in New Issue
Block a user