L constants are evil in 64 bits

This commit is contained in:
Vítor Santos Costa 2010-05-11 12:25:49 +01:00
parent c52dda489b
commit be2a3a635e
14 changed files with 37 additions and 31 deletions

4
C/absmi.c Normal file → Executable file
View File

@ -835,7 +835,7 @@ Yap_absmi(int inp)
cut_b = LCL0-(CELL *)(ASP[E_CB]); cut_b = LCL0-(CELL *)(ASP[E_CB]);
saveregs(); saveregs();
if(!Yap_growtrail (0, FALSE)) { if(!Yap_growtrail (0, FALSE)) {
Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * 16 * 1024L); Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16);
setregs(); setregs();
FAIL(); FAIL();
} }
@ -14277,7 +14277,7 @@ Yap_absmi(int inp)
#endif #endif
saveregs_and_ycache(); saveregs_and_ycache();
if(!Yap_growtrail (0, FALSE)) { if(!Yap_growtrail (0, FALSE)) {
Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * 16 * 1024L); Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16);
setregs_and_ycache(); setregs_and_ycache();
FAIL(); FAIL();
} }

2
C/amasm.c Normal file → Executable file
View File

@ -3769,7 +3769,7 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep)
case OUT_OF_TRAIL_ERROR: case OUT_OF_TRAIL_ERROR:
/* don't just return NULL */ /* don't just return NULL */
ARG1 = *tp; ARG1 = *tp;
if (!Yap_growtrail(64 * 1024L, FALSE)) { if (!Yap_growtrail(K64, FALSE)) {
return NULL; return NULL;
} }
Yap_Error_TYPE = YAP_NO_ERROR; Yap_Error_TYPE = YAP_NO_ERROR;

4
C/computils.c Normal file → Executable file
View File

@ -97,9 +97,9 @@ static char *
AllocCMem (UInt size, struct intermediates *cip) AllocCMem (UInt size, struct intermediates *cip)
{ {
#if SIZEOF_INT_P==8 #if SIZEOF_INT_P==8
size = (size + 7) & 0xfffffffffffffff8L; size = (size + 7) & ((UInt)-8);
#else #else
size = (size + 3) & 0xfffffffcL; size = (size + 3) & ((UInt)0xfffffffc);
#endif #endif
#if USE_SYSTEM_MALLOC #if USE_SYSTEM_MALLOC
if (!cip->blks || cip->blk_cur+size > cip->blk_top) { if (!cip->blks || cip->blk_cur+size > cip->blk_top) {

View File

@ -249,10 +249,10 @@ STATIC_PROTO(DBProp find_int_key, (Int));
static UInt new_trail_size(void) static UInt new_trail_size(void)
{ {
UInt sz = (Yap_TrailTop-(ADDR)TR)/2; UInt sz = (Yap_TrailTop-(ADDR)TR)/2;
if (sz < 64 * 1024L) if (sz < K64)
return 64 * 1024L; return K64;
if (sz > 1024*1024L) if (sz > M1)
return 1024*1024L; return M1;
return sz; return sz;
} }

2
C/gprof.c Normal file → Executable file
View File

@ -756,7 +756,7 @@ showprofres(UInt type) {
pr->pcs = 0L; pr->pcs = 0L;
pr++; pr++;
if (pr > (clauseentry *)Yap_TrailTop - 1024) { if (pr > (clauseentry *)Yap_TrailTop - 1024) {
Yap_growtrail(64 * 1024L, FALSE); Yap_growtrail(K64, FALSE);
} }
ProfPreds++; ProfPreds++;

14
C/grow.c Normal file → Executable file
View File

@ -1236,7 +1236,7 @@ fix_tabling_info(void)
static int static int
do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep) do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
{ {
unsigned long size = sizeof(CELL) * 16 * 1024L; unsigned long size = sizeof(CELL) * K16;
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows); int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
unsigned long sz = size << shift_factor; unsigned long sz = size << shift_factor;
@ -1252,7 +1252,7 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
size = YAP_ALLOC_SIZE; size = YAP_ALLOC_SIZE;
sz = AdjustPageSize(SizeOfOverflow); sz = AdjustPageSize(SizeOfOverflow);
} }
while(sz >= sizeof(CELL) * 16 * 1024L && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep)) { while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep)) {
size = size/2; size = size/2;
sz = size << shift_factor; sz = size << shift_factor;
if (sz < in_size) { if (sz < in_size) {
@ -1277,7 +1277,7 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
#ifdef TABLING #ifdef TABLING
fix_tabling_info(); fix_tabling_info();
#endif /* TABLING */ #endif /* TABLING */
if (sz >= sizeof(CELL) * 16 * 1024L) { if (sz >= sizeof(CELL) * K16) {
LOCK(SignalLock); LOCK(SignalLock);
ActiveSignals &= ~YAP_CDOVF_SIGNAL; ActiveSignals &= ~YAP_CDOVF_SIGNAL;
if (!ActiveSignals) if (!ActiveSignals)
@ -1427,7 +1427,7 @@ Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
int int
Yap_growglobal(CELL **ptr) Yap_growglobal(CELL **ptr)
{ {
unsigned long sz = sizeof(CELL) * 16 * 1024L; unsigned long sz = sizeof(CELL) * K16;
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
if (NOfThreads != 1) { if (NOfThreads != 1) {
@ -1662,8 +1662,8 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
size *= 2; size *= 2;
if (size < YAP_ALLOC_SIZE) if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE; size = YAP_ALLOC_SIZE;
if (size > 2048*1024) if (size > M2)
size = 2048*1024; size = M2;
if (size < size0) if (size < size0)
size=size0; size=size0;
/* adjust to a multiple of 256) */ /* adjust to a multiple of 256) */
@ -1824,7 +1824,7 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
Int p_size = FOREIGN_ThreadHandle(worker_p).ssize+FOREIGN_ThreadHandle(worker_p).tsize; Int p_size = FOREIGN_ThreadHandle(worker_p).ssize+FOREIGN_ThreadHandle(worker_p).tsize;
Int q_size = FOREIGN_ThreadHandle(worker_q).ssize+FOREIGN_ThreadHandle(worker_q).tsize; Int q_size = FOREIGN_ThreadHandle(worker_q).ssize+FOREIGN_ThreadHandle(worker_q).tsize;
if (p_size != q_size) { if (p_size != q_size) {
if (!(FOREIGN_ThreadHandle(worker_q).stack_address = realloc(FOREIGN_ThreadHandle(worker_q).stack_address,p_size*1024))) { if (!(FOREIGN_ThreadHandle(worker_q).stack_address = realloc(FOREIGN_ThreadHandle(worker_q).stack_address,p_size*K1))) {
exit(1); exit(1);
} }
} }

View File

@ -4025,7 +4025,7 @@ static Int
} }
if (Yap_Error_TYPE == OUT_OF_TRAIL_ERROR) { if (Yap_Error_TYPE == OUT_OF_TRAIL_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR; Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growtrail (sizeof(CELL) * 16 * 1024L, FALSE)) { if (!Yap_growtrail (sizeof(CELL) * K16, FALSE)) {
return FALSE; return FALSE;
} }
} else if (Yap_Error_TYPE == OUT_OF_AUXSPACE_ERROR) { } else if (Yap_Error_TYPE == OUT_OF_AUXSPACE_ERROR) {

2
C/scanner.c Normal file → Executable file
View File

@ -163,7 +163,7 @@ AllocScannerMemory(unsigned int size)
ScannerExtraBlocks = ptr; ScannerExtraBlocks = ptr;
return (char *)(ptr+1); return (char *)(ptr+1);
} else if (Yap_TrailTop <= AuxSpScan+size) { } else if (Yap_TrailTop <= AuxSpScan+size) {
UInt alloc_size = sizeof(CELL) * 16 * 1024L; UInt alloc_size = sizeof(CELL) * K16;
if (size > alloc_size) if (size > alloc_size)
alloc_size = size; alloc_size = size;

View File

@ -1059,8 +1059,8 @@ HandleSIGSEGV(int sig, siginfo_t *sip, ucontext_t *uap)
sip->si_code != SI_NOINFO && sip->si_code != SI_NOINFO &&
sip->si_code == SEGV_MAPERR && sip->si_code == SEGV_MAPERR &&
(void *)(sip->si_addr) > (void *)(Yap_HeapBase) && (void *)(sip->si_addr) > (void *)(Yap_HeapBase) &&
(void *)(sip->si_addr) < (void *)(Yap_TrailTop+64 * 1024L)) { (void *)(sip->si_addr) < (void *)(Yap_TrailTop+K64)) {
Yap_growtrail(64 * 1024L, TRUE); Yap_growtrail(K64, TRUE);
} else } else
#endif #endif
{ {
@ -1204,7 +1204,7 @@ SearchForTrailFault(siginfo_t *siginfo)
if ((ptr > (void *)Yap_TrailTop-1024 && if ((ptr > (void *)Yap_TrailTop-1024 &&
TR < (tr_fr_ptr) Yap_TrailTop+(64*1024))) { TR < (tr_fr_ptr) Yap_TrailTop+(64*1024))) {
if (!Yap_growtrail(64*1024, TRUE)) { if (!Yap_growtrail(64*1024, TRUE)) {
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "YAP failed to reserve %ld bytes in growtrail", 64*1024L); Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "YAP failed to reserve %ld bytes in growtrail", K64);
} }
/* just in case, make sure the OS keeps the signal handler. */ /* just in case, make sure the OS keeps the signal handler. */
/* my_signal_info(SIGSEGV, HandleSIGSEGV); */ /* my_signal_info(SIGSEGV, HandleSIGSEGV); */
@ -1334,13 +1334,13 @@ SearchForTrailFault(void)
#if OS_HANDLES_TR_OVERFLOW && !USE_SYSTEM_MALLOC #if OS_HANDLES_TR_OVERFLOW && !USE_SYSTEM_MALLOC
if ((TR > (tr_fr_ptr)Yap_TrailTop-1024 && if ((TR > (tr_fr_ptr)Yap_TrailTop-1024 &&
TR < (tr_fr_ptr)Yap_TrailTop+(64*1024))|| Yap_DBTrailOverflow()) { TR < (tr_fr_ptr)Yap_TrailTop+(64*1024))|| Yap_DBTrailOverflow()) {
long trsize = 64*2014L; long trsize = K64;
while ((CELL)TR > (CELL)Yap_TrailTop+trsize) { while ((CELL)TR > (CELL)Yap_TrailTop+trsize) {
trsize += 64*2014L; trsize += K64;
} }
if (!Yap_growtrail(trsize, TRUE)) { if (!Yap_growtrail(trsize, TRUE)) {
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "YAP failed to reserve %ld bytes in growtrail", 64*1024L); Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "YAP failed to reserve %ld bytes in growtrail", K64);
} }
/* just in case, make sure the OS keeps the signal handler. */ /* just in case, make sure the OS keeps the signal handler. */
/* my_signal_info(SIGSEGV, HandleSIGSEGV); */ /* my_signal_info(SIGSEGV, HandleSIGSEGV); */

6
H/Yap.h Normal file → Executable file
View File

@ -303,6 +303,12 @@ extern char Yap_Option[20];
#define ALIGN_LONGS 1 #define ALIGN_LONGS 1
#endif #endif
#define K1 ((CELL)1024)
#define K16 ((CELL)(1024*64))
#define K64 ((CELL)(1024*64))
#define M1 ((CELL)(1024*1024))
#define M2 ((CELL)(2048*1024))
/* basic data types */ /* basic data types */
typedef UInt CELL; typedef UInt CELL;

4
H/Yatom.h Normal file → Executable file
View File

@ -1394,8 +1394,8 @@ typedef enum
#include "YapHeap.h" #include "YapHeap.h"
#define PredHashInitialSize 1039L #define PredHashInitialSize ((UInt)1039)
#define PredHashIncrement 7919L #define PredHashIncrement ((UInt)7919)
EXTERN inline UInt STD_PROTO(PRED_HASH, (FunctorEntry *, Term, UInt)); EXTERN inline UInt STD_PROTO(PRED_HASH, (FunctorEntry *, Term, UInt));

4
H/alloc.h Normal file → Executable file
View File

@ -137,6 +137,6 @@ MALLOC_T calloc(size_t,size_t);
void Yap_add_memory_hole(ADDR, ADDR); void Yap_add_memory_hole(ADDR, ADDR);
#define SCRATCH_START_SIZE (64*1024L) #define SCRATCH_START_SIZE K64
#define SCRATCH_INC_SIZE (64*1024L) #define SCRATCH_INC_SIZE K64

2
H/heapgc.h Normal file → Executable file
View File

@ -20,7 +20,7 @@
/* macros used by garbage collection */ /* macros used by garbage collection */
#if TAG_64BITS #if TAG_64BITS
#define MaskAdr (~0x7L) #define MaskAdr (~((CELL)0x7))
#endif #endif
/* return pointer from object pointed to by ptr (remove tag & mark) */ /* return pointer from object pointed to by ptr (remove tag & mark) */

2
OPTYap/tab.macros.h Normal file → Executable file
View File

@ -605,7 +605,7 @@ static inline void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
static inline CELL *expand_auxiliary_stack(CELL *stack) { static inline CELL *expand_auxiliary_stack(CELL *stack) {
void *old_top = Yap_TrailTop; void *old_top = Yap_TrailTop;
INFORMATION_MESSAGE("Expanding trail in 64 Kbytes"); INFORMATION_MESSAGE("Expanding trail in 64 Kbytes");
if (! Yap_growtrail(64 * 1024L, TRUE)) { /* TRUE means 'contiguous_only' */ if (! Yap_growtrail(K64, TRUE)) { /* TRUE means 'contiguous_only' */
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)"); Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)");
return NULL; return NULL;
} else { } else {