|
|
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 provided
6: * that: (1) source distributions retain this entire copyright notice and
7: * comment, and (2) distributions including binaries display the following
8: * acknowledgement: ``This product includes software developed by the
9: * University of California, Berkeley and its contributors'' in the
10: * documentation or other materials provided with the distribution and in
11: * all advertising materials mentioning features or use of this software.
12: * Neither the name of the University nor the names of its contributors may
13: * be used to endorse or promote products derived from this software without
14: * specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: *
19: * @(#)general.h 1.5 (Berkeley) 6/28/90
20: */
21:
22: /*
23: * Some general definitions.
24: */
25:
26:
27: #define numberof(x) (sizeof x/sizeof x[0])
28: #define highestof(x) (numberof(x)-1)
29:
30: #if defined(unix)
31: #define ClearElement(x) bzero((char *)&x, sizeof x)
32: #define ClearArray(x) bzero((char *)x, sizeof x)
33: #else /* defined(unix) */
34: #define ClearElement(x) memset((char *)&x, 0, sizeof x)
35: #define ClearArray(x) memset((char *)x, 0, sizeof x)
36: #endif /* defined(unix) */
37:
38: #if defined(unix) /* Define BSD equivalent mem* functions */
39: #define memcpy(dest,src,n) bcopy(src,dest,n)
40: #define memmove(dest,src,n) bcopy(src,dest,n)
41: #define memset(s,c,n) if (c == 0) { \
42: bzero(s,n); \
43: } else { \
44: register char *src = s; \
45: register int count = n; \
46: \
47: while (count--) { \
48: *src++ = c; \
49: } \
50: }
51: #define memcmp(s1,s2,n) bcmp(s1,s2,n)
52: #endif /* defined(unix) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.