March 30, 2013
3:59 p.m.
On Sat, 30 Mar 2013 18:01:32 +0800, RS said:
Now I think this will spend more time than the kernel code when executed.
Have you actually examined the generated code on several popular architectures to see what gcc actually does? (hint - many things can constant-folded at compile time. So if the 3 values are #defined to constants, the expression (_IOC_NRSHIFT >> _IOC_NRBITS) - _IOC_NRSHIFT) will generate no actual shift or subtract instructions, merely another constant.