Exemple #1
0
void main()
{

unsigned int a[] ={ 4, 5, 22, 64};
int i;

for(i=0;i<4;i++)
	printf("%d : %d\n", a[i], ispowerof2(a[i]));

}
Exemple #2
0
static void configpagelen(runconfig *const cfg, const unsigned arg)
{
	const long sysplen = sysconf(_SC_PAGESIZE);
	if(sysplen != -1) { } else
	{
		fail("can't get system pagesize");
	}

	if(sysplen < 0x7fffffff) { } else
	{
		fail("system page length %ld is too long", sysplen);
	}

	unsigned flags = 0;
	unsigned plen = sysplen;

	const long alen = arg * 1024;
	if(alen < 0x7fffffff) { } else
	{
		fail("argument page length %ld is too long", alen);
	}

	if(alen > 0)
	{
		if(ispowerof2(alen) && alen > sysplen)
		{
			plen = alen;
			flags |= cfghugetlb;
		}
		else
		{
			fail("%u don't look like huge page length in KiB", arg);
		}
	}

	cfg->flags |= flags;
	cfg->pagelength = plen;
}
Exemple #3
0
 bool Aligned::supports ( size_t alignment )
 {
     return (ispowerof2(alignment));
 }