130674Sminshall /* 2*33815Sbostic * Copyright (c) 1988 Regents of the University of California. 3*33815Sbostic * All rights reserved. 431893Sminshall * 5*33815Sbostic * Redistribution and use in source and binary forms are permitted 6*33815Sbostic * provided that this notice is preserved and that due credit is given 7*33815Sbostic * to the University of California at Berkeley. The name of the University 8*33815Sbostic * may not be used to endorse or promote products derived from this 9*33815Sbostic * software without specific prior written permission. This software 10*33815Sbostic * is provided ``as is'' without express or implied warranty. 11*33815Sbostic * 12*33815Sbostic * @(#)general.h 3.2 (Berkeley) 03/28/88 1330674Sminshall */ 1430674Sminshall 15*33815Sbostic /* 16*33815Sbostic * Some general definitions. 17*33815Sbostic */ 1830674Sminshall 1930674Sminshall #define numberof(x) (sizeof x/sizeof x[0]) 2030674Sminshall #define highestof(x) (numberof(x)-1) 2130723Sminshall 2231092Sminshall #if defined(unix) 2331092Sminshall #define ClearElement(x) bzero((char *)&x, sizeof x) 2430723Sminshall #define ClearArray(x) bzero((char *)x, sizeof x) 2531092Sminshall #else /* defined(unix) */ 2631157Sminshall #define ClearElement(x) memset((char *)&x, 0, sizeof x) 2731092Sminshall #define ClearArray(x) memset((char *)x, 0, sizeof x) 2831092Sminshall #endif /* defined(unix) */ 2931092Sminshall 3031092Sminshall #if defined(unix) /* Define BSD equivalent mem* functions */ 3131092Sminshall #define memcpy(dest,src,n) bcopy(src,dest,n) 3231092Sminshall #define memmove(dest,src,n) bcopy(src,dest,n) 3331092Sminshall #define memset(s,c,n) if (c == 0) { \ 3431092Sminshall bzero(s,n); \ 3531092Sminshall } else { \ 3631174Sminshall register char *src = s; \ 3731174Sminshall register int count = n; \ 3831174Sminshall \ 3931174Sminshall while (count--) { \ 4031174Sminshall *src++ = c; \ 4131174Sminshall } \ 4231092Sminshall } 4331248Sminshall #define memcmp(s1,s2,n) bcmp(s1,s2,n) 4431092Sminshall #endif /* defined(unix) */ 45