X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/ad67d5e597c5eee7565b324022720e72014a0c0f..ef1f0408f691374664d1464de37b97f9c8d24f60:/usr/src/old/as.vax/asscanl.h diff --git a/usr/src/old/as.vax/asscanl.h b/usr/src/old/as.vax/asscanl.h index 60fa79cb91..bd63bc9a46 100644 --- a/usr/src/old/as.vax/asscanl.h +++ b/usr/src/old/as.vax/asscanl.h @@ -1,7 +1,11 @@ /* - * Copyright (c) 1982 Regents of the University of California - * @(#)asscanl.h 4.4 %G% + * Copyright (c) 1982 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)asscanl.h 5.1 (Berkeley) %G% */ + /* * This file contains definitions local to the files implementing * the character scanner and the token buffer managers. @@ -12,16 +16,10 @@ #include #include "as.h" #include "asscan.h" -/* - * Maps characters to their use in assembly language - */ -#define EOFCHAR (-1) -#define NEEDCHAR (-2) +#define EOFCHAR (-1) /* * The table of possible uses for each character to test set inclusion. - * Different than the above table, which knows about tokens yylex - * is to return. */ #define HEXFLAG 01 /* 'x' or 'X' */ #define HEXLDIGIT 02 /* 'a' .. 'f' */ @@ -40,31 +38,26 @@ #define FLOATFLAG 040000 /* 'd', 'D', 'f', 'F' */ #define INCHARSET(val, kind) (charsets[val] & (kind) ) -#ifdef getchar -#undef getchar -#endif -#define getchar() *inbufptr++ - -#ifdef ungetc -#undef ungetc -#endif -#define ungetc(char) *--inbufptr = char - /* - * NOTE: - * This version of the assembler does not use fread and fwrite - * for the token buffering. The token buffers are integrals of BUFSIZ - * at all times, so we use direct read and write. fread and fwrite - * as supplied from BTL in stdio are HORRENDOUSLY inefficient, - * as they use putchar for each character, nested two deep in loops. + * We use our own version of getchar/ungetc to get + * some speed improvement */ -#define writeTEST(pointer, size, nelements, ioptr) \ - write(ioptr->_file, pointer, nelements * size) != nelements * size - -#define readTEST(pointer, size, nelements, ioptr) \ - read(ioptr->_file, pointer, nelements * size) != nelements * size +extern char *Ginbufptr; +extern int Ginbufcnt; +#define REGTOMEMBUF Ginbufptr = inbufptr, Ginbufcnt = inbufcnt +#define MEMTOREGBUF inbufptr = Ginbufptr, inbufcnt = Ginbufcnt +#undef getchar +#define getchar() \ + (inbufcnt-- > 0 ? (*inbufptr++) : \ + (fillinbuffer(), \ + MEMTOREGBUF, \ + inbufptr[-1])) +#undef ungetc +#define ungetc(ch) \ + (++inbufcnt, *--inbufptr = ch) + /* - * Variables to manage the token buffering. + * Variables and definitions to manage the token buffering. * We scan (lexically analyze) a large number of tokens, and * then parse all of the tokens in the scan buffer. * This reduces procedure call overhead when the parser @@ -89,17 +82,18 @@ int bufno; /*which buffer number: 0,1 for tmp file*/ struct tokbufdesc tokbuf[2]; /*our initial increment of buffers*/ ptrall tokptr; /*where the current token comes from*/ ptrall tokub; /*the last token in the current token buffer*/ +/* + * as does not use fread and fwrite for the token buffering. + * The token buffers are integrals of BUFSIZ + * at all times, so we use direct read and write. + * fread and fwrite in stdio are HORRENDOUSLY inefficient, + * as they use putchar for each character, nested two deep in loops. + */ +#define writeTEST(pointer, size, nelements, ioptr) \ + write(ioptr->_file, pointer, nelements * size) != nelements * size -#define bstrlg(from, length) \ - *(lgtype *)from = length; \ - (bytetoktype *)from += sizeof(lgtype) + length - -#define bstrfromto(from,to) \ - *(lgtype *)from = (bytetoktype *)to - (bytetoktype *)from - sizeof(lgtype); \ - (bytetoktype *)from += sizeof(lgtype) + (bytetoktype *)to - (bytetoktype *)from - -#define eatstrlg(from) \ - (bytetoktype *)from += sizeof(lgtype) + *(lgtype *)from +#define readTEST(pointer, size, nelements, ioptr) \ + read(ioptr->_file, pointer, nelements * size) != nelements * size #define bskiplg(from, length) \ *(lgtype *)from = length; \