|
|
1.1 ! root 1: static char ID[] = "@(#) unuse.c: 1.1 3/16/82"; ! 2: ! 3: #include <stdio.h> ! 4: #include "sdp.h" ! 5: #include "define3.h" ! 6: ! 7: #ifdef SHORT ! 8: #define UN01 "UN01 " ! 9: #define UN02 "UN02 " ! 10: #define UN03 "UN03 " ! 11: #define UN04 "UN04 " ! 12: #define UN05 "UN05 " ! 13: #define UN06 "UN06 " ! 14: #define UN07 "UN07 " ! 15: #define UN08 "UN08 " ! 16: #define UN09 "UN09 " ! 17: #define UNAU "UNAU " ! 18: #else ! 19: #define UN01 "UN01 -- space not connected\n%o\n",sp ! 20: #define UN02 "UN02 -- id out of range\n%lo\t%lo\n",id,sp->maxpage ! 21: #define UN03 "UN03 -- attempt to unuse an item not core resident\n%o\t%lo\n",sp,id ! 22: #define UN04 "UN04 -- frame search failed\n%o\n",sp ! 23: #define UN05 "UN05 -- whichframe returned an impossible value\n%o\t%d\t%d\n",sp,whichframe,(sp->environ)->num_frames ! 24: #define UN06 "UN06 -- no permissions for WRTN\n%o\n",sp ! 25: #define UN07 "UN07 -- unknown permissions\n%o\t%d\n",sp,permissions ! 26: #define UN08 "UN08 -- attempt to unuse an unused item\n%o\n%O\n",sp,id ! 27: #define UN09 "%s","UN09 -- compilation made without either LFU or LRU defined\n" ! 28: #define UNAU "%s","UNAU -- audit failed in sdp_unuse\n" ! 29: #endif ! 30: ! 31: #ifdef SWEET ! 32: #define PROLOG ! 33: #define EPILOG ! 34: #else ! 35: #define PROLOG if( (aud_flag == AUDITON) && (aud_check() == ERROR) )\ ! 36: ERR_RET(UNAU,ERROR) ! 37: #define EPILOG if(aud_flag == AUDITON)\ ! 38: aud_set() ;\ ! 39: if(hist_fp != NULL)\ ! 40: fprintf(hist_fp,"UN\t%o\t%ld\t%d\n",sp,id,permissions) ; ! 41: #endif ! 42: ! 43: extern int aud_flag ; ! 44: extern struct LIBFILE *Glib_file ; ! 45: extern FILE *hist_fp ; ! 46: ! 47: extern int aud_check() ; ! 48: extern aud_set() ; ! 49: extern FATAL() ; ! 50: extern framesearch() ; ! 51: extern spsearch() ; ! 52: extern int rem_frame() ; ! 53: extern ins_frame() ; ! 54: ! 55: int /* SUCCESS or ERROR */ ! 56: sdp_unuse(sp,id,permissions) ! 57: register struct SPACE *sp ; ! 58: ITEMID id ; ! 59: int permissions ; ! 60: { ! 61: register struct MANAGER *manager ; ! 62: register int whichframe ; ! 63: register long usecount ; ! 64: ! 65: PROLOG ! 66: if(spsearch(sp) == NOTFOUND) ! 67: ERR_RET(UN01,ERROR) ! 68: ! 69: if(INVALID(sp,id)) ! 70: ERR_RET(UN02,ERROR) ! 71: ! 72: Glib_file = sp->lib_file ; ! 73: ! 74: switch(whichframe = framesearch(sp,id)) ! 75: { ! 76: case NOTFOUND: ! 77: ERR_RET(UN03,ERROR) ! 78: break ; ! 79: ! 80: case ERROR: ! 81: ERR_RET(UN04,ERROR) ! 82: break ; ! 83: ! 84: default: ! 85: if( (whichframe<0) || (whichframe >= (sp->environ)->num_frames) ) ! 86: ERR_RET(UN05,ERROR) ! 87: break ; ! 88: } ! 89: ! 90: ! 91: manager = (sp->environ)->manp ; ! 92: switch(permissions) ! 93: { ! 94: case WRTN: ! 95: if(sp->perms != WRTN) ! 96: ERR_RET(UN06,ERROR) ! 97: manager[whichframe].ref_chng = WRTN ; ! 98: break ; ! 99: ! 100: case RNLY: ! 101: break ; ! 102: ! 103: default: ! 104: ERR_RET(UN07,ERROR) ! 105: } ! 106: ! 107: usecount = --manager[whichframe].usecount ; ! 108: if(usecount < 0) ! 109: ERR_RET(UN08,ERROR) ! 110: ! 111: if(usecount == 0) ! 112: (sp->environ)->stats.curuse-- ; ! 113: #ifdef LRU ! 114: rem_frame(sp->environ,whichframe) ; ! 115: ins_frame(sp->environ,whichframe,(sp->environ)->num_frames) ; ! 116: #else ! 117: #ifdef LFU ! 118: if(manager[whichframe].forward != (sp->environ)->num_frames) ! 119: ins_frame(sp->environ,rem_frame(sp->environ,manager[whichframe].forward),whichframe) ; ! 120: #else ! 121: ERR_RET(UN09,ERROR) ! 122: #endif ! 123: #endif ! 124: EPILOG ! 125: return(SUCCESS) ; ! 126: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.