xref: /csrg-svn/usr.bin/pascal/pdx/defs.h (revision 22569)
1*22569Sdist /*
2*22569Sdist  * Copyright (c) 1980 Regents of the University of California.
3*22569Sdist  * All rights reserved.  The Berkeley software License Agreement
4*22569Sdist  * specifies the terms and conditions for redistribution.
5*22569Sdist  *
6*22569Sdist  *	@(#)defs.h	5.1 (Berkeley) 06/06/85
7*22569Sdist  */
85450Slinton 
95450Slinton /*
105450Slinton  * Global debugger defines.
115450Slinton  *
125450Slinton  * All files include this header.
135450Slinton  */
145450Slinton 
155450Slinton #include <stdio.h>
165450Slinton 
175450Slinton /*
185450Slinton  * Since C does not allow forward referencing of types,
195450Slinton  * all the global types are declared here.
205450Slinton  */
215450Slinton 
225450Slinton #define LOCAL static
235450Slinton #define NIL 0
245450Slinton 
255450Slinton typedef int BOOLEAN;
265450Slinton 
275450Slinton #define FALSE 0
285450Slinton #define TRUE 1
295450Slinton 
305450Slinton typedef unsigned int ADDRESS;		/* object code addresses */
315450Slinton typedef short LINENO;			/* source file line numbers */
325450Slinton typedef struct sym SYM;			/* symbol information structure */
335450Slinton typedef struct symtab SYMTAB;		/* symbol table */
345450Slinton typedef struct node NODE;		/* expression tree node */
355450Slinton typedef short OP;			/* tree operator */
365450Slinton typedef struct opinfo OPINFO;		/* tree operator information table */
375450Slinton typedef unsigned int WORD;		/* machine word */
385450Slinton typedef unsigned char BYTE;		/* machine byte */
395450Slinton typedef struct frame FRAME;		/* runtime activation record */
405450Slinton 
415450Slinton /*
425450Slinton  * Definitions of standard C library routines that aren't in the
435450Slinton  * standard I/O library, but which are generally useful.
445450Slinton  */
455450Slinton 
465450Slinton extern long atol();		/* ascii to long */
475450Slinton extern double atof();		/* ascii to floating point */
485450Slinton extern char *mktemp();		/* make a temporary file name */
495450Slinton 
505450Slinton /*
515450Slinton  * Definitions of library routines.
525450Slinton  */
535450Slinton 
545450Slinton char *cmdname;			/* name of command for error messages */
555450Slinton char *errfilename;		/* current file associated with error */
565450Slinton short errlineno;		/* line number associated with error */
575450Slinton 
585450Slinton error();			/* print an error message */
595450Slinton panic();			/* print error message and exit */
605450Slinton short numerrors();		/* return number of errors since last call */
615450Slinton 
625450Slinton /*
635450Slinton  * defintions for doing memory allocation
645450Slinton  */
655450Slinton 
665450Slinton extern char *malloc();
675450Slinton 
685450Slinton #define alloc(n, type)	((type *) malloc((unsigned) (n) * sizeof(type)))
695450Slinton #define dispose(p)	{ free((char *) p); p = NIL; }
705450Slinton 
715450Slinton /*
725450Slinton  * macros for doing freads + fwrites
735450Slinton  */
745450Slinton 
755450Slinton #define get(fp, var)	fread((char *) &(var), sizeof(var), 1, fp)
765450Slinton #define put(fp, var)	fwrite((char *) &(var), sizeof(var), 1, fp)
775450Slinton 
785450Slinton /*
795450Slinton  * string definitions
805450Slinton  */
815450Slinton 
825450Slinton extern char *strcpy();
835450Slinton extern int strlen();
845450Slinton 
855450Slinton #define strdup(s)		strcpy(malloc((unsigned) strlen(s) + 1), s)
865450Slinton #define streq(s1, s2)	(strcmp(s1, s2) == 0)
87