|
|
1.1 root 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: (1) source distributions retain this entire copyright
7: * notice and comment, and (2) distributions including binaries display
8: * the following acknowledgement: ``This product includes software
9: * developed by the University of California, Berkeley and its contributors''
10: * in the documentation or other materials provided with the distribution
11: * and in all advertising materials mentioning features or use of this
12: * software. Neither the name of the University nor the names of its
13: * contributors may be used to endorse or promote products derived
14: * from this software without specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: *
19: * @(#)defs.h 5.4 (Berkeley) 6/1/90
20: */
21:
22: /*
23: * Public definitions, common to all.
24: */
25:
26: #include <stdio.h>
27:
28: #ifdef sgi
29: # define double long float
30: # define atof _latof
31: # define IRIS
32: # define mc68000
33: #endif
34:
35: #define new(type) ((type) malloc(sizeof(struct type)))
36: #define newarr(type, n) ((type *) malloc((unsigned) (n) * sizeof(type)))
37: #define dispose(ptr) { free((char *) ptr); ptr = 0; }
38:
39: #define public
40: #define private static
41:
42: #define ord(enumcon) ((unsigned int) enumcon)
43: #define nil 0
44: #define and &&
45: #define or ||
46: #define not !
47: #define div /
48: #define mod %
49: #define max(a, b) ((a) > (b) ? (a) : (b))
50: #define min(a, b) ((a) < (b) ? (a) : (b))
51:
52: #define assert(b) { \
53: if (not(b)) { \
54: panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \
55: } \
56: }
57:
58: #define badcaseval(v) { \
59: panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \
60: }
61:
62: #define checkref(p) { \
63: if (p == nil) { \
64: panic("reference through nil pointer at line %d in file %s", \
65: __LINE__, __FILE__); \
66: } \
67: }
68:
69: typedef int Integer;
70: typedef int integer;
71: typedef char Char;
72: typedef double Real;
73: typedef double real;
74: typedef enum { false, true } Boolean;
75: typedef Boolean boolean;
76: typedef char *String;
77:
78: #define strdup(s) strcpy(malloc((unsigned) strlen(s) + 1), s)
79: #define streq(s1, s2) (strcmp(s1, s2) == 0)
80:
81: typedef FILE *File;
82: typedef int Fileid;
83: typedef String Filename;
84:
85: #define get(f, var) fread((char *) &(var), sizeof(var), 1, f)
86: #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f)
87:
88: #undef FILE
89:
90: extern long atol();
91: extern double atof();
92: extern char *malloc();
93: extern String strcpy(), index(), rindex();
94: extern int strlen();
95:
96: extern String cmdname;
97: extern String errfilename;
98: extern short errlineno;
99: extern int debug_flag[];
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.