Annotation of coherent/d/lib/libc/gen/monitor.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Monitor is an interface to the profil system call and to the
        !             3:  * program prof.  It starts the profil if `low' is non-NULL and
        !             4:  * otherwise dumps out the statistics information and turns off
        !             5:  * profileing.  The region of memory profiled is from `low' to
        !             6:  * `high', not includeing `high'.  `buff' is an array of `blen'
        !             7:  * shorts into which the profileing will take place.
        !             8:  * note that on the z8001, only stack monitoring and call counting
        !             9:  * are supported.
        !            10:  */
        !            11: #include "mon.h"
        !            12: 
        !            13: 
        !            14: #define MODE   0666                    /* mon.out creation mode */
        !            15: 
        !            16: 
        !            17: /*
        !            18:  * Note that the list pointed to by m_flst is never empty.  It always has
        !            19:  * a dummy entry on the end which has m_link field NULL.
        !            20:  */
        !            21: static struct m_flst   dummy[];
        !            22: struct m_flst          *_fnclst        = dummy;
        !            23: struct m_hdr   _mhdr;
        !            24: static short           *baddr;         /* buffer address */
        !            25: 
        !            26: #ifndef        Z8001
        !            27: monitor(low, high, buff, blen)
        !            28: vaddr_t        low,
        !            29:        high;
        !            30: short  buff[];
        !            31: int    blen;
        !            32: #else
        !            33: monitor(low)
        !            34: vaddr_t        low;
        !            35: #endif
        !            36: {
        !            37:        if (low == (vaddr_t)0) {
        !            38:                endmon();
        !            39:                return;
        !            40:        }
        !            41: #ifndef        Z8001
        !            42:        baddr = buff;
        !            43:        if (blen >= (high-low)/2) {
        !            44:                blen = (high-low)/2;
        !            45:                _mhdr.m_scale = (unsigned)-1;
        !            46:        } else
        !            47:                _mhdr.m_scale = ((long)blen << 17) / (high-low);
        !            48:        _mhdr.m_nbins = blen;
        !            49:        _mhdr.m_lowpc = low;
        !            50:        /* Without getting incredibly involved, this will do */
        !            51:        _mhdr.m_lowsp = ((vaddr_t)&blen) + sizeof(blen);
        !            52: #else
        !            53:        _mhdr.m_lowsp = 0xFFFEL;
        !            54: #endif
        !            55:        _mhdr.m_hisp = _mhdr.m_lowsp;
        !            56: #ifndef        Z8001
        !            57:        profil(buff, blen * sizeof *buff, low, _mhdr.m_scale);
        !            58: #endif
        !            59: }
        !            60: 
        !            61: 
        !            62: static endmon()
        !            63: {
        !            64:        register int    fd,
        !            65:                        cnt;
        !            66:        register struct m_flst  *flp;
        !            67: 
        !            68: #ifndef        Z8001
        !            69:        profil(NULL, 0, 0, 0);
        !            70: #endif
        !            71:        for (flp = _fnclst, cnt = 0; flp != dummy; flp = flp->m_link)
        !            72:                ++cnt;
        !            73:        _mhdr.m_nfuncs = cnt;
        !            74:        if ((fd=creat("mon.out", MODE)) < 0)
        !            75:                return;
        !            76:        write(fd, &_mhdr, sizeof _mhdr);
        !            77:        for (flp = _fnclst; flp != dummy; flp = flp->m_link)
        !            78:                write(fd, &flp->m_data, sizeof flp->m_data);
        !            79: #ifndef        Z8001
        !            80:        write(fd, baddr, _mhdr.m_nbins * sizeof *baddr);
        !            81: #endif
        !            82:        close(fd);
        !            83: }

unix.superglobalmegacorp.com

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