Annotation of 43BSD/contrib/icon/link/ilink.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * External declarations for the linker.
        !             3:  */
        !             4: 
        !             5: #include <stdio.h>
        !             6: #include "../h/config.h"
        !             7: 
        !             8: /*
        !             9:  * Miscellaneous external declarations.
        !            10:  */
        !            11: 
        !            12: extern FILE *infile;           /* current input file */
        !            13: extern FILE *outfile;          /* interpreter output file */
        !            14: extern FILE *dbgfile;          /* debug file */
        !            15: extern char inname[];          /* input file name */
        !            16: extern char outname[];         /* output file name */
        !            17: extern char *pname;            /* this program name (from command line) */
        !            18: extern int line;               /* source program line number (from ucode) */
        !            19: extern char *file;             /* source program file name (from ucode) */
        !            20: extern int statics;            /* total number of statics */
        !            21: extern int dynoff;             /* stack offset counter for locals */
        !            22: extern int argoff;             /* stack offset counter for arguments */
        !            23: extern int static1;            /* first static in procedure */
        !            24: extern int nlocal;             /* number of locals in local table */
        !            25: extern int nconst;             /* number of constants in constant table */
        !            26: extern int nrecords;           /* number of records in program */
        !            27: extern int trace;              /* initial setting of &trace */
        !            28: extern int Dflag;              /* debug flag */
        !            29: extern char ixhdr[];           /* header line for direct execution */
        !            30: extern char *iconx;            /* location of iconx to put in #! line */
        !            31: extern int hdrloc;             /* location to place hdr block at */
        !            32: extern struct lfile *lfiles;   /* list of files to link */
        !            33: extern struct lfile *getlfile();
        !            34: 
        !            35: /*
        !            36:  * Interpreter code file header - this is written at the start of
        !            37:  *  an icode file after the start-up program (if any) and the #! line.
        !            38:  */
        !            39: struct header {
        !            40:    int size;                   /* size of interpreter code */
        !            41:    int trace;                  /* initial value of &trace */
        !            42:    int records;                        /* location of record blocks */
        !            43:    int ftab;                   /* location of record/field table */
        !            44:    int globals;                        /* location of global variables */
        !            45:    int gnames;                 /* location of names of globals */
        !            46:    int statics;                        /* location of static variables */
        !            47:    int ident;                  /* location of identifier table */
        !            48:    } hdr;
        !            49: 
        !            50: /*
        !            51:  * Structures for symbol table entries.
        !            52:  */
        !            53: 
        !            54: struct lentry {                        /* local table entry */
        !            55:    char *l_name;               /*   name of variable */
        !            56:    int l_flag;                 /*   variable flags */
        !            57:    union {                     /*   value field */
        !            58:       int staticid;            /*     unique id for static variables */
        !            59:       int offset;              /*     stack offset for args and locals */
        !            60:       struct gentry *global;   /*     global table entry */
        !            61:       } l_val;
        !            62:    };
        !            63: 
        !            64: struct gentry {                        /* global table entry */
        !            65:    struct gentry *g_blink;     /*   link for bucket chain */
        !            66:    char *g_name;               /*   name of variable */
        !            67:    int g_flag;                 /*   variable flags */
        !            68:    int g_nargs;                /*   number of args or fields */
        !            69:    int g_procid;               /*   procedure or record id */
        !            70:    int g_pc;                   /*   position in icode of object */
        !            71:    };
        !            72: 
        !            73: struct centry {                        /* constant table entry */
        !            74:    int c_flag;                 /*   type of literal flag */
        !            75:    union {                     /*   value field */
        !            76:       long ival;               /*     integer */
        !            77:       double rval;             /*     real */
        !            78:       char *sval;              /*     string */
        !            79:       } c_val;
        !            80:    int c_length;               /*   length of literal string */
        !            81:    int c_pc;                   /*   position in icode of object */
        !            82:    };
        !            83: 
        !            84: struct ientry {                        /* identifier table entry */
        !            85:    struct ientry *i_blink;     /*   link for bucket chain */
        !            86:    char *i_name;               /*   pointer to string */
        !            87:    int i_length;               /*   length of string */
        !            88:    };
        !            89: 
        !            90: struct fentry {                        /* field table header entry */
        !            91:    struct fentry *f_blink;     /*   link for bucket chain */
        !            92:    char *f_name;               /*   name of field */
        !            93:    int f_fid;                  /*   field id */
        !            94:    struct rentry *f_rlist;     /*   head of list of records */
        !            95:    };
        !            96: 
        !            97: struct rentry {                        /* field table record list entry */
        !            98:    struct rentry *r_link;      /*   link for list of records */
        !            99:    int r_recid;                        /*   record id */
        !           100:    int r_fnum;                 /*   offset of field within record */
        !           101:    };
        !           102: 
        !           103: /*
        !           104:  * Structure for linked list of file names to link.
        !           105:  */
        !           106: struct lfile {
        !           107:    struct lfile *lf_link;      /* next file in list */
        !           108:    char *lf_name;              /* name of file */
        !           109:    };
        !           110: 
        !           111: /*
        !           112:  * Flag values in symbol tables.
        !           113:  */
        !           114: 
        !           115: #define F_GLOBAL           01  /* variable declared global externally */
        !           116: #define F_PROC             05  /* procedure (includes GLOBAL) */
        !           117: #define F_RECORD          011  /* record (includes GLOBAL) */
        !           118: #define F_DYNAMIC         020  /* variable declared local dynamic */
        !           119: #define F_STATIC          040  /* variable declared local static */
        !           120: #define F_BUILTIN        0101  /* identifier refers to built-in procedure */
        !           121: #define F_IMPERROR       0400  /* procedure has default error */
        !           122: #define F_ARGUMENT      01000  /* variable is a formal parameter */
        !           123: #define F_INTLIT        02000  /* literal is an integer */
        !           124: #define F_REALLIT       04000  /* literal is a real */
        !           125: #define F_STRLIT       010000  /* literal is a string */
        !           126: #define F_CSETLIT      020000  /* literal is a cset */
        !           127: #define F_LONGLIT      040000  /* literal is a long integer */
        !           128: 
        !           129: /*
        !           130:  * Symbol table region pointers.
        !           131:  */
        !           132: 
        !           133: extern struct gentry **ghash;  /* hash area for global table */
        !           134: extern struct ientry **ihash;  /* hash area for identifier table */
        !           135: extern struct fentry **fhash;  /* hash area for field table */
        !           136: 
        !           137: extern struct lentry *ltable;  /* local table */
        !           138: extern struct gentry *gtable;  /* global table */
        !           139: extern struct centry *ctable;  /* constant table */
        !           140: extern struct ientry *itable;  /* identifier table */
        !           141: extern struct fentry *ftable;  /* field table headers */
        !           142: extern struct rentry *rtable;  /* field table record lists */
        !           143: extern char *strings;          /* string space */
        !           144: extern int *labels;            /* label table */
        !           145: extern char *code;             /* generated code space */
        !           146: 
        !           147: extern struct gentry *gfree;   /* free pointer for global table */
        !           148: extern struct ientry *ifree;   /* free pointer for identifier table */
        !           149: extern struct fentry *ffree;   /* free pointer for field table headers */
        !           150: extern struct rentry *rfree;   /* free pointer for field table record lists */
        !           151: extern char *sfree;            /* free pointer for string space */
        !           152: extern char *codep;            /* free pointer for code space */
        !           153: 
        !           154: extern int lsize;              /* size of local table */
        !           155: extern int gsize;              /* size of global table */
        !           156: extern int csize;              /* size of constant table */
        !           157: extern int isize;              /* size of identifier table */
        !           158: extern int fsize;              /* size of field table headers */
        !           159: extern int rsize;              /* size of field table record lists */
        !           160: extern int ssize;              /* size of string space */
        !           161: extern int ihsize;             /* size of identifier table hash area */
        !           162: extern int ghsize;             /* size of global table hash area */
        !           163: extern int fhsize;             /* size of field table hash area */
        !           164: extern int maxlabels;          /* maximum number of labels per procedure */
        !           165: extern int maxcode;            /* maximum amount of code per procedure */
        !           166: 
        !           167: extern int gmask;              /* mask for global table hash */
        !           168: extern int imask;              /* mask for identifier table hash */
        !           169: extern int fmask;              /* mask for field table hash */
        !           170: 
        !           171: /*
        !           172:  * Symbol table parameters.
        !           173:  */
        !           174: 
        !           175: #define LSIZE           100    /* default size of local table */
        !           176: #define GSIZE           200    /* default size of global table */
        !           177: #define CSIZE           100    /* default size of constant table */
        !           178: #define ISIZE           500    /* default size of identifier table */
        !           179: #define FSIZE           100    /* default size of field table headers */
        !           180: #define RSIZE           100    /* default size of field table record lists */
        !           181: #define SSIZE          5000    /* default size of string space */
        !           182: #define GHSIZE           64    /* default size of global table hash area */
        !           183: #define IHSIZE          128    /* default size of identifier table hash area */
        !           184: #define FHSIZE           32    /* default size of field table hash area */
        !           185: #define MAXLABELS       500    /* default maximum number of labels/proc */
        !           186: 
        !           187: /*
        !           188:  * Hash computation macros.
        !           189:  */
        !           190: 
        !           191: #define ghasher(x)     (((int)x)&gmask)        /* for global table */
        !           192: #define fhasher(x)     (((int)x)&fmask)        /* for field table */
        !           193: 
        !           194: /*
        !           195:  * Machine-dependent constants.
        !           196:  */
        !           197: #ifdef VAX
        !           198: #define INTSIZE                   32   /* # of bits in an int */
        !           199: #define LOGINTSIZE         5   /* log of INTSIZE */
        !           200: #define MAXCODE                10000   /* default maximum amount of code/proc */
        !           201: #define OPSIZE             1   /* # of bytes for opcode */
        !           202: #define OPNDSIZE           4   /* # of bytes in interpreter operands */
        !           203: #define WORDSIZE  sizeof(int *)        /* # of bytes in a pointer (sizeof(int *)) */
        !           204: #endif VAX
        !           205: 
        !           206: #ifdef PORT
        !           207: #define INTSIZE                 x      /* # of bits in an int */
        !           208: #define LOGINTSIZE      x      /* log of INTSIZE */
        !           209: /*#define LONGS                        /* longs are different from ints */
        !           210: /*#define MINSHORT       x     /* smallest short integer */
        !           211: /*#define MAXSHORT       x     /* largest short integer */
        !           212: #define MAXCODE                 x      /* default maximum amount of code/proc */
        !           213: #define OPSIZE          1      /* # of bytes for opcode */
        !           214: #define OPNDSIZE         4     /* # of bytes in interpreter operands */
        !           215: #define WORDSIZE        4      /* # of bytes in a pointer (sizeof(int *)) */
        !           216: #endif PORT
        !           217: 
        !           218: #ifdef PDP11
        !           219: #define INTSIZE                16      /* # of bits in an int */
        !           220: #define LOGINTSIZE      4      /* log of INTSIZE */
        !           221: #define LONGS                  /* longs are different from ints */
        !           222: #define MINSHORT   0100000     /* smallest short integer */
        !           223: #define MAXSHORT    077777     /* largest short integer */
        !           224: #define MAXCODE              2000      /* default maximum amount of code/proc */
        !           225: #define OPSIZE          1      /* # of bytes for opcode */
        !           226: #define OPNDSIZE        2      /* # of bytes in interpreter operands */
        !           227: #define WORDSIZE sizeof(int *) /* # of bytes in a pointer (sizeof(int *)) */
        !           228: #endif PDP11
        !           229: 
        !           230: #define RKBLKSIZE 9*WORDSIZE   /* size of record constructor block */
        !           231: #define BITOFFMASK (INTSIZE-1)
        !           232: #define CSETSIZE (256/INTSIZE) /* number of ints to hold 256 cset
        !           233:                                     bits.  Use (256/INTSIZE)+1 if
        !           234:                                     256 % INTSIZE != 0 */
        !           235: 
        !           236: #define MAXHDR     1024        /* size of autoloading header */
        !           237: #define HDRFILE        IconxHdr
        !           238: 
        !           239: /*
        !           240:  * Cset accessing macros.  The definition of setb(b,c) is the total
        !           241:  *  result of the following definitions.  setb is only used in
        !           242:  *  code.c/emitcon.
        !           243:  */
        !           244: /*
        !           245:  * Offset in word of cs bit.
        !           246:  */
        !           247: #define CSOFF(b)       ((b) & BITOFFMASK) 
        !           248: /*
        !           249:  * Address of word of cs bit.
        !           250:  */
        !           251: #define CSPTR(b,c)     ((c) + (((b)&0377) >> LOGINTSIZE)) 
        !           252: /*
        !           253:  * Set bit b in cset c.
        !           254:  */
        !           255: #define setb(b,c)      (*CSPTR(b,c) |= (01 << CSOFF(b))) 
        !           256: /*
        !           257:  * Test bit b in cset c.
        !           258:  */
        !           259: #define tstb(b,c)      ((*CSPTR(b,c) >> CSOFF(b)) & 01) 

unix.superglobalmegacorp.com

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