allow randomization of initial address, this enables testing restore routine.
This commit is contained in:
parent
7155fbec22
commit
6c887452e6
17
C/alloc.c
17
C/alloc.c
@ -1401,13 +1401,28 @@ void
|
|||||||
Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack)
|
Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack)
|
||||||
{
|
{
|
||||||
UInt pm, sa, ta;
|
UInt pm, sa, ta;
|
||||||
|
void *addr;
|
||||||
|
|
||||||
pm = (Trail + Heap + Stack); /* memory to be
|
pm = (Trail + Heap + Stack); /* memory to be
|
||||||
* requested */
|
* requested */
|
||||||
sa = Stack; /* stack area size */
|
sa = Stack; /* stack area size */
|
||||||
ta = Trail; /* trail area size */
|
ta = Trail; /* trail area size */
|
||||||
|
|
||||||
InitHeap(InitWorkSpace(pm));
|
|
||||||
|
#if RANDOMIZE_START_ADDRESS
|
||||||
|
srand(time(NULL));
|
||||||
|
UInt x = (rand()% 100)*YAP_ALLOC_SIZE ;
|
||||||
|
fprintf(stderr,"x=%ulx\n", (unsigned long int)x);
|
||||||
|
pm += x;
|
||||||
|
#endif
|
||||||
|
addr = InitWorkSpace(pm);
|
||||||
|
#if RANDOMIZE_START_ADDRESS
|
||||||
|
addr = (char *)addr+x;
|
||||||
|
pm -= x;
|
||||||
|
fprintf(stderr,"addr=%p\n", addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
InitHeap(addr);
|
||||||
|
|
||||||
Yap_TrailTop = Yap_HeapBase + pm;
|
Yap_TrailTop = Yap_HeapBase + pm;
|
||||||
Yap_LocalBase = Yap_TrailTop - ta;
|
Yap_LocalBase = Yap_TrailTop - ta;
|
||||||
|
27
H/Yap.h
27
H/Yap.h
@ -254,11 +254,13 @@ extern char Yap_Option[20];
|
|||||||
#endif
|
#endif
|
||||||
#endif /* !IN_SECOND_QUADRANT */
|
#endif /* !IN_SECOND_QUADRANT */
|
||||||
|
|
||||||
|
/* #define RANDOMIZE_START_ADDRESS 1 */
|
||||||
|
|
||||||
#ifdef USE_SYSTEM_MALLOC
|
#ifdef USE_SYSTEM_MALLOC
|
||||||
#define HEAP_INIT_BASE 0L
|
#define HEAP_INIT_BASE 0L
|
||||||
#define AtomBase NULL
|
#define AtomBase NULL
|
||||||
#else
|
#else
|
||||||
#if defined(MMAP_ADDR) && (defined(USE_MMAP) || USE_SHMAT) && !defined(__simplescalar__)
|
#if defined(MMAP_ADDR) && (defined(USE_MMAP) || USE_SHMAT) && !defined(__simplescalar__) && !defined(RANDOMIZE_START_ADDRESS)
|
||||||
#define HEAP_INIT_BASE (MMAP_ADDR)
|
#define HEAP_INIT_BASE (MMAP_ADDR)
|
||||||
#define AtomBase ((char *)MMAP_ADDR)
|
#define AtomBase ((char *)MMAP_ADDR)
|
||||||
#else
|
#else
|
||||||
@ -850,7 +852,6 @@ FunctorOfTerm (Term t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if (defined(USE_SYSTEM_MALLOC) || USE_DL_MALLOC) && !defined(__LP64__)
|
|
||||||
#if USE_LOW32_TAGS
|
#if USE_LOW32_TAGS
|
||||||
|
|
||||||
inline EXTERN Term MkAtomTerm (Atom);
|
inline EXTERN Term MkAtomTerm (Atom);
|
||||||
@ -893,28 +894,6 @@ AtomOfTerm (Term t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
|
|
||||||
inline EXTERN Term MkAtomTerm (Atom);
|
|
||||||
|
|
||||||
inline EXTERN Term
|
|
||||||
MkAtomTerm (Atom a)
|
|
||||||
{
|
|
||||||
return (Term) (TAGGEDA (AtomTag, (CELL) (a) - HEAP_INIT_BASE));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline EXTERN Atom AtomOfTerm (Term t);
|
|
||||||
|
|
||||||
inline EXTERN Atom
|
|
||||||
AtomOfTerm (Term t)
|
|
||||||
{
|
|
||||||
return (Atom) (HEAP_INIT_BASE + NonTagPart (t));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline EXTERN int IsAtomTerm (Term);
|
inline EXTERN int IsAtomTerm (Term);
|
||||||
|
Reference in New Issue
Block a user