|
|
1.1 ! root 1: /* Copyright (c) 1979 Regents of the University of California */ ! 2: ! 3: /* static char sccsid[] = "@(#)vars.h 1.12 1/22/83"; */ ! 4: ! 5: #include <stdio.h> ! 6: ! 7: /* ! 8: * px - Berkeley Pascal interpreter ! 9: * ! 10: * Version 4.0, January 1981 ! 11: * ! 12: * Original version by Ken Thompson ! 13: * ! 14: * Substantial revisions by Bill Joy and Chuck Haley ! 15: * November-December 1976 ! 16: * ! 17: * Rewritten for VAX 11/780 by Kirk McKusick ! 18: * Fall 1978 ! 19: * ! 20: * Rewritten in ``C'' using libpc by Kirk McKusick ! 21: * Winter 1981 ! 22: * ! 23: * Px is described in detail in the "PX 4.0 Implementation Notes" ! 24: * The source code for px is in several major pieces: ! 25: * ! 26: * int.c C main program which reads in interpreter code ! 27: * interp.c Driver including main interpreter loop and ! 28: * the interpreter instructions grouped by their ! 29: * positions in the interpreter table. ! 30: * utilities.c Interpreter exit, backtrace, and runtime statistics. ! 31: * ! 32: * In addition there are several headers defining mappings for panic ! 33: * names into codes, and a definition of the interpreter transfer ! 34: * table. These are made by the script make.ed1 in this directory and ! 35: * the routine opc.c from ${PASCALDIR}. (see the makefile for details) ! 36: */ ! 37: #define PXPFILE "pmon.out" ! 38: #define BITSPERBYTE 8 ! 39: #define BITSPERLONG (BITSPERBYTE * sizeof(long)) ! 40: #define HZ 100 ! 41: #define NAMSIZ 76 ! 42: #define MAXFILES 32 ! 43: #define PREDEF 2 ! 44: #ifdef ADDR32 ! 45: #define STDLVL ((struct iorec *)(0x7ffffff1)) ! 46: #define GLVL ((struct iorec *)(0x7ffffff0)) ! 47: #endif ADDR32 ! 48: #ifdef ADDR16 ! 49: #define STDLVL ((struct iorec *)(0xfff1)) ! 50: #define GLVL ((struct iorec *)(0xfff0)) ! 51: #endif ADDR16 ! 52: #define FILNIL ((struct iorec *)(0)) ! 53: #define INPUT ((struct iorec *)(&input)) ! 54: #define OUTPUT ((struct iorec *)(&output)) ! 55: #define ERR ((struct iorec *)(&_err)) ! 56: #define PX 0 /* normal run of px */ ! 57: #define PIX 1 /* load and go */ ! 58: #define PIPE 2 /* bootstrap via a pipe */ ! 59: #define PDX 3 /* invoked by the debugger "pdx" */ ! 60: #define releq 0 ! 61: #define relne 2 ! 62: #define rellt 4 ! 63: #define relgt 6 ! 64: #define relle 8 ! 65: #define relge 10 ! 66: typedef enum {FALSE, TRUE} bool; ! 67: ! 68: /* ! 69: * interrupt and allocation routines ! 70: */ ! 71: extern long createtime; ! 72: extern char *PALLOC(); ! 73: extern char *malloc(); ! 74: extern long time(); ! 75: extern intr(); ! 76: extern memsize(); ! 77: extern syserr(); ! 78: extern liberr(); ! 79: ! 80: /* ! 81: * stack routines and structures ! 82: */ ! 83: struct sze8 { ! 84: char element[8]; ! 85: }; ! 86: extern short pop2(); ! 87: extern long pop4(); ! 88: extern double pop8(); ! 89: extern struct sze8 popsze8(); ! 90: extern char *pushsp(); ! 91: ! 92: /* ! 93: * emulated pc types ! 94: */ ! 95: union progcntr { ! 96: char *cp; ! 97: unsigned char *ucp; ! 98: short *sp; ! 99: unsigned short *usp; ! 100: long *lp; ! 101: double *dbp; ! 102: struct hdr *hdrp; ! 103: }; ! 104: ! 105: /* ! 106: * THE RUNTIME DISPLAY ! 107: * ! 108: * The entries in the display point to the active static block marks. ! 109: * The first entry in the display is for the global variables, ! 110: * then the procedure or function at level one, etc. ! 111: * Each display entry points to a stack frame as shown: ! 112: * ! 113: * base of stack frame ! 114: * --------------- ! 115: * | | ! 116: * | block mark | ! 117: * | | ! 118: * --------------- <-- display entry "stp" points here ! 119: * | | <-- display entry "locvars" points here ! 120: * | local | ! 121: * | variables | ! 122: * | | ! 123: * --------------- ! 124: * | | ! 125: * | expression | ! 126: * | temporary | ! 127: * | storage | ! 128: * | | ! 129: * - - - - - - - - ! 130: * ! 131: * The information in the block mark is thus at positive offsets from ! 132: * the display.stp pointer entries while the local variables are at negative ! 133: * offsets from display.locvars. The block mark actually consists of ! 134: * two parts. The first part is created at CALL and the second at entry, ! 135: * i.e. BEGIN. Thus: ! 136: * ! 137: * ------------------------- ! 138: * | | ! 139: * | Saved lino | ! 140: * | Saved lc | ! 141: * | Saved dp | ! 142: * | | ! 143: * ------------------------- ! 144: * | | ! 145: * | Saved (dp) | ! 146: * | | ! 147: * | Pointer to current | ! 148: * | routine header info | ! 149: * | | ! 150: * | Saved value of | ! 151: * | "curfile" | ! 152: * | | ! 153: * | Empty tos value | ! 154: * | | ! 155: * ------------------------- ! 156: */ ! 157: ! 158: /* ! 159: * program variables ! 160: */ ! 161: extern union display _display; /* runtime display */ ! 162: extern struct dispsave *_dp; /* ptr to active frame */ ! 163: extern long _lino; /* current line number */ ! 164: extern int _argc; /* number of passed args */ ! 165: extern char **_argv; /* values of passed args */ ! 166: extern bool _nodump; /* TRUE => no post mortum dump */ ! 167: extern long _runtst; /* TRUE => runtime tests */ ! 168: extern long _mode; /* execl by PX, PIPE, or PIX */ ! 169: extern long _stlim; /* statement limit */ ! 170: extern long _stcnt; /* statement count */ ! 171: extern long _seed; /* random number seed */ ! 172: extern char *_maxptr; /* maximum valid pointer */ ! 173: extern char *_minptr; /* minimum valid pointer */ ! 174: extern long *_pcpcount; /* pointer to pxp buffer */ ! 175: extern long _cntrs; /* number of counters */ ! 176: extern long _rtns; /* number of routine cntrs */ ! 177: ! 178: /* ! 179: * The file i/o routines maintain a notion of a "current file". ! 180: * A pointer to this file structure is kept in "curfile". ! 181: * ! 182: * file structures ! 183: */ ! 184: struct iorechd { ! 185: char *fileptr; /* ptr to file window */ ! 186: long lcount; /* number of lines printed */ ! 187: long llimit; /* maximum number of text lines */ ! 188: FILE *fbuf; /* FILE ptr */ ! 189: struct iorec *fchain; /* chain to next file */ ! 190: struct iorec *flev; /* ptr to associated file variable */ ! 191: char *pfname; /* ptr to name of file */ ! 192: short funit; /* file status flags */ ! 193: short fblk; /* index into active file table */ ! 194: long fsize; /* size of elements in the file */ ! 195: char fname[NAMSIZ]; /* name of associated UNIX file */ ! 196: }; ! 197: ! 198: struct iorec { ! 199: char *fileptr; /* ptr to file window */ ! 200: long lcount; /* number of lines printed */ ! 201: long llimit; /* maximum number of text lines */ ! 202: FILE *fbuf; /* FILE ptr */ ! 203: struct iorec *fchain; /* chain to next file */ ! 204: struct iorec *flev; /* ptr to associated file variable */ ! 205: char *pfname; /* ptr to name of file */ ! 206: short funit; /* file status flags */ ! 207: short fblk; /* index into active file table */ ! 208: long fsize; /* size of elements in the file */ ! 209: char fname[NAMSIZ]; /* name of associated UNIX file */ ! 210: char buf[BUFSIZ]; /* I/O buffer */ ! 211: char window[1]; /* file window element */ ! 212: }; ! 213: ! 214: /* ! 215: * unit flags ! 216: */ ! 217: #define FDEF 0x80 /* 1 => reserved file name */ ! 218: #define FTEXT 0x40 /* 1 => text file, process EOLN */ ! 219: #define FWRITE 0x20 /* 1 => open for writing */ ! 220: #define FREAD 0x10 /* 1 => open for reading */ ! 221: #define TEMP 0x08 /* 1 => temporary file */ ! 222: #define SYNC 0x04 /* 1 => window is out of sync */ ! 223: #define EOLN 0x02 /* 1 => at end of line */ ! 224: #define EOFF 0x01 /* 1 => at end of file */ ! 225: ! 226: /* ! 227: * file routines ! 228: */ ! 229: extern struct iorec *GETNAME(); ! 230: extern char *MKTEMP(); ! 231: ! 232: /* ! 233: * file record variables ! 234: */ ! 235: extern struct iorechd _fchain; /* head of active file chain */ ! 236: extern struct iorec *_actfile[]; /* table of active files */ ! 237: extern long _filefre; /* last used entry in _actfile */ ! 238: ! 239: /* ! 240: * standard files ! 241: */ ! 242: extern struct iorechd input; ! 243: extern struct iorechd output; ! 244: extern struct iorechd _err; ! 245: ! 246: /* ! 247: * Px execution profile array ! 248: */ ! 249: #ifdef PROFILE ! 250: #define NUMOPS 256 ! 251: extern long _profcnts[NUMOPS]; ! 252: #endif PROFILE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.