Added MEMCHECK and MEMFIX commands.

This commit is contained in:
claudio 2015-08-20 18:50:57 -04:00
parent a74b306254
commit d96e89ea4e
3 changed files with 46 additions and 3 deletions

View file

@ -37,7 +37,9 @@ static const HALFWORD const libnumberlist[]={ LIBRARY_NUMBER,0 };
// LIST OF COMMANDS EXPORTED, CHANGE FOR EACH LIBRARY
#define CMD_LIST \
CMD(TICKS)
CMD(TICKS), \
CMD(MEMCHECK), \
CMD(MEMFIX)
// ADD MORE OPCODES HERE
@ -84,6 +86,34 @@ void LIB_HANDLER()
rplNewBINTPush(ticks,DECBINT);
return;
}
case MEMCHECK:
{
// SYSTEM SANITY CHECK
if(rplVerifyDStack(0)) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
if(rplVerifyRStack()) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
if(rplVerifyTempOb()) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
if(rplVerifyDirectories(0)) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
return;
}
case MEMFIX:
{
if(rplVerifyDStack(0)) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
if(rplVerifyRStack()) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
if(rplVerifyTempOb()) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
if(rplVerifyDirectories(0)) rplPushDataNoGrow((WORDPTR)one_bint);
else rplPushDataNoGrow((WORDPTR)zero_bint);
return;
}
/*
case TRANSCENTABLE:

View file

@ -226,6 +226,19 @@ extern void rplGCollect();
void rplBackup(void (*writefunc)(unsigned int));
void rplRestoreBackup(void (*readfunc)(unsigned int));
// SYSTEM SANITY CHECKS
BINT rplVerifyObject(WORDPTR obj);
BINT rplIsTempObPointer(WORDPTR ptr);
BINT rplVerifyObjPointer(WORDPTR ptr);
BINT rplVerifyDStack(BINT fix);
BINT rplVerifyRStack();
BINT rplVerifyTempOb();
BINT rplVerifyDirectories(BINT fix);
// LAM FUNCTIONS

View file

@ -101,7 +101,7 @@ return 0;
BINT rplVerifyDStack(BINT fix)
{
BINT errors=0;
WORDPTR *stkptr=DSTop;
WORDPTR *stkptr=DSTop-1;
WORDPTR *bottom=DStkBottom;
do {
@ -153,7 +153,7 @@ return 1;
BINT rplVerifyRStack()
{
WORDPTR *stkptr=RSTop;
WORDPTR *stkptr=RSTop-1;
while(stkptr>=RStk) {
if((stkptr>=DStk)&&(stkptr<DSTop)) {