do it right
[unix-history] / usr / src / usr.bin / pascal / pdx / defs.h
CommitLineData
3cd5310a
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
6 * @(#)defs.h 5.1 (Berkeley) %G%
7 */
d6dc6657
ML
8
9/*
10 * Global debugger defines.
11 *
12 * All files include this header.
13 */
14
15#include <stdio.h>
16
17/*
18 * Since C does not allow forward referencing of types,
19 * all the global types are declared here.
20 */
21
22#define LOCAL static
23#define NIL 0
24
25typedef int BOOLEAN;
26
27#define FALSE 0
28#define TRUE 1
29
30typedef unsigned int ADDRESS; /* object code addresses */
31typedef short LINENO; /* source file line numbers */
32typedef struct sym SYM; /* symbol information structure */
33typedef struct symtab SYMTAB; /* symbol table */
34typedef struct node NODE; /* expression tree node */
35typedef short OP; /* tree operator */
36typedef struct opinfo OPINFO; /* tree operator information table */
37typedef unsigned int WORD; /* machine word */
38typedef unsigned char BYTE; /* machine byte */
39typedef struct frame FRAME; /* runtime activation record */
40
41/*
42 * Definitions of standard C library routines that aren't in the
43 * standard I/O library, but which are generally useful.
44 */
45
46extern long atol(); /* ascii to long */
47extern double atof(); /* ascii to floating point */
48extern char *mktemp(); /* make a temporary file name */
49
50/*
51 * Definitions of library routines.
52 */
53
54char *cmdname; /* name of command for error messages */
55char *errfilename; /* current file associated with error */
56short errlineno; /* line number associated with error */
57
58error(); /* print an error message */
59panic(); /* print error message and exit */
60short numerrors(); /* return number of errors since last call */
61
62/*
63 * defintions for doing memory allocation
64 */
65
66extern char *malloc();
67
68#define alloc(n, type) ((type *) malloc((unsigned) (n) * sizeof(type)))
69#define dispose(p) { free((char *) p); p = NIL; }
70
71/*
72 * macros for doing freads + fwrites
73 */
74
75#define get(fp, var) fread((char *) &(var), sizeof(var), 1, fp)
76#define put(fp, var) fwrite((char *) &(var), sizeof(var), 1, fp)
77
78/*
79 * string definitions
80 */
81
82extern char *strcpy();
83extern int strlen();
84
85#define strdup(s) strcpy(malloc((unsigned) strlen(s) + 1), s)
86#define streq(s1, s2) (strcmp(s1, s2) == 0)