xref: /titanic_51/usr/src/cmd/ipf/lib/common/count6bits.c (revision 37714ae43602c675f9dc59b070bfdf9fa702872c)
1 /*
2  * Copyright (C) 1993-2001 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: count6bits.c,v 1.4 2001/06/09 17:09:23 darrenr Exp $
7  */
8 
9 #include "ipf.h"
10 
11 
12 int count6bits(msk)
13 u_32_t *msk;
14 {
15 	int i = 0, k;
16 	u_32_t j;
17 
18 	for (k = 3; k >= 0; k--)
19 		if (msk[k] == 0xffffffff)
20 			i += 32;
21 		else {
22 			for (j = msk[k]; j; j <<= 1)
23 				if (j & 0x80000000)
24 					i++;
25 		}
26 	return i;
27 }
28