1 /****************************************************************
2 Copyright 1990, 1991 by AT&T Bell Laboratories and Bellcore.
4 Permission to use, copy, modify, and distribute this software
5 and its documentation for any purpose and without fee is hereby
6 granted, provided that the above copyright notice appear in all
7 copies and that both that the copyright notice and this
8 permission notice and warranty disclaimer appear in supporting
9 documentation, and that the names of AT&T Bell Laboratories or
10 Bellcore or any of their entities not be used in advertising or
11 publicity pertaining to distribution of the software without
12 specific, written prior permission.
14 AT&T and Bellcore disclaim all warranties with regard to this
15 software, including all implied warranties of merchantability
16 and fitness. In no event shall AT&T or Bellcore be liable for
17 any special, indirect or consequential damages or any damages
18 whatsoever resulting from loss of use, data or profits, whether
19 in an action of contract, negligence or other tortious action,
20 arising out of or in connection with the use or performance of
22 ****************************************************************/
27 #define MEMBSIZE 32000
28 #define GMEMBSIZE 16000
36 static char *last, *next;
40 if ((long)next & 0xe000000000000000)
41 next = (char *)(((long)next & 0x1fffffffffffffff) + 1);
47 next = (char *)(((long)next + sizeof(char *)-1)
48 & ~((long)sizeof(char *)-1));
52 if ((next += n) > last) {
53 rv = Alloc(n + GMEMBSIZE);
56 last = next + GMEMBSIZE;
62 struct memblock *next;
65 typedef struct memblock memblock;
67 static memblock *mem0;
68 memblock *curmemblock, *firstmemblock;
70 char *mem_first, *mem_next, *mem_last, *mem0_last;
75 curmemblock = firstmemblock = mem0
76 = (memblock *)Alloc(sizeof(memblock));
77 mem_first = mem0->buf;
79 mem_last = mem0->buf + MEMBSIZE;
80 mem0_last = mem0->buf + MEMBSIZE;
89 register char *rv, *s;
93 if ((long)mem_next & 0xe000000000000000)
94 mem_next = (char *)(((long)mem_next & 0x1fffffffffffffff) + 1);
97 if ((int)mem_next & 1)
100 mem_next = (char *)(((long)mem_next + sizeof(char *)-1)
101 & ~((long)sizeof(char *)-1));
108 fprintf(stderr, "mem(%d) failure!\n", n);
111 if (!(b = curmemblock->next)) {
112 b = (memblock *)Alloc(sizeof(memblock));
113 curmemblock->next = b;
118 mem_last = rv + sizeof(b->buf);
130 register char *s1, *se, **sf;
132 register int k = n + 2, t;
139 t = *(unsigned char *)s;
147 for(s = s0; s < se; s++) {
148 t = *(unsigned char *)s;
149 sprintf(s1, sf[t], t);
160 return strcpy(mem(strlen(s)+1,0), s);
164 new_iob_data(ios, name)
165 register io_setup *ios;
168 register iob_data *iod;
169 register char **s, **se;
172 mem(sizeof(iob_data) + ios->nelt*sizeof(char *), 1);
173 iod->next = iob_list;
175 iod->type = ios->fields[0];
176 iod->name = cpstring(name);
190 sprintf(buf, "%s%ld", pfx, n);
191 /* can't trust return type of sprintf -- BSD gets it wrong */
192 return strcpy(mem(strlen(buf)+1,0), buf);
195 static defines *define_list;
198 def_start(outfile, s1, s2, post)
200 char *s1, *s2, *post;
208 d = (defines *)mem(sizeof(defines)+n, 1);
209 d->next = define_list;
211 strcpy(d->defname, s1);
213 strcpy(d->defname + n1, s2);
214 nice_printf(outfile, "#define %s %s", d->defname, post);
218 other_undefs(outfile)
222 if (d = define_list) {
224 nice_printf(outfile, "\n");
226 nice_printf(outfile, "#undef %s\n", d->defname);
228 nice_printf(outfile, "\n");