scot_common.c 795 Bytes
#include <scot/scot_int.h>

#include <scot_common.h>


const char * scot_common_errmsg[] =
{
	"[COMMON]the path-string exceeded the maximum allowed size"
};

/*
 * returns the maximum exponent of the given value use when creating the
 * value with a base2-description. That is for example all
 * values between 16 an 31 (including both) will return 4.
 *
 * This is useful when creating an index from a bitmask value. A bitmask
 * with a single bit set would result in an integer index, that is unique
 * for every different bit.
 *
 * Maybe there is some issue with byte ordering here...i am not quite sure
 * as i do not use the shifted value and i never interpret single bytes out
 * of b2pot.
 */
int
base2exp (uint32_t b2pot)
{
	int exp = 0;

	for (; b2pot >>= 1; exp ++);

	return exp;
}