a.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <bio.h>
  12. #include "../5c/5.out.h"
  13. #ifndef EXTERN
  14. #define EXTERN extern
  15. #endif
  16. typedef struct Sym Sym;
  17. typedef struct Gen Gen;
  18. typedef struct Io Io;
  19. typedef struct Hist Hist;
  20. #define MAXALIGN 7
  21. #define FPCHIP 1
  22. #define NSYMB 8192
  23. #define BUFSIZ 8192
  24. #define HISTSZ 20
  25. #define NINCLUDE 10
  26. #define NHUNK 10000
  27. #define EOF (-1)
  28. #define IGN (-2)
  29. #define GETC() ((--fi.c < 0)? filbuf(): *fi.p++ & 0xff)
  30. #define NHASH 503
  31. #define STRINGSZ 200
  32. #define NMACRO 10
  33. struct Sym
  34. {
  35. Sym* link;
  36. char* macro;
  37. long value;
  38. ushort type;
  39. char *name;
  40. char sym;
  41. };
  42. #define S ((Sym*)0)
  43. EXTERN struct
  44. {
  45. char* p;
  46. int c;
  47. } fi;
  48. struct Io
  49. {
  50. Io* link;
  51. char b[BUFSIZ];
  52. char* p;
  53. short c;
  54. short f;
  55. };
  56. #define I ((Io*)0)
  57. EXTERN struct
  58. {
  59. Sym* sym;
  60. short type;
  61. } h[NSYM];
  62. struct Gen
  63. {
  64. Sym* sym;
  65. long offset;
  66. short type;
  67. short reg;
  68. short name;
  69. double dval;
  70. char sval[8];
  71. };
  72. struct Hist
  73. {
  74. Hist* link;
  75. char* name;
  76. long line;
  77. long offset;
  78. };
  79. #define H ((Hist*)0)
  80. enum
  81. {
  82. CLAST,
  83. CMACARG,
  84. CMACRO,
  85. CPREPROC,
  86. Always = 14,
  87. };
  88. EXTERN char debug[256];
  89. EXTERN Sym* hash[NHASH];
  90. EXTERN char* Dlist[30];
  91. EXTERN int nDlist;
  92. EXTERN Hist* ehist;
  93. EXTERN int newflag;
  94. EXTERN Hist* hist;
  95. EXTERN char* hunk;
  96. EXTERN char* include[NINCLUDE];
  97. EXTERN Io* iofree;
  98. EXTERN Io* ionext;
  99. EXTERN Io* iostack;
  100. EXTERN long lineno;
  101. EXTERN int nerrors;
  102. EXTERN long nhunk;
  103. EXTERN int ninclude;
  104. EXTERN Gen nullgen;
  105. EXTERN char* outfile;
  106. EXTERN int pass;
  107. EXTERN char* pathname;
  108. EXTERN long pc;
  109. EXTERN int peekc;
  110. EXTERN int sym;
  111. EXTERN char symb[NSYMB];
  112. EXTERN int thechar;
  113. EXTERN char* thestring;
  114. EXTERN long thunk;
  115. EXTERN Biobuf obuf;
  116. void* alloc(long);
  117. void* allocn(void*, long, long);
  118. void errorexit(void);
  119. void pushio(void);
  120. void newio(void);
  121. void newfile(char*, int);
  122. Sym* slookup(char*);
  123. Sym* lookup(void);
  124. void syminit(Sym*);
  125. long yylex(void);
  126. int getc(void);
  127. int getnsc(void);
  128. void unget(int);
  129. int escchar(int);
  130. void cinit(void);
  131. void pinit(char*);
  132. void cclean(void);
  133. int isreg(Gen*);
  134. void outcode(int, int, Gen*, int, Gen*);
  135. void zname(char*, int, int);
  136. void zaddr(Gen*, int);
  137. void ieeedtod(Ieee*, double);
  138. int filbuf(void);
  139. Sym* getsym(void);
  140. void domacro(void);
  141. void macund(void);
  142. void macdef(void);
  143. void macexpand(Sym*, char*);
  144. void macinc(void);
  145. void maclin(void);
  146. void macprag(void);
  147. void macif(int);
  148. void macend(void);
  149. void outhist(void);
  150. void dodefine(char*);
  151. void prfile(long);
  152. void linehist(char*, int);
  153. void gethunk(void);
  154. void yyerror(char*, ...);
  155. int yyparse(void);
  156. void setinclude(char*);
  157. int assemble(char*);
  158. /*
  159. * system-dependent stuff from ../cc/compat.c
  160. */
  161. enum /* keep in synch with ../cc/cc.h */
  162. {
  163. Plan9 = 1<<0,
  164. Unix = 1<<1,
  165. Windows = 1<<2,
  166. };
  167. int mywait(int*);
  168. int mycreat(char*, int);
  169. int systemtype(int);
  170. int pathchar(void);
  171. int myfork(void);
  172. void* mysbrk(ulong);