NetBSD/dist/ipf/lib/count6bits.c

30 lines
485 B
C

/* $NetBSD: count6bits.c,v 1.1.1.1 2004/03/28 08:56:18 martti Exp $ */
/*
* Copyright (C) 1993-2001 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Id: count6bits.c,v 1.4 2001/06/09 17:09:23 darrenr Exp
*/
#include "ipf.h"
int count6bits(msk)
u_32_t *msk;
{
int i = 0, k;
u_32_t j;
for (k = 3; k >= 0; k--)
if (msk[k] == 0xffffffff)
i += 32;
else {
for (j = msk[k]; j; j <<= 1)
if (j & 0x80000000)
i++;
}
return i;
}