Annotation of researchv9/jerq/sgs/libsdp/use.c, revision 1.1

1.1     ! root        1: static char ID[] = "@(#) use.c: 1.1 3/16/82";
        !             2: #include <stdio.h>
        !             3: #include "sdp.h"
        !             4: #include "define3.h"
        !             5: 
        !             6: #ifdef SHORT
        !             7: #define US01   "US01 "
        !             8: #define US02   "US02 "
        !             9: #define US03   "US03 "
        !            10: #define US04   "US04 "
        !            11: #define US05   "US05 "
        !            12: #define US06   "US06 "
        !            13: #define US07   "US07 "
        !            14: #define USAU   "USAU "
        !            15: #else
        !            16: #define US01   "US01 -- space not connected\n%o\n",sp
        !            17: #define US02   "US02 -- no permissions for WRTN\n%o\n",sp
        !            18: #define US03   "US03 -- unknown permissions\n%o\t%d\n",sp,permissions
        !            19: #define US04   "US04 -- id out of range\n%o\t%lo\t%lo\n",sp,id,sp->maxpage
        !            20: #define US05   "US05 -- id not aligned to %d-byte boundary\n%o\t%lo\n",sizeof(BOUNDARY),sp,id
        !            21: #define US06   "US06 -- framesearch returns impossible value\n%o\t%d\t%d\n",sp,whichframe,(sp->environ)->num_frames
        !            22: #define US07   "US07 -- fail to place item in frame\n%o\t%lo\n",sp,id
        !            23: #define USAU   "%s","USAU -- audit failed in sdp_use\n"
        !            24: #endif
        !            25: 
        !            26: #ifdef SWEET
        !            27: #define PROLOG
        !            28: #define EPILOG
        !            29: #else
        !            30: #define PROLOG         if( (aud_flag == AUDITON) && (aud_check() == ERROR) )\
        !            31:                                ERR_RET(USAU,NULL)
        !            32: #define EPILOG         if(aud_flag == AUDITON)\
        !            33:                                aud_set() ;\
        !            34:                        if(hist_fp != NULL)\
        !            35:                                fprintf(hist_fp,"US\t%o\t%ld\t%d\t%o\n",sp,id,permissions,manager[whichframe].frame_pntr+byte_offset) ;
        !            36: #endif
        !            37: 
        !            38: extern int aud_flag ;
        !            39: extern struct LIBFILE *Glib_file ;
        !            40: extern FILE *hist_fp ;
        !            41: 
        !            42: extern int aud_check() ;
        !            43: extern aud_set() ;
        !            44: extern FATAL() ;
        !            45: extern fault() ;
        !            46: extern framesearch() ;
        !            47: extern spearch() ;
        !            48: 
        !            49: BOUNDARY *                             /* pointer to item or NULL */
        !            50: sdp_use(sp,id,permissions)
        !            51: register struct SPACE  *sp ;
        !            52: ITEMID                 id ;
        !            53: int                    permissions ;
        !            54: {
        !            55:        register struct MANAGER *manager ;
        !            56:        register int            whichframe ;
        !            57:        register int            byte_offset ;
        !            58: 
        !            59:        PROLOG
        !            60:        if(spsearch(sp) == NOTFOUND)
        !            61:                ERR_RET(US01,NULL)
        !            62: 
        !            63:        switch(permissions)
        !            64:        {
        !            65:                case WRTN:
        !            66:                        if(sp->perms != WRTN)
        !            67:                                ERR_RET(US02,NULL)
        !            68: 
        !            69:                case RNLY:
        !            70:                        break ;
        !            71: 
        !            72:                default:
        !            73:                        ERR_RET(US03,NULL)
        !            74:        }
        !            75: 
        !            76:        if(INVALID(sp,id))
        !            77:                ERR_RET(US04,NULL)
        !            78:        if(id != ALIGNID(id))
        !            79:                ERR_RET(US05,NULL)
        !            80: 
        !            81:        Glib_file = sp->lib_file ;
        !            82: 
        !            83:        manager = (sp->environ)->manp ;
        !            84:        switch(whichframe = framesearch(sp,id))
        !            85:        {
        !            86:                case NOTFOUND:
        !            87:                        whichframe = fault(sp,id) ;
        !            88:                default:
        !            89:                        if( (whichframe<0) || (whichframe >= (sp->environ)->num_frames) )
        !            90:                                ERR_RET(US06,NULL)
        !            91:                        break ;
        !            92: 
        !            93:                case ERROR:
        !            94:                        ERR_RET(US07,NULL)
        !            95:                        break ;
        !            96:        }
        !            97: 
        !            98:        if( (manager[whichframe].ref_chng == RCNULL) || (permissions == WRTN) )
        !            99:                manager[whichframe].ref_chng = permissions ;
        !           100:        if(manager[whichframe].usecount == 0)
        !           101:        {
        !           102:                (sp->environ)->stats.curuse++ ;
        !           103:                if( (sp->environ)->stats.curuse > (sp->environ)->stats.maxuse )
        !           104:                        (sp->environ)->stats.maxuse = (sp->environ)->stats.curuse ;
        !           105:        }
        !           106:        manager[whichframe].usecount++ ;
        !           107:        (sp->environ)->stats.uses++ ;
        !           108:        byte_offset = id % (sp->environ)->frame_size ;
        !           109:        
        !           110:        EPILOG
        !           111:        return((BOUNDARY *)(manager[whichframe].frame_pntr + byte_offset)) ;
        !           112: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.