Find First Set. Used in Linux programming as a quick way to find which is the first bit of a word, starting from the least significant bit, that is set.
From the Linux kernel arch/x86/kernel/cpu/mtrr/generic.c:
high_width = ffs(size_or_mask & 0xffffffffUL) - 1;
high_width becomes the bit position of the least significant bit set in size_or_mask. Note, the least significant bit for ffs is 1, not 0, because 0 is returned if no bit is set. The -1 is used to convert the result of ffs() to the standard bit numbering.
27👍 25👎