xref: /csrg-svn/old/dbx/defs.h (revision 38105)
1 /*
2  * Copyright (c) 1983 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)defs.h	5.3 (Berkeley) 05/23/89
18  */
19 
20 /*
21  * Public definitions, common to all.
22  */
23 
24 #include <stdio.h>
25 
26 #ifdef sgi
27 #   define double long float
28 #   define atof _latof
29 #   define IRIS
30 #   define mc68000
31 #endif
32 
33 #define new(type)           ((type) malloc(sizeof(struct type)))
34 #define newarr(type, n)     ((type *) malloc((unsigned) (n) * sizeof(type)))
35 #define dispose(ptr)        { free((char *) ptr); ptr = 0; }
36 
37 #define public
38 #define private static
39 
40 #define ord(enumcon) ((unsigned int) enumcon)
41 #define nil 0
42 #define and &&
43 #define or ||
44 #define not !
45 #define div /
46 #define mod %
47 #define max(a, b)    ((a) > (b) ? (a) : (b))
48 #define min(a, b)    ((a) < (b) ? (a) : (b))
49 
50 #define assert(b) { \
51     if (not(b)) { \
52 	panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \
53     } \
54 }
55 
56 #define badcaseval(v) { \
57     panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \
58 }
59 
60 #define checkref(p) { \
61     if (p == nil) { \
62 	panic("reference through nil pointer at line %d in file %s", \
63 	    __LINE__, __FILE__); \
64     } \
65 }
66 
67 typedef int Integer;
68 typedef int integer;
69 typedef char Char;
70 typedef double Real;
71 typedef double real;
72 typedef enum { false, true } Boolean;
73 typedef Boolean boolean;
74 typedef char *String;
75 
76 #define strdup(s)       strcpy(malloc((unsigned) strlen(s) + 1), s)
77 #define streq(s1, s2)   (strcmp(s1, s2) == 0)
78 
79 typedef FILE *File;
80 typedef int Fileid;
81 typedef String Filename;
82 
83 #define get(f, var) fread((char *) &(var), sizeof(var), 1, f)
84 #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f)
85 
86 #undef FILE
87 
88 extern long atol();
89 extern double atof();
90 extern char *malloc();
91 extern String strcpy(), index(), rindex();
92 extern int strlen();
93 
94 extern String cmdname;
95 extern String errfilename;
96 extern short errlineno;
97 extern int debug_flag[];
98