xref: /csrg-svn/old/dbx/defs.h (revision 38105)
121629Sdist /*
2*38105Sbostic  * Copyright (c) 1983 The Regents of the University of California.
3*38105Sbostic  * All rights reserved.
421629Sdist  *
5*38105Sbostic  * Redistribution and use in source and binary forms are permitted
6*38105Sbostic  * provided that the above copyright notice and this paragraph are
7*38105Sbostic  * duplicated in all such forms and that any documentation,
8*38105Sbostic  * advertising materials, and other materials related to such
9*38105Sbostic  * distribution and use acknowledge that the software was developed
10*38105Sbostic  * by the University of California, Berkeley.  The name of the
11*38105Sbostic  * University may not be used to endorse or promote products derived
12*38105Sbostic  * from this software without specific prior written permission.
13*38105Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*38105Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*38105Sbostic  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*38105Sbostic  *
17*38105Sbostic  *	@(#)defs.h	5.3 (Berkeley) 05/23/89
1821629Sdist  */
1916626Ssam 
2014605Ssam /*
2114605Ssam  * Public definitions, common to all.
2214605Ssam  */
2314605Ssam 
2414605Ssam #include <stdio.h>
2514605Ssam 
2633314Sdonn #ifdef sgi
2733314Sdonn #   define double long float
2833314Sdonn #   define atof _latof
2933314Sdonn #   define IRIS
3033314Sdonn #   define mc68000
3133314Sdonn #endif
3233314Sdonn 
3314605Ssam #define new(type)           ((type) malloc(sizeof(struct type)))
3414605Ssam #define newarr(type, n)     ((type *) malloc((unsigned) (n) * sizeof(type)))
3514605Ssam #define dispose(ptr)        { free((char *) ptr); ptr = 0; }
3614605Ssam 
3714605Ssam #define public
3814605Ssam #define private static
3914605Ssam 
4014605Ssam #define ord(enumcon) ((unsigned int) enumcon)
4114605Ssam #define nil 0
4214605Ssam #define and &&
4314605Ssam #define or ||
4414605Ssam #define not !
4514605Ssam #define div /
4614605Ssam #define mod %
4714605Ssam #define max(a, b)    ((a) > (b) ? (a) : (b))
4814605Ssam #define min(a, b)    ((a) < (b) ? (a) : (b))
4914605Ssam 
5014605Ssam #define assert(b) { \
5114605Ssam     if (not(b)) { \
5214605Ssam 	panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \
5314605Ssam     } \
5414605Ssam }
5514605Ssam 
5614605Ssam #define badcaseval(v) { \
5714605Ssam     panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \
5814605Ssam }
5914605Ssam 
6014605Ssam #define checkref(p) { \
6114605Ssam     if (p == nil) { \
6214605Ssam 	panic("reference through nil pointer at line %d in file %s", \
6314605Ssam 	    __LINE__, __FILE__); \
6414605Ssam     } \
6514605Ssam }
6614605Ssam 
6714605Ssam typedef int Integer;
6816608Ssam typedef int integer;
6914605Ssam typedef char Char;
7014605Ssam typedef double Real;
7116608Ssam typedef double real;
7214605Ssam typedef enum { false, true } Boolean;
7316608Ssam typedef Boolean boolean;
7414605Ssam typedef char *String;
7514605Ssam 
7614605Ssam #define strdup(s)       strcpy(malloc((unsigned) strlen(s) + 1), s)
7714605Ssam #define streq(s1, s2)   (strcmp(s1, s2) == 0)
7814605Ssam 
7914605Ssam typedef FILE *File;
8014605Ssam typedef int Fileid;
8114605Ssam typedef String Filename;
8214605Ssam 
8314605Ssam #define get(f, var) fread((char *) &(var), sizeof(var), 1, f)
8414605Ssam #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f)
8514605Ssam 
8614605Ssam #undef FILE
8714605Ssam 
8814605Ssam extern long atol();
8914605Ssam extern double atof();
9014605Ssam extern char *malloc();
9114605Ssam extern String strcpy(), index(), rindex();
9214605Ssam extern int strlen();
9314605Ssam 
9414605Ssam extern String cmdname;
9514605Ssam extern String errfilename;
9614605Ssam extern short errlineno;
9714605Ssam extern int debug_flag[];
98