#line 1 "/usr/boyd/src/cmd/cc/lex.c" #line 1 "/usr/boyd/src/cmd/cc/./cc.h" #line 1 "/386/include/u.h" typedef unsigned short ushort; typedef unsigned char uchar; typedef unsigned long ulong; typedef unsigned int uint; typedef signed char schar; typedef long long vlong; typedef unsigned long long uvlong; typedef ushort Rune; typedef union FPdbleword FPdbleword; typedef long jmp_buf[2]; typedef unsigned int mpdigit; typedef unsigned char u8int; typedef unsigned short u16int; typedef unsigned int u32int; typedef unsigned long long u64int; union FPdbleword { double x; struct { ulong lo; ulong hi; }; }; typedef char* va_list; #line 56 "/386/include/u.h" #line 58 "/386/include/u.h" #line 64 "/386/include/u.h" #line 2 "/usr/boyd/src/cmd/cc/./cc.h" #line 1 "/sys/include/libc.h" #pragma lib "libc.a" #pragma src "/sys/src/libc" #line 11 "/sys/include/libc.h" extern void* memccpy(void*, void*, int, ulong); extern void* memset(void*, int, ulong); extern int memcmp(void*, void*, ulong); extern void* memcpy(void*, void*, ulong); extern void* memmove(void*, void*, ulong); extern void* memchr(void*, int, ulong); #line 21 "/sys/include/libc.h" extern char* strcat(char*, char*); extern char* strchr(char*, int); extern int strcmp(char*, char*); extern char* strcpy(char*, char*); extern char* strecpy(char*, char*, char*); extern char* strdup(char*); extern char* strncat(char*, char*, long); extern char* strncpy(char*, char*, long); extern int strncmp(char*, char*, long); extern char* strpbrk(char*, char*); extern char* strrchr(char*, int); extern char* strtok(char*, char*); extern long strlen(char*); extern long strspn(char*, char*); extern long strcspn(char*, char*); extern char* strstr(char*, char*); extern int cistrncmp(char*, char*, int); extern int cistrcmp(char*, char*); extern char* cistrstr(char*, char*); extern int tokenize(char*, char**, int); enum { UTFmax = 3, Runesync = 0x80, Runeself = 0x80, Runeerror = 0x80, }; #line 53 "/sys/include/libc.h" extern int runetochar(char*, Rune*); extern int chartorune(Rune*, char*); extern int runelen(long); extern int runenlen(Rune*, int); extern int fullrune(char*, int); extern int utflen(char*); extern int utfnlen(char*, long); extern char* utfrune(char*, long); extern char* utfrrune(char*, long); extern char* utfutf(char*, char*); extern char* utfecpy(char*, char*, char*); extern Rune* runestrcat(Rune*, Rune*); extern Rune* runestrchr(Rune*, Rune); extern int runestrcmp(Rune*, Rune*); extern Rune* runestrcpy(Rune*, Rune*); extern Rune* runestrncpy(Rune*, Rune*, long); extern Rune* runestrecpy(Rune*, Rune*, Rune*); extern Rune* runestrdup(Rune*); extern Rune* runestrncat(Rune*, Rune*, long); extern int runestrncmp(Rune*, Rune*, long); extern Rune* runestrrchr(Rune*, Rune); extern long runestrlen(Rune*); extern Rune* runestrstr(Rune*, Rune*); extern Rune tolowerrune(Rune); extern Rune totitlerune(Rune); extern Rune toupperrune(Rune); extern int isalpharune(Rune); extern int islowerrune(Rune); extern int isspacerune(Rune); extern int istitlerune(Rune); extern int isupperrune(Rune); #line 90 "/sys/include/libc.h" extern void* malloc(ulong); extern void* mallocz(ulong, int); extern void free(void*); extern ulong msize(void*); extern void* mallocalign(ulong, ulong, long, ulong); extern void* calloc(ulong, ulong); extern void* realloc(void*, ulong); extern void setmalloctag(void*, ulong); extern void setrealloctag(void*, ulong); extern ulong getmalloctag(void*); extern ulong getrealloctag(void*); extern void* malloctopoolblock(void*); #line 106 "/sys/include/libc.h" typedef struct Fmt Fmt; struct Fmt{ uchar runes; void *start; void *to; void *stop; int (*flush)(Fmt *); void *farg; int nfmt; va_list args; int r; int width; int prec; ulong flags; }; enum{ FmtWidth = 1, FmtLeft = FmtWidth << 1, FmtPrec = FmtLeft << 1, FmtSharp = FmtPrec << 1, FmtSpace = FmtSharp << 1, FmtSign = FmtSpace << 1, FmtZero = FmtSign << 1, FmtUnsigned = FmtZero << 1, FmtShort = FmtUnsigned << 1, FmtLong = FmtShort << 1, FmtVLong = FmtLong << 1, FmtComma = FmtVLong << 1, FmtByte = FmtComma << 1, FmtFlag = FmtByte << 1 }; extern int print(char*, ...); extern char* seprint(char*, char*, char*, ...); extern char* vseprint(char*, char*, char*, va_list); extern int snprint(char*, int, char*, ...); extern int vsnprint(char*, int, char*, va_list); extern char* smprint(char*, ...); extern char* vsmprint(char*, va_list); extern int sprint(char*, char*, ...); extern int fprint(int, char*, ...); extern int vfprint(int, char*, va_list); extern int runesprint(Rune*, char*, ...); extern int runesnprint(Rune*, int, char*, ...); extern int runevsnprint(Rune*, int, char*, va_list); extern Rune* runeseprint(Rune*, Rune*, char*, ...); extern Rune* runevseprint(Rune*, Rune*, char*, va_list); extern Rune* runesmprint(char*, ...); extern Rune* runevsmprint(char*, va_list); extern int fmtfdinit(Fmt*, int, char*, int); extern int fmtfdflush(Fmt*); extern int fmtstrinit(Fmt*); extern char* fmtstrflush(Fmt*); extern int runefmtstrinit(Fmt*); extern Rune* runefmtstrflush(Fmt*); #pragma varargck argpos fmtprint 2 #pragma varargck argpos fprint 2 #pragma varargck argpos print 1 #pragma varargck argpos runeseprint 3 #pragma varargck argpos runesmprint 1 #pragma varargck argpos runesnprint 3 #pragma varargck argpos runesprint 2 #pragma varargck argpos seprint 3 #pragma varargck argpos smprint 1 #pragma varargck argpos snprint 3 #pragma varargck argpos sprint 2 #pragma varargck type "lld" vlong #pragma varargck type "llx" vlong #pragma varargck type "lld" uvlong #pragma varargck type "llx" uvlong #pragma varargck type "ld" long #pragma varargck type "lx" long #pragma varargck type "ld" ulong #pragma varargck type "lx" ulong #pragma varargck type "d" int #pragma varargck type "x" int #pragma varargck type "c" int #pragma varargck type "C" int #pragma varargck type "d" uint #pragma varargck type "x" uint #pragma varargck type "c" uint #pragma varargck type "C" uint #pragma varargck type "f" double #pragma varargck type "e" double #pragma varargck type "g" double #pragma varargck type "s" char* #pragma varargck type "q" char* #pragma varargck type "S" Rune* #pragma varargck type "Q" Rune* #pragma varargck type "r" void #pragma varargck type "%" void #pragma varargck type "n" int* #pragma varargck type "p" void* #pragma varargck flag ',' #pragma varargck type "<" void* #pragma varargck type "[" void* #pragma varargck type "H" void* #pragma varargck type "lH" void* extern int fmtinstall(int, int (*)(Fmt*)); extern int dofmt(Fmt*, char*); extern int dorfmt(Fmt*, Rune*); extern int fmtprint(Fmt*, char*, ...); extern int fmtvprint(Fmt*, char*, va_list); extern int fmtrune(Fmt*, int); extern int fmtstrcpy(Fmt*, char*); extern int fmtrunestrcpy(Fmt*, Rune*); #line 223 "/sys/include/libc.h" extern int errfmt(Fmt *f); #line 228 "/sys/include/libc.h" extern char *unquotestrdup(char*); extern Rune *unquoterunestrdup(Rune*); extern char *quotestrdup(char*); extern Rune *quoterunestrdup(Rune*); extern int quotestrfmt(Fmt*); extern int quoterunestrfmt(Fmt*); extern void quotefmtinstall(void); extern int (*doquote)(int); extern int needsrcquote(int); #line 241 "/sys/include/libc.h" extern void srand(long); extern int rand(void); extern int nrand(int); extern long lrand(void); extern long lnrand(long); extern double frand(void); extern ulong truerand(void); extern ulong ntruerand(ulong); #line 253 "/sys/include/libc.h" extern ulong getfcr(void); extern void setfsr(ulong); extern ulong getfsr(void); extern void setfcr(ulong); extern double NaN(void); extern double Inf(int); extern int isNaN(double); extern int isInf(double, int); extern ulong umuldiv(ulong, ulong, ulong); extern long muldiv(long, long, long); extern double pow(double, double); extern double atan2(double, double); extern double fabs(double); extern double atan(double); extern double log(double); extern double log10(double); extern double exp(double); extern double floor(double); extern double ceil(double); extern double hypot(double, double); extern double sin(double); extern double cos(double); extern double tan(double); extern double asin(double); extern double acos(double); extern double sinh(double); extern double cosh(double); extern double tanh(double); extern double sqrt(double); extern double fmod(double, double); #line 292 "/sys/include/libc.h" typedef struct Tm { int sec; int min; int hour; int mday; int mon; int year; int wday; int yday; char zone[4]; int tzoff; } Tm; extern Tm* gmtime(long); extern Tm* localtime(long); extern char* asctime(Tm*); extern char* ctime(long); extern double cputime(void); extern long times(long*); extern long tm2sec(Tm*); extern vlong nsec(void); extern void cycles(uvlong*); #line 322 "/sys/include/libc.h" enum { PNPROC = 1, PNGROUP = 2, }; extern void _assert(char*); extern int abs(int); extern int atexit(void(*)(void)); extern void atexitdont(void(*)(void)); extern int atnotify(int(*)(void*, char*), int); extern double atof(char*); extern int atoi(char*); extern long atol(char*); extern vlong atoll(char*); extern double charstod(int(*)(void*), void*); extern char* cleanname(char*); extern int decrypt(void*, void*, int); extern int encrypt(void*, void*, int); extern int dec64(uchar*, int, char*, int); extern int enc64(char*, int, uchar*, int); extern int dec32(uchar*, int, char*, int); extern int enc32(char*, int, uchar*, int); extern int dec16(uchar*, int, char*, int); extern int enc16(char*, int, uchar*, int); extern int encodefmt(Fmt*); extern void exits(char*); extern double frexp(double, int*); extern ulong getcallerpc(void*); extern char* getenv(char*); extern int getfields(char*, char**, int, int, char*); extern int gettokens(char *, char **, int, char *); extern char* getuser(void); extern char* getwd(char*, int); extern int iounit(int); extern long labs(long); extern double ldexp(double, int); extern void longjmp(jmp_buf, int); extern char* mktemp(char*); extern double modf(double, double*); extern int netcrypt(void*, void*); extern void notejmp(void*, jmp_buf, int); extern void perror(char*); extern int postnote(int, int, char *); extern double pow10(int); extern int putenv(char*, char*); extern void qsort(void*, long, long, int (*)(void*, void*)); extern int setjmp(jmp_buf); extern double strtod(char*, char**); extern long strtol(char*, char**, int); extern ulong strtoul(char*, char**, int); extern vlong strtoll(char*, char**, int); extern uvlong strtoull(char*, char**, int); extern void sysfatal(char*, ...); #pragma varargck argpos sysfatal 1 extern void syslog(int, char*, char*, ...); #pragma varargck argpos syslog 3 extern long time(long*); extern int tolower(int); extern int toupper(int); #line 386 "/sys/include/libc.h" enum { Profoff, Profuser, Profkernel, Proftime, Profsample, }; extern void prof(void (*fn)(void*), void *arg, int entries, int what); #line 398 "/sys/include/libc.h" typedef struct Lock { int val; } Lock; extern int _tas(int*); extern void lock(Lock*); extern void unlock(Lock*); extern int canlock(Lock*); typedef struct QLp QLp; struct QLp { int inuse; QLp *next; char state; }; typedef struct QLock { Lock lock; int locked; QLp *head; QLp *tail; } QLock; extern void qlock(QLock*); extern void qunlock(QLock*); extern int canqlock(QLock*); extern void _qlockinit(ulong (*)(ulong, ulong)); typedef struct RWLock { Lock lock; int readers; int writer; QLp *head; QLp *tail; } RWLock; extern void rlock(RWLock*); extern void runlock(RWLock*); extern int canrlock(RWLock*); extern void wlock(RWLock*); extern void wunlock(RWLock*); extern int canwlock(RWLock*); typedef struct Rendez { QLock *l; QLp *head; QLp *tail; } Rendez; extern void rsleep(Rendez*); extern int rwakeup(Rendez*); extern int rwakeupall(Rendez*); extern void** privalloc(void); extern void privfree(void**); #line 465 "/sys/include/libc.h" extern int accept(int, char*); extern int announce(char*, char*); extern int dial(char*, char*, char*, int*); extern void setnetmtpt(char*, int, char*); extern int hangup(int); extern int listen(char*, char*); extern char* netmkaddr(char*, char*, char*); extern int reject(int, char*, char*); #line 478 "/sys/include/libc.h" extern int pushssl(int, char*, char*, char*, int*); extern int pushtls(int, char*, char*, int, char*, char*); #line 484 "/sys/include/libc.h" typedef struct NetConnInfo NetConnInfo; struct NetConnInfo { char *dir; char *root; char *spec; char *lsys; char *lserv; char *rsys; char *rserv; char *laddr; char *raddr; }; extern NetConnInfo* getnetconninfo(char*, int); extern void freenetconninfo(NetConnInfo*); #line 504 "/sys/include/libc.h" enum { RFNAMEG = (1<<0), RFENVG = (1<<1), RFFDG = (1<<2), RFNOTEG = (1<<3), RFPROC = (1<<4), RFMEM = (1<<5), RFNOWAIT = (1<<6), RFCNAMEG = (1<<10), RFCENVG = (1<<11), RFCFDG = (1<<12), RFREND = (1<<13), RFNOMNT = (1<<14) }; typedef struct Qid { uvlong path; ulong vers; uchar type; } Qid; typedef struct Dir { ushort type; uint dev; Qid qid; ulong mode; ulong atime; ulong mtime; vlong length; char *name; char *uid; char *gid; char *muid; } Dir; typedef struct Waitmsg { int pid; ulong time[3]; char *msg; } Waitmsg; typedef struct IOchunk { void *addr; ulong len; } IOchunk; extern void _exits(char*); extern void abort(void); extern int access(char*, int); extern long alarm(ulong); extern int await(char*, int); extern int bind(char*, char*, int); extern int brk(void*); extern int chdir(char*); extern int close(int); extern int create(char*, int, ulong); extern int dup(int, int); extern int errstr(char*, uint); extern int exec(char*, char*[]); extern int execl(char*, ...); extern int fork(void); extern int rfork(int); extern int fauth(int, char*); extern int fstat(int, uchar*, int); extern int fwstat(int, uchar*, int); extern int fversion(int, int, char*, int); extern int mount(int, int, char*, int, char*); extern int unmount(char*, char*); extern int noted(int); extern int notify(void(*)(void*, char*)); extern int open(char*, int); extern int fd2path(int, char*, int); extern int pipe(int*); extern long pread(int, void*, long, vlong); extern long preadv(int, IOchunk*, int, vlong); extern long pwrite(int, void*, long, vlong); extern long pwritev(int, IOchunk*, int, vlong); extern long read(int, void*, long); extern long readn(int, void*, long); extern long readv(int, IOchunk*, int); extern int remove(char*); extern void* sbrk(ulong); extern long oseek(int, long, int); extern vlong seek(int, vlong, int); extern long segattach(int, char*, void*, ulong); extern int segbrk(void*, void*); extern int segdetach(void*); extern int segflush(void*, ulong); extern int segfree(void*, ulong); extern int sleep(long); extern int stat(char*, uchar*, int); extern Waitmsg* wait(void); extern int waitpid(void); extern long write(int, void*, long); extern long writev(int, IOchunk*, int); extern int wstat(char*, uchar*, int); extern ulong rendezvous(ulong, ulong); extern Dir* dirstat(char*); extern Dir* dirfstat(int); extern int dirwstat(char*, Dir*); extern int dirfwstat(int, Dir*); extern long dirread(int, Dir**); extern void nulldir(Dir*); extern long dirreadall(int, Dir**); extern int getpid(void); extern int getppid(void); extern void rerrstr(char*, uint); extern char* sysname(void); extern void werrstr(char*, ...); #pragma varargck argpos werrstr 1 extern char *argv0; #line 697 "/sys/include/libc.h" #line 700 "/sys/include/libc.h" #line 702 "/sys/include/libc.h" extern char end[]; #line 3 "/usr/boyd/src/cmd/cc/./cc.h" #line 1 "/sys/include/bio.h" #pragma src "/sys/src/libbio" #pragma lib "libbio.a" typedef struct Biobuf Biobuf; typedef struct Biobufhdr Biobufhdr; enum { Bsize = 8*1024, Bungetsize = 4, Bmagic = 0x314159, Beof = -1, Bbad = -2, Binactive = 0, Bractive, Bwactive, Bracteof, }; struct Biobufhdr { int icount; int ocount; int rdline; int runesize; int state; int fid; int flag; vlong offset; int bsize; uchar* bbuf; uchar* ebuf; uchar* gbuf; }; struct Biobuf { Biobufhdr; uchar b[Bungetsize+Bsize]; }; int Bbuffered(Biobufhdr*); int Bfildes(Biobufhdr*); int Bflush(Biobufhdr*); int Bgetc(Biobufhdr*); int Bgetd(Biobufhdr*, double*); long Bgetrune(Biobufhdr*); int Binit(Biobuf*, int, int); int Binits(Biobufhdr*, int, int, uchar*, int); int Blinelen(Biobufhdr*); vlong Boffset(Biobufhdr*); Biobuf* Bopen(char*, int); int Bprint(Biobufhdr*, char*, ...); int Bvprint(Biobufhdr*, char*, va_list); int Bputc(Biobufhdr*, int); int Bputrune(Biobufhdr*, long); void* Brdline(Biobufhdr*, int); char* Brdstr(Biobufhdr*, int, int); long Bread(Biobufhdr*, void*, long); vlong Bseek(Biobufhdr*, vlong, int); int Bterm(Biobufhdr*); int Bungetc(Biobufhdr*); int Bungetrune(Biobufhdr*); long Bwrite(Biobufhdr*, void*, long); #pragma varargck argpos Bprint 2 #line 4 "/usr/boyd/src/cmd/cc/./cc.h" #line 1 "/sys/include/ctype.h" #pragma src "/sys/src/libc/port" #pragma lib "libc.a" extern unsigned char _ctype[]; #line 5 "/usr/boyd/src/cmd/cc/./cc.h" #pragma lib "../cc/cc.a$O" typedef struct Node Node; typedef struct Sym Sym; typedef struct Type Type; typedef struct Funct Funct; typedef struct Decl Decl; typedef struct Io Io; typedef struct Hist Hist; typedef struct Term Term; typedef struct Init Init; typedef struct Bits Bits; struct Bits { ulong b[5]; }; struct Node { Node* left; Node* right; void* label; long pc; int reg; long xoffset; double fconst; vlong vconst; char* cstring; ushort* rstring; Sym* sym; Type* type; long lineno; char op; char class; char etype; char complex; char addable; char scale; char garb; }; struct Sym { Sym* link; Type* type; Type* suetag; Type* tenum; char* macro; long varlineno; long offset; vlong vconst; double fconst; Node* label; ushort lexical; char *name; ushort block; ushort sueblock; char class; char sym; char aused; char sig; }; enum{ SIGNONE = 0, SIGDONE = 1, SIGINTERN = 2, SIGNINTERN = 1729*325*1729, }; struct Decl { Decl* link; Sym* sym; Type* type; long varlineno; long offset; short val; ushort block; char class; char aused; }; struct Type { Sym* sym; Sym* tag; Funct* funct; Type* link; Type* down; long width; long offset; long lineno; char shift; char nbits; char etype; char garb; }; struct Init { int code; ulong value; char* s; }; extern struct { char* p; long c; } fi; struct Io { Io* link; char* p; char* cb; char* cp; char* cbe; long c; short f; }; struct Hist { Hist* link; char* name; long line; long offset; }; extern Hist* hist; struct Term { vlong mult; Node *node; }; enum { Axxx, Ael1, Ael2, Asu2, Aarg0, Aarg1, Aarg2, Aaut3, NALIGN, }; enum { Plan9 = 1<<0, Unix = 1<<1, Windows = 1<<2, }; enum { DMARK, DAUTO, DSUE, DLABEL, }; enum { OXXX, OADD, OADDR, OAND, OANDAND, OARRAY, OAS, OASI, OASADD, OASAND, OASASHL, OASASHR, OASDIV, OASHL, OASHR, OASLDIV, OASLMOD, OASLMUL, OASLSHR, OASMOD, OASMUL, OASOR, OASSUB, OASXOR, OBIT, OBREAK, OCASE, OCAST, OCOMMA, OCOND, OCONST, OCONTINUE, ODIV, ODOT, ODOTDOT, ODWHILE, OENUM, OEQ, OFOR, OFUNC, OGE, OGOTO, OGT, OHI, OHS, OIF, OIND, OINDREG, OINIT, OLABEL, OLDIV, OLE, OLIST, OLMOD, OLMUL, OLO, OLS, OLSHR, OLT, OMOD, OMUL, ONAME, ONE, ONOT, OOR, OOROR, OPOSTDEC, OPOSTINC, OPREDEC, OPREINC, OPROTO, OREGISTER, ORETURN, OSET, OSIGN, OSIZE, OSTRING, OLSTRING, OSTRUCT, OSUB, OSWITCH, OUNION, OUSED, OWHILE, OXOR, ONEG, OCOM, OPOS, OELEM, OTST, OINDEX, OFAS, OREGPAIR, OEND }; enum { TXXX, TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, TVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND, TFUNC, TARRAY, TVOID, TSTRUCT, TUNION, TENUM, NTYPE, TAUTO = NTYPE, TEXTERN, TSTATIC, TTYPEDEF, TTYPESTR, TREGISTER, TCONSTNT, TVOLATILE, TUNSIGNED, TSIGNED, TDOT, TFILE, TOLD, NALLTYPES, }; enum { CXXX, CAUTO, CEXTERN, CGLOBL, CSTATIC, CLOCAL, CTYPEDEF, CTYPESTR, CPARAM, CSELEM, CLABEL, CEXREG, NCTYPES, }; enum { GXXX = 0, GCONSTNT = 1<<0, GVOLATILE = 1<<1, NGTYPES = 1<<2, GINCOMPLETE = 1<<2, }; enum { BCHAR = 1L<etype) | BUNSIGNED); ndef = 0; outfile = 0; include[ninclude++] = "."; for((argv0||(argv0=*argv)),argv++,argc--; argv[0] && argv[0][0]=='-' && argv[0][1]; argc--, argv++) { char *_args, *_argt; Rune _argc; _args = &argv[0][1]; if(_args[0]=='-' && _args[1]==0){ argc--; argv++; break; } _argc = 0; while(*_args && (_args += chartorune(&_argc, _args))) switch(_argc) { default: c = _argc; if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': outfile =(_argt=_args, _args="", (*_argt? _argt: argv[1]? (argc--, *++argv): 0)); break; case 'D': p =(_argt=_args, _args="", (*_argt? _argt: argv[1]? (argc--, *++argv): 0)); if(p) { defs[ndef++] = p; dodefine(p); } break; case 'I': p =(_argt=_args, _args="", (*_argt? _argt: argv[1]? (argc--, *++argv): 0)); setinclude(p); break; }SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc); if(argc < 1 && outfile == 0) { print("usage: %cc [-options] files\n", thechar); errorexit(); } if(argc > 1 && systemtype(Windows)){ print("can't compile multiple files on windows\n"); errorexit(); } if(argc > 1 && !systemtype(Windows)) { nproc = 1; if(p = getenv("NPROC")) nproc = atol(p); c = 0; nout = 0; for(;;) { while(nout < nproc && argc > 0) { i = myfork(); if(i < 0) { i = mywait(&status); if(i < 0) { print("cannot create a process\n"); errorexit(); } if(status) c++; nout--; continue; } if(i == 0) { fprint(2, "%s:\n", *argv); if (compile(*argv, defs, ndef)) errorexit(); exits(0); } nout++; argc--; argv++; } i = mywait(&status); if(i < 0) { if(c) errorexit(); exits(0); } if(status) c++; nout--; } } if(argc == 0) c = compile("stdin", defs, ndef); else c = compile(argv[0], defs, ndef); if(c) errorexit(); exits(0); } int compile(char *file, char **defs, int ndef) { char ofile[400], incfile[20]; char *p, *av[100], opt[256]; int i, c, fd[2]; strcpy(ofile, file); p = utfrrune(ofile, pathchar()); if(p) { *p++ = 0; if(!debug['.']) include[0] = strdup(ofile); } else p = ofile; if(outfile == 0) { outfile = p; if(outfile) { if(p = utfrrune(outfile, '.')) if(p[1] == 'c' && p[2] == 0) p[0] = 0; p = utfrune(outfile, 0); if(debug['a'] && debug['n']) strcat(p, ".acid"); else if(debug['Z'] && debug['n']) strcat(p, "_pickle.c"); else { p[0] = '.'; p[1] = thechar; p[2] = 0; } } else outfile = "/dev/null"; } if(p = getenv("INCLUDE")) { setinclude(p); } else { if(systemtype(Plan9)) { sprint(incfile, "/%s/include", thestring); setinclude(strdup(incfile)); setinclude("/sys/include"); } } if((debug['a'] || debug['Z']) && !debug['n']) { outfile = 0; Binit(&outbuf, 1,1); } else { c = mycreat(outfile, 0664); if(c < 0) { diag(((Node*)0), "cannot open %s", outfile); outfile = 0; errorexit(); } Binit(&outbuf, c,1); } newio(); if(debug['p']) { if(systemtype(Windows)) { diag(((Node*)0), "-p option not supported on windows"); errorexit(); } if(myaccess(file) < 0) { diag(((Node*)0), "%s does not exist", file); errorexit(); } if(mypipe(fd) < 0) { diag(((Node*)0), "pipe failed"); errorexit(); } switch(myfork()) { case -1: diag(((Node*)0), "fork failed"); errorexit(); case 0: close(fd[0]); mydup(fd[1], 1); close(fd[1]); av[0] = "/bin/cpp"; i = 1; if(debug['+']) { sprint(opt, "-+"); av[i++] = strdup(opt); } for(c = 0; c < ndef; c++) { sprint(opt, "-D%s", defs[c]); av[i++] = strdup(opt); } for(c = 0; c < ninclude; c++) { sprint(opt, "-I%s", include[c]); av[i++] = strdup(opt); } if(strcmp(file, "stdin") != 0) av[i++] = file; av[i] = 0; if(debug['p'] > 1) { for(c = 0; c < i; c++) fprint(2, "%s ", av[c]); print("\n"); } myexec(av[0], av); fprint(2, "can't exec C preprocessor %s: %r\n","/bin/cpp"); errorexit(); default: close(fd[1]); newfile(file, fd[0]); break; } } else { if(strcmp(file, "stdin") == 0) newfile(file, 0); else newfile(file, -1); } yyparse(); if(!debug['a'] && !debug['Z']) gclean(); return nerrors; } void errorexit(void) { if(outfile) remove(outfile); exits("error"); } void pushio(void) { Io *i; i = iostack; if(i ==((Io*)0)) { yyerror("botch in pushio"); errorexit(); } i->p = fi.p; i->c = fi.c; } void newio(void) { Io *i; static int pushdepth = 0; i = iofree; if(i ==((Io*)0)) { pushdepth++; if(pushdepth > 1000) { yyerror("macro/io expansion too deep"); errorexit(); } i = alloc(sizeof(*i)); i->cb = i->cp = alloc(0); i->cb = allocn(i->cb, 0,8192); i->cbe = i->cb + 8192; } else iofree = i->link; i->cb[0] = '\0'; i->cp = i->cb; i->c = 0; i->f = -1; ionext = i; } char extio(Io *i, char c) { long m, n; m = i->cbe - i->cb; n = (m * 3) / 2 + 1; print("REALLOC m %ld n %ld\n", m, n); i->cb = allocn(i->cb, m, n); i->cp = i->cb + m; i->cbe = i->cb + n; *i->cp++ = c; return c; } void addios(Io *i, char *p) { do { ((i ->cp == i ->cbe) ? extio(i, (*p)) : (* i ->cp++ = (*p)); } while (*p++ != '\0'); } void newfile(char *s, int f) { Io *i; if(debug['e']) print("%L: %s\n", lineno, s); i = ionext; i->link = iostack; iostack = i; i->f = f; if(f < 0) i->f = open(s, 0); if(i->f < 0) { yyerror("%cc: %r: %s", thechar, s); errorexit(); } fi.c = 0; linehist(s, 0); } Sym* slookup(char *s) { strcpy(symb, s); return lookup(); } Sym* lookup(void) { Sym *s; ulong h; char *p; int c, n; h = 0; for(p=symb; *p;) { h = h * 3; h += *p++; } n = (p - symb) + 1; if((long)h < 0) h = ~h; h %= 1024; c = symb[0]; for(s = hash[h]; s !=((Sym*)0); s = s->link) { if(s->name[0] != c) continue; if(strcmp(s->name, symb) == 0) return s; } s = alloc(sizeof(*s)); s->name = alloc(n); memmove(s->name, symb, n); strcpy(s->name, symb); s->link = hash[h]; hash[h] = s; syminit(s); return s; } void syminit(Sym *s) { s->lexical = 57367; s->block = 0; s->offset = 0; s->type =((Type*)0); s->suetag =((Type*)0); s->class = CXXX; s->aused = 0; s->sig = SIGNONE; } enum { Numdec = 1<<0, Numlong = 1<<1, Numuns = 1<<2, Numvlong = 1<<3, Numflt = 1<<4, }; long yylex(void) { vlong vv; long c, c1; char *cp; Rune rune; Sym *s; if(peekc !=(-2)) { c = peekc; peekc =(-2); goto l1; } l0: c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); l1: if(c >= Runeself) { #line 445 "/usr/boyd/src/cmd/cc/lex.c" cp = symb; goto talph; } if((_ctype[(unsigned char)(c)]& 010)) { if(c == '\n') lineno++; goto l0; } if((_ctype[(unsigned char)(c)]&(01 | 02))) { cp = symb; if(c != 'L') goto talph; *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c == '\'') { c = escchar('\'', 1, 0); if(c ==(-1)) c = '\''; c1 = escchar('\'', 1, 0); if(c1 !=(-1)) { yyerror("missing '"); peekc = c1; } yylval.vval = convvtox(c, TUSHORT); return 57373; } if(c == '"') { goto caselq; } goto talph; } if((_ctype[(unsigned char)(c)]& 04)) goto tnum; switch(c) { case(-1): peekc =(-1); return -1; case '_': cp = symb; goto talph; case '#': domacro(); goto l0; case '.': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if((_ctype[(unsigned char)(c1)]& 04)) { cp = symb; *cp++ = c; c = c1; c1 = 0; goto casedot; } break; case '"': strcpy(symb, "\"\""); cp = alloc(0); c1 = 0; for(;;) { c = escchar('"', 0, 1); if(c ==(-1)) break; if(c &(1<<20)) { cp = allocn(cp, c1, 1); cp[c1++] = c; } else { rune = c; c = runelen(rune); cp = allocn(cp, c1, c); runetochar(cp+c1, &rune); c1 += c; } } yylval.sval.l = c1; do { cp = allocn(cp, c1, 1); cp[c1++] = 0; } while(c1 & 7); yylval.sval.s = cp; return 57377; caselq: strcpy(symb, "\"L\""); cp = alloc(0); c1 = 0; for(;;) { c = escchar('"', 1, 0); if(c ==(-1)) break; cp = allocn(cp, c1, sizeof(ushort)); *(ushort*)(cp + c1) = c; c1 += sizeof(ushort); } yylval.sval.l = c1; do { cp = allocn(cp, c1, sizeof(ushort)); *(ushort*)(cp + c1) = 0; c1 += sizeof(ushort); } while(c1 & 7); yylval.sval.s = cp; return 57378; case '\'': c = escchar('\'', 0, 0); if(c ==(-1)) c = '\''; c1 = escchar('\'', 0, 0); if(c1 !=(-1)) { yyerror("missing '"); peekc = c1; } vv = c; yylval.vval = convvtox(vv, TUCHAR); if(yylval.vval != vv) yyerror("overflow in character constant: 0x%lx", c); else if(c & 0x80) warn(((Node*)0), "sign-extended character constant"); yylval.vval = convvtox(vv, TCHAR); return 57371; case '/': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '*') { for(;;) { c = getr(); while(c == '*') { c = getr(); if(c == '/') goto l0; } if(c ==(-1)) { yyerror("eof in comment"); errorexit(); } } } if(c1 == '/') { for(;;) { c = getr(); if(c == '\n') goto l0; if(c ==(-1)) { yyerror("eof in comment"); errorexit(); } } } if(c1 == '=') return 57349; break; case '*': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '=') return 57348; break; case '%': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '=') return 57350; break; case '+': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '+') return 57365; if(c1 == '=') return 57346; break; case '-': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '-') return 57364; if(c1 == '=') return 57347; if(c1 == '>') return 57366; break; case '>': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '>') { c = 57363; c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '=') return 57351; break; } if(c1 == '=') return 57361; break; case '<': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '<') { c = 57362; c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '=') return 57352; break; } if(c1 == '=') return 57360; break; case '=': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '=') return 57358; break; case '!': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '=') return 57359; break; case '&': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '&') return 57357; if(c1 == '=') return 57353; break; case '|': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '|') return 57356; if(c1 == '=') return 57355; break; case '^': c1 =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 == '=') return 57354; break; default: return c; } peekc = c1; return c; talph: #line 708 "/usr/boyd/src/cmd/cc/lex.c" for(;;) { if(c >= Runeself) { for(c1=0;;) { cp[c1++] = c; if(fullrune(cp, c1)) break; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); } cp += c1; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); continue; } if(!(_ctype[(unsigned char)(c)]&(01 | 02 | 04)) && c != '_') break; *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); } *cp = 0; if(debug['L']) print("%L: %s\n", lineno, symb); peekc = c; s = lookup(); if(s->macro) { newio(); macexpand(s, ionext); pushio(); ionext->link = iostack; iostack = ionext; cp = iostack->cb; fi.p = cp; fi.c = strlen(cp); if(peekc !=(-2)) { cp[fi.c++] = peekc; cp[fi.c] = 0; peekc =(-2); } goto l0; } yylval.sym = s; if(s->class == CTYPEDEF || s->class == CTYPESTR) return 57368; return s->lexical; tnum: c1 = 0; cp = symb; if(c != '0') { c1 |= Numdec; for(;;) { *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if((_ctype[(unsigned char)(c)]& 04)) continue; goto dc; } } *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c == 'x' || c == 'X') for(;;) { *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if((_ctype[(unsigned char)(c)]& 04)) continue; if(c >= 'a' && c <= 'f') continue; if(c >= 'A' && c <= 'F') continue; if(cp == symb+2) yyerror("malformed hex constant"); goto ncu; } if(c < '0' || c > '7') goto dc; for(;;) { if(c >= '0' && c <= '7') { *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); continue; } goto ncu; } dc: if(c == '.') goto casedot; if(c == 'e' || c == 'E') goto casee; ncu: if((c == 'U' || c == 'u') && !(c1 & Numuns)) { c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); c1 |= Numuns; goto ncu; } if((c == 'L' || c == 'l') && !(c1 & Numvlong)) { c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c1 & Numlong) c1 |= Numvlong; c1 |= Numlong; goto ncu; } *cp = 0; peekc = c; if(mpatov(symb, &yylval.vval)) yyerror("overflow in constant"); if(c1 & Numvlong) { if(c1 & Numuns) { c = 57376; goto nret; } yylval.vval = convvtox(yylval.vval, TVLONG); if(yylval.vval < 0) { c = 57376; goto nret; } c = 57375; goto nret; } if(c1 & Numlong) { if(c1 & Numuns) { c = 57374; goto nret; } yylval.vval = convvtox(yylval.vval, TLONG); if(yylval.vval < 0) { c = 57374; goto nret; } c = 57372; goto nret; } if(c1 & Numuns) { c = 57373; goto nret; } yylval.vval = convvtox(yylval.vval, TINT); if(yylval.vval < 0) { c = 57373; goto nret; } c = 57371; goto nret; nret: return c; casedot: for(;;) { *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(!(_ctype[(unsigned char)(c)]& 04)) break; } if(c != 'e' && c != 'E') goto caseout; casee: *cp++ = 'e'; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c == '+' || c == '-') { *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); } if(!(_ctype[(unsigned char)(c)]& 04)) yyerror("malformed fp constant exponent"); while((_ctype[(unsigned char)(c)]& 04)) { *cp++ = c; c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); } caseout: if(c == 'L' || c == 'l') { c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); c1 |= Numlong; } else if(c == 'F' || c == 'f') { c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); c1 |= Numflt; } *cp = 0; peekc = c; yylval.dval = strtod(symb,((void*)0)); if(isInf(yylval.dval, 1) || isInf(yylval.dval, -1)) { yyerror("overflow in float constant"); yylval.dval = 0; } if(c1 & Numflt) return 57369; return 57370; } #line 906 "/usr/boyd/src/cmd/cc/lex.c" int mpatov(char *s, vlong *v) { vlong n, nn; int c; n = 0; c = *s; if(c == '0') goto oct; while(c = *s++) { if(c >= '0' && c <= '9') nn = n*10 + c-'0'; else goto bad; if(n < 0 && nn >= 0) goto bad; n = nn; } goto out; oct: s++; c = *s; if(c == 'x' || c == 'X') goto hex; while(c = *s++) { if(c >= '0' || c <= '7') nn = n*8 + c-'0'; else goto bad; if(n < 0 && nn >= 0) goto bad; n = nn; } goto out; hex: s++; while(c = *s++) { if(c >= '0' && c <= '9') c += 0-'0'; else if(c >= 'a' && c <= 'f') c += 10-'a'; else if(c >= 'A' && c <= 'F') c += 10-'A'; else goto bad; nn = n*16 + c; if(n < 0 && nn >= 0) goto bad; n = nn; } out: *v = n; return 0; bad: *v = ~0; return 1; } int getc(void) { int c; if(peekc !=(-2)) { c = peekc; peekc =(-2); } else c =((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)); if(c == '\n') lineno++; if(c ==(-1)) { yyerror("End of file"); errorexit(); } return c; } long getr(void) { int c, i; char str[UTFmax+1]; Rune rune; c = getc(); if(c < Runeself) return c; i = 0; str[i++] = c; loop: c = getc(); str[i++] = c; if(!fullrune(str, i)) goto loop; c = chartorune(&rune, str); if(rune == Runeerror && c == 1) { nearln = lineno; diag(((Node*)0), "illegal rune in string"); for(c=0; c0; i--) { c = getc(); if(c >= '0' && c <= '9') { l = l*16 + c-'0'; continue; } if(c >= 'a' && c <= 'f') { l = l*16 + c-'a' + 10; continue; } if(c >= 'A' && c <= 'F') { l = l*16 + c-'A' + 10; continue; } unget(c); break; } if(escflg) l |=(1<<20); return l; } if(c >= '0' && c <= '7') { #line 1103 "/usr/boyd/src/cmd/cc/lex.c" i = 2; if(longflg) i = 5; l = c - '0'; for(; i>0; i--) { c = getc(); if(c >= '0' && c <= '7') { l = l*8 + c-'0'; continue; } unget(c); } if(escflg) l |=(1<<20); return l; } switch(c) { case '\n': goto loop; case 'n': return '\n'; case 't': return '\t'; case 'b': return '\b'; case 'r': return '\r'; case 'f': return '\f'; case 'a': return '\a'; case 'v': return '\v'; } return c; } struct { char *name; ushort lexical; ushort type; } itab[] = { "auto",57379, 0, "break",57380, 0, "case",57381, 0, "char",57382, TCHAR, "const",57411, 0, "continue",57383, 0, "default",57384, 0, "do",57385, 0, "double",57386, TDOUBLE, "else",57387, 0, "enum",57409, 0, "extern",57388, 0, "float",57389, TFLOAT, "for",57390, 0, "goto",57391, 0, "if",57392, 0, "int",57393, TINT, "long",57394, TLONG, "register",57395, 0, "return",57396, 0, "SET",57413, 0, "short",57397, TSHORT, "signed",57410, 0, "signof",57414, 0, "sizeof",57398, 0, "static",57400, 0, "struct",57401, 0, "switch",57402, 0, "typedef",57403, 0, "typestr",57404, 0, "union",57405, 0, "unsigned",57406, 0, "USED",57399, 0, "void",57408, TVOID, "volatile",57412, 0, "while",57407, 0, 0 }; void cinit(void) { Sym *s; int i; Type *t; nerrors = 0; lineno = 1; iostack =((Io*)0); iofree =((Io*)0); peekc =(-2); nhunk = 0; types[TXXX] =((Type*)0); types[TCHAR] = typ(TCHAR,((Type*)0)); types[TUCHAR] = typ(TUCHAR,((Type*)0)); types[TSHORT] = typ(TSHORT,((Type*)0)); types[TUSHORT] = typ(TUSHORT,((Type*)0)); types[TINT] = typ(TINT,((Type*)0)); types[TUINT] = typ(TUINT,((Type*)0)); types[TLONG] = typ(TLONG,((Type*)0)); types[TULONG] = typ(TULONG,((Type*)0)); types[TVLONG] = typ(TVLONG,((Type*)0)); types[TUVLONG] = typ(TUVLONG,((Type*)0)); types[TFLOAT] = typ(TFLOAT,((Type*)0)); types[TDOUBLE] = typ(TDOUBLE,((Type*)0)); types[TVOID] = typ(TVOID,((Type*)0)); types[TENUM] = typ(TENUM,((Type*)0)); types[TFUNC] = typ(TFUNC, types[TINT]); types[TIND] = typ(TIND, types[TVOID]); for(i=0; i< 1024; i++) hash[i] =((Sym*)0); for(i=0; itab[i].name; i++) { s = slookup(itab[i].name); s->lexical = itab[i].lexical; if(itab[i].type != 0) s->type = types[itab[i].type]; } blockno = 0; autobn = 0; autoffset = 0; t = typ(TARRAY, types[TCHAR]); t->width = 0; symstring = slookup(".string"); symstring->class = CSTATIC; symstring->type = t; t = typ(TARRAY, types[TCHAR]); t->width = 0; nodproto = new(OPROTO,((Node*)0),((Node*)0)); dclstack =((Decl*)0); pathname = allocn(pathname, 0, 100); if(mygetwd(pathname, 99) == 0) { pathname = allocn(pathname, 100, 900); if(mygetwd(pathname, 999) == 0) strcpy(pathname, "/???"); } fmtinstall('O', Oconv); fmtinstall('T', Tconv); fmtinstall('F', FNconv); fmtinstall('L', Lconv); fmtinstall('Q', Qconv); fmtinstall('|', VBconv); } int filbuf(void) { Io *i; loop: i = iostack; if(i ==((Io*)0)) return(-1); if(i->f < 0) goto pop; fi.c = read(i->f, i->cb, i->cbe - i->cb) - 1; if(fi.c < 0) { close(i->f); linehist(0, 0); goto pop; } fi.p = i->cb + 1; return i->cb[0] & 0xff; pop: iostack = i->link; i->link = iofree; iofree = i; i = iostack; if(i ==((Io*)0)) return(-1); fi.p = i->p; fi.c = i->c; if(--fi.c < 0) goto loop; return *fi.p++ & 0xff; } int Oconv(Fmt *fp) { int a; a =((sizeof(int) == 1)? ((int *)(fp->args += 4))[-4]: (sizeof(int) == 2)? ((int *)(fp->args += 4))[-2]: ((int *)(fp->args += sizeof(int)))[-1]); if(a < OXXX || a > OEND) return fmtprint(fp, "***badO %d***", a); return fmtstrcpy(fp, onames[a]); } int Lconv(Fmt *fp) { char str[200], s[200]; Hist *h; struct { Hist* incl; long idel; Hist* line; long ldel; } a[20]; long l, d; int i, n; l =((sizeof(long) == 1)? ((long *)(fp->args += 4))[-4]: (sizeof(long) == 2)? ((long *)(fp->args += 4))[-2]: ((long *)(fp->args += sizeof(long)))[-1]); n = 0; for(h = hist; h !=((Hist*)0); h = h->link) { if(l < h->line) break; if(h->name) { if(h->offset != 0) { if(n > 0 && n < 20 && h->offset >= 0) { a[n-1].line = h; a[n-1].ldel = h->line - h->offset + 1; } } else { if(n < 20) { a[n].incl = h; a[n].idel = h->line; a[n].line = 0; } n++; } continue; } n--; if(n > 0 && n < 20) { d = h->line - a[n].incl->line; a[n-1].ldel += d; a[n-1].idel += d; } } if(n > 20) n = 20; str[0] = 0; for(i=n-1; i>=0; i--) { if(i != n-1) { if(fp->flags & ~(FmtWidth|FmtPrec)) break; strcat(str, " "); } if(a[i].line) snprint(s,200, "%s:%ld[%s:%ld]", a[i].line->name, l-a[i].ldel+1, a[i].incl->name, l-a[i].idel+1); else snprint(s,200, "%s:%ld", a[i].incl->name, l-a[i].idel+1); if(strlen(s)+strlen(str) >= 200 -10) break; strcat(str, s); l = a[i].incl->line - 1; } if(n == 0) strcat(str, ""); return fmtstrcpy(fp, str); } int Tconv(Fmt *fp) { char str[200 +20], s[200 +20]; Type *t, *t1; int et; long n; str[0] = 0; for(t =((sizeof(Type*) == 1)? ((Type* *)(fp->args += 4))[-4]: (sizeof(Type*) == 2)? ((Type* *)(fp->args += 4))[-2]: ((Type* *)(fp->args += sizeof(Type*)))[-1]); t !=((Type*)0); t = t->link) { et = t->etype; if(str[0]) strcat(str, " "); if(t->garb&~GINCOMPLETE) { sprint(s, "%s ", gnames[t->garb&~GINCOMPLETE]); if(strlen(str) + strlen(s) < 200) strcat(str, s); } sprint(s, "%s", tnames[et]); if(strlen(str) + strlen(s) < 200) strcat(str, s); if(et == TFUNC && (t1 = t->down)) { sprint(s, "(%T", t1); if(strlen(str) + strlen(s) < 200) strcat(str, s); while(t1 = t1->down) { sprint(s, ", %T", t1); if(strlen(str) + strlen(s) < 200) strcat(str, s); } if(strlen(str) + strlen(s) < 200) strcat(str, ")"); } if(et == TARRAY) { n = t->width; if(t->link && t->link->width) n /= t->link->width; sprint(s, "[%ld]", n); if(strlen(str) + strlen(s) < 200) strcat(str, s); } if(t->nbits) { sprint(s, " %d:%d", t->shift, t->nbits); if(strlen(str) + strlen(s) < 200) strcat(str, s); } if(typesu[et]) { if(t->tag) { strcat(str, " "); if(strlen(str) + strlen(t->tag->name) < 200) strcat(str, t->tag->name); } else strcat(str, " {}"); break; } } return fmtstrcpy(fp, str); } int FNconv(Fmt *fp) { char *str; Node *n; n =((sizeof(Node*) == 1)? ((Node* *)(fp->args += 4))[-4]: (sizeof(Node*) == 2)? ((Node* *)(fp->args += 4))[-2]: ((Node* *)(fp->args += sizeof(Node*)))[-1]); str = ""; if(n !=((Node*)0) && (n->op == ONAME || n->op == ODOT || n->op == OELEM)) str = n->sym->name; return fmtstrcpy(fp, str); } int Qconv(Fmt *fp) { char str[200 +20], *s; long b; int i; str[0] = 0; for(b =((sizeof(long) == 1)? ((long *)(fp->args += 4))[-4]: (sizeof(long) == 2)? ((long *)(fp->args += 4))[-2]: ((long *)(fp->args += sizeof(long)))[-1]); b;) { i = bitno(b); if(str[0]) strcat(str, " "); s = qnames[i]; if(strlen(str) + strlen(s) >= 200) break; strcat(str, s); b &= ~(1L << i); } return fmtstrcpy(fp, str); } int VBconv(Fmt *fp) { char str[200]; int i, n, t, pc; n =((sizeof(int) == 1)? ((int *)(fp->args += 4))[-4]: (sizeof(int) == 2)? ((int *)(fp->args += 4))[-2]: ((int *)(fp->args += sizeof(int)))[-1]); pc = 0; i = 0; while(pc < n) { t = (pc+4) & ~3; if(t <= n) { str[i++] = '\t'; pc = t; continue; } str[i++] = ' '; pc++; } str[i] = 0; return fmtstrcpy(fp, str); } #line 1485 "/usr/boyd/src/cmd/cc/lex.c" void* alloc(long n) { void *p; while((ulong)hunk & 7) { hunk++; nhunk--; } while(nhunk < n) gethunk(); p = hunk; nhunk -= n; hunk += n; return p; } void* allocn(void *p, long on, long n) { void *q; q = (uchar*)p + on; if(q != hunk || nhunk < n) { while(nhunk < on+n) gethunk(); memmove(hunk, p, on); p = hunk; hunk += on; nhunk -= on; } hunk += n; nhunk -= n; return p; } void setinclude(char *p) { int i; char *e; while(*p != 0) { e = strchr(p, ' '); if(e != 0) *e = '\0'; for(i=1; i < ninclude; i++) if(strcmp(p, include[i]) == 0) break; if(i >= ninclude) include[ninclude++] = p; if(ninclude >(sizeof(include)/sizeof((include)[0]))) { diag(((Node*)0), "ninclude too small %d",(sizeof(include)/sizeof((include)[0]))); exits("ninclude"); } if(e == 0) break; p = e+1; } }