]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.old-deja/g++.mike/p785.C
typo typo fixes fixes
[thirdparty/gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p785.C
1 // Special g++ Options: -w
2 // Build don't link:
3 // prms-id: 785
4
5 //# 1 "GctNameRef.List.cc"
6 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine++.h" 1
7 // -*- C++ -*-
8 #ifndef FALSE
9 #define FALSE false
10 #endif
11 #ifndef TRUE
12 #define TRUE true
13 #endif
14
15
16 //
17 // WATCHOUT - CC 2.1 uses regular old cpp as its #ifdef processor
18 // whereas GNU uses a special preprocessor (actually ``gcc-cpp -+'')
19 // This implies that there can be no C++ comments on lines which are
20 // to be understood by cpp. Actually it turns out that only lines
21 // with grammatical structures (such as ``#if defined( ... )'') are
22 // affected, but this is probably a good rule to follow elsewhere too.
23 //
24
25 //
26 // Define a ``Standard C++ Unix Machine''
27 //
28 // By whatever means are available in sumachine and elsewhere,
29 // figure out what type of C++ world we are on.
30 //
31 // See also "sumachine.h"
32 //
33 //
34 // This file is expected to be included as the first #include file in
35 // all .cc files This file should be included in each and every src file
36 // compiled b/c it ensures that the environment which those src files
37 // expect exists either by fiat or by faking it.
38 //
39
40
41 //
42 // Its GNU C++
43 //
44 // This pragma only works under g++ 1 (it no longer works for gcc2)
45
46
47
48
49 // Because between releases of Cygnus' stuff, the definitions keep bouncing
50 // around between so fast that one can't
51 // keep one's code compiling ... Just include them all and be done with it.
52 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdlib.h" 1
53
54
55
56
57
58 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
59
60
61 extern "C" {
62
63
64
65 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/mips/lib/gcc/decstatn/cygnus-1.96/include/stddef.h" 1
66
67
68
69
70
71
72 /* This avoids lossage on Sunos but only if stdtypes.h comes first.
73 There's no way to win with the other order! Sun lossage. */
74
75 /* In case nobody has defined these types, but we aren't running under
76 GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
77 __WCHAR_TYPE__ have reasonable values. This can happen if the
78 parts of GCC is compiled by an older compiler, that actually
79 include gstddef.h, such as collect2. */
80
81 /* Signed type of difference of two pointers. */
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 typedef long int ptrdiff_t;
97
98
99
100
101
102
103 /* Unsigned type of `sizeof' something. */
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 typedef int size_t;
119
120
121
122
123
124
125 /* Data type for wide chars. */
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 typedef int wchar_t;
141
142
143
144
145
146
147
148
149 /* A null pointer constant. */
150
151
152
153
154 /* Offset of member MEMBER in a struct of type TYPE. */
155
156
157
158
159
160 //# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 2
161
162
163
164
165 }
166
167 //# 6 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdlib.h" 2
168
169
170 extern "C" {
171
172 int abs(int);
173
174
175 void abort(void);
176
177
178
179
180 double atof(const char*);
181 int atoi(const char*);
182 long atol(const char*);
183
184 int atexit(auto void (*p) (void));
185 int bsearch (const void *, const void *, size_t,
186 size_t, auto int (*ptf)(const void*, const void*));
187 void* calloc(size_t, size_t);
188 void cfree(void*);
189
190
191 void exit(int);
192
193
194
195
196 char* fcvt(double, int, int*, int*);
197 void free(void*);
198 char* getenv(const char*);
199 int getopt(int, const char**, const char*);
200 int getpw(int, char*);
201 char* gcvt(double, int, char*);
202 char* ecvt(double, int, int*, int*);
203 extern char** environ;
204
205 long labs(long);
206 void* malloc(size_t);
207 size_t malloc_usable_size(void*);
208 int putenv(const char*);
209 extern char* optarg;
210 extern int opterr;
211 extern int optind;
212 void qsort(void*, size_t, size_t, auto int (*ptf)(void*,void*));
213 int rand(void);
214 void* realloc(void*, size_t);
215 int setkey(const char*);
216 int srand(unsigned int);
217 double strtod(const char*, char**);
218 long strtol(const char*, char**, int);
219 unsigned long stroul(const char**, int);
220 int system(const char*);
221
222 long random(void);
223 void srandom(int);
224 char* setstate(char*);
225 char* initstate(unsigned, char*, int);
226
227 double drand48(void);
228 void lcong48(short*);
229 long jrand48(short*);
230 long lrand48(void);
231 long mrand48(void);
232 long nrand48(short*);
233 short* seed48(short*);
234 void srand48(long);
235
236 char* ctermid(char*);
237 char* cuserid(char*);
238 char* tempnam(const char*, const char*);
239 char* tmpnam(char*);
240
241 }
242
243 //# 44 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine++.h" 2
244
245 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 1
246 // This may look like C code, but it is really -*- C++ -*-
247 /*
248 Copyright (C) 1988, 1992 Free Software Foundation
249 written by Doug Lea (dl@rocky.oswego.edu)
250
251 This file is part of the GNU C++ Library. This library is free
252 software; you can redistribute it and/or modify it under the terms of
253 the GNU Library General Public License as published by the Free
254 Software Foundation; either version 2 of the License, or (at your
255 option) any later version. This library is distributed in the hope
256 that it will be useful, but WITHOUT ANY WARRANTY; without even the
257 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
258 PURPOSE. See the GNU Library General Public License for more details.
259 You should have received a copy of the GNU Library General Public
260 License along with this library; if not, write to the Free Software
261 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
262 */
263
264
265
266
267
268 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
269 //# 12 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h"
270
271 //# 23 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 2
272
273 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdlib.h" 1
274
275
276 //# 80 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdlib.h"
277
278 //# 24 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 2
279
280 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/string.h" 1
281
282
283
284
285 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
286 //# 12 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h"
287
288 //# 5 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/string.h" 2
289
290
291
292 extern "C" {
293
294 char* strcat(char*, const char*);
295 char* strchr(const char*, int);
296 int strcmp(const char*, const char*);
297 int strcoll(const char*, const char*);
298 char* strcpy(char*, const char*);
299 size_t strcspn(const char*, const char*);
300 char* strdup(const char*);
301
302 char* strncat(char*, const char*, size_t);
303 int strncmp(const char*, const char*, size_t);
304 char* strncpy(char*, const char*, size_t);
305 char* strpbrk(const char*, const char*);
306 char* strrchr(const char*, int);
307 size_t strspn(const char*, const char*);
308 char* strstr(const char*, const char *);
309 char* strtok(char*, const char*);
310 size_t strxfrm(char*, const char*, size_t);
311
312 }
313
314
315
316
317
318
319
320 extern "C" {
321 char* index(const char*, int);
322 char* rindex(const char*, int);
323 }
324
325
326
327 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/memory.h" 1
328
329
330
331
332 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
333 //# 12 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h"
334
335 //# 5 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/memory.h" 2
336
337
338 extern "C" {
339
340 void* memalign(size_t, size_t);
341 void* memccpy(void*, const void*, int, size_t);
342 void* memchr(const void*, int, size_t);
343
344
345 void* memset(void*, int, size_t);
346 int ffs(int);
347 size_t getpagesize(void);
348 void* valloc(size_t);
349
350 }
351
352
353
354
355
356
357
358
359
360 extern "C" {
361 void bcopy(const void*, void*, size_t); // USG uses version in bcopy.c
362 int bcmp(const void*, const void*, int);
363 void bzero(void*, int);
364 }
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381 //# 43 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/string.h" 2
382
383
384
385 //# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 2
386
387 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/memory.h" 1
388
389 //# 49 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/memory.h"
390
391 //# 26 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 2
392
393 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/unistd.h" 1
394
395
396
397 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
398 //# 12 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h"
399
400 //# 4 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/unistd.h" 2
401
402
403 extern "C" {
404
405
406 void _exit(int);
407
408
409
410
411 unsigned alarm(unsigned);
412 int brk(void*);
413 int chdir(const char*);
414 int chmod(const char*, int);
415 int chown(const char*, int, int);
416 int close(int);
417 char* crypt(const char*, const char*);
418 int dup(int);
419 int dup2(int, int);
420 char* encrypt(char*, int);
421 int execl(const char*, const char *, ...);
422 int execle(const char*, const char *, ...);
423 int execlp(const char*, const char*, ...);
424 int exect(const char*, const char**, char**);
425 int execv(const char*, const char**);
426 int execve(const char*, const char**, char**);
427 int execvp(const char*, const char**);
428 int fchown(int, int, int);
429 int fork(void);
430 int fsync(int);
431 int ftruncate(int, unsigned long);
432 char* getcwd(char*, int);
433 int getdomainname(char*, int);
434 int getdtablesize(void);
435
436 int getgroups(int, int*);
437 int geteuid(void);
438 int getegid(void);
439 int getgid(void);
440 long gethostid(void);
441 int gethostname(char*, int);
442 int getpgrp(...);
443 int getpid(void);
444 int getppid(void);
445 char* getlogin(void);
446 char* getpass(const char*);
447 unsigned getuid(void);
448 int ioctl(int, int, void*);
449 int isatty(int);
450 int link(const char*, const char*);
451 int mkstemp(char*);
452 char* mktemp(char*);
453 int nice(int);
454
455 void volatile pause(void);
456
457
458
459 int pipe(int*);
460 int readlink(const char*, char*, int);
461 int rename(const char*, const char*);
462 int rmdir(const char*);
463 void* sbrk(int);
464 int syscall(int, ...);
465 int setgid(int);
466 int sethostname(const char*, int);
467 int setpgrp(...);
468 int setregid(int, int);
469 int setreuid(int, int);
470 int setuid(int);
471 unsigned sleep(unsigned);
472 void swab(void*, void*, int);
473 int symlink(const char*, const char*);
474 int truncate(const char*, unsigned long);
475 char* ttyname(int);
476 int ttyslot(void);
477 // int umask(int); /* commented out for now; wrong for SunOs4.1 */
478 int unlink(const char*);
479 int vfork(void);
480 int vadvise(int);
481 int vhangup(void);
482
483 long lseek(int, long, int);
484 int read(int, void*, size_t);
485 int write(int, const void*, size_t);
486 int access(const char*, int);
487
488 int flock(int, int);
489
490
491 }
492
493
494
495
496 //# 27 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 2
497
498 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdio.h" 1
499 // This may look like C code, but it is really -*- C++ -*-
500 /*
501 Copyright (C) 1988 Free Software Foundation
502 written by Doug Lea (dl@rocky.oswego.edu)
503
504 This file is part of the GNU C++ Library. This library is free
505 software; you can redistribute it and/or modify it under the terms of
506 the GNU Library General Public License as published by the Free
507 Software Foundation; either version 2 of the License, or (at your
508 option) any later version. This library is distributed in the hope
509 that it will be useful, but WITHOUT ANY WARRANTY; without even the
510 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
511 PURPOSE. See the GNU Library General Public License for more details.
512 You should have received a copy of the GNU Library General Public
513 License along with this library; if not, write to the Free Software
514 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
515 */
516
517 /*
518 * Please check the following before installing this file:
519 *
520 * Make sure USG is #defined if you are on a USG system!
521 *
522 * Check the value of _NFILE against the one in your /usr/include/stdio.h.
523 * (USG only)
524 *
525 * Check whether your libc.a sprintf function returns
526 * an int (as do most) versus a char* (BSD), and (un)comment
527 * the corresponding SPRINTF_RETURNS_INT line.
528 *
529 * Check the value of BUFSIZ against the one in your /usr/include/stdio.h.
530 *
531 * Carefully check the fields and order of _iobuf declaration against
532 * the one in your /usr/include/stdio.h. Xenix-based systems
533 * may need some re-ordering of _iobuf. fields.
534 *
535 * Note that some _IOXXX #defines may not be present in your
536 * /usr/include/stdio.h. This is ok, so long as the ones that
537 * are present in both are set to the same values.
538 *
539 * Some of the prototypes refer to functions that may not be
540 * present in your libc.a. This is ok so long as you do not
541 * actually call such functions.
542 *
543 */
544
545
546
547 //#pragma interface
548
549
550
551
552
553
554
555 // Note: The #define _stdio_h is at the end of this file,
556 // in case #include_next finds an installed version of this
557 // same file -- we want it to continue until it finds the C version.
558
559 /*
560 HAVE_VPRINTF should be set if vprintf is in libc.a
561 HAVE_SETVBUF should be set if setvbuf is in libc.a
562 HAVE_SETLINEBUF should be set if setlinebuf in libc.a
563
564 The following are probably correct for the listed systems
565
566 */
567
568
569
570
571
572 //# 85 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdio.h"
573
574
575
576 //# 158 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdio.h"
577
578
579 extern "C" {
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608 //# 1 "/usr/include/stdio.h" 1
609 /* @(#)stdio.h 4.6 (ULTRIX) 3/1/91 */
610 /************************************************************************
611 * *
612 * Copyright (c) 1985 by *
613 * Digital Equipment Corporation, Maynard, MA *
614 * All rights reserved. *
615 * *
616 * This software is furnished under a license and may be used and *
617 * copied only in accordance with the terms of such license and *
618 * with the inclusion of the above copyright notice. This *
619 * software or any other copies thereof may not be provided or *
620 * otherwise made available to any other person. No title to and *
621 * ownership of the software is hereby transferred. *
622 * *
623 * This software is derived from software received from the *
624 * University of California, Berkeley, and from Bell *
625 * Laboratories. Use, duplication, or disclosure is subject to *
626 * restrictions under license agreements with University of *
627 * California and with AT&T. *
628 * *
629 * The information in this software is subject to change without *
630 * notice and should not be construed as a commitment by Digital *
631 * Equipment Corporation. *
632 * *
633 * Digital assumes no responsibility for the use or reliability *
634 * of its software on equipment which is not supplied by Digital. *
635 * *
636 ************************************************************************/
637 /************************************************************************
638 * Modification History
639 *
640 * Mitch Condylis 28-Feb-1991
641 * Changed _file member of FILE structure from char to short
642 * as part of work to increase max number of open file descriptors.
643 *
644 * Mike Thomas, 7-Sep-1990
645 * 016 Back out most of 015. Leave in explicit declarations.
646 *
647 * Mike Thomas, 21-Aug-1990
648 * 015 DECwest ANSI - change _filbuf to __filbuf for ANSI compliance.
649 * Explicitly declare __filbuf under __STDC__.
650 * Likewise flsbuf.
651 *
652 * 014 Mike Thomas, 08-Jun-90
653 * Changed _POSIX_SOURCE reference back to POSIX.
654 *
655 * 013 Dan Smith, 23-Feb-90
656 * Added const to several prototypes. More namespace protection.
657 * Changed reference of POSIX to _POSIX_SOURCE.
658 *
659 * Jon Reeves, 07-Dec-1989
660 * 012 Namespace protection.
661 *
662 * Jon Reeves, 09-Nov-1989
663 * 011 Fix putc properly: could still sign-extend in some cases before.
664 *
665 * Linda Wilson, 06-Oct-1989
666 * 010 Declare sprintf as int for std conformance
667 *
668 * Jon Reeves, 25-Aug-1989
669 * 009 Fix putc[har] for 8-bit mode (unsigned int->char)
670 *
671 * Jon Reeves, 18-Jul-1989
672 * 008 Add getw, putw for X/Open conformance.
673 *
674 * Jon Reeves, 31-May-1989
675 * 007 ANSI conformance; clean up rogue comments. sprintf is still
676 * wrong.
677 *
678 * Lu Anne Van de Pas, 02-Jun-1986
679 * 006 Added ending "/" to P_tmpdir string.
680 *
681 * David L Ballenger, 22-Nov-1985
682 * 005 Correct definition of sprintf() for System V environment.
683 *
684 * David L Ballenger, 01-Aug-1985
685 * 004 Add _IOAPPEND flag for files opened with "A" or "A+".
686 *
687 * David L Ballenger, 26-Jun-1985
688 * 003 Add changes so that FILE structures are allocated dynamically.
689 *
690 * Larry Cohen, 23-April-1985
691 * - change NFILE from 20 to 64
692 *
693 * David L Ballenger, 13-Mar-1985
694 * 0001 Add System V definitions.
695 ************************************************************************/
696
697 //# 1 "/usr/include/ansi_compat.h" 1
698 /*
699 * @(#)ansi_compat.h 4.4 (ULTRIX) 10/8/90
700 */
701
702 /************************************************************************
703 * *
704 * Copyright (c) 1990 by *
705 * Digital Equipment Corporation, Maynard, MA *
706 * All rights reserved. *
707 * *
708 * This software is furnished under a license and may be used and *
709 * copied only in accordance with the terms of such license and *
710 * with the inclusion of the above copyright notice. This *
711 * software or any other copies thereof may not be provided or *
712 * otherwise made available to any other person. No title to and *
713 * ownership of the software is hereby transferred. *
714 * *
715 * The information in this software is subject to change without *
716 * notice and should not be construed as a commitment by Digital *
717 * Equipment Corporation. *
718 * *
719 * Digital assumes no responsibility for the use or reliability *
720 * of its software on equipment which is not supplied by Digital. *
721 * *
722 ************************************************************************/
723
724 /*
725 * To avoid namespace pollution when using the ULTRIX header files under the
726 * DEC ANSI compiler, all user-visible header files were modifed to reference
727 * ANSI-style predefined macro name rather than their traditional names
728 * (__ultrix vice ultrix). Every file which accesses a predefined macro name
729 * must include this file before any other files are included or the macros
730 * are tested.
731 *
732 * In strict ANSI mode, the appropriate ANSI-style macros are already
733 * defined and the redefinitions in this file will not be seen. When using
734 * pcc, the traditional macro names are defined and this file will define
735 * ANSI-style equivalents of the traditional names. When using the DEC C
736 * compiler, both the traditional and ANSI predefined macro names are
737 * available so the definitions in this file are not made visible.
738 *
739 */
740
741
742 //# 116 "/usr/include/ansi_compat.h"
743
744 //# 89 "/usr/include/stdio.h" 2
745
746
747
748
749
750
751
752
753
754
755
756
757
758 /* Note: spacing must match, too, to avoid warnings */
759
760
761
762
763 extern struct _iobuf {
764 int _cnt;
765 char *_ptr;
766 char *_base;
767 int _bufsiz;
768 short _flag;
769 short _file;
770 } _iob[3 ];
771 typedef struct _iobuf FILE;
772
773 typedef long fpos_t;
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791 /* fseek() values */
792
793
794
795
796
797
798
799 /*
800 * prototype
801 *
802 */
803 extern int getc( FILE *__stream );
804 extern int getchar( void );
805 extern int putc( int __c, FILE *__stream);
806 extern int putchar( int __c);
807 extern int feof( FILE *__stream );
808 extern int ferror( FILE *__stream );
809 extern int fileno( FILE *__stream );
810 extern int _filbuf( FILE *p);
811 extern int _flsbuf( unsigned char x , FILE *p);
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828 typedef char *va_list;
829
830 /*
831 * prototypes
832 *
833 */
834 extern void clearerr( FILE *__stream);
835 extern int fclose( FILE *__stream );
836 extern FILE * c_proto_fdopen ( int __filedes, char *__type );
837 extern int fflush( FILE *__stream );
838 extern int fgetc( FILE *__stream );
839 extern int fgetpos( FILE *__stream, fpos_t *__pos );
840 extern char * fgets( char *__s, int __n, FILE *__stream );
841 extern FILE * c_proto_fopen ( const char *__filename, const char *__type );
842 extern int c_proto_fprintf ( FILE *__stream, const char *__format, ... );
843 extern int fputc( int __c, FILE *__stream );
844 extern int c_proto_fputs ( const char *__s, FILE *__stream );
845 extern size_t fread( void *__ptr, size_t __size,
846 size_t __nitems, FILE *__stream );
847 extern FILE * c_proto_freopen ( const char *__filename, const char *__type,
848 FILE *__stream );
849 extern int c_proto_fscanf ( FILE *__stream, const char *__format, ... );
850 extern int fseek( FILE *__stream, long __offset, int __ptrname );
851 extern int fsetpos( FILE *__stream, const fpos_t *__pos );
852 extern long ftell( FILE *__stream );
853 extern size_t c_proto_fwrite ( const void *__ptr, size_t __size,
854 size_t __nitems, FILE *__stream );
855 extern char * gets( char *__s );
856 extern void c_proto_perror ( const char *__s );
857 extern FILE * c_proto_popen (const char *__command, const char *__type );
858 extern int c_proto_printf ( const char *__format, ... );
859 extern int c_proto_puts ( const char *__s );
860 extern int remove( const char *__filename );
861 extern int rename( const char *__from, const char *__to );
862 extern void c_proto_rewind ( FILE *__stream );
863 extern int c_proto_scanf ( const char *__format, ... );
864 extern void c_proto_setbuf ( FILE *__stream, char *__buf );
865 extern int c_proto_setvbuf ( FILE *__stream, char *__buf,
866 int __type, size_t __size );
867 extern int c_proto_sscanf ( const char *__s, const char *__format, ... );
868 extern FILE * tmpfile( void );
869 extern char * tmpnam( char *__s );
870 extern int ungetc( int __c, FILE *__stream );
871 extern int c_proto_vfprintf ( FILE *__stream, const char *__format, va_list __ap );
872 extern int c_proto_vprintf ( const char *__format, va_list __ap );
873 extern int c_proto_vsprintf ( char *__s, const char *__format, va_list __ap);
874
875
876 extern char * c_proto_tempnam ( const char *__dir, const char *__pfx);
877 extern int c_proto_putw ( int __w, FILE *__stream );
878 extern int getw(FILE *__stream);
879 extern int pclose( FILE *__stream );
880
881
882 //# 298 "/usr/include/stdio.h"
883
884
885
886 /* function prototype */
887 extern int c_proto_sprintf ( char *__s, const char *__format, ... );
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907 //# 189 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdio.h" 2
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938 }
939
940
941
942
943
944 extern "C" {
945
946 //# 239 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stdio.h"
947
948 int fclose(FILE*);
949 FILE* fdopen(int, const char*);
950 int fflush(FILE*);
951 int fgetc(FILE*);
952 char* fgets(char*, int, FILE *);
953 FILE* fopen(const char*, const char*);
954 int fprintf(FILE*, const char* ...);
955 int fputc(int, FILE*);
956 int fputs(const char*, FILE*);
957 size_t fread(void*, size_t, size_t, FILE*);
958
959
960
961 FILE* freopen(const char*, const char*, FILE*);
962
963 int fscanf(FILE*, const char* ...);
964 int fseek(FILE*, long, int);
965 long ftell(FILE *);
966 unsigned int fwrite(const void*, unsigned int, unsigned int, FILE*);
967 char* gets(char*);
968 int getw(FILE*);
969 int pclose(FILE*);
970 void perror(const char*);
971 FILE* popen(const char*, const char*);
972 int printf(const char* ...);
973 int puts(const char*);
974 int putw(int, FILE*);
975 int rewind(FILE*);
976 int scanf(const char* ...);
977 int setbuf(FILE*, char*);
978 int setbuffer(FILE*, char*, int);
979 int setlinebuf(FILE*);
980 int setvbuf(FILE*, char*, int, unsigned int);
981 int sscanf(char*, const char* ...);
982 FILE* tmpfile();
983 int ungetc(int, FILE*);
984 int vfprintf(FILE*, const char*, ...);
985
986 // Third arg to vprintf must be '...' for some machines, & doesn't
987 // hurt for others.
988
989 int vprintf(const char*, ... );
990
991
992
993
994
995 char* sprintf(char*, const char*, ...);
996 char* vsprintf(char*, const char*, ...);
997
998
999 }
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018 //# 28 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 2
1019
1020 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/errno.h" 1
1021
1022
1023 extern "C" {
1024
1025
1026
1027
1028
1029 //# 1 "/usr/include/errno.h" 1
1030 /* @(#)errno.h 2.4 (ULTRIX) 11/10/89 */
1031
1032 /************************************************************************
1033 * *
1034 * Copyright (c) 1984, 1987 by *
1035 * Digital Equipment Corporation, Maynard, MA *
1036 * All rights reserved. *
1037 * *
1038 * This software is furnished under a license and may be used and *
1039 * copied only in accordance with the terms of such license and *
1040 * with the inclusion of the above copyright notice. This *
1041 * software or any other copies thereof may not be provided or *
1042 * otherwise made available to any other person. No title to and *
1043 * ownership of the software is hereby transferred. *
1044 * *
1045 * This software is derived from software received from the *
1046 * University of California, Berkeley, and from Bell *
1047 * Laboratories. Use, duplication, or disclosure is subject to *
1048 * restrictions under license agreements with University of *
1049 * California and with AT&T. *
1050 * *
1051 * The information in this software is subject to change without *
1052 * notice and should not be construed as a commitment by Digital *
1053 * Equipment Corporation. *
1054 * *
1055 * Digital assumes no responsibility for the use or reliability *
1056 * of its software on equipment which is not supplied by Digital. *
1057 * *
1058 ************************************************************************/
1059 /*
1060 *
1061 * Modification history:
1062 *
1063 * 10 Jul 89 -- jlr
1064 * Added ENOSYS for POSIX
1065 *
1066 * 13 Jan 88 -- map
1067 * Added ENOLCK for POSIX
1068 *
1069 * 4 Aug 86 -- chet
1070 * Moved NFS error codes to match SUN's.
1071 *
1072 * 24 Feb 86 -- depp
1073 * Added EALIGN error code
1074 *
1075 * 28-Mar-85 -- David L Ballenger
1076 * Add mapping of System V error numbers from BRL package.
1077 *
1078 * 01 Mar 85 -- depp
1079 * Added System V IPC error codes error codes.
1080 *
1081 */
1082
1083 /*
1084 * Error codes
1085 */
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120 /* math software */
1121
1122
1123
1124 /* non-blocking and interrupt i/o */
1125
1126
1127
1128 /* ipc/network software */
1129
1130 /* argument errors */
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144 /* operational errors */
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158 /* */
1159
1160
1161
1162 /* should be rearranged */
1163
1164
1165
1166
1167 /* quotas & mush */
1168
1169
1170
1171
1172 /* NFS error codes */
1173
1174
1175
1176 /* IPC errors
1177 */
1178
1179
1180
1181 /* Alignment error of some type (i.e., cluster, page, block ...) */
1182
1183
1184 /* System V mappings from BRL package
1185 */
1186
1187
1188 /* POSIX errnos
1189 */
1190
1191
1192
1193 /*
1194 * DUP (Diagnostic/Utilities Protocol) related error numbers.
1195 */
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210 /* External definition of errno from System V
1211 */
1212
1213 extern int errno;
1214
1215 //# 9 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/errno.h" 2
1216
1217
1218
1219
1220 extern char* sys_errlist[];
1221 extern int sys_nerr;
1222 extern int errno;
1223 void perror(const char*);
1224 char* strerr(int);
1225
1226
1227 }
1228
1229
1230 //# 29 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 2
1231
1232
1233
1234 //# 45 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine++.h" 2
1235
1236 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/builtin.h" 1
1237 // This may look like C code, but it is really -*- C++ -*-
1238
1239 /*
1240 Copyright (C) 1988, 1992 Free Software Foundation
1241 written by Doug Lea (dl@rocky.oswego.edu)
1242
1243 This file is part of the GNU C++ Library. This library is free
1244 software; you can redistribute it and/or modify it under the terms of
1245 the GNU Library General Public License as published by the Free
1246 Software Foundation; either version 2 of the License, or (at your
1247 option) any later version. This library is distributed in the hope
1248 that it will be useful, but WITHOUT ANY WARRANTY; without even the
1249 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
1250 PURPOSE. See the GNU Library General Public License for more details.
1251 You should have received a copy of the GNU Library General Public
1252 License along with this library; if not, write to the Free Software
1253 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
1254 */
1255
1256 /*
1257 arithmetic, etc. functions on built in types
1258 */
1259
1260
1261
1262
1263 //#pragma interface
1264
1265
1266
1267 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
1268 //# 12 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h"
1269
1270 //# 31 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/builtin.h" 2
1271
1272 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h" 1
1273 // This may look like C code, but it is really -*- C++ -*-
1274 /*
1275 Copyright (C) 1988, 1992 Free Software Foundation
1276 written by Doug Lea (dl@rocky.oswego.edu)
1277
1278 This file is part of the GNU C++ Library. This library is free
1279 software; you can redistribute it and/or modify it under the terms of
1280 the GNU Library General Public License as published by the Free
1281 Software Foundation; either version 2 of the License, or (at your
1282 option) any later version. This library is distributed in the hope
1283 that it will be useful, but WITHOUT ANY WARRANTY; without even the
1284 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
1285 PURPOSE. See the GNU Library General Public License for more details.
1286 You should have received a copy of the GNU Library General Public
1287 License along with this library; if not, write to the Free Software
1288 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
1289 */
1290
1291
1292 //# 31 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/std.h"
1293
1294 //# 32 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/builtin.h" 2
1295
1296 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/math.h" 1
1297 // This may look like C code, but it is really -*- C++ -*-
1298 /*
1299 Copyright (C) 1988 Free Software Foundation
1300 written by Doug Lea (dl@rocky.oswego.edu)
1301
1302 This file is part of the GNU C++ Library. This library is free
1303 software; you can redistribute it and/or modify it under the terms of
1304 the GNU Library General Public License as published by the Free
1305 Software Foundation; either version 2 of the License, or (at your
1306 option) any later version. This library is distributed in the hope
1307 that it will be useful, but WITHOUT ANY WARRANTY; without even the
1308 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
1309 PURPOSE. See the GNU Library General Public License for more details.
1310 You should have received a copy of the GNU Library General Public
1311 License along with this library; if not, write to the Free Software
1312 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
1313 */
1314
1315
1316
1317
1318 //#pragma interface
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330 //# 64 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/math.h"
1331
1332 extern "C" {
1333
1334 double acos(double);
1335 double acosh(double);
1336 double asin(double);
1337 double asinh(double);
1338 double atan(double);
1339 double atan2(double, double);
1340 double atanh(double);
1341 double cbrt(double);
1342 double ceil(double);
1343 double copysign(double,double);
1344 double cos(double);
1345 double cosh(double);
1346 double drem(double,double);
1347 double erf(double);
1348 double erfc(double);
1349 double exp(double);
1350 double expm1(double);
1351 double fabs(double);
1352 double finite(double);
1353 double floor(double);
1354 double frexp(double, int*);
1355 double gamma(double);
1356 double hypot(double,double);
1357 double infnan(int);
1358
1359 /* see below */
1360 int isinf(double);
1361 int isnan(double);
1362
1363 double j0(double);
1364 double j1(double);
1365 double jn(int, double);
1366 double ldexp(double, int);
1367 double lgamma(double);
1368 double log(double);
1369 double log10(double);
1370 double log1p(double);
1371 double logb(double);
1372 double modf(double, double*);
1373 double pow(double, double);
1374 double rint(double);
1375 double scalb(double, int);
1376 double sin(double);
1377 double sinh(double);
1378 double sqrt(double);
1379 double tan(double);
1380 double tanh(double);
1381 double y0(double);
1382 double y1(double);
1383 double yn(int, double);
1384
1385 double aint(double);
1386 double anint(double);
1387 int irint(double);
1388 int nint(double);
1389 }
1390
1391
1392
1393 /* libg++ doesn't use this since it is not available on some systems */
1394
1395 /* the following ifdef is just for compiling OOPS */
1396
1397
1398 struct libm_exception
1399 {
1400 int type;
1401 char* name;
1402 double arg1, arg2, retval;
1403 };
1404
1405
1406
1407
1408
1409
1410
1411
1412 extern "C" int matherr(libm_exception*);
1413
1414
1415
1416 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/values.h" 1
1417 // This may look like C code, but it is really -*- C++ -*-
1418 /*
1419 Copyright (C) 1988 Free Software Foundation
1420 written by Doug Lea (dl@rocky.oswego.edu)
1421
1422 This file is part of the GNU C++ Library. This library is free
1423 software; you can redistribute it and/or modify it under the terms of
1424 the GNU Library General Public License as published by the Free
1425 Software Foundation; either version 2 of the License, or (at your
1426 option) any later version. This library is distributed in the hope
1427 that it will be useful, but WITHOUT ANY WARRANTY; without even the
1428 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
1429 PURPOSE. See the GNU Library General Public License for more details.
1430 You should have received a copy of the GNU Library General Public
1431 License along with this library; if not, write to the Free Software
1432 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
1433 */
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461 //# 150 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/values.h"
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487 //# 149 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/math.h" 2
1488
1489
1490 /* On some systems, HUGE ought to be MAXFLOAT or IEEE infinity */
1491
1492
1493
1494
1495
1496
1497 /* sequents don't supply these. The following should suffice */
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507 /* These seem to be sun & sysV names of these constants */
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557 //# 33 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/builtin.h" 2
1558
1559
1560 typedef void (*one_arg_error_handler_t)(const char*);
1561 typedef void (*two_arg_error_handler_t)(const char*, const char*);
1562
1563 long gcd(long, long);
1564 long lg(unsigned long);
1565 double pow(double, long);
1566 long pow(long, long);
1567
1568 double start_timer();
1569 double return_elapsed_time(double last_time = 0.0);
1570
1571 char* itoa(long x, int base = 10, int width = 0);
1572 char* itoa(unsigned long x, int base = 10, int width = 0);
1573
1574 char* itoa(long long x, int base = 10, int width = 0);
1575 char* itoa(unsigned long long x, int base = 10, int width = 0);
1576
1577 char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6);
1578
1579 char* hex(long x, int width);
1580 char* hex(unsigned long x, int width);
1581 char* hex(int x, int width);
1582 char* hex(short x, int width);
1583 char* hex(unsigned int x, int width);
1584 char* hex(unsigned short x, int width);
1585
1586 char* oct(long x, int width);
1587 char* oct(unsigned long x, int width);
1588 char* oct(int x, int width);
1589 char* oct(short x, int width);
1590 char* oct(unsigned int x, int width) ;
1591 char* oct(unsigned short x, int width);
1592
1593 char* dec(long x, int width);
1594 char* dec(unsigned long x, int width);
1595 char* dec(int x, int width);
1596 char* dec(short x, int width);
1597 char* dec(unsigned int x, int width) ;
1598 char* dec(unsigned short x, int width);
1599
1600 char* form(const char* fmt ...);
1601 char* chr(char ch, int width = 0);
1602 char* str(const char* s, int width = 0);
1603
1604 unsigned int hashpjw(const char*);
1605 unsigned int multiplicativehash(int);
1606 unsigned int foldhash(double);
1607
1608 extern void default_one_arg_error_handler(const char*);
1609 extern void default_two_arg_error_handler(const char*, const char*);
1610
1611 extern two_arg_error_handler_t lib_error_handler;
1612
1613 extern two_arg_error_handler_t
1614 set_lib_error_handler(two_arg_error_handler_t f);
1615
1616
1617 double abs(double arg);
1618 float abs(float arg);
1619 short abs(short arg);
1620 long abs(long arg);
1621 int sign(long arg);
1622 int sign(double arg);
1623 long sqr(long arg);
1624 double sqr(double arg);
1625 int even(long arg);
1626 int odd(long arg);
1627 long lcm(long x, long y);
1628 void setbit(long& x, long b);
1629 void clearbit(long& x, long b);
1630 int testbit(long x, long b);
1631
1632 signed char min(signed char a, signed char b);
1633 unsigned char min(unsigned char a, unsigned char b);
1634
1635 signed short min(signed short a, signed short b);
1636 unsigned short min(unsigned short a, unsigned short b);
1637
1638 signed int min(signed int a, signed int b);
1639 unsigned int min(unsigned int a, unsigned int b);
1640
1641 signed long min(signed long a, signed long b);
1642 unsigned long min(unsigned long a, unsigned long b);
1643
1644 float min(float a, float b);
1645
1646 double min(double a, double b);
1647
1648 signed char max(signed char a, signed char b);
1649 unsigned char max(unsigned char a, unsigned char b);
1650
1651 signed short max(signed short a, signed short b);
1652 unsigned short max(unsigned short a, unsigned short b);
1653
1654 signed int max(signed int a, signed int b);
1655 unsigned int max(unsigned int a, unsigned int b);
1656
1657 signed long max(signed long a, signed long b);
1658 unsigned long max(unsigned long a, unsigned long b);
1659
1660 float max(float a, float b);
1661
1662 double max(double a, double b);
1663
1664
1665
1666
1667 inline double abs(double arg)
1668 {
1669 return (arg < 0.0)? -arg : arg;
1670 }
1671
1672 inline float abs(float arg)
1673 {
1674 return (arg < 0.0)? -arg : arg;
1675 }
1676
1677 inline short abs(short arg)
1678 {
1679 return (arg < 0)? -arg : arg;
1680 }
1681
1682 inline long abs(long arg)
1683 {
1684 return (arg < 0)? -arg : arg;
1685 }
1686
1687 inline int sign(long arg)
1688 {
1689 return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 );
1690 }
1691
1692 inline int sign(double arg)
1693 {
1694 return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 );
1695 }
1696
1697 inline long sqr(long arg)
1698 {
1699 return arg * arg;
1700 }
1701
1702 inline double sqr(double arg)
1703 {
1704 return arg * arg;
1705 }
1706
1707 inline int even(long arg)
1708 {
1709 return !(arg & 1);
1710 }
1711
1712 inline int odd(long arg)
1713 {
1714 return (arg & 1);
1715 }
1716
1717 inline long lcm(long x, long y)
1718 {
1719 return x / gcd(x, y) * y;
1720 }
1721
1722 inline void setbit(long& x, long b)
1723 {
1724 x |= (1 << b);
1725 }
1726
1727 inline void clearbit(long& x, long b)
1728 {
1729 x &= ~(1 << b);
1730 }
1731
1732 inline int testbit(long x, long b)
1733 {
1734 return ((x & (1 << b)) != 0);
1735 }
1736
1737
1738
1739
1740 //# 46 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine++.h" 2
1741
1742
1743 //# 65 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine++.h"
1744
1745
1746 // Take the nice stuff that the regular sumachine.h provides
1747 extern "C" {
1748 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h" 1
1749
1750
1751
1752 /*
1753 * Define a ``Standard Unix Machine''
1754 *
1755 * By whatever means are available in /lib/cpp, figure out
1756 * what type of operating system, maker, machine architecture
1757 * and architecture instance we are on.
1758 *
1759 * OPSYS_TYPE - the type of operating system (e.g. vms)
1760 * OPSYS_SUBTYPE - the subtype of operating system (e.g. bsd, sys5, etc)
1761 * OPSYS_MFR - the manufacturer (e.g. Hewlett-Packard)
1762 * OPSYS_VERS - the operating system version (e.g. sun 4.0)
1763 *
1764 * CPU_TYPE - the architecture (e.g. 68K)
1765 * CPU_MODEL - the architecture instance (e.g. 68010)
1766 *
1767 *
1768 * This file should be #included as the 1st line of each and every .c file
1769 *
1770 * It ensures that the environment which those src files expect exists
1771 * either by fiat or by faking it where the host operating system is not
1772 * up to snuff.
1773 */
1774
1775 /*
1776 * The OPSYS specifics
1777 *
1778 * Parameterized with the best known /lib/cpp predefines
1779 */
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789 /*
1790 * Note that everyone defines the symbol unix except IBM's AIX 3.1
1791 * which doesn't define unix but DOES define the symbol _AIX
1792 */
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814 /*
1815 * WATCHOUT - the newer gcc doesn't define __GNU__
1816 * So we may have to define __GNU__ ourselves
1817 *
1818 * __GNU__ is the old way
1819 * __GNUC__ is the new way
1820 *
1821 * Use gcc -v somefile.c to determine what is being passed.
1822 */
1823
1824 /*
1825 * GNU doesn't know about any opsys-specific
1826 * cpp tokens, so we must figure them out for it.
1827 * GNU does however know about architecture-tokens
1828 */
1829 //# 93 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
1830
1831
1832
1833
1834 /* then if defined(vax) || defined(mips) */
1835 /* then if >= ultrix 4.2 => defined(__vax) || defined(__mips) */
1836
1837
1838 /*
1839 * gcc 1.39 uses the words mips and __mips__ while Ultrix 4.2 has
1840 * been coded in terms of __mips (only!) - so we have to hack it.
1841 *
1842 * See from Ultrix 4.2
1843 *
1844 * Unfortunately also, is turned on only if __STDC__
1845 * is undefined. gcc defines __STDC__ and you can't undef it. So
1846 * We are forced here (as with math.h) to copy and
1847 * strip off the #if !defined(__STDC__).
1848 *
1849 * Further unfortunateness occurs in that the only way we have of
1850 * discovering that we're in Ultrix 4.2 is to #include
1851 * and check for the vector unit support #defined there. However
1852 * we need the workarounds to be defined first in
1853 * order to get the full effect of .
1854 *
1855 * So we have to do all this stuff under any and all Ultrix versions.
1856 *
1857 * We also have to work around the fact that the GNU (gcc 1.95.0 and later)
1858 * compilers may be defining this stuff already
1859 */
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928 /* end of fakeout */
1929
1930
1931 /*
1932 * The r2000 and r3000 are indistinguishable (so far)
1933 */
1934
1935
1936 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/sys/types.h" 1
1937
1938
1939 extern "C"
1940 {
1941
1942
1943
1944
1945
1946 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
1947 //# 12 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h"
1948
1949 //# 10 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/sys/types.h" 2
1950
1951
1952
1953
1954
1955 //# 1 "/usr/include/sys/types.h" 1
1956 /* @(#)types.h 4.3 (ULTRIX) 2/28/91 */
1957
1958 /************************************************************************
1959 * *
1960 * Copyright (c) 1984 - 1989 by *
1961 * Digital Equipment Corporation, Maynard, MA *
1962 * All rights reserved. *
1963 * *
1964 * This software is furnished under a license and may be used and *
1965 * copied only in accordance with the terms of such license and *
1966 * with the inclusion of the above copyright notice. This *
1967 * software or any other copies thereof may not be provided or *
1968 * otherwise made available to any other person. No title to and *
1969 * ownership of the software is hereby transferred. *
1970 * *
1971 * This software is derived from software received from the *
1972 * University of California, Berkeley, and from Bell *
1973 * Laboratories. Use, duplication, or disclosure is subject to *
1974 * restrictions under license agreements with University of *
1975 * California and with AT&T. *
1976 * *
1977 * The information in this software is subject to change without *
1978 * notice and should not be construed as a commitment by Digital *
1979 * Equipment Corporation. *
1980 * *
1981 * Digital assumes no responsibility for the use or reliability *
1982 * of its software on equipment which is not supplied by Digital. *
1983 * *
1984 ************************************************************************/
1985
1986 /* ------------------------------------------------------------------------
1987 * Modification History: /sys/h/types.h
1988 *
1989 * 20-Dec-1989 Larry Scott
1990 * added #ifdef's for compliance
1991 *
1992 * 16-Jun-1989 Jon Reeves
1993 * size_t must be unsigned, per ANSI and X/Open
1994 *
1995 * 05-Jun-1989 Jon Reeves
1996 * Change latch name for size_t; it's in lots of headers.
1997 *
1998 * 12-May-1989 Todd M. Katz TMK0001
1999 * Added volatile type definitions: vu_long, vu_short, vu_char,
2000 * v_long, v_short, and v_char.
2001 *
2002 * 08-May-1989 -- Ken Lesniak
2003 * Conditionalize items also defined in time.h.
2004 *
2005 * 1-Feb-89 -- jmartin
2006 * typedef s_char
2007 *
2008 * 15-Jan-88 lp
2009 * Merge of final 43BSD changes.
2010 *
2011 * 31-August-1987 -- Mark Parenti
2012 * Add definitions needed for POSIX compliance
2013 *
2014 * 27-April-1987 -- Larry Cohen
2015 * Modify the typedef "fd_set" to accomodate 64 file descriptors.
2016 *
2017 * David L Ballenger, 8-Mar-1985
2018 * 0002 Add types for System V compatibility.
2019 *
2020 * 23 Oct 84 -- jrs
2021 * Add ifdef so we can be nested without problem
2022 * Derived from 4.2BSD, labeled:
2023 * types.h 6.2 84/06/09
2024 *
2025 * -----------------------------------------------------------------------
2026 */
2027
2028
2029
2030
2031
2032
2033
2034 //# 1 "/usr/include/ansi_compat.h" 1
2035 /*
2036 * @(#)ansi_compat.h 4.4 (ULTRIX) 10/8/90
2037 */
2038
2039 /************************************************************************
2040 * *
2041 * Copyright (c) 1990 by *
2042 * Digital Equipment Corporation, Maynard, MA *
2043 * All rights reserved. *
2044 * *
2045 * This software is furnished under a license and may be used and *
2046 * copied only in accordance with the terms of such license and *
2047 * with the inclusion of the above copyright notice. This *
2048 * software or any other copies thereof may not be provided or *
2049 * otherwise made available to any other person. No title to and *
2050 * ownership of the software is hereby transferred. *
2051 * *
2052 * The information in this software is subject to change without *
2053 * notice and should not be construed as a commitment by Digital *
2054 * Equipment Corporation. *
2055 * *
2056 * Digital assumes no responsibility for the use or reliability *
2057 * of its software on equipment which is not supplied by Digital. *
2058 * *
2059 ************************************************************************/
2060
2061 /*
2062 * To avoid namespace pollution when using the ULTRIX header files under the
2063 * DEC ANSI compiler, all user-visible header files were modifed to reference
2064 * ANSI-style predefined macro name rather than their traditional names
2065 * (__ultrix vice ultrix). Every file which accesses a predefined macro name
2066 * must include this file before any other files are included or the macros
2067 * are tested.
2068 *
2069 * In strict ANSI mode, the appropriate ANSI-style macros are already
2070 * defined and the redefinitions in this file will not be seen. When using
2071 * pcc, the traditional macro names are defined and this file will define
2072 * ANSI-style equivalents of the traditional names. When using the DEC C
2073 * compiler, both the traditional and ANSI predefined macro names are
2074 * available so the definitions in this file are not made visible.
2075 *
2076 */
2077
2078
2079 //# 116 "/usr/include/ansi_compat.h"
2080
2081 //# 79 "/usr/include/sys/types.h" 2
2082
2083
2084
2085
2086 /*
2087 * Basic system types and major/minor device constructing/busting macros.
2088 */
2089
2090 /* major part of a device */
2091
2092
2093 /* minor part of a device */
2094
2095
2096 /* make a device number */
2097
2098
2099 typedef unsigned char u_char;
2100 typedef unsigned short u_short;
2101 typedef unsigned int u_int;
2102 typedef unsigned int uint; /* sys V compatibility */
2103 typedef unsigned long u_long;
2104 typedef unsigned short ushort; /* sys III compat */
2105
2106 typedef volatile char v_char;
2107 typedef volatile short v_short;
2108 typedef volatile long v_long;
2109 typedef volatile unsigned char vu_char;
2110 typedef volatile unsigned short vu_short;
2111 typedef volatile unsigned long vu_long;
2112
2113 typedef
2114
2115 signed
2116
2117 char s_char;
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127 typedef struct _physadr { int r[1]; } *physadr;
2128 /*
2129 * WARNING:
2130 * this must match the definition of kernel jmpbuf's in machine/pcb.h
2131 */
2132 typedef struct label_t {
2133 int val[12];
2134 } label_t;
2135
2136
2137 typedef struct _quad { long val[2]; } quad;
2138 typedef long daddr_t;
2139 typedef char * caddr_t;
2140 typedef u_long gno_t;
2141 typedef short cnt_t; /* sys V compatibility */
2142 typedef long swblk_t;
2143 typedef long paddr_t; /* sys V compatibility */
2144 typedef long audit_ID_t;
2145
2146
2147 typedef short dev_t;
2148 typedef short gid_t; /* POSIX compliance */
2149 typedef unsigned long ino_t;
2150 typedef unsigned short mode_t; /* POSIX compliance */
2151 typedef short nlink_t; /* POSIX compliance */
2152 typedef int off_t;
2153
2154
2155 typedef int pid_t; /* POSIX compliance */
2156
2157 typedef short uid_t; /* POSIX compliance */
2158
2159
2160 typedef int time_t;
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170 typedef int clock_t; /* POSIX compliance */
2171
2172 typedef long key_t; /* sys V compatibility */
2173
2174
2175
2176
2177 /*
2178 * The maximum number of file descriptors is now a configurable option
2179 * (max_nofile variable in /sys/conf/{mips|vax}/param.c).
2180 * The getdtablesize(2) system call should be used to obtain the
2181 * current limit. The value returned by getdtablesize() must be greater
2182 * than 64, and less than or equal to MAX_NOFILE in types.h . The
2183 * MAX_NOFILE define is needed for backward compatability with broken
2184 * programs that need a static sized array for selecting. These programs
2185 * should be modified to use the getdtablesize() interface for sizing.
2186 */
2187
2188
2189 /*
2190 * Select uses bit masks of file descriptors in longs.
2191 * These macros manipulate such bit fields (the filesystem macros use chars).
2192 * FD_SETSIZE may be defined by the user, but the default here
2193 * should be >= NOFILE (param.h).
2194 */
2195
2196
2197
2198
2199 /* How many things we'll allow select to use. 0 if unlimited */
2200
2201 typedef long fd_mask;
2202
2203
2204
2205
2206
2207
2208 typedef struct fd_set {
2209 fd_mask fds_bits[(((4096 )+(( (sizeof(fd_mask) * 8 ) )-1))/( (sizeof(fd_mask) * 8 ) )) ];
2210 } fd_set;
2211
2212
2213
2214
2215
2216
2217
2218
2219 //# 15 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/sys/types.h" 2
2220
2221
2222
2223
2224
2225
2226 }
2227
2228
2229
2230
2231 //# 199 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h" 2
2232
2233 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/signal.h" 1
2234 // This may look like C code, but it is really -*- C++ -*-
2235 /*
2236 Copyright (C) 1989 Free Software Foundation
2237 written by Doug Lea (dl@rocky.oswego.edu)
2238
2239 This file is part of the GNU C++ Library. This library is free
2240 software; you can redistribute it and/or modify it under the terms of
2241 the GNU Library General Public License as published by the Free
2242 Software Foundation; either version 2 of the License, or (at your
2243 option) any later version. This library is distributed in the hope
2244 that it will be useful, but WITHOUT ANY WARRANTY; without even the
2245 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
2246 PURPOSE. See the GNU Library General Public License for more details.
2247 You should have received a copy of the GNU Library General Public
2248 License along with this library; if not, write to the Free Software
2249 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
2250 */
2251
2252
2253
2254 extern "C" {
2255
2256
2257
2258
2259 //# 1 "/usr/include/signal.h" 1
2260 /* @(#)signal.h 2.8 (ULTRIX) 11/9/89 */
2261
2262 /************************************************************************
2263 * *
2264 * Copyright (c) 1987-1989 by *
2265 * Digital Equipment Corporation, Maynard, MA *
2266 * All rights reserved. *
2267 * *
2268 * This software is furnished under a license and may be used and *
2269 * copied only in accordance with the terms of such license and *
2270 * with the inclusion of the above copyright notice. This *
2271 * software or any other copies thereof may not be provided or *
2272 * otherwise made available to any other person. No title to and *
2273 * ownership of the software is hereby transferred. *
2274 * *
2275 * This software is derived from software received from the *
2276 * University of California, Berkeley, and from Bell *
2277 * Laboratories. Use, duplication, or disclosure is subject to *
2278 * restrictions under license agreements with University of *
2279 * California and with AT&T. *
2280 * *
2281 * The information in this software is subject to change without *
2282 * notice and should not be construed as a commitment by Digital *
2283 * Equipment Corporation. *
2284 * *
2285 * Digital assumes no responsibility for the use or reliability *
2286 * of its software on equipment which is not supplied by Digital. *
2287 * *
2288 ************************************************************************/
2289 /************************************************************************
2290 * Modification History *
2291 * *
2292 * Debby Haeck 11/14/90 *
2293 * added new Vector Arithmetic Exception handling codes *
2294 * Debby Haeck 9/4/90 *
2295 * added new u_code for vector support *
2296 * ILL_VECOP_FAULT, ILL_VECINST_FAULT, TERM_VECT_HARD and *
2297 * TERM_VECT_TOOMANY *
2298 * Tak Yin Wong 3/390 *
2299 * Add ifdef's for POSIX and XOPEN *
2300 * Linda Wilson 9/12/89 *
2301 * typedef sigset_t for X/OPEN *
2302 * Linda Wilson 9/12/89 *
2303 * ifdef out sigmask for POSIX *
2304 * Jon Reeves 7/14/89 *
2305 * Add X/Open mandated function declarations. *
2306 * Jon Reeves 5/16/89 *
2307 * Add new BRK_STACKOVERFLOW def from MIPS 2.0 cmplrs *
2308 * Jon Reeves 5/12/89 *
2309 * Add raise() and sig_atomic_t for ANSI *
2310 * Mark Parenti 2/06/88 *
2311 * Change SA_CLDSTOP to SA_NOCLDSTOP per POSIX change *
2312 * Fred Glover 1/12/88 *
2313 * Add SIGLOST - server crash Sys-V lock notification *
2314 * *
2315 * Larry Cohen 10/1/85 *
2316 * Add SIGWINCH - window change signal *
2317 * *
2318 * Greg Depp 25 Jun 85 *
2319 * Moved SIGUSR1 and SIGUSR2 to 30 and 31 to conform with Berkeley *
2320 * *
2321 * David L Ballenger, 28-Mar-1985 *
2322 * 0001 Add definitions for System V compatibility *
2323 * *
2324 ************************************************************************/
2325
2326
2327
2328
2329
2330
2331
2332
2333 //# 1 "/usr/include/ansi_compat.h" 1
2334 /*
2335 * @(#)ansi_compat.h 4.4 (ULTRIX) 10/8/90
2336 */
2337
2338 /************************************************************************
2339 * *
2340 * Copyright (c) 1990 by *
2341 * Digital Equipment Corporation, Maynard, MA *
2342 * All rights reserved. *
2343 * *
2344 * This software is furnished under a license and may be used and *
2345 * copied only in accordance with the terms of such license and *
2346 * with the inclusion of the above copyright notice. This *
2347 * software or any other copies thereof may not be provided or *
2348 * otherwise made available to any other person. No title to and *
2349 * ownership of the software is hereby transferred. *
2350 * *
2351 * The information in this software is subject to change without *
2352 * notice and should not be construed as a commitment by Digital *
2353 * Equipment Corporation. *
2354 * *
2355 * Digital assumes no responsibility for the use or reliability *
2356 * of its software on equipment which is not supplied by Digital. *
2357 * *
2358 ************************************************************************/
2359
2360 /*
2361 * To avoid namespace pollution when using the ULTRIX header files under the
2362 * DEC ANSI compiler, all user-visible header files were modifed to reference
2363 * ANSI-style predefined macro name rather than their traditional names
2364 * (__ultrix vice ultrix). Every file which accesses a predefined macro name
2365 * must include this file before any other files are included or the macros
2366 * are tested.
2367 *
2368 * In strict ANSI mode, the appropriate ANSI-style macros are already
2369 * defined and the redefinitions in this file will not be seen. When using
2370 * pcc, the traditional macro names are defined and this file will define
2371 * ANSI-style equivalents of the traditional names. When using the DEC C
2372 * compiler, both the traditional and ANSI predefined macro names are
2373 * available so the definitions in this file are not made visible.
2374 *
2375 */
2376
2377
2378 //# 116 "/usr/include/ansi_compat.h"
2379
2380 //# 74 "/usr/include/signal.h" 2
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399 /* absent or non-vector capable sys */
2400 /* CHME, CHMS, CHMU are not yet given back to users reasonably */
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420 /* the following are used to for Vector Arithmetic Exception handling */
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460 /* Add System V signal definitions (DLB001) */
2461
2462
2463
2464
2465
2466
2467
2468 /*
2469 * Codes for the mips break instruction.
2470 */
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487 /* Accesses to sig_atomic_t are atomic, even with async interrupts.
2488 Not an issue for us, but ANSI requires the definition. */
2489 typedef long sig_atomic_t;
2490 typedef int sigset_t; /* type used for sigsetops() functions */
2491
2492
2493 /*
2494 * Signal vector "template" used in sigvec call.
2495 */
2496 struct sigvec {
2497 void (*sv_handler)(); /* signal handler */
2498 sigset_t sv_mask; /* signal mask to apply */
2499 int sv_flags; /* see signal options below */
2500 };
2501
2502
2503 /*
2504 * The following structure must be exactly the same as the above structure
2505 * with the names changed for POSIX compliance.
2506 */
2507 struct sigaction {
2508 void (*sa_handler)(); /* signal handler */
2509 sigset_t sa_mask; /* signal mask to apply */
2510 int sa_flags; /* see signal options below */
2511 };
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526 /* Defines for sigprocmask() call. POSIX.
2527 */
2528
2529
2530
2531
2532
2533
2534 /*
2535 * Structure used in sigstack call.
2536 */
2537 struct sigstack {
2538 char *ss_sp; /* signal stack pointer */
2539 int ss_onstack; /* current status */
2540 };
2541
2542 /*
2543 * Information pushed on stack when a signal is delivered.
2544 * This is used by the kernel to restore state following
2545 * execution of the signal handler. It is also made available
2546 * to the handler to allow it to properly restore state if
2547 * a non-standard exit is performed.
2548 *
2549 //#ifdef __vax
2550 * XXX - sigcontext needs updating per 4.3BSD - rr
2551 *
2552 //#endif __vax
2553 //#ifdef __mips
2554 * WARNING: THE sigcontext MUST BE KEPT CONSISTENT WITH /usr/include/setjmp.h
2555 * AND THE LIBC ROUTINES setjmp() AND longjmp()
2556 //#endif __mips
2557 */
2558 struct sigcontext {
2559
2560 /*
2561 * BEGIN REGION THAT MUST CORRESPOND WITH setjmp.h
2562 * BEGIN REGION THAT MUST CORRESPOND WITH A jmp_buf
2563 */
2564
2565 int sc_onstack; /* sigstack state to restore */
2566 int sc_mask; /* signal mask to restore */
2567
2568
2569
2570
2571
2572
2573 int sc_pc; /* pc at time of signal */
2574 /*
2575 * General purpose registers
2576 */
2577 int sc_regs[32]; /* processor regs 0 to 31 */
2578 int sc_mdlo; /* mul/div low */
2579 int sc_mdhi; /* mul/div high */
2580 /*
2581 * Floating point coprocessor state
2582 */
2583 int sc_ownedfp; /* fp has been used */
2584 int sc_fpregs[32]; /* fp regs 0 to 31 */
2585 int sc_fpc_csr; /* floating point control and status reg */
2586 int sc_fpc_eir; /* floating point exception instruction reg */
2587 /*
2588 * END OF REGION THAT MUST AGREE WITH setjmp.h
2589 * END OF jmp_buf REGION
2590 */
2591 /*
2592 * System coprocessor registers at time of signal
2593 */
2594 int sc_cause; /* cp0 cause register */
2595 int sc_badvaddr; /* cp0 bad virtual address */
2596 int sc_badpaddr; /* cpu bd bad physical address */
2597
2598 };
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622 /*
2623 * prototypes
2624 *
2625 */
2626 extern void (*signal(int __sig, void(*__func)(int)))(int);
2627 int raise( int __sig );
2628 int kill( pid_t __pid, int __sig );
2629 int sigemptyset( sigset_t *__set );
2630 int sigfillset( sigset_t *__set );
2631 int sigaddset( sigset_t *__set, int __signo );
2632 int sigdelset( sigset_t *__set, int __signo );
2633 int sigismember( const sigset_t *__set, int __signo );
2634 int sigaction( int __sig, const struct sigaction *__act,
2635 struct sigaction *__oact );
2636 int sigprocmask( int __how, const sigset_t *__set, sigset_t *__oset );
2637 int sigpending( sigset_t *__set );
2638 int sigsuspend( const sigset_t *__sigmask );
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650 /*
2651 * Macro for converting signal number to a mask suitable for
2652 * sigblock().
2653 */
2654
2655
2656
2657
2658
2659
2660 //# 26 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/signal.h" 2
2661
2662
2663
2664
2665 // The Interviews folks call this SignalHandler. Might as well conform.
2666 // Beware: some systems think that SignalHandler returns int.
2667 typedef void (*SignalHandler) (int);
2668
2669 extern SignalHandler signal(int sig, SignalHandler action);
2670 extern SignalHandler sigset(int sig, SignalHandler action);
2671 extern SignalHandler ssignal(int sig, SignalHandler action);
2672 extern int gsignal (int sig);
2673 extern int kill (int pid, int sig);
2674 extern int killpg(int, int);
2675 extern int siginterrupt(int, int);
2676 extern void psignal(unsigned, char*);
2677
2678
2679 extern int sigsetmask(int mask);
2680 extern int sigblock(int mask);
2681 extern int sigpause(int mask);
2682 extern int sigvec(int sig, struct sigvec* v, struct sigvec* prev);
2683
2684
2685 // The Interviews version also has these ...
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699 }
2700
2701
2702
2703 //# 200 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h" 2
2704
2705
2706 /*
2707 * Note that in Ultrix 4.2 renames all of the
2708 * previously-predefined cpp names to __names. Also there is
2709 * new support for vector processors - TERM_VECT_HARD etc.
2710 */
2711
2712 //# 244 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2713
2714
2715 //# 263 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2716
2717 //# 283 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2718
2719 /* { */
2720 //# 298 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2721
2722 //# 319 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2723
2724 //# 328 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2725
2726 //# 345 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753 //# 387 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2754
2755
2756
2757
2758
2759
2760
2761 /*
2762 * THE CPU specifics
2763 *
2764 * Parameterized with the best known /lib/cpp predefines
2765 * Set up for a middle-of-the-road machine.
2766 */
2767
2768 /*
2769 * DECstation Processor
2770 * 2100 R2000 (slower clock)
2771 * 3100 R2000
2772 * 5000 R3000
2773 * 5400 R3000
2774 * ???? R6000
2775 */
2776 /*
2777 * We might be on the R3000 machine, but there is really
2778 * no way of distinguishing that from the src-code level.
2779 * The GNU people define some stuff, but its usually wrong.
2780 */
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798 //# 453 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808 //# 471 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838 //# 512 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2839
2840 /* will we be porting to this? */
2841 //# 522 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2842
2843
2844 //# 537 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
2845
2846
2847 /*
2848 * The following MUST be literals else /lib/cpp cannot do
2849 * == operations on them. Remember cpp does strcmps, not MATH
2850 *
2851 * OPSYS_TYPE
2852 *
2853 * #if OPSYS_TYPE == MD_opsystype
2854 * #endif
2855 */
2856
2857
2858
2859
2860
2861
2862 /*
2863 * OPSYS_SUBTYPE
2864 *
2865 * #if OPSYS_SUBTYPE == MD_opsyssubtype
2866 * #endif
2867 */
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879 /*
2880 * OPSYS_MFR
2881 *
2882 * #if OPSYS_MFR == MD_opsysmfr
2883 * #endif
2884 */
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900 /*
2901 * OPSYS_VERS
2902 *
2903 * #if OPSYS_VERS == MD_opsysvers
2904 * #endif
2905 * #if OPSYS_MFR == MD_opsysmfr && OPSYS_VERS <= MD_opsysvers
2906 * #endif
2907 */
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032 /*
3033 * CPU_TYPE
3034 *
3035 * #if CPU_TYPE == MD_cputype
3036 * #endif
3037 */
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058 /*
3059 * CPU_MODEL
3060 *
3061 * #if CPU_MODEL == MD_modelname
3062 * #endif
3063 */
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126 /* don't add this stuff in if the query program display.sh is being run */
3127
3128 //# 1754 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine.h"
3129
3130
3131
3132
3133
3134 //# 69 "/sandbox/wbaker/wbaker0/source/mips/include/sumachine++.h" 2
3135
3136 }
3137
3138 // Always turn this stuff on b/c otherwise nothing works
3139
3140
3141
3142
3143
3144 //# 1 "GctNameRef.List.cc" 2
3145
3146 //# 1 "../../../../mips/include/Gct/genclasses.h" 1
3147 // -*- C++ -*-
3148
3149
3150
3151 //
3152 // genclasses - The GNU Container Classes
3153 //
3154 // Expects to be included by Gct.h or where appropriate
3155 // especially before any genclass class headerfile is included.
3156 //
3157 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
3158 //
3159
3160
3161 // Make sure that we get all of the inline functions too but prevent duplicate
3162 // definition warnings.
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173 //
3174 // Turn off the definitions of these hash functions
3175 //
3176 // unsigned hash(GctAstRef&)
3177 //
3178 // So that the following will match and be used instead:
3179 //
3180 // unsigned hash(GctRef&)
3181 //
3182 // The idea is to not allow the various header files to
3183 // create (say) ``unsigned hash(GctAstRef&)'' but to use
3184 // ``hash(x)'' for the hash function anyway. We just want
3185 // the hash() function used to be ``unsigned hash(GctRef&)''
3186 //
3187
3188
3189 //# 1 "../../../../mips/include/Gct/Reference.h" 1
3190 // -*- C++ -*-
3191
3192
3193
3194 //
3195 // Classes:
3196 // GctRef
3197 // GctReferenceObject
3198 //
3199 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
3200 //
3201
3202
3203
3204
3205
3206 //#pragma interface
3207
3208
3209
3210 //# 1 "../../../../mips/include/Gct/Reference/GctReferenceCount.h" 1
3211 // -*- C++ -*-
3212
3213
3214
3215 //
3216 // GctReferenceCount class
3217 //
3218 // Expects to be included by Gct/Reference.h
3219 //
3220 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
3221 //
3222
3223
3224
3225
3226
3227 //#pragma interface
3228
3229
3230
3231
3232
3233 //# 25 "../../../../mips/include/Gct/Reference/GctReferenceCount.h" 2
3234
3235
3236 //# 1 "../../../../mips/include/Gct/GctErrorHandler.h" 1
3237 // -*- C++ -*-
3238
3239
3240
3241 //
3242 // GctErrorHandler class
3243 //
3244 // Expects to be included by Gct.h
3245 //
3246 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
3247 //
3248
3249
3250
3251
3252
3253 //#pragma interface
3254
3255
3256
3257 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
3258
3259
3260
3261
3262
3263
3264
3265 //# 25 "../../../../mips/include/Gct/GctErrorHandler.h" 2
3266
3267 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 1
3268 // This may look like C code, but it is really -*- C++ -*-
3269 /*
3270 Copyright (C) 1988 Free Software Foundation
3271 written by Doug Lea (dl@rocky.oswego.edu)
3272
3273 This file is part of the GNU C++ Library. This library is free
3274 software; you can redistribute it and/or modify it under the terms of
3275 the GNU Library General Public License as published by the Free
3276 Software Foundation; either version 2 of the License, or (at your
3277 option) any later version. This library is distributed in the hope
3278 that it will be useful, but WITHOUT ANY WARRANTY; without even the
3279 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
3280 PURPOSE. See the GNU Library General Public License for more details.
3281 You should have received a copy of the GNU Library General Public
3282 License along with this library; if not, write to the Free Software
3283 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3284 */
3285
3286
3287
3288
3289 //#pragma interface
3290
3291
3292
3293 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 1
3294
3295
3296
3297 // Compatibility with old library.
3298
3299
3300 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
3301 // This is part of the iostream library, providing -*- C++ -*- input/output.
3302 // Copyright (C) 1991 Per Bothner.
3303 //
3304 // This library is free software; you can redistribute it and/or
3305 // modify it under the terms of the GNU Library General Public
3306 // License as published by the Free Software Foundation; either
3307 // version 2 of the License, or (at your option) any later version.
3308 //
3309 // This library is distributed in the hope that it will be useful,
3310 // but WITHOUT ANY WARRANTY; without even the implied warranty of
3311 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3312 // Library General Public License for more details.
3313 //
3314 // You should have received a copy of the GNU Library General Public
3315 // License along with this library; if not, write to the Free
3316 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3317
3318
3319
3320 //#pragma interface
3321
3322
3323
3324
3325 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 1
3326 // This is part of the iostream library, providing -*- C++ -*- input/output.
3327 // Copyright (C) 1991 Per Bothner.
3328 //
3329 // This library is free software; you can redistribute it and/or
3330 // modify it under the terms of the GNU Library General Public
3331 // License as published by the Free Software Foundation; either
3332 // version 2 of the License, or (at your option) any later version.
3333 //
3334 // This library is distributed in the hope that it will be useful,
3335 // but WITHOUT ANY WARRANTY; without even the implied warranty of
3336 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3337 // Library General Public License for more details.
3338 //
3339 // You should have received a copy of the GNU Library General Public
3340 // License along with this library; if not, write to the Free
3341 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3342
3343
3344
3345
3346 //#pragma interface
3347
3348
3349 /* KLUDGES!! */
3350 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
3351 //# 12 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h"
3352
3353 //# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 2
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370 class ostream; class streambuf;
3371
3372 typedef long streamoff, streampos;
3373
3374 struct _ios_fields { // The data members of an ios.
3375 streambuf *_strbuf;
3376 ostream* _tie;
3377 long _width;
3378 unsigned long _flags;
3379 char _fill;
3380 unsigned char _state;
3381 unsigned short _precision;
3382 };
3383
3384
3385 enum state_value { _good = 0, _eof = 1, _fail = 2, _bad = 4 };
3386
3387
3388 class ios : public _ios_fields {
3389 public:
3390 enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 };
3391 enum open_mode {
3392 in=1,
3393 out=2,
3394 ate=4,
3395 app=8,
3396 trunc=16,
3397 nocreate=32,
3398 noreplace=64 };
3399 enum seek_dir { beg, cur, end};
3400 enum { skipws=01, left=02, right=04, internal=010,
3401 dec=020, oct=040, hex=0100,
3402 showbase=0200, showpoint=0400, uppercase=01000, showpos=02000,
3403 scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000,
3404 dont_close=0x80000000 //Don't close streambuf when destroying stream
3405 };
3406
3407 ostream* tie() { return _tie; }
3408 ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
3409
3410 // Methods to change the format state.
3411 char fill() { return _fill; }
3412 char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; }
3413 unsigned long flags() { return _flags; }
3414 unsigned long flags(unsigned long new_val) {
3415 unsigned long old_val = _flags; _flags = new_val; return old_val; }
3416 unsigned short precision() { return _precision; }
3417 unsigned short precision(int newp) {
3418 unsigned short oldp = _precision; _precision = (unsigned short)newp;
3419 return oldp; }
3420 unsigned long setf(unsigned long val) {
3421 unsigned long oldbits = _flags;
3422 _flags |= val; return oldbits; }
3423 unsigned long setf(unsigned long val, unsigned long mask) {
3424 unsigned long oldbits = _flags;
3425 _flags = (_flags & ~mask) | (val & mask); return oldbits; }
3426 unsigned long unsetf(unsigned long mask) {
3427 unsigned long oldbits = _flags & mask;
3428 _flags &= ~mask; return oldbits; }
3429 long width() { return _width; }
3430 long width(long val) { long save = _width; _width = val; return save; }
3431
3432 static const unsigned long basefield;
3433 static const unsigned long adjustfield;
3434 static const unsigned long floatfield;
3435
3436 streambuf* rdbuf() { return _strbuf; }
3437 void clear(int state = 0) { _state = state; }
3438 int good() { return _state == 0; }
3439 int eof() { return _state & ios::eofbit; }
3440 int fail() { return _state & (ios::badbit|ios::failbit); }
3441 int bad() { return _state & ios::badbit; }
3442 int rdstate() { return _state; }
3443 void set(int flag) { _state |= flag; }
3444 operator void*() { return fail() ? (void*)0 : (void*)this; }
3445 int operator!() { return fail(); }
3446
3447
3448 void unset(state_value flag) { _state &= ~flag; }
3449 void close();
3450 int is_open();
3451 int readable();
3452 int writable();
3453
3454
3455 protected:
3456 ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' ';
3457 _flags=ios::skipws; _precision=6; }
3458 };
3459
3460
3461
3462
3463 typedef ios::seek_dir _seek_dir;
3464
3465
3466 // Magic numbers and bits for the _flags field.
3467 // The magic numbers use the high-order bits of _flags;
3468 // the remaining bits are abailable for variable flags.
3469 // Note: The magic numbers must all be negative if stdio
3470 // emulation is desired.
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486 struct __streambuf {
3487 // NOTE: If this is changed, also change __FILE in stdio/stdio.h!
3488 int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
3489 char* _gptr; /* Current get pointer */
3490 char* _egptr; /* End of get area. */
3491 char* _eback; /* Start of putback+get area. */
3492 char* _pbase; /* Start of put area. */
3493 char* _pptr; /* Current put pointer. */
3494 char* _epptr; /* End of put area. */
3495 char* _base; /* Start of reserve area. */
3496 char* _ebuf; /* End of reserve area. */
3497 struct streambuf *_chain;
3498 };
3499
3500 struct streambuf : private __streambuf {
3501 friend class ios;
3502 friend class istream;
3503 friend class ostream;
3504 protected:
3505 static streambuf* _list_all; /* List of open streambufs. */
3506 streambuf*& xchain() { return _chain; }
3507 void _un_link();
3508 void _link_in();
3509 char* gptr() const { return _gptr; }
3510 char* pptr() const { return _pptr; }
3511 char* egptr() const { return _egptr; }
3512 char* epptr() const { return _epptr; }
3513 char* pbase() const { return _pbase; }
3514 char* eback() const { return _eback; }
3515 char* ebuf() const { return _ebuf; }
3516 char* base() const { return _base; }
3517 void xput_char(char c) { *_pptr++ = c; }
3518 int xflags() { return _flags; }
3519 int xflags(int f) { int fl = _flags; _flags = f; return fl; }
3520 void xsetflags(int f) { _flags |= f; }
3521 void gbump(int n) { _gptr += n; }
3522 void pbump(int n) { _pptr += n; }
3523 void setb(char* b, char* eb, int a=0);
3524 void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; }
3525 void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; }
3526 public:
3527 static int flush_all();
3528 static void flush_all_linebuffered(); // Flush all line buffered files.
3529 virtual int underflow(); // Leave public for now
3530 virtual int overflow(int c = (-1) ); // Leave public for now
3531 virtual int doallocate();
3532 virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
3533 virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
3534 int sputbackc(char c);
3535 int sungetc();
3536 streambuf();
3537 virtual ~streambuf();
3538 int unbuffered() { return _flags & 2 ? 1 : 0; }
3539 int linebuffered() { return _flags & 0x4000 ? 1 : 0; }
3540 void unbuffered(int i)
3541 { if (i) _flags |= 2 ; else _flags &= ~2 ; }
3542 void linebuffered(int i)
3543 { if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; }
3544 int allocate() {
3545 if (base() || unbuffered()) return 0;
3546 else return doallocate(); }
3547 virtual int sync();
3548 virtual int pbackfail(int c);
3549 virtual int ungetfail();
3550 virtual streambuf* setbuf(char* p, int len);
3551 int in_avail() { return _egptr - _gptr; }
3552 int out_waiting() { return _pptr - _pbase; }
3553 virtual int sputn(const char* s, int n);
3554 virtual int sgetn(char* s, int n);
3555 long sgetline(char* buf, size_t n, char delim, int putback_delim);
3556 int sbumpc() {
3557 if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
3558 else return *(unsigned char*)_gptr++; }
3559 int sgetc() {
3560 if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
3561 else return *(unsigned char*)_gptr; }
3562 int snextc() {
3563 if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
3564 else return *(unsigned char*)_gptr; }
3565 int sputc(int c) {
3566 if (_pptr >= _epptr) return overflow(c);
3567 return *_pptr++ = c, (unsigned char)c; }
3568 int vscan(char const *fmt0, char* ap);
3569 int vform(char const *fmt0, char* ap);
3570 };
3571
3572 struct __file_fields {
3573 char _fake;
3574 char _shortbuf[1];
3575 short _fileno;
3576 int _blksize;
3577 char* _save_gptr;
3578 char* _save_egptr;
3579 long _offset;
3580 };
3581
3582 class filebuf : public streambuf {
3583 struct __file_fields _fb;
3584 void init();
3585 public:
3586 filebuf();
3587 filebuf(int fd);
3588 filebuf(int fd, char* p, int len);
3589 ~filebuf();
3590 filebuf* attach(int fd);
3591 filebuf* open(const char *filename, const char *mode);
3592 filebuf* open(const char *filename, int mode, int prot = 0664);
3593 virtual int underflow();
3594 virtual int overflow(int c = (-1) );
3595 int is_open() { return _fb._fileno >= 0; }
3596 int fd() { return is_open() ? _fb._fileno : (-1) ; }
3597 filebuf* close();
3598 virtual int doallocate();
3599 virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
3600 int sputn(const char* s, int n);
3601 int sgetn(char* s, int n);
3602 protected: // See documentation in filebuf.C.
3603 virtual int pbackfail(int c);
3604 virtual int sync();
3605 int is_reading() { return eback() != egptr(); }
3606 char* cur_ptr() { return is_reading() ? gptr() : pptr(); }
3607 /* System's idea of pointer */
3608 char* file_ptr() { return _fb._save_gptr ? _fb._save_egptr : egptr(); }
3609 int do_flush();
3610 // Low-level operations (Usually invoke system calls.)
3611 virtual int sys_read(char* buf, size_t size);
3612 virtual long sys_seek(long , _seek_dir);
3613 virtual long sys_write(const void*, long);
3614 virtual int sys_stat(void*); // Actually, a (struct stat*)
3615 virtual int sys_close();
3616 };
3617
3618
3619 inline int ios::readable() { return rdbuf()->_flags & 4 ; }
3620 inline int ios::writable() { return rdbuf()->_flags & 8 ; }
3621 inline int ios::is_open() {return rdbuf()->_flags & 4 +8 ;}
3622
3623
3624
3625
3626 //# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 2
3627
3628
3629 class istream; class ostream;
3630 typedef istream& (*__imanip)(istream&);
3631 typedef ostream& (*__omanip)(ostream&);
3632
3633 extern istream& ws(istream& ins);
3634 extern ostream& flush(ostream& outs);
3635 extern ostream& endl(ostream& outs);
3636 extern ostream& ends(ostream& outs);
3637
3638 class ostream : public ios
3639 {
3640 void do_osfx();
3641 public:
3642 ostream();
3643 ostream(streambuf* sb, ostream* tied=0 );
3644 ~ostream();
3645
3646 int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; }
3647 void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
3648 do_osfx(); }
3649 streambuf* ostreambuf() const { return _strbuf; }
3650 ostream& flush();
3651 ostream& put(char c);
3652 ostream& write(const char *s, int n);
3653 ostream& write(const unsigned char *s, int n) { return write((char*)s, n);}
3654 ostream& write(const void *s, int n) { return write((char*)s, n);}
3655 ostream& seekp(streampos);
3656 ostream& seekp(streamoff, _seek_dir);
3657 streampos tellp();
3658 ostream& form(const char *format ...);
3659 ostream& vform(const char *format, char* args);
3660 };
3661
3662 ostream& operator<<(ostream&, char c);
3663 ostream& operator<<(ostream& os, unsigned char c) { return os << (char)c; }
3664 //ostream& operator<<(ostream &os, signed char c) { return os << (char)c; }
3665 extern ostream& operator<<(ostream&, const char *s);
3666 inline ostream& operator<<(ostream& os, const unsigned char *s)
3667 { return os << (const char*)s; }
3668 //inline ostream& operator<<(ostream& os, const signed char *s)
3669 //{ return os << (const char*)s; }
3670 ostream& operator<<(ostream&, void *p);
3671 ostream& operator<<(ostream&, int n);
3672 ostream& operator<<(ostream&, long n);
3673 ostream& operator<<(ostream&, unsigned int n);
3674 ostream& operator<<(ostream&, unsigned long n);
3675 ostream& operator<<(ostream& os, short n) {return os << (int)n;}
3676 ostream& operator<<(ostream& os, unsigned short n)
3677 {return os << (unsigned int)n;}
3678 ostream& operator<<(ostream&, float n);
3679 ostream& operator<<(ostream&, double n);
3680 ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
3681 ostream& operator<<(ostream&, streambuf*);
3682
3683 class istream : public ios
3684 {
3685 size_t _gcount;
3686 public:
3687 istream();
3688 istream(streambuf* sb, ostream*tied=0 );
3689 ~istream();
3690 streambuf* istreambuf() const { return _strbuf; }
3691 istream& get(char& c);
3692 istream& get(unsigned char& c);
3693 istream& read(char *ptr, int n);
3694 istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
3695 istream& read(void *ptr, int n) { return read((char*)ptr, n); }
3696 int get() { return _strbuf->sbumpc(); }
3697 istream& getline(char* ptr, int len, char delim = '\n');
3698 istream& get(char* ptr, int len, char delim = '\n');
3699 istream& gets(char **s, char delim = '\n');
3700 int ipfx(int need) {
3701 if (!good()) { set(ios::failbit); return 0; }
3702 if (_tie && (need == 0 || rdbuf()->in_avail())) ; /* THIS IS BAD */
3703 if (!need && (flags() & ios::skipws) && !ws(*this)) return 0;
3704 return 1;
3705 }
3706 int ipfx0() { // Optimized version of ipfx(0).
3707 if (!good()) { set(ios::failbit); return 0; }
3708 if (_tie) _tie->flush();
3709 if ((flags() & ios::skipws) && !ws(*this)) return 0;
3710 return 1;
3711 }
3712 int ipfx1() { // Optimized version of ipfx(1).
3713 if (!good()) { set(ios::failbit); return 0; }
3714 if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
3715 return 1;
3716 }
3717 size_t gcount() { return _gcount; }
3718 istream& seekg(streampos);
3719 istream& seekg(streamoff, _seek_dir);
3720 streampos tellg();
3721 istream& putback(char ch) {
3722 if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
3723 return *this;}
3724 istream& unget() {
3725 if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
3726 return *this;}
3727
3728 istream& unget(char ch) { return putback(ch); }
3729 int skip(int i);
3730
3731 };
3732
3733 istream& operator>>(istream&, char*);
3734 istream& operator>>(istream& is, unsigned char* p) { return is >> (char*)p; }
3735 //istream& operator>>(istream& is, signed char* p) { return is >> (char*)p; }
3736 istream& operator>>(istream&, char& c);
3737 istream& operator>>(istream&, unsigned char& c);
3738 //istream& operator>>(istream&, signed char& c);
3739 istream& operator>>(istream&, int&);
3740 istream& operator>>(istream&, long&);
3741 istream& operator>>(istream&, short&);
3742 istream& operator>>(istream&, unsigned int&);
3743 istream& operator>>(istream&, unsigned long&);
3744 istream& operator>>(istream&, unsigned short&);
3745 istream& operator>>(istream&, float&);
3746 istream& operator>>(istream&, double&);
3747 istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
3748
3749 class iostream : public ios {
3750 size_t _gcount;
3751 public:
3752 iostream();
3753 operator istream&() { return *(istream*)this; }
3754 operator ostream&() { return *(ostream*)this; }
3755 ~iostream();
3756 // NOTE: These duplicate istream methods.
3757 istream& get(char& c) { return ((istream*)this)->get(c); }
3758 istream& get(unsigned char& c) { return ((istream*)this)->get(c); }
3759 istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); }
3760 istream& read(unsigned char *ptr, int n)
3761 { return ((istream*)this)->read((char*)ptr, n); }
3762 istream& read(void *ptr, int n)
3763 { return ((istream*)this)->read((char*)ptr, n); }
3764 int get() { return _strbuf->sbumpc(); }
3765 istream& getline(char* ptr, int len, char delim = '\n')
3766 { return ((istream*)this)->getline(ptr, len, delim); }
3767 istream& get(char* ptr, int len, char delim = '\n')
3768 { return ((istream*)this)->get(ptr, len, delim); }
3769 istream& gets(char **s, char delim = '\n')
3770 { return ((istream*)this)->gets(s, delim); }
3771 int ipfx(int need) { return ((istream*)this)->ipfx(need); }
3772 int ipfx0() { return ((istream*)this)->ipfx0(); }
3773 int ipfx1() { return ((istream*)this)->ipfx1(); }
3774 size_t gcount() { return _gcount; }
3775 istream& putback(char ch) { return ((istream*)this)->putback(ch); }
3776 istream& unget() { return ((istream*)this)->unget(); }
3777 istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); }
3778 istream& seekg(streamoff off, _seek_dir dir)
3779 { return ((istream*)this)->seekg(off, dir); }
3780 streampos tellg() { return ((istream*)this)->tellg(); }
3781
3782 istream& unget(char ch) { return putback(ch); }
3783
3784
3785 // NOTE: These duplicate ostream methods.
3786 int opfx() { return ((ostream*)this)->opfx(); }
3787 void osfx() { ((ostream*)this)->osfx(); }
3788 ostream& flush() { return ((ostream*)this)->flush(); }
3789 ostream& put(char c) { return ((ostream*)this)->put(c); }
3790 ostream& write(const char *s, int n)
3791 { return ((ostream*)this)->write(s, n); }
3792 ostream& write(const unsigned char *s, int n)
3793 { return ((ostream*)this)->write((char*)s, n); }
3794 ostream& write(const void *s, int n)
3795 { return ((ostream*)this)->write((char*)s, n); }
3796 ostream& form(const char *format ...);
3797 ostream& vform(const char *format, char* args)
3798 { return ((ostream*)this)->vform(format, args); }
3799 ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); }
3800 ostream& seekp(streamoff off, _seek_dir dir)
3801 { return ((ostream*)this)->seekp(off, dir); }
3802 streampos tellp() { return ((ostream*)this)->tellp(); }
3803 };
3804
3805 extern istream cin;
3806 extern ostream cout, cerr, clog; // clog->rdbuf() == cerr->rdbuf()
3807
3808 inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; }
3809
3810 struct Iostream_init { } ; // Compatibility hack for AT&T libraray.
3811
3812
3813 //# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 2
3814
3815
3816 extern char* form(char*, ...);
3817
3818 extern char* dec(long, int=0);
3819 extern char* dec(int, int=0);
3820 extern char* dec(unsigned long, int=0);
3821 extern char* dec(unsigned int, int=0);
3822
3823 extern char* hex(long, int=0);
3824 extern char* hex(int, int=0);
3825 extern char* hex(unsigned long, int=0);
3826 extern char* hex(unsigned int, int=0);
3827
3828 extern char* oct(long, int=0);
3829 extern char* oct(int, int=0);
3830 extern char* oct(unsigned long, int=0);
3831 extern char* oct(unsigned int, int=0);
3832
3833 inline istream& WS(istream& str) { return ws(str); }
3834
3835
3836 //# 26 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2
3837
3838 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Regex.h" 1
3839 // This may look like C code, but it is really -*- C++ -*-
3840 /*
3841 Copyright (C) 1988 Free Software Foundation
3842 written by Doug Lea (dl@rocky.oswego.edu)
3843
3844 This file is part of the GNU C++ Library. This library is free
3845 software; you can redistribute it and/or modify it under the terms of
3846 the GNU Library General Public License as published by the Free
3847 Software Foundation; either version 2 of the License, or (at your
3848 option) any later version. This library is distributed in the hope
3849 that it will be useful, but WITHOUT ANY WARRANTY; without even the
3850 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
3851 PURPOSE. See the GNU Library General Public License for more details.
3852 You should have received a copy of the GNU Library General Public
3853 License along with this library; if not, write to the Free Software
3854 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3855 */
3856
3857
3858
3859
3860 //#pragma interface
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870 struct re_pattern_buffer; // defined elsewhere
3871 struct re_registers;
3872
3873 class Regex
3874 {
3875 private:
3876
3877 Regex(const Regex&) {} // no X(X&)
3878 void operator = (const Regex&) {} // no assignment
3879
3880 protected:
3881 re_pattern_buffer* buf;
3882 re_registers* reg;
3883
3884 public:
3885 Regex(const char* t,
3886 int fast = 0,
3887 int bufsize = 40,
3888 const char* transtable = 0);
3889
3890 ~Regex();
3891
3892 int match(const char* s, int len, int pos = 0) const;
3893 int search(const char* s, int len,
3894 int& matchlen, int startpos = 0) const;
3895 int match_info(int& start, int& length, int nth = 0) const;
3896
3897 int OK() const; // representation invariant
3898 };
3899
3900 // some built in regular expressions
3901
3902 extern const Regex RXwhite; // = "[ \n\t\r\v\f]+"
3903 extern const Regex RXint; // = "-?[0-9]+"
3904 extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
3905 // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
3906 // \\([eE][---+]?[0-9]+\\)?"
3907 extern const Regex RXalpha; // = "[A-Za-z]+"
3908 extern const Regex RXlowercase; // = "[a-z]+"
3909 extern const Regex RXuppercase; // = "[A-Z]+"
3910 extern const Regex RXalphanum; // = "[0-9A-Za-z]+"
3911 extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*"
3912
3913
3914
3915 //# 27 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2
3916
3917
3918 struct StrRep // internal String representations
3919 {
3920 unsigned short len; // string length
3921 unsigned short sz; // allocated space
3922 char s[1]; // the string starts here
3923 // (at least 1 char for trailing null)
3924 // allocated & expanded via non-public fcts
3925 };
3926
3927 // primitive ops on StrReps -- nearly all String fns go through these.
3928
3929 StrRep* Salloc(StrRep*, const char*, int, int);
3930 StrRep* Scopy(StrRep*, StrRep*);
3931 StrRep* Sresize(StrRep*, int);
3932 StrRep* Scat(StrRep*, const char*, int, const char*, int);
3933 StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int);
3934 StrRep* Sprepend(StrRep*, const char*, int);
3935 StrRep* Sreverse(StrRep*, StrRep*);
3936 StrRep* Supcase(StrRep*, StrRep*);
3937 StrRep* Sdowncase(StrRep*, StrRep*);
3938 StrRep* Scapitalize(StrRep*, StrRep*);
3939
3940 // These classes need to be defined in the order given
3941
3942 class String;
3943 class SubString;
3944
3945 class SubString
3946 {
3947 friend class String;
3948 protected:
3949
3950 String& S; // The String I'm a substring of
3951 unsigned short pos; // starting position in S's rep
3952 unsigned short len; // length of substring
3953
3954 void assign(StrRep*, const char*, int = -1);
3955 SubString(String& x, int p, int l);
3956 SubString(const SubString& x);
3957
3958 public:
3959
3960 // Note there are no public constructors. SubStrings are always
3961 // created via String operations
3962
3963 ~SubString();
3964
3965 void operator = (const String& y);
3966 void operator = (const SubString& y);
3967 void operator = (const char* t);
3968 void operator = (char c);
3969
3970 // return 1 if target appears anywhere in SubString; else 0
3971
3972 int contains(char c) const;
3973 int contains(const String& y) const;
3974 int contains(const SubString& y) const;
3975 int contains(const char* t) const;
3976 int contains(const Regex& r) const;
3977
3978 // return 1 if target matches entire SubString
3979
3980 int matches(const Regex& r) const;
3981
3982 // IO
3983
3984 friend ostream& operator<<(ostream& s, const SubString& x);
3985
3986 // status
3987
3988 unsigned int length() const;
3989 int empty() const;
3990 const char* chars() const;
3991
3992 int OK() const;
3993
3994 };
3995
3996
3997 class String
3998 {
3999 friend class SubString;
4000
4001 protected:
4002 StrRep* rep; // Strings are pointers to their representations
4003
4004 // some helper functions
4005
4006 int search(int, int, const char*, int = -1) const;
4007 int search(int, int, char) const;
4008 int match(int, int, int, const char*, int = -1) const;
4009 int _gsub(const char*, int, const char* ,int);
4010 int _gsub(const Regex&, const char*, int);
4011 SubString _substr(int, int);
4012
4013 public:
4014
4015 // constructors & assignment
4016
4017 String();
4018 String(const String& x);
4019 String(const SubString& x);
4020 String(const char* t);
4021 String(const char* t, int len);
4022 String(char c);
4023
4024 ~String();
4025
4026 void operator = (const String& y);
4027 void operator = (const char* y);
4028 void operator = (char c);
4029 void operator = (const SubString& y);
4030
4031 // concatenation
4032
4033 void operator += (const String& y);
4034 void operator += (const SubString& y);
4035 void operator += (const char* t);
4036 void operator += (char c);
4037
4038 void prepend(const String& y);
4039 void prepend(const SubString& y);
4040 void prepend(const char* t);
4041 void prepend(char c);
4042
4043
4044 // procedural versions:
4045 // concatenate first 2 args, store result in last arg
4046
4047 friend void cat(const String&, const String&, String&);
4048 friend void cat(const String&, const SubString&, String&);
4049 friend void cat(const String&, const char*, String&);
4050 friend void cat(const String&, char, String&);
4051
4052 friend void cat(const SubString&, const String&, String&);
4053 friend void cat(const SubString&, const SubString&, String&);
4054 friend void cat(const SubString&, const char*, String&);
4055 friend void cat(const SubString&, char, String&);
4056
4057 friend void cat(const char*, const String&, String&);
4058 friend void cat(const char*, const SubString&, String&);
4059 friend void cat(const char*, const char*, String&);
4060 friend void cat(const char*, char, String&);
4061
4062 // double concatenation, by request. (yes, there are too many versions,
4063 // but if one is supported, then the others should be too...)
4064 // Concatenate first 3 args, store in last arg
4065
4066 friend void cat(const String&,const String&, const String&,String&);
4067 friend void cat(const String&,const String&,const SubString&,String&);
4068 friend void cat(const String&,const String&, const char*, String&);
4069 friend void cat(const String&,const String&, char, String&);
4070 friend void cat(const String&,const SubString&,const String&,String&);
4071 friend void cat(const String&,const SubString&,const SubString&,String&);
4072 friend void cat(const String&,const SubString&, const char*, String&);
4073 friend void cat(const String&,const SubString&, char, String&);
4074 friend void cat(const String&,const char*, const String&, String&);
4075 friend void cat(const String&,const char*, const SubString&, String&);
4076 friend void cat(const String&,const char*, const char*, String&);
4077 friend void cat(const String&,const char*, char, String&);
4078
4079 friend void cat(const char*, const String&, const String&,String&);
4080 friend void cat(const char*,const String&,const SubString&,String&);
4081 friend void cat(const char*,const String&, const char*, String&);
4082 friend void cat(const char*,const String&, char, String&);
4083 friend void cat(const char*,const SubString&,const String&,String&);
4084 friend void cat(const char*,const SubString&,const SubString&,String&);
4085 friend void cat(const char*,const SubString&, const char*, String&);
4086 friend void cat(const char*,const SubString&, char, String&);
4087 friend void cat(const char*,const char*, const String&, String&);
4088 friend void cat(const char*,const char*, const SubString&, String&);
4089 friend void cat(const char*,const char*, const char*, String&);
4090 friend void cat(const char*,const char*, char, String&);
4091
4092
4093 // searching & matching
4094
4095 // return position of target in string or -1 for failure
4096
4097 int index(char c, int startpos = 0) const;
4098 int index(const String& y, int startpos = 0) const;
4099 int index(const SubString& y, int startpos = 0) const;
4100 int index(const char* t, int startpos = 0) const;
4101 int index(const Regex& r, int startpos = 0) const;
4102
4103 // return 1 if target appears anyhere in String; else 0
4104
4105 int contains(char c) const;
4106 int contains(const String& y) const;
4107 int contains(const SubString& y) const;
4108 int contains(const char* t) const;
4109 int contains(const Regex& r) const;
4110
4111 // return 1 if target appears anywhere after position pos
4112 // (or before, if pos is negative) in String; else 0
4113
4114 int contains(char c, int pos) const;
4115 int contains(const String& y, int pos) const;
4116 int contains(const SubString& y, int pos) const;
4117 int contains(const char* t, int pos) const;
4118 int contains(const Regex& r, int pos) const;
4119
4120 // return 1 if target appears at position pos in String; else 0
4121
4122 int matches(char c, int pos = 0) const;
4123 int matches(const String& y, int pos = 0) const;
4124 int matches(const SubString& y, int pos = 0) const;
4125 int matches(const char* t, int pos = 0) const;
4126 int matches(const Regex& r, int pos = 0) const;
4127
4128 // return number of occurences of target in String
4129
4130 int freq(char c) const;
4131 int freq(const String& y) const;
4132 int freq(const SubString& y) const;
4133 int freq(const char* t) const;
4134
4135 // SubString extraction
4136
4137 // Note that you can't take a substring of a const String, since
4138 // this leaves open the possiblility of indirectly modifying the
4139 // String through the SubString
4140
4141 SubString at(int pos, int len);
4142 SubString operator () (int pos, int len); // synonym for at
4143
4144 SubString at(const String& x, int startpos = 0);
4145 SubString at(const SubString& x, int startpos = 0);
4146 SubString at(const char* t, int startpos = 0);
4147 SubString at(char c, int startpos = 0);
4148 SubString at(const Regex& r, int startpos = 0);
4149
4150 SubString before(int pos);
4151 SubString before(const String& x, int startpos = 0);
4152 SubString before(const SubString& x, int startpos = 0);
4153 SubString before(const char* t, int startpos = 0);
4154 SubString before(char c, int startpos = 0);
4155 SubString before(const Regex& r, int startpos = 0);
4156
4157 SubString through(int pos);
4158 SubString through(const String& x, int startpos = 0);
4159 SubString through(const SubString& x, int startpos = 0);
4160 SubString through(const char* t, int startpos = 0);
4161 SubString through(char c, int startpos = 0);
4162 SubString through(const Regex& r, int startpos = 0);
4163
4164 SubString from(int pos);
4165 SubString from(const String& x, int startpos = 0);
4166 SubString from(const SubString& x, int startpos = 0);
4167 SubString from(const char* t, int startpos = 0);
4168 SubString from(char c, int startpos = 0);
4169 SubString from(const Regex& r, int startpos = 0);
4170
4171 SubString after(int pos);
4172 SubString after(const String& x, int startpos = 0);
4173 SubString after(const SubString& x, int startpos = 0);
4174 SubString after(const char* t, int startpos = 0);
4175 SubString after(char c, int startpos = 0);
4176 SubString after(const Regex& r, int startpos = 0);
4177
4178
4179 // deletion
4180
4181 // delete len chars starting at pos
4182 void del(int pos, int len);
4183
4184 // delete the first occurrence of target after startpos
4185
4186 void del(const String& y, int startpos = 0);
4187 void del(const SubString& y, int startpos = 0);
4188 void del(const char* t, int startpos = 0);
4189 void del(char c, int startpos = 0);
4190 void del(const Regex& r, int startpos = 0);
4191
4192 // global substitution: substitute all occurrences of pat with repl
4193
4194 int gsub(const String& pat, const String& repl);
4195 int gsub(const SubString& pat, const String& repl);
4196 int gsub(const char* pat, const String& repl);
4197 int gsub(const char* pat, const char* repl);
4198 int gsub(const Regex& pat, const String& repl);
4199
4200 // friends & utilities
4201
4202 // split string into array res at separators; return number of elements
4203
4204 friend int split(const String& x, String res[], int maxn,
4205 const String& sep);
4206 friend int split(const String& x, String res[], int maxn,
4207 const Regex& sep);
4208
4209 friend String common_prefix(const String& x, const String& y,
4210 int startpos = 0);
4211 friend String common_suffix(const String& x, const String& y,
4212 int startpos = -1);
4213 friend String replicate(char c, int n);
4214 friend String replicate(const String& y, int n);
4215 friend String join(String src[], int n, const String& sep);
4216
4217 // simple builtin transformations
4218
4219 friend String reverse(const String& x);
4220 friend String upcase(const String& x);
4221 friend String downcase(const String& x);
4222 friend String capitalize(const String& x);
4223
4224 // in-place versions of above
4225
4226 void reverse();
4227 void upcase();
4228 void downcase();
4229 void capitalize();
4230
4231 // element extraction
4232
4233 char& operator [] (int i);
4234 char elem(int i) const;
4235 char firstchar() const;
4236 char lastchar() const;
4237
4238 // conversion
4239
4240 operator const char*() const;
4241 const char* chars() const;
4242
4243
4244 // IO
4245
4246 friend ostream& operator<<(ostream& s, const String& x);
4247 friend ostream& operator<<(ostream& s, const SubString& x);
4248 friend istream& operator>>(istream& s, String& x);
4249
4250 friend int readline(istream& s, String& x,
4251 char terminator = '\n',
4252 int discard_terminator = 1);
4253
4254 // status
4255
4256 unsigned int length() const;
4257 int empty() const;
4258
4259 // preallocate some space for String
4260 void alloc(int newsize);
4261
4262 // report current allocation (not length!)
4263
4264 int allocation() const;
4265
4266
4267 volatile void error(const char* msg) const;
4268
4269 int OK() const;
4270 };
4271
4272 typedef String StrTmp; // for backward compatibility
4273
4274 // other externs
4275
4276 int compare(const String& x, const String& y);
4277 int compare(const String& x, const SubString& y);
4278 int compare(const String& x, const char* y);
4279 int compare(const SubString& x, const String& y);
4280 int compare(const SubString& x, const SubString& y);
4281 int compare(const SubString& x, const char* y);
4282 int fcompare(const String& x, const String& y); // ignore case
4283
4284 extern StrRep _nilStrRep;
4285 extern String _nilString;
4286
4287 // other inlines
4288
4289 String operator + (const String& x, const String& y);
4290 String operator + (const String& x, const SubString& y);
4291 String operator + (const String& x, const char* y);
4292 String operator + (const String& x, char y);
4293 String operator + (const SubString& x, const String& y);
4294 String operator + (const SubString& x, const SubString& y);
4295 String operator + (const SubString& x, const char* y);
4296 String operator + (const SubString& x, char y);
4297 String operator + (const char* x, const String& y);
4298 String operator + (const char* x, const SubString& y);
4299
4300 int operator==(const String& x, const String& y);
4301 int operator!=(const String& x, const String& y);
4302 int operator> (const String& x, const String& y);
4303 int operator>=(const String& x, const String& y);
4304 int operator< (const String& x, const String& y);
4305 int operator<=(const String& x, const String& y);
4306 int operator==(const String& x, const SubString& y);
4307 int operator!=(const String& x, const SubString& y);
4308 int operator> (const String& x, const SubString& y);
4309 int operator>=(const String& x, const SubString& y);
4310 int operator< (const String& x, const SubString& y);
4311 int operator<=(const String& x, const SubString& y);
4312 int operator==(const String& x, const char* t);
4313 int operator!=(const String& x, const char* t);
4314 int operator> (const String& x, const char* t);
4315 int operator>=(const String& x, const char* t);
4316 int operator< (const String& x, const char* t);
4317 int operator<=(const String& x, const char* t);
4318 int operator==(const SubString& x, const String& y);
4319 int operator!=(const SubString& x, const String& y);
4320 int operator> (const SubString& x, const String& y);
4321 int operator>=(const SubString& x, const String& y);
4322 int operator< (const SubString& x, const String& y);
4323 int operator<=(const SubString& x, const String& y);
4324 int operator==(const SubString& x, const SubString& y);
4325 int operator!=(const SubString& x, const SubString& y);
4326 int operator> (const SubString& x, const SubString& y);
4327 int operator>=(const SubString& x, const SubString& y);
4328 int operator< (const SubString& x, const SubString& y);
4329 int operator<=(const SubString& x, const SubString& y);
4330 int operator==(const SubString& x, const char* t);
4331 int operator!=(const SubString& x, const char* t);
4332 int operator> (const SubString& x, const char* t);
4333 int operator>=(const SubString& x, const char* t);
4334 int operator< (const SubString& x, const char* t);
4335 int operator<=(const SubString& x, const char* t);
4336
4337
4338
4339
4340 // status reports, needed before defining other things
4341
4342 inline unsigned int String::length() const { return rep->len; }
4343 inline int String::empty() const { return rep->len == 0; }
4344 inline const char* String::chars() const { return &(rep->s[0]); }
4345 inline int String::allocation() const { return rep->sz; }
4346 inline void String::alloc(int newsize) { rep = Sresize(rep, newsize); }
4347
4348 inline unsigned int SubString::length() const { return len; }
4349 inline int SubString::empty() const { return len == 0; }
4350 inline const char* SubString::chars() const { return &(S.rep->s[pos]); }
4351
4352
4353 // constructors
4354
4355 inline String::String()
4356 : rep(&_nilStrRep) {}
4357 inline String::String(const String& x)
4358 : rep(Scopy(0, x.rep)) {}
4359 inline String::String(const char* t)
4360 : rep(Salloc(0, t, -1, -1)) {}
4361 inline String::String(const char* t, int tlen)
4362 : rep(Salloc(0, t, tlen, tlen)) {}
4363 inline String::String(const SubString& y)
4364 : rep(Salloc(0, y.chars(), y.length(), y.length())) {}
4365 inline String::String(char c)
4366 : rep(Salloc(0, &c, 1, 1)) {}
4367
4368 inline String::~String() { if (rep != &_nilStrRep) delete rep; }
4369
4370 inline SubString::SubString(const SubString& x)
4371 :S(x.S), pos(x.pos), len(x.len) {}
4372 inline SubString::SubString(String& x, int first, int l)
4373 :S(x), pos(first), len(l) {}
4374
4375 inline SubString::~SubString() {}
4376
4377 // assignment
4378
4379 inline void String::operator = (const String& y)
4380 {
4381 rep = Scopy(rep, y.rep);
4382 }
4383
4384 inline void String::operator=(const char* t)
4385 {
4386 rep = Salloc(rep, t, -1, -1);
4387 }
4388
4389 inline void String::operator=(const SubString& y)
4390 {
4391 rep = Salloc(rep, y.chars(), y.length(), y.length());
4392 }
4393
4394 inline void String::operator=(char c)
4395 {
4396 rep = Salloc(rep, &c, 1, 1);
4397 }
4398
4399
4400 inline void SubString::operator = (const char* ys)
4401 {
4402 assign(0, ys);
4403 }
4404
4405 inline void SubString::operator = (char ch)
4406 {
4407 assign(0, &ch, 1);
4408 }
4409
4410 inline void SubString::operator = (const String& y)
4411 {
4412 assign(y.rep, y.chars(), y.length());
4413 }
4414
4415 inline void SubString::operator = (const SubString& y)
4416 {
4417 assign(y.S.rep, y.chars(), y.length());
4418 }
4419
4420 // Zillions of cats...
4421
4422 inline void cat(const String& x, const String& y, String& r)
4423 {
4424 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
4425 }
4426
4427 inline void cat(const String& x, const SubString& y, String& r)
4428 {
4429 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
4430 }
4431
4432 inline void cat(const String& x, const char* y, String& r)
4433 {
4434 r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
4435 }
4436
4437 inline void cat(const String& x, char y, String& r)
4438 {
4439 r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
4440 }
4441
4442 inline void cat(const SubString& x, const String& y, String& r)
4443 {
4444 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
4445 }
4446
4447 inline void cat(const SubString& x, const SubString& y, String& r)
4448 {
4449 r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
4450 }
4451
4452 inline void cat(const SubString& x, const char* y, String& r)
4453 {
4454 r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
4455 }
4456
4457 inline void cat(const SubString& x, char y, String& r)
4458 {
4459 r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
4460 }
4461
4462 inline void cat(const char* x, const String& y, String& r)
4463 {
4464 r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
4465 }
4466
4467 inline void cat(const char* x, const SubString& y, String& r)
4468 {
4469 r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
4470 }
4471
4472 inline void cat(const char* x, const char* y, String& r)
4473 {
4474 r.rep = Scat(r.rep, x, -1, y, -1);
4475 }
4476
4477 inline void cat(const char* x, char y, String& r)
4478 {
4479 r.rep = Scat(r.rep, x, -1, &y, 1);
4480 }
4481
4482 inline void cat(const String& a, const String& x, const String& y, String& r)
4483 {
4484 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
4485 }
4486
4487 inline void cat(const String& a, const String& x, const SubString& y, String& r)
4488 {
4489 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
4490 }
4491
4492 inline void cat(const String& a, const String& x, const char* y, String& r)
4493 {
4494 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
4495 }
4496
4497 inline void cat(const String& a, const String& x, char y, String& r)
4498 {
4499 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
4500 }
4501
4502 inline void cat(const String& a, const SubString& x, const String& y, String& r)
4503 {
4504 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
4505 }
4506
4507 inline void cat(const String& a, const SubString& x, const SubString& y, String& r)
4508 {
4509 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
4510 }
4511
4512 inline void cat(const String& a, const SubString& x, const char* y, String& r)
4513 {
4514 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
4515 }
4516
4517 inline void cat(const String& a, const SubString& x, char y, String& r)
4518 {
4519 r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
4520 }
4521
4522 inline void cat(const String& a, const char* x, const String& y, String& r)
4523 {
4524 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
4525 }
4526
4527 inline void cat(const String& a, const char* x, const SubString& y, String& r)
4528 {
4529 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
4530 }
4531
4532 inline void cat(const String& a, const char* x, const char* y, String& r)
4533 {
4534 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1);
4535 }
4536
4537 inline void cat(const String& a, const char* x, char y, String& r)
4538 {
4539 r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1);
4540 }
4541
4542
4543 inline void cat(const char* a, const String& x, const String& y, String& r)
4544 {
4545 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
4546 }
4547
4548 inline void cat(const char* a, const String& x, const SubString& y, String& r)
4549 {
4550 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
4551 }
4552
4553 inline void cat(const char* a, const String& x, const char* y, String& r)
4554 {
4555 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
4556 }
4557
4558 inline void cat(const char* a, const String& x, char y, String& r)
4559 {
4560 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
4561 }
4562
4563 inline void cat(const char* a, const SubString& x, const String& y, String& r)
4564 {
4565 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
4566 }
4567
4568 inline void cat(const char* a, const SubString& x, const SubString& y, String& r)
4569 {
4570 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
4571 }
4572
4573 inline void cat(const char* a, const SubString& x, const char* y, String& r)
4574 {
4575 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
4576 }
4577
4578 inline void cat(const char* a, const SubString& x, char y, String& r)
4579 {
4580 r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
4581 }
4582
4583 inline void cat(const char* a, const char* x, const String& y, String& r)
4584 {
4585 r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
4586 }
4587
4588 inline void cat(const char* a, const char* x, const SubString& y, String& r)
4589 {
4590 r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
4591 }
4592
4593 inline void cat(const char* a, const char* x, const char* y, String& r)
4594 {
4595 r.rep = Scat(r.rep, a, -1, x, -1, y, -1);
4596 }
4597
4598 inline void cat(const char* a, const char* x, char y, String& r)
4599 {
4600 r.rep = Scat(r.rep, a, -1, x, -1, &y, 1);
4601 }
4602
4603
4604 // operator versions
4605
4606 inline void String::operator +=(const String& y)
4607 {
4608 cat(*this, y, *this);
4609 }
4610
4611 inline void String::operator +=(const SubString& y)
4612 {
4613 cat(*this, y, *this);
4614 }
4615
4616 inline void String::operator += (const char* y)
4617 {
4618 cat(*this, y, *this);
4619 }
4620
4621 inline void String:: operator +=(char y)
4622 {
4623 cat(*this, y, *this);
4624 }
4625
4626 // constructive concatenation
4627
4628
4629
4630 inline String operator + (const String& x, const String& y) return r;
4631 {
4632 cat(x, y, r);
4633 }
4634
4635 inline String operator + (const String& x, const SubString& y) return r;
4636 {
4637 cat(x, y, r);
4638 }
4639
4640 inline String operator + (const String& x, const char* y) return r;
4641 {
4642 cat(x, y, r);
4643 }
4644
4645 inline String operator + (const String& x, char y) return r;
4646 {
4647 cat(x, y, r);
4648 }
4649
4650 inline String operator + (const SubString& x, const String& y) return r;
4651 {
4652 cat(x, y, r);
4653 }
4654
4655 inline String operator + (const SubString& x, const SubString& y) return r;
4656 {
4657 cat(x, y, r);
4658 }
4659
4660 inline String operator + (const SubString& x, const char* y) return r;
4661 {
4662 cat(x, y, r);
4663 }
4664
4665 inline String operator + (const SubString& x, char y) return r;
4666 {
4667 cat(x, y, r);
4668 }
4669
4670 inline String operator + (const char* x, const String& y) return r;
4671 {
4672 cat(x, y, r);
4673 }
4674
4675 inline String operator + (const char* x, const SubString& y) return r;
4676 {
4677 cat(x, y, r);
4678 }
4679
4680 inline String reverse(const String& x) return r;
4681 {
4682 r.rep = Sreverse(x.rep, r.rep);
4683 }
4684
4685 inline String upcase(const String& x) return r;
4686 {
4687 r.rep = Supcase(x.rep, r.rep);
4688 }
4689
4690 inline String downcase(const String& x) return r;
4691 {
4692 r.rep = Sdowncase(x.rep, r.rep);
4693 }
4694
4695 inline String capitalize(const String& x) return r;
4696 {
4697 r.rep = Scapitalize(x.rep, r.rep);
4698 }
4699
4700 //# 883 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h"
4701
4702
4703 // prepend
4704
4705 inline void String::prepend(const String& y)
4706 {
4707 rep = Sprepend(rep, y.chars(), y.length());
4708 }
4709
4710 inline void String::prepend(const char* y)
4711 {
4712 rep = Sprepend(rep, y, -1);
4713 }
4714
4715 inline void String::prepend(char y)
4716 {
4717 rep = Sprepend(rep, &y, 1);
4718 }
4719
4720 inline void String::prepend(const SubString& y)
4721 {
4722 rep = Sprepend(rep, y.chars(), y.length());
4723 }
4724
4725 // misc transformations
4726
4727
4728 inline void String::reverse()
4729 {
4730 rep = Sreverse(rep, rep);
4731 }
4732
4733
4734 inline void String::upcase()
4735 {
4736 rep = Supcase(rep, rep);
4737 }
4738
4739
4740 inline void String::downcase()
4741 {
4742 rep = Sdowncase(rep, rep);
4743 }
4744
4745
4746 inline void String::capitalize()
4747 {
4748 rep = Scapitalize(rep, rep);
4749 }
4750
4751 // element extraction
4752
4753 inline char& String::operator [] (int i)
4754 {
4755 if (((unsigned)i) >= length()) error("invalid index");
4756 return rep->s[i];
4757 }
4758
4759 inline char String::elem (int i) const
4760 {
4761 if (((unsigned)i) >= length()) error("invalid index");
4762 return rep->s[i];
4763 }
4764
4765 inline char String::firstchar() const
4766 {
4767 return elem(0);
4768 }
4769
4770 inline char String::lastchar() const
4771 {
4772 return elem(length() - 1);
4773 }
4774
4775 // searching
4776
4777 inline int String::index(char c, int startpos) const
4778 {
4779 return search(startpos, length(), c);
4780 }
4781
4782 inline int String::index(const char* t, int startpos) const
4783 {
4784 return search(startpos, length(), t);
4785 }
4786
4787 inline int String::index(const String& y, int startpos) const
4788 {
4789 return search(startpos, length(), y.chars(), y.length());
4790 }
4791
4792 inline int String::index(const SubString& y, int startpos) const
4793 {
4794 return search(startpos, length(), y.chars(), y.length());
4795 }
4796
4797 inline int String::index(const Regex& r, int startpos) const
4798 {
4799 int unused; return r.search(chars(), length(), unused, startpos);
4800 }
4801
4802 inline int String::contains(char c) const
4803 {
4804 return search(0, length(), c) >= 0;
4805 }
4806
4807 inline int String::contains(const char* t) const
4808 {
4809 return search(0, length(), t) >= 0;
4810 }
4811
4812 inline int String::contains(const String& y) const
4813 {
4814 return search(0, length(), y.chars(), y.length()) >= 0;
4815 }
4816
4817 inline int String::contains(const SubString& y) const
4818 {
4819 return search(0, length(), y.chars(), y.length()) >= 0;
4820 }
4821
4822 inline int String::contains(char c, int p) const
4823 {
4824 return match(p, length(), 0, &c, 1) >= 0;
4825 }
4826
4827 inline int String::contains(const char* t, int p) const
4828 {
4829 return match(p, length(), 0, t) >= 0;
4830 }
4831
4832 inline int String::contains(const String& y, int p) const
4833 {
4834 return match(p, length(), 0, y.chars(), y.length()) >= 0;
4835 }
4836
4837 inline int String::contains(const SubString& y, int p) const
4838 {
4839 return match(p, length(), 0, y.chars(), y.length()) >= 0;
4840 }
4841
4842 inline int String::contains(const Regex& r) const
4843 {
4844 int unused; return r.search(chars(), length(), unused, 0) >= 0;
4845 }
4846
4847 inline int String::contains(const Regex& r, int p) const
4848 {
4849 return r.match(chars(), length(), p) >= 0;
4850 }
4851
4852
4853 inline int String::matches(const SubString& y, int p) const
4854 {
4855 return match(p, length(), 1, y.chars(), y.length()) >= 0;
4856 }
4857
4858 inline int String::matches(const String& y, int p) const
4859 {
4860 return match(p, length(), 1, y.chars(), y.length()) >= 0;
4861 }
4862
4863 inline int String::matches(const char* t, int p) const
4864 {
4865 return match(p, length(), 1, t) >= 0;
4866 }
4867
4868 inline int String::matches(char c, int p) const
4869 {
4870 return match(p, length(), 1, &c, 1) >= 0;
4871 }
4872
4873 inline int String::matches(const Regex& r, int p) const
4874 {
4875 int l = (p < 0)? -p : length() - p;
4876 return r.match(chars(), length(), p) == l;
4877 }
4878
4879
4880 inline int SubString::contains(const char* t) const
4881 {
4882 return S.search(pos, pos+len, t) >= 0;
4883 }
4884
4885 inline int SubString::contains(const String& y) const
4886 {
4887 return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
4888 }
4889
4890 inline int SubString::contains(const SubString& y) const
4891 {
4892 return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
4893 }
4894
4895 inline int SubString::contains(char c) const
4896 {
4897 return S.search(pos, pos+len, 0, c) >= 0;
4898 }
4899
4900 inline int SubString::contains(const Regex& r) const
4901 {
4902 int unused; return r.search(chars(), len, unused, 0) >= 0;
4903 }
4904
4905 inline int SubString::matches(const Regex& r) const
4906 {
4907 return r.match(chars(), len, 0) == len;
4908 }
4909
4910
4911 inline int String::gsub(const String& pat, const String& r)
4912 {
4913 return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
4914 }
4915
4916 inline int String::gsub(const SubString& pat, const String& r)
4917 {
4918 return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
4919 }
4920
4921 inline int String::gsub(const Regex& pat, const String& r)
4922 {
4923 return _gsub(pat, r.chars(), r.length());
4924 }
4925
4926 inline int String::gsub(const char* pat, const String& r)
4927 {
4928 return _gsub(pat, -1, r.chars(), r.length());
4929 }
4930
4931 inline int String::gsub(const char* pat, const char* r)
4932 {
4933 return _gsub(pat, -1, r, -1);
4934 }
4935
4936
4937
4938 inline ostream& operator<<(ostream& s, const String& x)
4939 {
4940 s << x.chars(); return s;
4941 }
4942
4943 // a zillion comparison operators
4944
4945 inline int operator==(const String& x, const String& y)
4946 {
4947 return compare(x, y) == 0;
4948 }
4949
4950 inline int operator!=(const String& x, const String& y)
4951 {
4952 return compare(x, y) != 0;
4953 }
4954
4955 inline int operator>(const String& x, const String& y)
4956 {
4957 return compare(x, y) > 0;
4958 }
4959
4960 inline int operator>=(const String& x, const String& y)
4961 {
4962 return compare(x, y) >= 0;
4963 }
4964
4965 inline int operator<(const String& x, const String& y)
4966 {
4967 return compare(x, y) < 0;
4968 }
4969
4970 inline int operator<=(const String& x, const String& y)
4971 {
4972 return compare(x, y) <= 0;
4973 }
4974
4975 inline int operator==(const String& x, const SubString& y)
4976 {
4977 return compare(x, y) == 0;
4978 }
4979
4980 inline int operator!=(const String& x, const SubString& y)
4981 {
4982 return compare(x, y) != 0;
4983 }
4984
4985 inline int operator>(const String& x, const SubString& y)
4986 {
4987 return compare(x, y) > 0;
4988 }
4989
4990 inline int operator>=(const String& x, const SubString& y)
4991 {
4992 return compare(x, y) >= 0;
4993 }
4994
4995 inline int operator<(const String& x, const SubString& y)
4996 {
4997 return compare(x, y) < 0;
4998 }
4999
5000 inline int operator<=(const String& x, const SubString& y)
5001 {
5002 return compare(x, y) <= 0;
5003 }
5004
5005 inline int operator==(const String& x, const char* t)
5006 {
5007 return compare(x, t) == 0;
5008 }
5009
5010 inline int operator!=(const String& x, const char* t)
5011 {
5012 return compare(x, t) != 0;
5013 }
5014
5015 inline int operator>(const String& x, const char* t)
5016 {
5017 return compare(x, t) > 0;
5018 }
5019
5020 inline int operator>=(const String& x, const char* t)
5021 {
5022 return compare(x, t) >= 0;
5023 }
5024
5025 inline int operator<(const String& x, const char* t)
5026 {
5027 return compare(x, t) < 0;
5028 }
5029
5030 inline int operator<=(const String& x, const char* t)
5031 {
5032 return compare(x, t) <= 0;
5033 }
5034
5035 inline int operator==(const SubString& x, const String& y)
5036 {
5037 return compare(y, x) == 0;
5038 }
5039
5040 inline int operator!=(const SubString& x, const String& y)
5041 {
5042 return compare(y, x) != 0;
5043 }
5044
5045 inline int operator>(const SubString& x, const String& y)
5046 {
5047 return compare(y, x) < 0;
5048 }
5049
5050 inline int operator>=(const SubString& x, const String& y)
5051 {
5052 return compare(y, x) <= 0;
5053 }
5054
5055 inline int operator<(const SubString& x, const String& y)
5056 {
5057 return compare(y, x) > 0;
5058 }
5059
5060 inline int operator<=(const SubString& x, const String& y)
5061 {
5062 return compare(y, x) >= 0;
5063 }
5064
5065 inline int operator==(const SubString& x, const SubString& y)
5066 {
5067 return compare(x, y) == 0;
5068 }
5069
5070 inline int operator!=(const SubString& x, const SubString& y)
5071 {
5072 return compare(x, y) != 0;
5073 }
5074
5075 inline int operator>(const SubString& x, const SubString& y)
5076 {
5077 return compare(x, y) > 0;
5078 }
5079
5080 inline int operator>=(const SubString& x, const SubString& y)
5081 {
5082 return compare(x, y) >= 0;
5083 }
5084
5085 inline int operator<(const SubString& x, const SubString& y)
5086 {
5087 return compare(x, y) < 0;
5088 }
5089
5090 inline int operator<=(const SubString& x, const SubString& y)
5091 {
5092 return compare(x, y) <= 0;
5093 }
5094
5095 inline int operator==(const SubString& x, const char* t)
5096 {
5097 return compare(x, t) == 0;
5098 }
5099
5100 inline int operator!=(const SubString& x, const char* t)
5101 {
5102 return compare(x, t) != 0;
5103 }
5104
5105 inline int operator>(const SubString& x, const char* t)
5106 {
5107 return compare(x, t) > 0;
5108 }
5109
5110 inline int operator>=(const SubString& x, const char* t)
5111 {
5112 return compare(x, t) >= 0;
5113 }
5114
5115 inline int operator<(const SubString& x, const char* t)
5116 {
5117 return compare(x, t) < 0;
5118 }
5119
5120 inline int operator<=(const SubString& x, const char* t)
5121 {
5122 return compare(x, t) <= 0;
5123 }
5124
5125
5126 // a helper needed by at, before, etc.
5127
5128 inline SubString String::_substr(int first, int l)
5129 {
5130 if (first >= length() )
5131 return SubString(_nilString, 0, 0) ;
5132 else
5133 return SubString(*this, first, l);
5134 }
5135
5136
5137
5138
5139
5140 //# 26 "../../../../mips/include/Gct/GctErrorHandler.h" 2
5141
5142 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
5143 // This is part of the iostream library, providing -*- C++ -*- input/output.
5144 // Copyright (C) 1991 Per Bothner.
5145 //
5146 // This library is free software; you can redistribute it and/or
5147 // modify it under the terms of the GNU Library General Public
5148 // License as published by the Free Software Foundation; either
5149 // version 2 of the License, or (at your option) any later version.
5150 //
5151 // This library is distributed in the hope that it will be useful,
5152 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5153 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5154 // Library General Public License for more details.
5155 //
5156 // You should have received a copy of the GNU Library General Public
5157 // License along with this library; if not, write to the Free
5158 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5159
5160 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
5161
5162 //# 27 "../../../../mips/include/Gct/GctErrorHandler.h" 2
5163
5164
5165 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1
5166 // -*- C++ -*-
5167
5168
5169
5170 //
5171 // Fake up a libstuff++
5172 //
5173 // This is done as a complete and utter hack; this library has no function
5174 // at all being in the boot area; it is here solely in order to provide a
5175 // libstuff++ against which the Makefiles can resolve link lines.
5176 //
5177 // The only reason that this is done is to allow the STANDARD_C++_LIBRARIES
5178 // as provided by the Makefile templates in the boot area to be the same
5179 // ones that are used by the tools outside this hierarchy.
5180 //
5181 // The tools outside this hierarchy use a different libstuff++; one that is
5182 // written in C++. This one is not written in C++ in order to be simpler.
5183 //
5184
5185
5186
5187
5188
5189 //#pragma interface
5190
5191
5192
5193 extern "C" {
5194 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 1
5195
5196
5197
5198 /*
5199 * Useful stuff
5200 */
5201
5202 /*
5203 */
5204
5205 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/ansi.h" 1
5206
5207
5208
5209
5210 /*
5211 * ANSI Compiler Support
5212 *
5213 * David Harrison
5214 * University of California, Berkeley
5215 * 1988
5216 *
5217 * ANSI compatible compilers are supposed to define the preprocessor
5218 * directive __STDC__. Based on this directive, this file defines
5219 * certain ANSI specific macros.
5220 *
5221 * ARGS:
5222 * Used in function prototypes. Example:
5223 * extern int foo
5224 * ARGS((char *blah, double threshold));
5225 */
5226
5227 /*
5228 *
5229 * Modifications
5230 * Wendell C Baker
5231 * University of California, Berkeley
5232 */
5233
5234 /* Function prototypes */
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262 //# 15 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2
5263
5264
5265
5266 /*
5267 * If g++, then we stub out part of this thing and let the C++ types take
5268 * over and do the same job; some compatibility must be given however
5269 */
5270
5271 /*
5272 * Use the GNU libg++ definition
5273 */
5274 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
5275
5276
5277
5278
5279
5280
5281
5282 //# 26 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2
5283
5284 //# 35 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h"
5285
5286
5287 /*
5288 * Make various pieces of C code that use the old ``Boolean''
5289 * be compatible by faking up the definition of Boolean using
5290 * the new bool type.
5291 */
5292
5293
5294 //# 58 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h"
5295
5296
5297 typedef long FitAny; /* can fit any integral type */
5298
5299 /*
5300 * typedef char *String; - DO NOT USE THIS - it conflicts with C++
5301 * typedef char **Stringv; - just use char* and char** instead.
5302 * - void* can be used for arbitrary pointers
5303 */
5304
5305
5306
5307
5308 extern int nocase_strcmp (char *, char *) ;
5309 extern int nocase_strncmp (char *, char *, int) ;
5310
5311 extern bool nocase_strequal (char *, char *) ;
5312 extern bool nocase_strnequal (char *, char *, int) ;
5313
5314 extern bool lead_strequal (char *, char *) ;
5315 extern bool nocase_lead_strequal (char *, char *) ;
5316
5317 extern int strhash (char *, int) ;
5318 extern int nocase_strhash (char *, int) ;
5319
5320 extern int sign (int) ;
5321
5322 /*
5323 * Some useful macros.
5324 */
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354 //# 33 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
5355
5356 }
5357
5358 //
5359 // This is here because we wish to provide externs for the two
5360 // functions btoa(bool, unsigned = 0) and operator<<(ostream&, bool)
5361 // because they are not provided in bool.h.
5362 //
5363 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
5364
5365
5366
5367
5368
5369
5370
5371 //# 41 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
5372
5373 extern const char *stringify(bool b);
5374 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
5375 // This is part of the iostream library, providing -*- C++ -*- input/output.
5376 // Copyright (C) 1991 Per Bothner.
5377 //
5378 // This library is free software; you can redistribute it and/or
5379 // modify it under the terms of the GNU Library General Public
5380 // License as published by the Free Software Foundation; either
5381 // version 2 of the License, or (at your option) any later version.
5382 //
5383 // This library is distributed in the hope that it will be useful,
5384 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5385 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5386 // Library General Public License for more details.
5387 //
5388 // You should have received a copy of the GNU Library General Public
5389 // License along with this library; if not, write to the Free
5390 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5391
5392 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
5393
5394 //# 43 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
5395
5396 extern ostream& operator<<(ostream&, bool);
5397
5398 // Should this be kept separate? bool isn't, but then is
5399 // included here only to define ostream& operator<<(ostream&, bool)
5400 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 1
5401 // -*- C++ -*-
5402
5403
5404
5405 //
5406 // unit enum
5407 //
5408 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
5409 //
5410
5411
5412 //
5413 // unit enum
5414 //
5415 // This _looks_ silly, but it has an important theoretical basis in category
5416 // theory. For the pragmatic reason for its existence, see the example below.
5417 //
5418 enum unit {
5419 UNIT = 1,
5420 };
5421
5422 extern const char *stringify(unit u);
5423
5424 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
5425 // This is part of the iostream library, providing -*- C++ -*- input/output.
5426 // Copyright (C) 1991 Per Bothner.
5427 //
5428 // This library is free software; you can redistribute it and/or
5429 // modify it under the terms of the GNU Library General Public
5430 // License as published by the Free Software Foundation; either
5431 // version 2 of the License, or (at your option) any later version.
5432 //
5433 // This library is distributed in the hope that it will be useful,
5434 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5435 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5436 // Library General Public License for more details.
5437 //
5438 // You should have received a copy of the GNU Library General Public
5439 // License along with this library; if not, write to the Free
5440 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5441
5442 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
5443
5444 //# 28 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 2
5445
5446 extern ostream& operator<<(ostream&, unit);
5447
5448 //
5449 // A unit is used in cases where the type signature of an overloaded
5450 // function must be differentiated in some stronger way than can be
5451 // denoted unambiguously in the C++ syntax. This enum is used to give
5452 // one of the functions a different type signature, thereby allowing
5453 // the overloading.
5454 //
5455 // The use of ``unit'' instead of int or bool is important because a unit
5456 // has only one possible value; therefore it adds no more information to
5457 // the code. For example, say a bool was used instead, then in the testing
5458 // phase, would have to ask: what if TRUE was given, what if FALSE was given.
5459 // The problem is compounded if char or int is used.
5460 //
5461 // Example:
5462 //
5463 // class ID {
5464 // public:
5465 // ID(); // construct a null ID
5466 // ID(unit); // alloc a ID with a new id
5467 // private:
5468 // static unsigned high_water;
5469 // unsigned id;
5470 // };
5471 //
5472 // Try working this example save that ID implements all of the generic
5473 // features of the identifier object, but the high_water is stored
5474 // in the heir. That is what originally motivated the creation of unit.
5475 //
5476
5477
5478 //# 48 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
5479
5480
5481 //
5482 // In the spirit of the standard GNU error handler functions
5483 // as described in
5484 // typedef void (*one_arg_error_handler_t)(const char*);
5485 // a one argument error handler function pointer
5486 // typedef void (*two_arg_error_handler_t)(const char*, const char*);
5487 // a two argument error handler function pointer
5488 //
5489 // And now the NEW
5490 //
5491 // typedef void (*zero_arg_error_handler_t)();
5492 // a zero argument error handler function pointer
5493 //
5494 typedef void (*zero_arg_error_handler_t)();
5495
5496 //
5497 // In the spirit of the default GNU error handler functions
5498 // as described in
5499 // extern void default_one_arg_error_handler(const char *message);
5500 // print out message on stderr, and do the default thing (abort)
5501 // extern void default_two_arg_error_handler(const char *kind, const char *message);
5502 // print out kind and message on stderr, and do the default thing (abort)
5503 //
5504 // And now the NEW
5505 //
5506 // extern void default_zero_arg_error_handler(const char *message);
5507 // do the default thing (abort)
5508 //
5509 extern void default_zero_arg_error_handler();
5510
5511 // Guaranteed to exit (1)
5512 extern void exit_zero_arg_error_handler();
5513 extern void exit_one_arg_error_handler(const char *message);
5514 extern void exit_two_arg_error_handler(const char *kind, const char *message);
5515
5516 // Guaranteed to abort()
5517 extern void abort_zero_arg_error_handler();
5518 extern void abort_one_arg_error_handler(const char *message);
5519 extern void abort_two_arg_error_handler(const char *kind, const char *message);
5520
5521 //
5522 // In the spirit of the standard GNU error handlers
5523 // as described in
5524 // extern void verbose_File_error_handler(const char*);
5525 // perror and set errno = 0
5526 // extern void quiet_File_error_handler(const char*);
5527 // set errno = 0
5528 // extern void fatal_File_error_handler(const char*);
5529 // perror and exit 1
5530 //
5531 // And now the NEW
5532 //
5533 // extern void preserve_File_error_handler(const char *message);
5534 // no perror, no assignment to errno.
5535 //
5536 extern void preserve_File_error_handler(const char *message);
5537
5538
5539 //# 29 "../../../../mips/include/Gct/GctErrorHandler.h" 2
5540
5541 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
5542 // -*- C++ -*-
5543
5544
5545
5546 //
5547 // tostrstream class
5548 //
5549 // A terminated oststream - an ostsrstream that auto-terminates on str()
5550 //
5551 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
5552 //
5553
5554
5555
5556
5557
5558 //#pragma interface
5559
5560
5561
5562 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 1
5563 // This is part of the iostream library, providing input/output for C++.
5564 // Copyright (C) 1991 Per Bothner.
5565 //
5566 // This library is free software; you can redistribute it and/or
5567 // modify it under the terms of the GNU Library General Public
5568 // License as published by the Free Software Foundation; either
5569 // version 2 of the License, or (at your option) any later version.
5570 //
5571 // This library is distributed in the hope that it will be useful,
5572 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5573 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5574 // Library General Public License for more details.
5575 //
5576 // You should have received a copy of the GNU Library General Public
5577 // License along with this library; if not, write to the Free
5578 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5579
5580
5581
5582
5583 //#pragma interface
5584
5585 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
5586 // This is part of the iostream library, providing -*- C++ -*- input/output.
5587 // Copyright (C) 1991 Per Bothner.
5588 //
5589 // This library is free software; you can redistribute it and/or
5590 // modify it under the terms of the GNU Library General Public
5591 // License as published by the Free Software Foundation; either
5592 // version 2 of the License, or (at your option) any later version.
5593 //
5594 // This library is distributed in the hope that it will be useful,
5595 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5596 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5597 // Library General Public License for more details.
5598 //
5599 // You should have received a copy of the GNU Library General Public
5600 // License along with this library; if not, write to the Free
5601 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5602
5603 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
5604
5605 //# 23 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 2
5606
5607
5608 class strstreambuf : public streambuf {
5609 size_t *lenp; /* current (logical) length (i.e. valid data bytes) */
5610 size_t *sizep; /* allocated (physical) buffer size */
5611 char **bufp;
5612 size_t _len;
5613 size_t _size;
5614 char *buf;
5615 int _frozen;
5616 protected:
5617 virtual int overflow(int = (-1) );
5618 public:
5619 strstreambuf();
5620 strstreambuf(int initial);
5621 strstreambuf(char *ptr, int size, char *pstart = 0 );
5622 ~strstreambuf();
5623 int frozen() { return _frozen; }
5624 void freeze(int n=1) { _frozen = n != 0; }
5625 size_t pcount();
5626 char *str();
5627 };
5628
5629 class istrstream : public istream {
5630 public:
5631 istrstream(char*);
5632 istrstream(char*, int);
5633 strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; }
5634 };
5635
5636 class ostrstream : public ostream {
5637 public:
5638 ostrstream();
5639 ostrstream(char *cp, int n, int mode=ios::out);
5640 size_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
5641 char *str() { return ((strstreambuf*)_strbuf)->str(); }
5642 void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }
5643 int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }
5644 strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; }
5645 };
5646
5647
5648 //# 25 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 2
5649
5650
5651 //
5652 // tostrstream class
5653 //
5654 // An isteam class that doesn't have that nasty skipws parameter that
5655 // you have to remember to set. This class simply provides the istream
5656 // functionality with a set of constructors which defaults skipws to
5657 // FALSE (instead of defaulting to TRUE as is the case with plain istream).
5658 //
5659 class tostrstream: public ostrstream {
5660 public:
5661 tostrstream(): ostrstream()
5662 { }
5663 // This constructor defines cp as the buffer to use for the
5664 // stream (instead of one of its own devising); it does NOT
5665 // initialize the ostrstream to contain cp (of length n).
5666 tostrstream(char *cp, int n, int mode=ios::out): ostrstream(cp, n, mode)
5667 { }
5668 char *str()
5669 {
5670 char *s = ostrstream::str();
5671 s[ostrstream::pcount()] = '\0';
5672 return s;
5673 }
5674 };
5675
5676
5677 //# 30 "../../../../mips/include/Gct/GctErrorHandler.h" 2
5678
5679
5680 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1
5681 // -*- C++ -*-
5682
5683
5684
5685 //
5686 // GttObject class (is abstract)
5687 //
5688 // Expects to be included where needed explicitly.
5689 //
5690 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
5691 //
5692
5693
5694
5695
5696
5697 //#pragma interface
5698
5699
5700
5701 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
5702 // -*- C++ -*-
5703 //# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h"
5704
5705 //# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2
5706
5707
5708 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 1
5709 // -*- C++ -*-
5710
5711
5712
5713 //
5714 // GttErrorHandler class
5715 //
5716 // Expects to be included by Gtt.h
5717 //
5718 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
5719 //
5720
5721
5722
5723
5724
5725 //#pragma interface
5726
5727
5728
5729 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
5730
5731
5732
5733
5734
5735
5736
5737 //# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2
5738
5739
5740 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1
5741 // -*- C++ -*-
5742 //# 107 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h"
5743
5744 //# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2
5745
5746 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
5747 // -*- C++ -*-
5748 //# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h"
5749
5750 //# 28 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2
5751
5752
5753 //
5754 // It is expected that this will be virtually multiply inherited
5755 // into all of the classes that need error reporting services.
5756 //
5757 // The typical way to have that done is by inheriting the GttObject
5758 // as a virtual base class.
5759 //
5760
5761 //
5762 // GttErrorHandler class
5763 //
5764 class GttErrorHandler {
5765 public:
5766 GttErrorHandler();
5767 GttErrorHandler(const char *program);
5768 virtual ~GttErrorHandler();
5769
5770 //
5771 // Error messages
5772 // - an unacceptable, but expected and recoverable condition
5773 // was detected (but the test fails)
5774 // - errors are for ``the expected environment was not found''
5775 // rather than for ``file couldn't be opened''
5776 // - these messages cannot be shut off
5777 // - the error handler determines the recovery action
5778 // TODO - one day exceptions will be used here
5779 //
5780 static void error(const char *message);
5781 static void error(tostrstream& message);
5782
5783 static void error(const char *function, const char *message);
5784 static void error(const char *function, tostrstream& message);
5785
5786 static void error(const char *class_name, const char *method, const char *message);
5787 static void error(const char *class_name, const char *method, tostrstream& message);
5788
5789 //
5790 // Fatal messages
5791 // - an unacceptable and unexpected error was detected
5792 // the data invariants were violated, there is no recovery
5793 // - these messages cannot be shut off
5794 // - the error handler determines the recovery action
5795 // TODO - one day exceptions will be used here
5796 //
5797 static void fatal(const char *message);
5798 static void fatal(tostrstream& message);
5799
5800 static void fatal(const char *function, const char *message);
5801 static void fatal(const char *function, tostrstream& message);
5802
5803 static void fatal(const char *class_name, const char *method, const char *message);
5804 static void fatal(const char *class_name, const char *method, tostrstream& message);
5805 private:
5806 //
5807 // Two underscores are used here in order to prevent confusion of these
5808 // private variables with any of the heir's private variables. Note that
5809 // access control is different than visibility in C++, so all the variable
5810 // names in a class hierarchy must be unique.
5811 //
5812
5813 static bool __partial_init;
5814 static void __partial_initialize();
5815 static bool __full_init;
5816 static void __full_initialize(const char *program);
5817 static char *__program;
5818
5819 static void __handle_error();
5820 static void __handle_fatal();
5821 static void __add_newline(const char *message);
5822
5823 static bool __output_valid();
5824 static ostream *__output;
5825 };
5826
5827
5828 //# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2
5829
5830
5831 //
5832 // GttObject class (is abstract)
5833 //
5834 class GttObject: virtual public GttErrorHandler {
5835 protected:
5836 GttObject();
5837 GttObject(const GttObject&);
5838 virtual ~GttObject(); // ensure descendants have virtual destructors
5839
5840 public:
5841 //
5842 // I/O Support
5843 //
5844 // The value typically persists only long enough for an i/o operation
5845 // to be performed (see the defintion of output via operator<<(... ) below)
5846 virtual const char *stringify();
5847 protected:
5848 // This is the buffer into which the printed representation of this
5849 // object will be put when the time comes. It is associated with the
5850 // object so it will never go away (so long as the object exists).
5851 // Use a pointer so that you only pay for the space when I/O is used
5852 tostrstream *stringbuf;
5853 void clear_stringbuf();
5854
5855 public:
5856 //
5857 // Consistency
5858 //
5859 // The global data invariant for the whole object (heirs included).
5860 // This OK function will call the local invariant function ok() if
5861 // necessary and in addition the OK functions of the heirs
5862 // This is expected to compute the data invariant of the object.
5863 // It will execute GctErrorHandler::fatal if there is wrong.
5864 virtual void OK() const;
5865
5866 protected:
5867 //
5868 // consistency
5869 //
5870 // This function computes the invariant which is local to this object.
5871 // It does not call any of the ancestor's OK() or ok() functions.
5872 // It is not a virtual function so that it can be called from within a
5873 // constructor with impunity. Thus this function MUST NOT call any
5874 // virtual functions either; it should call them by their full name if
5875 // that is necessary. The global OK() function will call this function
5876 // as necessary.
5877 //
5878 // This function must NOT NEVER EVER be made virtual.
5879 void ok() const;
5880
5881 protected:
5882 //
5883 // Class Name
5884 //
5885 // This must return a static (constant) string which is the name
5886 // of the class being declared. By convention, not all classes
5887 // must have one of these, but the major root abstract class must
5888 // have one in order to allow the stringify() to work approximately
5889 // correctly.
5890 virtual const char *class_name() const = 0;
5891 };
5892
5893 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
5894 // This is part of the iostream library, providing -*- C++ -*- input/output.
5895 // Copyright (C) 1991 Per Bothner.
5896 //
5897 // This library is free software; you can redistribute it and/or
5898 // modify it under the terms of the GNU Library General Public
5899 // License as published by the Free Software Foundation; either
5900 // version 2 of the License, or (at your option) any later version.
5901 //
5902 // This library is distributed in the hope that it will be useful,
5903 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5904 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5905 // Library General Public License for more details.
5906 //
5907 // You should have received a copy of the GNU Library General Public
5908 // License along with this library; if not, write to the Free
5909 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5910
5911 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
5912
5913 //# 91 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2
5914
5915 extern ostream& operator<<(ostream&, GttObject&);
5916
5917 // There may be other X& operator<<(X&, GttObject&) defined in the
5918 // packages defining class X. For example see the definition of
5919 // GttUnitObject& operator<<(GttUnitObject&, GttObject&) in Unit.
5920
5921
5922 //# 32 "../../../../mips/include/Gct/GctErrorHandler.h" 2
5923
5924
5925 //
5926 // It is expected that this will be virtually multiply inherited
5927 // into all of the classes that need error reporting services.
5928 //
5929 // The typical way to have that done is by inheriting the GctObject
5930 // as a virtual base class.
5931 //
5932
5933 //
5934 // GctErrorHandler class
5935 //
5936 // GPP_1_96_BUG
5937 // NOTE - virtual public GttObject should be MI into GctObject - but that
5938 // causes g++ 1.96 to segfault; so we must inherit GttObject here and use SI
5939 // GPP_1_96_BUG
5940 class GctErrorHandler: virtual public GttObject {
5941 public:
5942 GctErrorHandler();
5943 GctErrorHandler(const String& program);
5944 virtual ~GctErrorHandler();
5945
5946 //
5947 // Debugging messages
5948 // - these are turned off for production code.
5949 // - these messages can be shut off
5950 //
5951 static void debug(const char *message);
5952 static void debug(tostrstream& message);
5953
5954 static void debug(const char *function, const char *message);
5955 static void debug(const char *function, tostrstream& message);
5956
5957 static void debug(const char *class_name, const char *method, const char *message);
5958 static void debug(const char *class_name, const char *method, tostrstream& message);
5959
5960 static bool debug(); // current debug switch
5961 static void debug(bool value); // change the debug switch
5962
5963 //
5964 // Informational messages
5965 // - these correspond to a ``verbose'' mode
5966 // - these are not errors, just chatty progress reports
5967 // - these messages can be shut off
5968 //
5969 static void note(const char *message);
5970 static void note(tostrstream& message);
5971
5972 static void note(const char *function, const char *message);
5973 static void note(const char *function, tostrstream& message);
5974
5975 static void note(const char *class_name, const char *method, const char *message);
5976 static void note(const char *class_name, const char *method, tostrstream& message);
5977
5978 static bool note(); // current note switch
5979 static void note(bool value); // change the note switch
5980
5981 //
5982 // Warning messages
5983 // - warnings are system-recoverable errors
5984 // - the system has noticed something and taken some
5985 // corrective action
5986 // - these messages can be shut off
5987 //
5988 static void warning(const char *message);
5989 static void warning(tostrstream& message);
5990
5991 static void warning(const char *function, const char *message);
5992 static void warning(const char *function, tostrstream& message);
5993
5994 static void warning(const char *class_name, const char *method, const char *message);
5995 static void warning(const char *class_name, const char *method, tostrstream& message);
5996
5997 static bool warning(); // current warning switch
5998 static void warning(bool value); // change the warning switch
5999
6000 //
6001 // Error messages
6002 // - an unacceptable, but expected and recoverable
6003 // condition was detected
6004 // - errors are for ``the expected environment was not found''
6005 // rather than for ``file couldn't be opened''
6006 // - these messages cannot be shut off
6007 // - the error handler determines the recovery action
6008 // TODO - one day exceptions will be used here
6009 //
6010 static void error(const char *message);
6011 static void error(tostrstream& message);
6012
6013 static void error(const char *function, const char *message);
6014 static void error(const char *function, tostrstream& message);
6015
6016 static void error(const char *class_name, const char *method, const char *message);
6017 static void error(const char *class_name, const char *method, tostrstream& message);
6018
6019 // can't turn off errors - no ``static void error(bool value);''
6020 static zero_arg_error_handler_t error(); // current error handler
6021 static void error(zero_arg_error_handler_t handler);// change the error handler
6022
6023 static void error_is_lib_error_handler(); // change the error handler
6024 static void error_is_exit(); // change the error handler
6025
6026 // Describes the fatal handler - WATCHOUT - implicitly uses AllocRing
6027 static const char *error_handler_description();
6028
6029 //
6030 // Fatal messages
6031 // - an unacceptable and unexpected error was detected
6032 // the data invariants were violated, there is no recovery
6033 // - these messages cannot be shut off
6034 // - the error handler determines the recovery action
6035 // TODO - one day exceptions will be used here
6036 //
6037 static void fatal(const char *message);
6038 static void fatal(tostrstream& message);
6039
6040 static void fatal(const char *function, const char *message);
6041 static void fatal(const char *function, tostrstream& message);
6042
6043 static void fatal(const char *class_name, const char *method, const char *message);
6044 static void fatal(const char *class_name, const char *method, tostrstream& message);
6045
6046 // can't turn off fatals - no ``static void fatal(bool value);''
6047 static zero_arg_error_handler_t fatal(); // return the fatal handler
6048 static void fatal(zero_arg_error_handler_t handler); // change the fatal handler
6049
6050 static void fatal_is_exit(); // change the fatal handler
6051 static void fatal_is_abort(); // change the fatal handler
6052
6053 // Describes the fatal handler - WATCHOUT - implicitly uses AllocRing
6054 static const char *fatal_handler_description();
6055 private:
6056 //
6057 // Two underscores are used here in order to prevent confusion of these
6058 // private variables with any of the heir's private variables. Note that
6059 // access control is different than visibility in C++, so all the variable
6060 // names in a class hierarchy must be unique.
6061 //
6062 static bool __debug;
6063 static bool __note;
6064 static bool __warning;
6065 static void (*__error_handler)(); // can't turn off errors
6066 static void (*__fatal_handler)(); // can't turn off fatals
6067
6068 static bool __partial_init;
6069 static void __partial_initialize();
6070 static bool __full_init;
6071 static void __full_initialize(const char *program);
6072 static char *__program;
6073
6074 static void __handle_error();
6075 static void __handle_fatal();
6076 static void __add_newline(const char *message);
6077 static void __message_switch(bool value, bool& flag, const char *description);
6078 static void __message_switch(bool value, bool& flag);
6079 static const char *__describe_handler(zero_arg_error_handler_t handler);
6080
6081 static bool __output_valid();
6082 static ostream *__output;
6083
6084 // GPP_1_96_BUG
6085 const char *class_name() const;
6086 // GPP_1_96_BUG
6087 };
6088
6089
6090 //# 27 "../../../../mips/include/Gct/Reference/GctReferenceCount.h" 2
6091
6092
6093 class GctReferenceCount: virtual public GctErrorHandler {
6094 public:
6095 GctReferenceCount();
6096
6097 void inc();
6098 void dec();
6099 bool zero() const;
6100 private:
6101 unsigned _count;
6102 };
6103
6104 inline
6105 GctReferenceCount::GctReferenceCount()
6106 {
6107 this->_count = 0;
6108 }
6109
6110 inline void
6111 GctReferenceCount::inc()
6112 {
6113 this->_count++;
6114 }
6115
6116 inline void
6117 GctReferenceCount::dec()
6118 {
6119 if (this->debug()) {
6120 if (this->_count == 0)
6121 this->error("GctReferenceCount", "dec()",
6122 "attempt to decrement a zero refcount");
6123 }
6124
6125 // Protect against decrementing off zero in case
6126 // this->debug() is not turned on to signal the error.
6127 if (this->_count)
6128 this->_count--;
6129 }
6130
6131 inline bool
6132 GctReferenceCount::zero() const
6133 {
6134 return (bool)(this->_count == 0);
6135 }
6136
6137
6138 //# 25 "../../../../mips/include/Gct/Reference.h" 2
6139
6140 //# 1 "../../../../mips/include/Gct/Reference/GctReferenceObject.h" 1
6141 // -*- C++ -*-
6142
6143
6144
6145 //
6146 // GctReferenceObject class
6147 //
6148 // Expects to be included by Gct/Reference.h
6149 //
6150 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
6151 //
6152
6153
6154
6155
6156
6157 //#pragma interface
6158
6159
6160
6161 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
6162
6163
6164
6165
6166
6167
6168
6169 //# 25 "../../../../mips/include/Gct/Reference/GctReferenceObject.h" 2
6170
6171
6172 //# 1 "../../../../mips/include/Gct/Object/GctHashObject.h" 1
6173 // -*- C++ -*-
6174
6175
6176
6177 //
6178 // GctHashObject class (is abstract)
6179 //
6180 // Expects to be included by Object.h or where needed explicitly.
6181 //
6182 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
6183 //
6184
6185
6186
6187
6188
6189 //#pragma interface
6190
6191
6192
6193 //# 1 "../../../../mips/include/Gct/Object/GctObject.h" 1
6194 // -*- C++ -*-
6195
6196
6197
6198 //
6199 // GctObject class (is abstract)
6200 //
6201 // Expects to be included by Object.h or where needed explicitly.
6202 //
6203 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
6204 //
6205
6206
6207
6208
6209
6210 //#pragma interface
6211
6212
6213
6214 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
6215 // -*- C++ -*-
6216 //# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h"
6217
6218 //# 25 "../../../../mips/include/Gct/Object/GctObject.h" 2
6219
6220
6221 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1
6222 // -*- C++ -*-
6223 //# 98 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h"
6224
6225 //# 27 "../../../../mips/include/Gct/Object/GctObject.h" 2
6226
6227
6228 //# 1 "../../../../mips/include/Gct/GctErrorHandler.h" 1
6229 // -*- C++ -*-
6230 //# 198 "../../../../mips/include/Gct/GctErrorHandler.h"
6231
6232 //# 29 "../../../../mips/include/Gct/Object/GctObject.h" 2
6233
6234
6235 //
6236 // GctObject class (is abstract)
6237 //
6238 class GctObject: virtual public GctErrorHandler /*, virtual public GttObject*/ {
6239 protected:
6240 GctObject();
6241 GctObject(const GctObject&);
6242 virtual ~GctObject(); // ensure descendants have virtual destructors
6243
6244 public:
6245 //
6246 // I/O Support
6247 //
6248 // The value typically persists only long enough for an i/o operation
6249 // to be performed (see the defintion of output via operator<<(... ) below)
6250 virtual const char *stringify();
6251 protected:
6252 // This is the buffer into which the printed representation of this
6253 // object will be put when the time comes. It is associated with the
6254 // object so it will never go away (so long as the object exists).
6255 // Use a pointer so that you only pay for the space when I/O is used
6256 tostrstream *stringbuf;
6257 void clear_stringbuf();
6258
6259 public:
6260 //
6261 // Consistency (global consistency)
6262 //
6263 // The global data invariant for the whole object (heirs included).
6264 // This OK function will call the local invariant function ok() if
6265 // necessary and in addition the OK functions of the heirs
6266 // This is expected to compute the data invariant of the object.
6267 // It will execute GctErrorHandler::fatal if there is wrong.
6268 virtual void OK() const;
6269
6270 protected:
6271 //
6272 // consistency (local consistency)
6273 //
6274 // This function computes the invariant which is local to this object.
6275 // It does not call any of the ancestor's OK() or ok() functions.
6276 // It is not a virtual function so that it can be called from within a
6277 // constructor with impunity. Thus this function MUST NOT call any
6278 // virtual functions either; it should call them by their full name if
6279 // that is necessary. The global OK() function will call this function
6280 // as necessary.
6281 //
6282 // This function must NOT NEVER EVER be made virtual.
6283 void ok() const;
6284 protected:
6285 //
6286 // Class Name
6287 //
6288 // This must return a static (constant) string which is the name
6289 // of the class being declared. By convention, not all classes
6290 // must have one of these, but the major root abstract class must
6291 // have one in order to allow the stringify() to work approximately
6292 // correctly.
6293 virtual const char *class_name() const = 0;
6294
6295 public:
6296 //
6297 // The ``id'' of this object
6298 //
6299 // NOTE - we explicitly allow the situation where this function
6300 // can return the address of the object - the ``this'' pointer
6301 // instead of a computed id field (the __object_id field below).
6302 //
6303 // This function is protected because we don't want too much dependence
6304 // on this notion of object identity. I want to be able to rip it
6305 // out if it becomes to cumbersome.
6306 unsigned objectId() const;
6307 private:
6308 //
6309 // Symbolic ID
6310 //
6311 // NOTE - Normally this would be implemented by the `this' pointer.
6312 // TODO - remove this for production code
6313 //
6314 // However, in order to make the test suites run on all machines, we
6315 // make this into a symbolic id that is maintained with each object.
6316 // Thus the valid outputs are always consistent across all machines.
6317 unsigned __object_id;
6318 static unsigned __next_id;
6319 };
6320
6321 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
6322 // This is part of the iostream library, providing -*- C++ -*- input/output.
6323 // Copyright (C) 1991 Per Bothner.
6324 //
6325 // This library is free software; you can redistribute it and/or
6326 // modify it under the terms of the GNU Library General Public
6327 // License as published by the Free Software Foundation; either
6328 // version 2 of the License, or (at your option) any later version.
6329 //
6330 // This library is distributed in the hope that it will be useful,
6331 // but WITHOUT ANY WARRANTY; without even the implied warranty of
6332 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6333 // Library General Public License for more details.
6334 //
6335 // You should have received a copy of the GNU Library General Public
6336 // License along with this library; if not, write to the Free
6337 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6338
6339 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
6340
6341 //# 117 "../../../../mips/include/Gct/Object/GctObject.h" 2
6342
6343 extern ostream& operator<<(ostream&, GctObject&);
6344
6345
6346 //# 25 "../../../../mips/include/Gct/Object/GctHashObject.h" 2
6347
6348
6349 //
6350 // GctHashObject class (is abstract)
6351 //
6352 class GctHashObject: virtual public GctObject {
6353 protected:
6354 GctHashObject();
6355 GctHashObject(const GctHashObject&);
6356
6357 public:
6358 //
6359 // hash support
6360 //
6361 virtual unsigned hash() const;
6362 };
6363
6364
6365 //# 27 "../../../../mips/include/Gct/Reference/GctReferenceObject.h" 2
6366
6367
6368 class GctRef;
6369
6370 //
6371 // GctReferenceObject class
6372 //
6373 class GctReferenceObject: virtual public GctHashObject {
6374 public:
6375 // Aid in using operator new() to allocate dynamic
6376 // instances of heirs to GctReferenceObject.
6377 // An error is reported if result_of_new is nil.
6378 static void ensure_new_succeeded(GctReferenceObject *result_of_new,
6379 const char *class_name,
6380 const char *args_supplied = "");
6381
6382 // the stringify() is standard
6383 void OK() const;
6384 protected:
6385 GctReferenceObject(const bool refcounting = FALSE);
6386 GctReferenceObject(const GctReferenceObject&,
6387 const bool refcounting = FALSE);
6388 virtual ~GctReferenceObject();
6389
6390 void operator=(const GctReferenceObject&);
6391
6392 void ok() const;
6393
6394 // Disallowed (create pointers to objects via new only)
6395 // It is kept protected so that heirs can do *-cast-& tricks to work
6396 // around the contravariance of abstract virtuals. This operator should
6397 // never be used to return an address of a GctReferenceObject.
6398 GctReferenceObject *operator&() const;
6399 private:
6400 const char *class_name() const;
6401
6402 bool _destructed; // ensure no use of destructed objects
6403 // this bit guards against the destruct-before-copy g++ bug
6404
6405 bool _refcounting; // was allocated via operator new()
6406 GctReferenceCount _refcount;
6407
6408 // TODO - these names can never be used again in a derived
6409 // class; should they be obfuscated some to free up the
6410 // names (these are good, commonly-used names).
6411 void reference();
6412 void dereference(GctReferenceObject *&);
6413 void kill();
6414
6415 bool refcounted() const;
6416 void refcounting(); // as if given in the constructor
6417
6418 // Using this scheme, only GctRef can manipulate the
6419 // reference count via reference(), dereference(). The derived
6420 // classes cannot do such, and the _refcount field is not
6421 // available to be tweaked by GctRef in any way other
6422 // way than the inc/dec/zero interface.
6423 friend class GctRef;
6424 };
6425
6426
6427 //# 26 "../../../../mips/include/Gct/Reference.h" 2
6428
6429 //# 1 "../../../../mips/include/Gct/Reference/GctRef.h" 1
6430 // -*- C++ -*-
6431
6432
6433
6434 //
6435 // GctRef class
6436 //
6437 // Expects to be included by Gct/Reference.h
6438 //
6439 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
6440 //
6441
6442
6443
6444
6445
6446 //#pragma interface
6447
6448
6449
6450 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
6451
6452
6453
6454
6455
6456
6457
6458 //# 25 "../../../../mips/include/Gct/Reference/GctRef.h" 2
6459
6460
6461 //# 1 "../../../../mips/include/Gct/Object/GctHashObject.h" 1
6462 // -*- C++ -*-
6463 //# 42 "../../../../mips/include/Gct/Object/GctHashObject.h"
6464
6465 //# 27 "../../../../mips/include/Gct/Reference/GctRef.h" 2
6466
6467
6468 class GctReferenceObject;
6469
6470 class GctRef: virtual public GctHashObject {
6471 public:
6472 GctRef();
6473 GctRef(const GctRef&);
6474 virtual ~GctRef();
6475
6476 void operator=(GctRef&);
6477
6478 // Accessor functions
6479 bool valid() const; // the managed pointer is !null
6480 bool null() const; // the managed pointer is null
6481
6482 GctReferenceObject *ref() const; // faults if not valid
6483 operator void*() const; // unchecked reference
6484
6485 void nullify(); // set the managed pointer to null
6486 void invalidate(); // set the managed pointer to null
6487
6488 unsigned hash() const;
6489
6490 // the stringify() is standard
6491 void OK() const;
6492 protected:
6493 void ok() const;
6494
6495 // We want to make sure pointers do not float around for very long.
6496 // This constructor is used by descendants of this class only; it is
6497 // expected that such descendants will have friend functions which
6498 // will call ``new MumbleObject()'' and return a GctRef to THAT.
6499 // MumbleObject would be a descendant of GctReferenceObject
6500 GctRef(GctReferenceObject *);
6501 friend class GctReferenceObject;
6502 private:
6503 const char *class_name() const;
6504
6505 GctReferenceObject *_pointer; // may store 0
6506
6507 bool _destructed; // ensure no use of destructed objects
6508 // this bit guards against the destruct-before-copy g++ bug
6509 };
6510
6511 inline
6512 GctRef::operator void*() const
6513 { return this->_pointer; }
6514
6515 inline bool
6516 GctRef::valid() const
6517 { return (bool)(this->_pointer != 0); }
6518
6519 inline bool
6520 GctRef::null() const
6521 { return (bool)(this->_pointer == 0); }
6522
6523 //
6524 // Required operations for the container classes
6525 //
6526 // NOTE: we can't use const here because the genclass code doesn't
6527 // That is the ONLY reason for not using const reference args here.
6528 //
6529 extern int operator==(GctRef&, GctRef&);
6530 extern int operator!=(GctRef&, GctRef&);
6531
6532 extern int operator<=(GctRef&, GctRef&);
6533 extern int operator<(GctRef&, GctRef&);
6534
6535 extern int operator>=(GctRef&, GctRef&);
6536 extern int operator>(GctRef&, GctRef&);
6537
6538 extern unsigned hash(GctRef&);
6539
6540
6541 //# 27 "../../../../mips/include/Gct/Reference.h" 2
6542
6543
6544
6545 //# 47 "../../../../mips/include/Gct/genclasses.h" 2
6546
6547
6548 //# 1 "../../../../mips/include/Gct/Ast/GctAstRef.h" 1
6549 // -*- C++ -*-
6550
6551
6552
6553 //
6554 // GctAstRef class
6555 //
6556 // Expects to be included by Gct/Ast.h
6557 //
6558 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
6559 //
6560
6561
6562
6563
6564
6565 //#pragma interface
6566
6567
6568
6569 //# 1 "../../../../mips/include/Gct/Reference.h" 1
6570 // -*- C++ -*-
6571 //# 29 "../../../../mips/include/Gct/Reference.h"
6572
6573 //# 25 "../../../../mips/include/Gct/Ast/GctAstRef.h" 2
6574
6575
6576 //# 1 "../../../../mips/include/Gct/Ast/GctAstType.h" 1
6577 // -*- C++ -*-
6578
6579
6580
6581 //
6582 // GctAstType enum
6583 //
6584 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
6585 //
6586
6587
6588 //
6589 // GctAstType enum
6590 //
6591 enum GctAstType {
6592 Gct_Leaf,
6593 Gct_Tree
6594 };
6595
6596 extern const char *stringify(GctAstType a);
6597
6598 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
6599 // This is part of the iostream library, providing -*- C++ -*- input/output.
6600 // Copyright (C) 1991 Per Bothner.
6601 //
6602 // This library is free software; you can redistribute it and/or
6603 // modify it under the terms of the GNU Library General Public
6604 // License as published by the Free Software Foundation; either
6605 // version 2 of the License, or (at your option) any later version.
6606 //
6607 // This library is distributed in the hope that it will be useful,
6608 // but WITHOUT ANY WARRANTY; without even the implied warranty of
6609 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6610 // Library General Public License for more details.
6611 //
6612 // You should have received a copy of the GNU Library General Public
6613 // License along with this library; if not, write to the Free
6614 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6615
6616 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
6617
6618 //# 26 "../../../../mips/include/Gct/Ast/GctAstType.h" 2
6619
6620 extern ostream& operator<<(ostream&, GctAstType);
6621
6622
6623 //# 27 "../../../../mips/include/Gct/Ast/GctAstRef.h" 2
6624
6625
6626 class GctAst;
6627 class GctTree;
6628 class GctLeaf;
6629
6630 class GctAstRef: public GctRef {
6631 public:
6632 GctAstRef();
6633 GctAstRef(const GctAstRef&);
6634
6635 GctAst *ref() const; // may return 0 (not requires valid)
6636
6637 GctAstType concrete_type() const; // requires valid()
6638 GctTree *tree() const; // never return 0 - typechecked
6639 GctLeaf *leaf() const; // never return 0 - typechecked
6640 protected:
6641 // We make sure pointers do not float around for very long.
6642 // This constructor cooperates with Gct{Leaf,Tree}::New
6643 // (all flavors) to allow for the creation of new dynamic structures.
6644 GctAstRef(GctAst *);
6645 friend class GctLeaf;
6646 friend class GctTree;
6647 };
6648
6649
6650 //# 49 "../../../../mips/include/Gct/genclasses.h" 2
6651
6652
6653
6654 //# 2 "GctNameRef.List.cc" 2
6655
6656 //# 1 "../../../../mips/include/Gct/Name/GctNameRef.h" 1
6657 // -*- C++ -*-
6658
6659
6660
6661 //
6662 // GctNameRef class
6663 //
6664 // Expects to be included by Gct/Name.h
6665 //
6666 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
6667 //
6668
6669
6670
6671
6672
6673 //#pragma interface
6674
6675
6676
6677 //# 1 "../../../../mips/include/Gct/Reference.h" 1
6678 // -*- C++ -*-
6679 //# 29 "../../../../mips/include/Gct/Reference.h"
6680
6681 //# 25 "../../../../mips/include/Gct/Name/GctNameRef.h" 2
6682
6683
6684 //# 1 "../../../../mips/include/Gct/Name/GctNameType.h" 1
6685 // -*- C++ -*-
6686
6687
6688
6689 //
6690 // GctNameType enum
6691 //
6692 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
6693 //
6694
6695
6696 //
6697 // GctNameType enum
6698 //
6699 enum GctNameType {
6700 Gct_Identifier,
6701 Gct_Signature,
6702 };
6703
6704 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
6705 // This is part of the iostream library, providing -*- C++ -*- input/output.
6706 // Copyright (C) 1991 Per Bothner.
6707 //
6708 // This library is free software; you can redistribute it and/or
6709 // modify it under the terms of the GNU Library General Public
6710 // License as published by the Free Software Foundation; either
6711 // version 2 of the License, or (at your option) any later version.
6712 //
6713 // This library is distributed in the hope that it will be useful,
6714 // but WITHOUT ANY WARRANTY; without even the implied warranty of
6715 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6716 // Library General Public License for more details.
6717 //
6718 // You should have received a copy of the GNU Library General Public
6719 // License along with this library; if not, write to the Free
6720 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6721
6722 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
6723
6724 //# 24 "../../../../mips/include/Gct/Name/GctNameType.h" 2
6725
6726
6727 extern char *ntoa(GctNameType n, unsigned width = 0);
6728 extern ostream& operator<<(ostream&, GctNameType);
6729
6730
6731 //# 27 "../../../../mips/include/Gct/Name/GctNameRef.h" 2
6732
6733
6734 class GctName;
6735 class GctIdentifier;
6736 class GctSignature;
6737
6738 class GctNameRef: public GctRef {
6739 public:
6740 GctNameRef();
6741 GctNameRef(const GctNameRef&);
6742
6743 GctName *ref() const; // may return 0 (not requires valid())
6744
6745 GctNameType concrete_type() const; // requires valid()
6746 GctIdentifier *identifier() const; // never return 0 - typechecked
6747 GctSignature *signature() const; // never return 0 - typechecked
6748 protected:
6749 // We make sure pointers do not float around for very long.
6750 // This constructor cooperates with GctIdentifier::New and
6751 // GctSignature::New (all flavors) to allow for the creation of new
6752 // dynamic structures.
6753 GctNameRef(GctName *);
6754 friend class GctIdentifier;
6755 friend class GctSignature;
6756
6757 private:
6758 const char *class_name() const;
6759 };
6760
6761 //
6762 // Required operations for use by genclass container classes
6763 //
6764 // These are more specific than the ones supplied by GctRef
6765 // because they use the name of the attribute as the key for
6766 // comparison instead of the pointer stored as a void* value.
6767 //
6768 // NOTE: we can't use const here because the genclass code doesn't
6769 // That is the ONLY reason for not using const reference args here.
6770 //
6771 extern int operator==(GctNameRef&, GctNameRef&);
6772 extern int operator!=(GctNameRef&, GctNameRef&);
6773
6774 extern int operator<=(GctNameRef&, GctNameRef&);
6775 extern int operator<(GctNameRef&, GctNameRef&);
6776
6777 extern int operator>=(GctNameRef&, GctNameRef&);
6778 extern int operator>(GctNameRef&, GctNameRef&);
6779
6780 // extern unsigned hash(GctNameRef&)
6781 // is handled by the previous declaration of
6782 // extern unsigned hash(GctRef&);
6783
6784
6785 //# 3 "GctNameRef.List.cc" 2
6786
6787 // This may look like C code, but it is really -*- C++ -*-
6788 /*
6789 Copyright (C) 1988 Free Software Foundation
6790 written by Doug Lea (dl@rocky.oswego.edu)
6791
6792 This file is part of GNU CC.
6793
6794 GNU CC is distributed in the hope that it will be useful,
6795 but WITHOUT ANY WARRANTY. No author or distributor
6796 accepts responsibility to anyone for the consequences of using it
6797 or for whether it serves any particular purpose or works at all,
6798 unless he says so in writing. Refer to the GNU CC General Public
6799 License for full details.
6800
6801 Everyone is granted permission to copy, modify and redistribute
6802 GNU CC, but only under the conditions described in the
6803 GNU CC General Public License. A copy of this license is
6804 supposed to have been given to you along with GNU CC so you
6805 can know your rights and responsibilities. It should be in a
6806 file named COPYING. Among other things, the copyright notice
6807 and this notice must be preserved on all copies.
6808 */
6809
6810
6811 //#pragma implementation
6812
6813 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/builtin.h" 1
6814 // This may look like C code, but it is really -*- C++ -*-
6815
6816 /*
6817 Copyright (C) 1988, 1992 Free Software Foundation
6818 written by Doug Lea (dl@rocky.oswego.edu)
6819
6820 This file is part of the GNU C++ Library. This library is free
6821 software; you can redistribute it and/or modify it under the terms of
6822 the GNU Library General Public License as published by the Free
6823 Software Foundation; either version 2 of the License, or (at your
6824 option) any later version. This library is distributed in the hope
6825 that it will be useful, but WITHOUT ANY WARRANTY; without even the
6826 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
6827 PURPOSE. See the GNU Library General Public License for more details.
6828 You should have received a copy of the GNU Library General Public
6829 License along with this library; if not, write to the Free Software
6830 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
6831 */
6832
6833 /*
6834 arithmetic, etc. functions on built in types
6835 */
6836
6837
6838 //# 214 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/builtin.h"
6839
6840 //# 30 "GctNameRef.List.cc" 2
6841
6842 //# 1 "genclasses/GctNameRef.List.h" 1
6843 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Pix.h" 1
6844
6845
6846
6847 typedef void* Pix;
6848
6849 //# 1 "genclasses/GctNameRef.List.h" 2
6850
6851 // This may look like C code, but it is really -*- C++ -*-
6852 /*
6853 Copyright (C) 1988 Free Software Foundation
6854 written by Doug Lea (dl@rocky.oswego.edu)
6855
6856 This file is part of GNU CC.
6857
6858 GNU CC is distributed in the hope that it will be useful,
6859 but WITHOUT ANY WARRANTY. No author or distributor
6860 accepts responsibility to anyone for the consequences of using it
6861 or for whether it serves any particular purpose or works at all,
6862 unless he says so in writing. Refer to the GNU CC General Public
6863 License for full details.
6864
6865 Everyone is granted permission to copy, modify and redistribute
6866 GNU CC, but only under the conditions described in the
6867 GNU CC General Public License. A copy of this license is
6868 supposed to have been given to you along with GNU CC so you
6869 can know your rights and responsibilities. It should be in a
6870 file named COPYING. Among other things, the copyright notice
6871 and this notice must be preserved on all copies.
6872 */
6873
6874
6875
6876
6877 //#pragma once
6878 //#pragma interface
6879
6880
6881
6882
6883
6884 typedef void (*GctNameRefProcedure)(GctNameRef&);
6885 typedef GctNameRef (*GctNameRefMapper)(GctNameRef&);
6886 typedef GctNameRef (*GctNameRefCombiner)(GctNameRef&, GctNameRef&);
6887 typedef int (*GctNameRefPredicate)(GctNameRef&);
6888 typedef int (*GctNameRefComparator)(GctNameRef&, GctNameRef&);
6889
6890
6891 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Pix.h" 1
6892
6893
6894
6895
6896
6897 //# 42 "genclasses/GctNameRef.List.h" 2
6898
6899
6900 struct GctNameRefListNode
6901 {
6902 GctNameRefListNode* tl;
6903 short ref;
6904 GctNameRef hd;
6905 };
6906
6907 extern GctNameRefListNode NilGctNameRefListNode;
6908
6909 class GctNameRefList
6910 {
6911 protected:
6912 GctNameRefListNode* P;
6913
6914 GctNameRefList(GctNameRefListNode* p);
6915 public:
6916 GctNameRefList();
6917 GctNameRefList(GctNameRef& head);
6918 GctNameRefList(GctNameRef& head, GctNameRefList& tl);
6919 GctNameRefList(GctNameRefList& a);
6920 GctNameRefList(Pix p);
6921 ~GctNameRefList();
6922
6923 GctNameRefList& operator = (GctNameRefList& a);
6924
6925 int null();
6926 int valid();
6927 operator const void* ();
6928 int operator ! ();
6929
6930 int length() const;
6931 int list_length();
6932
6933 GctNameRef& get();
6934 GctNameRef& head();
6935 GctNameRef& operator [] (int n);
6936
6937 GctNameRefList nth(int n);
6938 GctNameRefList tail();
6939 GctNameRefList last() const;
6940
6941 GctNameRefList find(GctNameRef& targ);
6942 GctNameRefList find(GctNameRefList& targ);
6943 int contains(GctNameRef& targ) const;
6944 int contains(GctNameRefList& targ) const;
6945 int position(GctNameRef& targ);
6946
6947 friend GctNameRefList copy(GctNameRefList& a);
6948 friend GctNameRefList concat(GctNameRefList& a, GctNameRefList& b);
6949 friend GctNameRefList append(GctNameRefList& a, GctNameRefList& b);
6950 friend GctNameRefList map(GctNameRefMapper f, GctNameRefList& a);
6951 friend GctNameRefList merge(GctNameRefList& a, GctNameRefList& b, GctNameRefComparator f);
6952 friend GctNameRefList combine(GctNameRefCombiner f, GctNameRefList& a, GctNameRefList& b);
6953 friend GctNameRefList reverse(GctNameRefList& a);
6954 friend GctNameRefList select(GctNameRefPredicate f, GctNameRefList& a);
6955 friend GctNameRefList remove(GctNameRef& targ, GctNameRefList& a);
6956 friend GctNameRefList remove(GctNameRefPredicate f, GctNameRefList& a);
6957 friend GctNameRefList subst(GctNameRef& old, GctNameRef& repl, GctNameRefList& a);
6958
6959 void push(GctNameRef& x);
6960 GctNameRef pop();
6961
6962 void set_tail(GctNameRefList& p);
6963 void append(GctNameRefList& p);
6964 void prepend(GctNameRefList& p);
6965 void del(GctNameRef& targ);
6966 void del(GctNameRefPredicate f);
6967 void select(GctNameRefPredicate f);
6968 void subst(GctNameRef& old, GctNameRef& repl);
6969 void reverse();
6970 void sort(GctNameRefComparator f);
6971
6972 void apply(GctNameRefProcedure f);
6973 GctNameRef reduce(GctNameRefCombiner f, GctNameRef& base);
6974
6975 friend int operator == (GctNameRefList& a, GctNameRefList& b);
6976 friend int operator != (GctNameRefList& a, GctNameRefList& b);
6977
6978 Pix first() const;
6979 void next(Pix& p) const;
6980 Pix seek(GctNameRef& item) const;
6981 GctNameRef& operator () (Pix p) const;
6982 int owns(Pix p) const;
6983
6984 void error(const char*) const;
6985 int OK() const;
6986 };
6987
6988
6989
6990 inline void reference(GctNameRefListNode* p)
6991 {
6992 if (p->ref >= 0) ++p->ref;
6993 }
6994
6995 inline void dereference(GctNameRefListNode* p)
6996 {
6997 while (p->ref > 0 && --p->ref == 0)
6998 {
6999 GctNameRefListNode* n = p->tl;
7000 delete(p);
7001 p = n;
7002 }
7003 }
7004
7005
7006 inline GctNameRefListNode* newGctNameRefListNode(GctNameRef& h)
7007 {
7008 GctNameRefListNode* p = new GctNameRefListNode;
7009 p->ref = 1;
7010 p->hd = h;
7011 return p;
7012 }
7013
7014 inline GctNameRefListNode* newGctNameRefListNode(GctNameRef& h, GctNameRefListNode* t)
7015 {
7016 GctNameRefListNode* p = new GctNameRefListNode;
7017 p->ref = 1;
7018 p->hd = h;
7019 p->tl = t;
7020 return p;
7021 }
7022
7023
7024 inline GctNameRefList::~GctNameRefList()
7025 {
7026 dereference(P);
7027 }
7028
7029 inline GctNameRefList::GctNameRefList()
7030 {
7031 P = &NilGctNameRefListNode;
7032 }
7033
7034 inline GctNameRefList::GctNameRefList(GctNameRefListNode* p)
7035 {
7036 P = p;
7037 }
7038
7039 inline GctNameRefList::GctNameRefList(GctNameRef& head)
7040 {
7041 P = newGctNameRefListNode(head);
7042 P->tl = &NilGctNameRefListNode;
7043 }
7044
7045 inline GctNameRefList::GctNameRefList(GctNameRef& head, GctNameRefList& tl)
7046 {
7047 P = newGctNameRefListNode(head, tl.P);
7048 reference(P->tl);
7049 }
7050
7051 inline GctNameRefList::GctNameRefList(GctNameRefList& a)
7052 {
7053 reference(a.P);
7054 P = a.P;
7055 }
7056
7057
7058 inline GctNameRef& GctNameRefList::get()
7059 {
7060 return P->hd;
7061 }
7062
7063 inline GctNameRef& GctNameRefList::head()
7064 {
7065 return P->hd;
7066 }
7067
7068
7069 inline GctNameRefList GctNameRefList::tail()
7070 {
7071 reference(P->tl);
7072 return GctNameRefList(P->tl);
7073 }
7074
7075
7076
7077 inline int GctNameRefList::null()
7078 {
7079 return P == &NilGctNameRefListNode;
7080 }
7081
7082 inline int GctNameRefList::valid()
7083 {
7084 return P != &NilGctNameRefListNode;
7085 }
7086
7087 inline GctNameRefList::operator const void* ()
7088 {
7089 return (P == &NilGctNameRefListNode)? 0 : this;
7090 }
7091
7092 inline int GctNameRefList::operator ! ()
7093 {
7094 return (P == &NilGctNameRefListNode);
7095 }
7096
7097
7098 inline void GctNameRefList::push(GctNameRef& head)
7099 {
7100 GctNameRefListNode* oldp = P;
7101 P = newGctNameRefListNode(head, oldp);
7102 }
7103
7104
7105 inline int operator != (GctNameRefList& x, GctNameRefList& y)
7106 {
7107 return !(x == y);
7108 }
7109
7110 inline Pix GctNameRefList::first() const
7111 {
7112 return (P == &NilGctNameRefListNode)? 0 : Pix(P);
7113 }
7114
7115 inline GctNameRef& GctNameRefList::operator () (Pix p) const
7116 {
7117 return ((GctNameRefListNode*)p)->hd;
7118 }
7119
7120 inline void GctNameRefList::next(Pix& p) const
7121 {
7122 if (p != 0)
7123 {
7124 p = Pix(((GctNameRefListNode*)p)->tl);
7125 if (p == &NilGctNameRefListNode) p = 0;
7126 }
7127 }
7128
7129 inline GctNameRefList::GctNameRefList(Pix p)
7130 {
7131 P = (GctNameRefListNode*)p;
7132 reference(P);
7133 }
7134
7135
7136
7137 //# 31 "GctNameRef.List.cc" 2
7138
7139
7140 GctNameRefListNode NilGctNameRefListNode;
7141
7142 class init_NilGctNameRefListNode
7143 {
7144 public:
7145 inline init_NilGctNameRefListNode()
7146 {
7147 NilGctNameRefListNode.tl = &NilGctNameRefListNode;
7148 NilGctNameRefListNode.ref = -1;
7149 }
7150 };
7151
7152 static init_NilGctNameRefListNode NilGctNameRefListNode_initializer;
7153
7154 GctNameRefList& GctNameRefList::operator = (GctNameRefList& a)
7155 {
7156 reference(a.P);
7157 dereference(P);
7158 P = a.P;
7159 return *this;
7160 }
7161
7162 GctNameRef GctNameRefList::pop()
7163 {
7164 GctNameRef res = P->hd;
7165 GctNameRefListNode* tail = P->tl;
7166 reference(tail);
7167 dereference(P);
7168 P = tail;
7169 return res;
7170 }
7171
7172 void GctNameRefList::set_tail(GctNameRefList& a)
7173 {
7174 reference(a.P);
7175 dereference(P->tl);
7176 P->tl = a.P;
7177 }
7178
7179 GctNameRefList GctNameRefList::nth(int n)
7180 {
7181 GctNameRefListNode* p;
7182 for (p = P; n-- > 0; p = p->tl);
7183 reference(p);
7184 return GctNameRefList(p);
7185 }
7186
7187 GctNameRefList GctNameRefList::last() const
7188 {
7189 GctNameRefListNode* p = P;
7190 if (p != &NilGctNameRefListNode) while (p->tl != &NilGctNameRefListNode) p = p->tl;
7191 reference(p);
7192 return GctNameRefList(p);
7193 }
7194
7195 void GctNameRefList::append(GctNameRefList& l)
7196 {
7197 GctNameRefListNode* p = P;
7198 GctNameRefListNode* a = l.P;
7199 reference(a);
7200 if (p != &NilGctNameRefListNode)
7201 {
7202 while (p->tl != &NilGctNameRefListNode) p = p->tl;
7203 p->tl = a;
7204 }
7205 else
7206 P = a;
7207 }
7208
7209 int GctNameRefList::length() const
7210 {
7211 int l = 0;
7212 for (GctNameRefListNode* p = P; p != &NilGctNameRefListNode; p = p->tl) ++l;
7213 return l;
7214 }
7215
7216 GctNameRef& GctNameRefList::operator [] (int n)
7217 {
7218 GctNameRefListNode* p;
7219 for (p = P; n-- > 0; p = p->tl);
7220 return (p->hd);
7221 }
7222
7223 int operator == (GctNameRefList& x, GctNameRefList& y)
7224 {
7225 GctNameRefListNode* a = x.P;
7226 GctNameRefListNode* b = y.P;
7227
7228 for (;;)
7229 {
7230 if (a == &NilGctNameRefListNode)
7231 return b == &NilGctNameRefListNode;
7232 else if (b == &NilGctNameRefListNode)
7233 return 0;
7234 else if (a->hd == b->hd)
7235 {
7236 a = a->tl;
7237 b = b->tl;
7238 }
7239 else
7240 return 0;
7241 }
7242 }
7243
7244
7245 void GctNameRefList::apply(GctNameRefProcedure f)
7246 {
7247 for(GctNameRefListNode* p = P; p != &NilGctNameRefListNode; p = p->tl)
7248 (*f)((p->hd));
7249 }
7250
7251 void GctNameRefList::subst(GctNameRef& old, GctNameRef& repl)
7252 {
7253 for(GctNameRefListNode* p = P; p != &NilGctNameRefListNode; p = p->tl)
7254 if (p->hd == old)
7255 p->hd = repl;
7256 }
7257
7258 GctNameRef GctNameRefList::reduce(GctNameRefCombiner f, GctNameRef& base)
7259 {
7260 GctNameRef r = base;
7261 for(GctNameRefListNode* p = P; p != &NilGctNameRefListNode; p = p->tl)
7262 r = (*f)(r, (p->hd));
7263 return r;
7264 }
7265
7266 int GctNameRefList::position(GctNameRef& targ)
7267 {
7268 int l = 0;
7269 GctNameRefListNode* p = P;
7270 for (;;)
7271 {
7272 if (p == &NilGctNameRefListNode)
7273 return -1;
7274 else if (p->hd == targ)
7275 return l;
7276 else
7277 {
7278 ++l;
7279 p = p->tl;
7280 }
7281 }
7282 }
7283
7284 int GctNameRefList::contains(GctNameRef& targ) const
7285 {
7286 GctNameRefListNode* p = P;
7287 for (;;)
7288 {
7289 if (p == &NilGctNameRefListNode)
7290 return 0;
7291 else if (p->hd == targ)
7292 return 1;
7293 else
7294 p = p->tl;
7295 }
7296 }
7297
7298 GctNameRefList GctNameRefList::find(GctNameRef& targ)
7299 {
7300 GctNameRefListNode* p;
7301 for (p = P; p != &NilGctNameRefListNode && !(p->hd == targ); p=p->tl);
7302 reference(p);
7303 return GctNameRefList(p);
7304 }
7305
7306 Pix GctNameRefList::seek(GctNameRef& targ) const
7307 {
7308 GctNameRefListNode* p = P;
7309 for (;;)
7310 {
7311 if (p == &NilGctNameRefListNode)
7312 return 0;
7313 else if (p->hd == targ)
7314 return Pix(p);
7315 else
7316 p = p->tl;
7317 }
7318 }
7319
7320 int GctNameRefList::owns(Pix i) const
7321 {
7322 GctNameRefListNode* p = P;
7323 for (;;)
7324 {
7325 if (p == &NilGctNameRefListNode)
7326 return 0;
7327 else if (Pix(p) == i)
7328 return 1;
7329 else
7330 p = p->tl;
7331 }
7332 }
7333
7334 GctNameRefList GctNameRefList::find(GctNameRefList& target)
7335 {
7336 GctNameRefListNode* targ = target.P;
7337 if (targ == &NilGctNameRefListNode)
7338 return GctNameRefList(targ);
7339
7340 GctNameRefListNode* p = P;
7341 while (p != &NilGctNameRefListNode)
7342 {
7343 if (p->hd == targ->hd)
7344 {
7345 GctNameRefListNode* a = p->tl;
7346 GctNameRefListNode* t = targ->tl;
7347 for(;;)
7348 {
7349 if (t == &NilGctNameRefListNode)
7350 {
7351 reference(p);
7352 return GctNameRefList(p);
7353 }
7354 else if (a == &NilGctNameRefListNode || !(a->hd == t->hd))
7355 break;
7356 else
7357 {
7358 a = a->tl;
7359 t = t->tl;
7360 }
7361 }
7362 }
7363 p = p->tl;
7364 }
7365 return GctNameRefList(&NilGctNameRefListNode);
7366 }
7367
7368 int GctNameRefList::contains(GctNameRefList& target) const
7369 {
7370 GctNameRefListNode* targ = target.P;
7371 if (targ == &NilGctNameRefListNode)
7372 return 0;
7373
7374 GctNameRefListNode* p = P;
7375 while (p != &NilGctNameRefListNode)
7376 {
7377 if (p->hd == targ->hd)
7378 {
7379 GctNameRefListNode* a = p->tl;
7380 GctNameRefListNode* t = targ->tl;
7381 for(;;)
7382 {
7383 if (t == &NilGctNameRefListNode)
7384 return 1;
7385 else if (a == &NilGctNameRefListNode || !(a->hd == t->hd))
7386 break;
7387 else
7388 {
7389 a = a->tl;
7390 t = t->tl;
7391 }
7392 }
7393 }
7394 p = p->tl;
7395 }
7396 return 0;
7397 }
7398
7399 void GctNameRefList::del(GctNameRef& targ)
7400 {
7401 GctNameRefListNode* h = P;
7402
7403 for (;;)
7404 {
7405 if (h == &NilGctNameRefListNode)
7406 {
7407 P = h;
7408 return;
7409 }
7410 else if (h->hd == targ)
7411 {
7412 GctNameRefListNode* nxt = h->tl;
7413 reference(nxt);
7414 dereference(h);
7415 h = nxt;
7416 }
7417 else
7418 break;
7419 }
7420
7421 GctNameRefListNode* trail = h;
7422 GctNameRefListNode* p = h->tl;
7423 while (p != &NilGctNameRefListNode)
7424 {
7425 if (p->hd == targ)
7426 {
7427 GctNameRefListNode* nxt = p->tl;
7428 reference(nxt);
7429 dereference(p);
7430 trail->tl = nxt;
7431 p = nxt;
7432 }
7433 else
7434 {
7435 trail = p;
7436 p = p->tl;
7437 }
7438 }
7439 P = h;
7440 }
7441
7442 void GctNameRefList::del(GctNameRefPredicate f)
7443 {
7444 GctNameRefListNode* h = P;
7445 for (;;)
7446 {
7447 if (h == &NilGctNameRefListNode)
7448 {
7449 P = h;
7450 return;
7451 }
7452 else if ((*f)(h->hd))
7453 {
7454 GctNameRefListNode* nxt = h->tl;
7455 reference(nxt);
7456 dereference(h);
7457 h = nxt;
7458 }
7459 else
7460 break;
7461 }
7462
7463 GctNameRefListNode* trail = h;
7464 GctNameRefListNode* p = h->tl;
7465 while (p != &NilGctNameRefListNode)
7466 {
7467 if ((*f)(p->hd))
7468 {
7469 GctNameRefListNode* nxt = p->tl;
7470 reference(nxt);
7471 dereference(p);
7472 trail->tl = nxt;
7473 p = nxt;
7474 }
7475 else
7476 {
7477 trail = p;
7478 p = p->tl;
7479 }
7480 }
7481 P = h;
7482 }
7483
7484 void GctNameRefList::select(GctNameRefPredicate f)
7485 {
7486 GctNameRefListNode* h = P;
7487 for (;;)
7488 {
7489 if (h == &NilGctNameRefListNode)
7490 {
7491 P = h;
7492 return;
7493 }
7494 else if (!(*f)(h->hd))
7495 {
7496 GctNameRefListNode* nxt = h->tl;
7497 reference(nxt);
7498 dereference(h);
7499 h = nxt;
7500 }
7501 else
7502 break;
7503 }
7504 GctNameRefListNode* trail = h;
7505 GctNameRefListNode* p = h->tl;
7506 while (p != &NilGctNameRefListNode)
7507 {
7508 if (!(*f)(p->hd))
7509 {
7510 GctNameRefListNode* nxt = p->tl;
7511 reference(nxt);
7512 dereference(p);
7513 trail->tl = nxt;
7514 p = nxt;
7515 }
7516 else
7517 {
7518 trail = p;
7519 p = p->tl;
7520 }
7521 }
7522 P = h;
7523 }
7524
7525 void GctNameRefList::reverse()
7526 {
7527 GctNameRefListNode* l = &NilGctNameRefListNode;
7528 GctNameRefListNode* p = P;
7529 while (p != &NilGctNameRefListNode)
7530 {
7531 GctNameRefListNode* nxt = p->tl;
7532 p->tl = l;
7533 l = p;
7534 p = nxt;
7535 }
7536 P = l;
7537 }
7538
7539
7540 GctNameRefList copy(GctNameRefList& x)
7541 {
7542 GctNameRefListNode* a = x.P;
7543 if (a == &NilGctNameRefListNode)
7544 return GctNameRefList(a);
7545 else
7546 {
7547 GctNameRefListNode* h = newGctNameRefListNode(a->hd);
7548 GctNameRefListNode* trail = h;
7549 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7550 {
7551 GctNameRefListNode* n = newGctNameRefListNode(a->hd);
7552 trail->tl = n;
7553 trail = n;
7554 }
7555 trail->tl = &NilGctNameRefListNode;
7556 return GctNameRefList(h);
7557 }
7558 }
7559
7560
7561 GctNameRefList subst(GctNameRef& old, GctNameRef& repl, GctNameRefList& x)
7562 {
7563 GctNameRefListNode* a = x.P;
7564 if (a == &NilGctNameRefListNode)
7565 return GctNameRefList(a);
7566 else
7567 {
7568 GctNameRefListNode* h = new GctNameRefListNode;
7569 h->ref = 1;
7570 if (a->hd == old)
7571 h->hd = repl;
7572 else
7573 h->hd = a->hd;
7574 GctNameRefListNode* trail = h;
7575 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7576 {
7577 GctNameRefListNode* n = new GctNameRefListNode;
7578 n->ref = 1;
7579 if (a->hd == old)
7580 n->hd = repl;
7581 else
7582 n->hd = a->hd;
7583 trail->tl = n;
7584 trail = n;
7585 }
7586 trail->tl = &NilGctNameRefListNode;
7587 return GctNameRefList(h);
7588 }
7589 }
7590
7591 GctNameRefList combine(GctNameRefCombiner f, GctNameRefList& x, GctNameRefList& y)
7592 {
7593 GctNameRefListNode* a = x.P;
7594 GctNameRefListNode* b = y.P;
7595 if (a == &NilGctNameRefListNode || b == &NilGctNameRefListNode)
7596 return GctNameRefList(&NilGctNameRefListNode);
7597 else
7598 {
7599 GctNameRefListNode* h = newGctNameRefListNode((*f)(a->hd, b->hd));
7600 GctNameRefListNode* trail = h;
7601 a = a->tl;
7602 b = b->tl;
7603 while (a != &NilGctNameRefListNode && b != &NilGctNameRefListNode)
7604 {
7605 GctNameRefListNode* n = newGctNameRefListNode((*f)(a->hd, b->hd));
7606 trail->tl = n;
7607 trail = n;
7608 a = a->tl;
7609 b = b->tl;
7610 }
7611 trail->tl = &NilGctNameRefListNode;
7612 return GctNameRefList(h);
7613 }
7614 }
7615
7616 GctNameRefList reverse(GctNameRefList& x)
7617 {
7618 GctNameRefListNode* a = x.P;
7619 if (a == &NilGctNameRefListNode)
7620 return GctNameRefList(a);
7621 else
7622 {
7623 GctNameRefListNode* l = newGctNameRefListNode(a->hd);
7624 l->tl = &NilGctNameRefListNode;
7625 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7626 {
7627 GctNameRefListNode* n = newGctNameRefListNode(a->hd);
7628 n->tl = l;
7629 l = n;
7630 }
7631 return GctNameRefList(l);
7632 }
7633 }
7634
7635 GctNameRefList append(GctNameRefList& x, GctNameRefList& y)
7636 {
7637 GctNameRefListNode* a = x.P;
7638 GctNameRefListNode* b = y.P;
7639 reference(b);
7640 if (a != &NilGctNameRefListNode)
7641 {
7642 GctNameRefListNode* h = newGctNameRefListNode(a->hd);
7643 GctNameRefListNode* trail = h;
7644 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7645 {
7646 GctNameRefListNode* n = newGctNameRefListNode(a->hd);
7647 trail->tl = n;
7648 trail = n;
7649 }
7650 trail->tl = b;
7651 return GctNameRefList(h);
7652 }
7653 else
7654 return GctNameRefList(b);
7655 }
7656
7657 void GctNameRefList::prepend(GctNameRefList& y)
7658 {
7659 GctNameRefListNode* b = y.P;
7660 if (b != &NilGctNameRefListNode)
7661 {
7662 GctNameRefListNode* h = newGctNameRefListNode(b->hd);
7663 GctNameRefListNode* trail = h;
7664 for(b = b->tl; b != &NilGctNameRefListNode; b = b->tl)
7665 {
7666 GctNameRefListNode* n = newGctNameRefListNode(b->hd);
7667 trail->tl = n;
7668 trail = n;
7669 }
7670 trail->tl = P;
7671 P = h;
7672 }
7673 }
7674
7675 GctNameRefList concat(GctNameRefList& x, GctNameRefList& y)
7676 {
7677 GctNameRefListNode* a = x.P;
7678 GctNameRefListNode* b = y.P;
7679 if (a != &NilGctNameRefListNode)
7680 {
7681 GctNameRefListNode* h = newGctNameRefListNode(a->hd);
7682 GctNameRefListNode* trail = h;
7683 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7684 {
7685 GctNameRefListNode* n = newGctNameRefListNode(a->hd);
7686 trail->tl = n;
7687 trail = n;
7688 };
7689 for(;b != &NilGctNameRefListNode; b = b->tl)
7690 {
7691 GctNameRefListNode* n = newGctNameRefListNode(b->hd);
7692 trail->tl = n;
7693 trail = n;
7694 }
7695 trail->tl = &NilGctNameRefListNode;
7696 return GctNameRefList(h);
7697 }
7698 else if (b != &NilGctNameRefListNode)
7699 {
7700 GctNameRefListNode* h = newGctNameRefListNode(b->hd);
7701 GctNameRefListNode* trail = h;
7702 for(b = b->tl; b != &NilGctNameRefListNode; b = b->tl)
7703 {
7704 GctNameRefListNode* n = newGctNameRefListNode(b->hd);
7705 trail->tl = n;
7706 trail = n;
7707 }
7708 trail->tl = &NilGctNameRefListNode;
7709 return GctNameRefList(h);
7710 }
7711 else
7712 return GctNameRefList(&NilGctNameRefListNode);
7713 }
7714
7715 GctNameRefList select(GctNameRefPredicate f, GctNameRefList& x)
7716 {
7717 GctNameRefListNode* a = x.P;
7718 GctNameRefListNode* h = &NilGctNameRefListNode;
7719 while (a != &NilGctNameRefListNode)
7720 {
7721 if ((*f)(a->hd))
7722 {
7723 h = newGctNameRefListNode(a->hd);
7724 GctNameRefListNode* trail = h;
7725 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7726 {
7727 if ((*f)(a->hd))
7728 {
7729 GctNameRefListNode* n = newGctNameRefListNode(a->hd);
7730 trail->tl = n;
7731 trail = n;
7732 }
7733 }
7734 trail->tl = &NilGctNameRefListNode;
7735 break;
7736 }
7737 else
7738 a = a->tl;
7739 }
7740 return GctNameRefList(h);
7741 }
7742
7743 GctNameRefList remove(GctNameRefPredicate f, GctNameRefList& x)
7744 {
7745 GctNameRefListNode* a = x.P;
7746 GctNameRefListNode* h = &NilGctNameRefListNode;
7747 while (a != &NilGctNameRefListNode)
7748 {
7749 if (!(*f)(a->hd))
7750 {
7751 h = newGctNameRefListNode(a->hd);
7752 GctNameRefListNode* trail = h;
7753 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7754 {
7755 if (!(*f)(a->hd))
7756 {
7757 GctNameRefListNode* n = newGctNameRefListNode(a->hd);
7758 trail->tl = n;
7759 trail = n;
7760 }
7761 }
7762 trail->tl = &NilGctNameRefListNode;
7763 break;
7764 }
7765 else
7766 a = a->tl;
7767 }
7768 return GctNameRefList(h);
7769 }
7770
7771 GctNameRefList remove(GctNameRef& targ, GctNameRefList& x)
7772 {
7773 GctNameRefListNode* a = x.P;
7774 GctNameRefListNode* h = &NilGctNameRefListNode;
7775 while (a != &NilGctNameRefListNode)
7776 {
7777 if (!(a->hd == targ))
7778 {
7779 h = newGctNameRefListNode(a->hd);
7780 GctNameRefListNode* trail = h;
7781 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7782 {
7783 if (!(a->hd == targ))
7784 {
7785 GctNameRefListNode* n = newGctNameRefListNode(a->hd);
7786 trail->tl = n;
7787 trail = n;
7788 }
7789 }
7790 trail->tl = &NilGctNameRefListNode;
7791 break;
7792 }
7793 else
7794 a = a->tl;
7795 }
7796 return GctNameRefList(h);
7797 }
7798
7799 GctNameRefList map(GctNameRefMapper f, GctNameRefList& x)
7800 {
7801 GctNameRefListNode* a = x.P;
7802 GctNameRefListNode* h = &NilGctNameRefListNode;
7803 if (a != &NilGctNameRefListNode)
7804 {
7805 h = newGctNameRefListNode((*f)(a->hd));
7806 GctNameRefListNode* trail = h;
7807 for(a = a->tl; a != &NilGctNameRefListNode; a = a->tl)
7808 {
7809 GctNameRefListNode* n = newGctNameRefListNode((*f)(a->hd));
7810 trail->tl = n;
7811 trail = n;
7812 }
7813 trail->tl = &NilGctNameRefListNode;
7814 }
7815 return GctNameRefList(h);
7816 }
7817
7818
7819 GctNameRefList merge(GctNameRefList& x, GctNameRefList& y, GctNameRefComparator f)
7820 {
7821 GctNameRefListNode* a = x.P;
7822 GctNameRefListNode* b = y.P;
7823
7824 if (a == &NilGctNameRefListNode)
7825 {
7826 if (b == &NilGctNameRefListNode)
7827 return GctNameRefList(&NilGctNameRefListNode);
7828 else
7829 return copy(y);
7830 }
7831 else if (b == &NilGctNameRefListNode)
7832 return copy(x);
7833
7834 GctNameRefListNode* h = new GctNameRefListNode;
7835 h->ref = 1;
7836 if ((*f)(a->hd, b->hd) <= 0)
7837 {
7838 h->hd = a->hd;
7839 a = a->tl;
7840 }
7841 else
7842 {
7843 h->hd = b->hd;
7844 b = b->tl;
7845 }
7846
7847 GctNameRefListNode* r = h;
7848
7849 for(;;)
7850 {
7851 if (a == &NilGctNameRefListNode)
7852 {
7853 while (b != &NilGctNameRefListNode)
7854 {
7855 GctNameRefListNode* n = new GctNameRefListNode;
7856 n->ref = 1;
7857 n->hd = b->hd;
7858 r->tl = n;
7859 r = n;
7860 b = b->tl;
7861 }
7862 r->tl = &NilGctNameRefListNode;
7863 return GctNameRefList(h);
7864 }
7865 else if (b == &NilGctNameRefListNode)
7866 {
7867 while (a != &NilGctNameRefListNode)
7868 {
7869 GctNameRefListNode* n = new GctNameRefListNode;
7870 n->ref = 1;
7871 n->hd = a->hd;
7872 r->tl = n;
7873 r = n;
7874 a = a->tl;
7875 }
7876 r->tl = &NilGctNameRefListNode;
7877 return GctNameRefList(h);
7878 }
7879 else if ((*f)(a->hd, b->hd) <= 0)
7880 {
7881 GctNameRefListNode* n = new GctNameRefListNode;
7882 n->ref = 1;
7883 n->hd = a->hd;
7884 r->tl = n;
7885 r = n;
7886 a = a->tl;
7887 }
7888 else
7889 {
7890 GctNameRefListNode* n = new GctNameRefListNode;
7891 n->ref = 1;
7892 n->hd = b->hd;
7893 r->tl = n;
7894 r = n;
7895 b = b->tl;
7896 }
7897 }
7898 }
7899
7900 void GctNameRefList::sort(GctNameRefComparator f)
7901 {
7902 // strategy: place runs in queue, merge runs until done
7903 // This is often very fast
7904
7905 if (P == &NilGctNameRefListNode || P->tl == &NilGctNameRefListNode)
7906 return;
7907
7908 int qlen = 250; // guess a good queue size, realloc if necessary
7909
7910 GctNameRefListNode** queue = (GctNameRefListNode**)malloc(qlen * sizeof(GctNameRefListNode*));
7911
7912 GctNameRefListNode* h = P;
7913 GctNameRefListNode* a = h;
7914 GctNameRefListNode* b = a->tl;
7915 int qin = 0;
7916
7917 while (b != &NilGctNameRefListNode)
7918 {
7919 if ((*f)(a->hd, b->hd) > 0)
7920 {
7921 if (h == a) // minor optimization: ensure runlen >= 2
7922 {
7923 h = b;
7924 a->tl = b->tl;
7925 b->tl = a;
7926 b = a->tl;
7927 }
7928 else
7929 {
7930 if (qin >= qlen)
7931 {
7932 qlen *= 2;
7933 queue = (GctNameRefListNode**)realloc(queue, qlen * sizeof(GctNameRefListNode*));
7934 }
7935 queue[qin++] = h;
7936 a->tl = &NilGctNameRefListNode;
7937 h = a = b;
7938 b = b->tl;
7939 }
7940 }
7941 else
7942 {
7943 a = b;
7944 b = b->tl;
7945 }
7946 }
7947
7948 int count = qin;
7949 queue[qin] = h;
7950 if (++qin >= qlen) qin = 0;
7951 int qout = 0;
7952
7953 while (count-- > 0)
7954 {
7955 a = queue[qout];
7956 if (++qout >= qlen) qout = 0;
7957 b = queue[qout];
7958 if (++qout >= qlen) qout = 0;
7959
7960 if ((*f)(a->hd, b->hd) <= 0)
7961 {
7962 h = a;
7963 a = a->tl;
7964 }
7965 else
7966 {
7967 h = b;
7968 b = b->tl;
7969 }
7970 queue[qin] = h;
7971 if (++qin >= qlen) qin = 0;
7972
7973 for (;;)
7974 {
7975 if (a == &NilGctNameRefListNode)
7976 {
7977 h->tl = b;
7978 break;
7979 }
7980 else if (b == &NilGctNameRefListNode)
7981 {
7982 h->tl = a;
7983 break;
7984 }
7985 else if ((*f)(a->hd, b->hd) <= 0)
7986 {
7987 h->tl = a;
7988 h = a;
7989 a = a->tl;
7990 }
7991 else
7992 {
7993 h->tl = b;
7994 h = b;
7995 b = b->tl;
7996 }
7997 }
7998 }
7999 P = queue[qout];
8000 free(queue);
8001 }
8002
8003 int GctNameRefList::list_length()
8004 {
8005 GctNameRefListNode* fast = P;
8006 if (fast == &NilGctNameRefListNode)
8007 return 0;
8008
8009 GctNameRefListNode* slow = fast->tl;
8010 if (slow == &NilGctNameRefListNode)
8011 return 1;
8012
8013 fast = slow->tl;
8014 int n = 2;
8015
8016 for (;;)
8017 {
8018 if (fast == &NilGctNameRefListNode)
8019 return n;
8020 else if (fast->tl == &NilGctNameRefListNode)
8021 return n+1;
8022 else if (fast == slow)
8023 return -1;
8024 else
8025 {
8026 n += 2;
8027 fast = fast->tl->tl;
8028 slow = slow->tl;
8029 }
8030 }
8031 }
8032
8033 void GctNameRefList::error(const char* msg) const
8034 {
8035 (*lib_error_handler)("List", msg);
8036 }
8037
8038 int GctNameRefList::OK() const
8039 {
8040 int v = P != 0; // have a node
8041 // check that all nodes OK, even if circular:
8042
8043 GctNameRefListNode* fast = P;
8044 if (fast != &NilGctNameRefListNode)
8045 {
8046 v &= fast->ref != 0;
8047 GctNameRefListNode* slow = fast->tl;
8048 v &= slow->ref != 0;
8049 if (v && slow != &NilGctNameRefListNode)
8050 {
8051 fast = slow->tl;
8052 v &= fast->ref != 0;
8053 while (v)
8054 {
8055 if (fast == &NilGctNameRefListNode)
8056 break;
8057 else if (fast->tl == &NilGctNameRefListNode)
8058 break;
8059 else if (fast == slow)
8060 break;
8061 else
8062 {
8063 v &= fast->ref != 0 && slow->ref != 0;
8064 fast = fast->tl->tl;
8065 slow = slow->tl;
8066 }
8067 }
8068 }
8069 }
8070 if (!v) error ("invariant failure");
8071 return v;
8072 }