Commit | Line | Data |
---|---|---|
6941fcc4 EA |
1 | /* |
2 | ** USEFUL.H -- Some useful stuff. | |
916b3375 | 3 | ** |
c7c68208 | 4 | ** @(#)useful.h 4.1 %G% |
6941fcc4 EA |
5 | */ |
6 | ||
1146de6b | 7 | # ifndef makedev |
6e36536d | 8 | # include <sys/types.h> |
1146de6b EA |
9 | # endif |
10 | ||
11 | /* support for bool type */ | |
12 | typedef char bool; | |
6941fcc4 EA |
13 | # define TRUE 1 |
14 | # define FALSE 0 | |
15 | ||
16 | # ifndef NULL | |
17 | # define NULL 0 | |
18 | # endif NULL | |
21d76258 | 19 | |
1146de6b | 20 | /* bit hacking */ |
9e7b5f61 | 21 | # define bitset(bit, word) (((word) & (bit)) != 0) |
29871fef | 22 | |
04308aae EA |
23 | /* some simple functions */ |
24 | # ifndef max | |
25 | # define max(a, b) ((a) > (b) ? (a) : (b)) | |
26 | # define min(a, b) ((a) < (b) ? (a) : (b)) | |
27 | # endif max | |
28 | ||
4e5e456f EA |
29 | /* assertions */ |
30 | # ifndef NASSERT | |
31 | # define ASSERT(expr, msg, parm)\ | |
32 | if (!(expr))\ | |
33 | {\ | |
34 | fprintf(stderr, "assertion botch: %s:%d: ", __FILE__, __LINE__);\ | |
35 | fprintf(stderr, msg, parm);\ | |
36 | } | |
37 | # else NASSERT | |
38 | # define ASSERT(expr, msg, parm) | |
39 | # endif NASSERT | |
40 | ||
41 | /* sccs id's */ | |
42 | # ifndef lint | |
43 | # define SCCSID(arg) static char SccsId[] = "arg"; | |
44 | # else lint | |
45 | # define SCCSID(arg) | |
46 | # endif lint | |
47 | ||
29871fef | 48 | /* define the types of some common functions */ |
3991d0f8 EA |
49 | extern char *strcpy(), *strncpy(); |
50 | extern char *strcat(), *strncat(); | |
29871fef EA |
51 | extern char *malloc(); |
52 | extern char *index(), *rindex(); | |
53 | extern int errno; | |
54 | extern char *sprintf(); | |
62fff4f9 | 55 | extern time_t time(); |
29871fef EA |
56 | extern char *ctime(); |
57 | # ifndef V6 | |
58 | extern char *getenv(); | |
04674b08 EA |
59 | # endif V6 |
60 | # ifndef VMUNIX | |
040bceaf EA |
61 | typedef unsigned short u_short; |
62 | typedef long u_long; | |
63 | typedef char u_char; | |
64 | typedef int void; | |
04674b08 | 65 | # endif VMUNIX |