|
|
1.1 root 1: /*
2: * Copyright (c) 1988 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 this notice is preserved and that due credit is given
7: * to the University of California at Berkeley. The name of the University
8: * may not be used to endorse or promote products derived from this
9: * software without specific prior written permission. This software
10: * is provided ``as is'' without express or implied warranty.
11: *
12: * @(#)general.h 1.2 (Berkeley) 3/8/88
13: */
14:
15: /*
16: * Some general definitions.
17: *
18: * @(#)general.h 3.1 (Berkeley) 8/11/87
19: */
20:
21:
22: #define numberof(x) (sizeof x/sizeof x[0])
23: #define highestof(x) (numberof(x)-1)
24:
25: #if defined(unix)
26: #define ClearElement(x) bzero((char *)&x, sizeof x)
27: #define ClearArray(x) bzero((char *)x, sizeof x)
28: #else /* defined(unix) */
29: #define ClearElement(x) memset((char *)&x, 0, sizeof x)
30: #define ClearArray(x) memset((char *)x, 0, sizeof x)
31: #endif /* defined(unix) */
32:
33: #if defined(unix) /* Define BSD equivalent mem* functions */
34: #define memcpy(dest,src,n) bcopy(src,dest,n)
35: #define memmove(dest,src,n) bcopy(src,dest,n)
36: #define memset(s,c,n) if (c == 0) { \
37: bzero(s,n); \
38: } else { \
39: register char *src = s; \
40: register int count = n; \
41: \
42: while (count--) { \
43: *src++ = c; \
44: } \
45: }
46: #define memcmp(s1,s2,n) bcmp(s1,s2,n)
47: #endif /* defined(unix) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.