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