132142Sminshall /* 2*33685Sbostic * Copyright (c) 1988 Regents of the University of California. 3*33685Sbostic * All rights reserved. 4*33685Sbostic * 5*33685Sbostic * Redistribution and use in source and binary forms are permitted 6*33685Sbostic * provided that this notice is preserved and that due credit is given 7*33685Sbostic * to the University of California at Berkeley. The name of the University 8*33685Sbostic * may not be used to endorse or promote products derived from this 9*33685Sbostic * software without specific prior written permission. This software 10*33685Sbostic * is provided ``as is'' without express or implied warranty. 11*33685Sbostic * 12*33685Sbostic * @(#)general.h 1.2 (Berkeley) 03/08/88 13*33685Sbostic */ 14*33685Sbostic 15*33685Sbostic /* 1632142Sminshall * Some general definitions. 1732142Sminshall * 1832142Sminshall * @(#)general.h 3.1 (Berkeley) 8/11/87 1932142Sminshall */ 2032142Sminshall 2132142Sminshall 2232142Sminshall #define numberof(x) (sizeof x/sizeof x[0]) 2332142Sminshall #define highestof(x) (numberof(x)-1) 2432142Sminshall 2532142Sminshall #if defined(unix) 2632142Sminshall #define ClearElement(x) bzero((char *)&x, sizeof x) 2732142Sminshall #define ClearArray(x) bzero((char *)x, sizeof x) 2832142Sminshall #else /* defined(unix) */ 2932142Sminshall #define ClearElement(x) memset((char *)&x, 0, sizeof x) 3032142Sminshall #define ClearArray(x) memset((char *)x, 0, sizeof x) 3132142Sminshall #endif /* defined(unix) */ 3232142Sminshall 3332142Sminshall #if defined(unix) /* Define BSD equivalent mem* functions */ 3432142Sminshall #define memcpy(dest,src,n) bcopy(src,dest,n) 3532142Sminshall #define memmove(dest,src,n) bcopy(src,dest,n) 3632142Sminshall #define memset(s,c,n) if (c == 0) { \ 3732142Sminshall bzero(s,n); \ 3832142Sminshall } else { \ 3932142Sminshall register char *src = s; \ 4032142Sminshall register int count = n; \ 4132142Sminshall \ 4232142Sminshall while (count--) { \ 4332142Sminshall *src++ = c; \ 4432142Sminshall } \ 4532142Sminshall } 4632142Sminshall #define memcmp(s1,s2,n) bcmp(s1,s2,n) 4732142Sminshall #endif /* defined(unix) */ 48