Some compilers have 128-bit integers. I used __uint128_t in code that was compiled using gcc in the AMD64 architecture.
If you use a compiler with 128-bit integers, you can simply reuse your existing code as it makes no assumptions about the size of the word.
, , , , . , ():
for (i = 0; i < 4 && netmask[i] != 0xffffffff; ++i)
netmask[i], , , .
, , , , - :
int contiguous(uint32_t **netmask)
{
int i;
for (i = 0; i < 4; ++i) {
if ((~netmask[i] + 1) & (~netmask[i])) return 0;
}
for (i = 0; i < 3; ++i) {
if ((netmask[i] != 0xffffffff) && (netmask[i+1] != 0)) return 0;
}
return 1;
}
, , 0 128 . , .