What does “>>=” mean in Linux kernel source code?

老子叫甜甜 提交于 2020-01-04 01:40:06

问题


in Linux kernel source code, I find below code:

    h++;
    pending >>= 1;

It is part of __do_softirq(void). But what does ">>=" mean? Why isn't it ">>" as I remember? Thanks!


回答1:


It simply does

pending = pending >>1;

In short it divides by 2 an unsigned int.

That's the same construct than +=, /=, etc.

It's not just pending >>1 as you remember because that wouldn't store the result of the shift operation in the variable.




回答2:


It's equivalent to

pending = pending >> 1;

Which bitshifts right the bits in pending. This would have the effect of dividing an unsigned int by 2. >> and << are the bitshift operators, and the combination with = behaves the same way += and /= do.



来源:https://stackoverflow.com/questions/11246466/what-does-mean-in-linux-kernel-source-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!