121629Sdist /* 238105Sbostic * Copyright (c) 1983 The Regents of the University of California. 338105Sbostic * All rights reserved. 421629Sdist * 5*42683Sbostic * %sccs.include.redist.c% 638105Sbostic * 7*42683Sbostic * @(#)defs.h 5.4 (Berkeley) 06/01/90 821629Sdist */ 916626Ssam 1014605Ssam /* 1114605Ssam * Public definitions, common to all. 1214605Ssam */ 1314605Ssam 1414605Ssam #include <stdio.h> 1514605Ssam 1633314Sdonn #ifdef sgi 1733314Sdonn # define double long float 1833314Sdonn # define atof _latof 1933314Sdonn # define IRIS 2033314Sdonn # define mc68000 2133314Sdonn #endif 2233314Sdonn 2314605Ssam #define new(type) ((type) malloc(sizeof(struct type))) 2414605Ssam #define newarr(type, n) ((type *) malloc((unsigned) (n) * sizeof(type))) 2514605Ssam #define dispose(ptr) { free((char *) ptr); ptr = 0; } 2614605Ssam 2714605Ssam #define public 2814605Ssam #define private static 2914605Ssam 3014605Ssam #define ord(enumcon) ((unsigned int) enumcon) 3114605Ssam #define nil 0 3214605Ssam #define and && 3314605Ssam #define or || 3414605Ssam #define not ! 3514605Ssam #define div / 3614605Ssam #define mod % 3714605Ssam #define max(a, b) ((a) > (b) ? (a) : (b)) 3814605Ssam #define min(a, b) ((a) < (b) ? (a) : (b)) 3914605Ssam 4014605Ssam #define assert(b) { \ 4114605Ssam if (not(b)) { \ 4214605Ssam panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \ 4314605Ssam } \ 4414605Ssam } 4514605Ssam 4614605Ssam #define badcaseval(v) { \ 4714605Ssam panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \ 4814605Ssam } 4914605Ssam 5014605Ssam #define checkref(p) { \ 5114605Ssam if (p == nil) { \ 5214605Ssam panic("reference through nil pointer at line %d in file %s", \ 5314605Ssam __LINE__, __FILE__); \ 5414605Ssam } \ 5514605Ssam } 5614605Ssam 5714605Ssam typedef int Integer; 5816608Ssam typedef int integer; 5914605Ssam typedef char Char; 6014605Ssam typedef double Real; 6116608Ssam typedef double real; 6214605Ssam typedef enum { false, true } Boolean; 6316608Ssam typedef Boolean boolean; 6414605Ssam typedef char *String; 6514605Ssam 6614605Ssam #define strdup(s) strcpy(malloc((unsigned) strlen(s) + 1), s) 6714605Ssam #define streq(s1, s2) (strcmp(s1, s2) == 0) 6814605Ssam 6914605Ssam typedef FILE *File; 7014605Ssam typedef int Fileid; 7114605Ssam typedef String Filename; 7214605Ssam 7314605Ssam #define get(f, var) fread((char *) &(var), sizeof(var), 1, f) 7414605Ssam #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f) 7514605Ssam 7614605Ssam #undef FILE 7714605Ssam 7814605Ssam extern long atol(); 7914605Ssam extern double atof(); 8014605Ssam extern char *malloc(); 8114605Ssam extern String strcpy(), index(), rindex(); 8214605Ssam extern int strlen(); 8314605Ssam 8414605Ssam extern String cmdname; 8514605Ssam extern String errfilename; 8614605Ssam extern short errlineno; 8714605Ssam extern int debug_flag[]; 88