121629Sdist /* 221629Sdist * Copyright (c) 1983 Regents of the University of California. 321629Sdist * All rights reserved. The Berkeley software License Agreement 421629Sdist * specifies the terms and conditions for redistribution. 521629Sdist * 6*33314Sdonn * @(#)defs.h 5.2 (Berkeley) 01/12/88 721629Sdist */ 816626Ssam 914605Ssam /* 1014605Ssam * Public definitions, common to all. 1114605Ssam */ 1214605Ssam 1314605Ssam #include <stdio.h> 1414605Ssam 15*33314Sdonn #ifdef sgi 16*33314Sdonn # define double long float 17*33314Sdonn # define atof _latof 18*33314Sdonn # define IRIS 19*33314Sdonn # define mc68000 20*33314Sdonn #endif 21*33314Sdonn 2214605Ssam #define new(type) ((type) malloc(sizeof(struct type))) 2314605Ssam #define newarr(type, n) ((type *) malloc((unsigned) (n) * sizeof(type))) 2414605Ssam #define dispose(ptr) { free((char *) ptr); ptr = 0; } 2514605Ssam 2614605Ssam #define public 2714605Ssam #define private static 2814605Ssam 2914605Ssam #define ord(enumcon) ((unsigned int) enumcon) 3014605Ssam #define nil 0 3114605Ssam #define and && 3214605Ssam #define or || 3314605Ssam #define not ! 3414605Ssam #define div / 3514605Ssam #define mod % 3614605Ssam #define max(a, b) ((a) > (b) ? (a) : (b)) 3714605Ssam #define min(a, b) ((a) < (b) ? (a) : (b)) 3814605Ssam 3914605Ssam #define assert(b) { \ 4014605Ssam if (not(b)) { \ 4114605Ssam panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \ 4214605Ssam } \ 4314605Ssam } 4414605Ssam 4514605Ssam #define badcaseval(v) { \ 4614605Ssam panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \ 4714605Ssam } 4814605Ssam 4914605Ssam #define checkref(p) { \ 5014605Ssam if (p == nil) { \ 5114605Ssam panic("reference through nil pointer at line %d in file %s", \ 5214605Ssam __LINE__, __FILE__); \ 5314605Ssam } \ 5414605Ssam } 5514605Ssam 5614605Ssam typedef int Integer; 5716608Ssam typedef int integer; 5814605Ssam typedef char Char; 5914605Ssam typedef double Real; 6016608Ssam typedef double real; 6114605Ssam typedef enum { false, true } Boolean; 6216608Ssam typedef Boolean boolean; 6314605Ssam typedef char *String; 6414605Ssam 6514605Ssam #define strdup(s) strcpy(malloc((unsigned) strlen(s) + 1), s) 6614605Ssam #define streq(s1, s2) (strcmp(s1, s2) == 0) 6714605Ssam 6814605Ssam typedef FILE *File; 6914605Ssam typedef int Fileid; 7014605Ssam typedef String Filename; 7114605Ssam 7214605Ssam #define get(f, var) fread((char *) &(var), sizeof(var), 1, f) 7314605Ssam #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f) 7414605Ssam 7514605Ssam #undef FILE 7614605Ssam 7714605Ssam extern long atol(); 7814605Ssam extern double atof(); 7914605Ssam extern char *malloc(); 8014605Ssam extern String strcpy(), index(), rindex(); 8114605Ssam extern int strlen(); 8214605Ssam 8314605Ssam extern String cmdname; 8414605Ssam extern String errfilename; 8514605Ssam extern short errlineno; 8614605Ssam extern int debug_flag[]; 87