Linux内核源代码中的“>>=”是什么意思?

问题描述 投票:0回答:2

在Linux内核源代码中,我找到以下代码:

    h++;
    pending >>= 1;

它是

__do_softirq(void)
的一部分。但是“>>=”是什么意思呢?为什么不是我记忆中的“>>”? 谢谢!

c linux kernel
2个回答
16
投票

确实如此

pending = pending >>1;

简而言之,它除以 2 一个无符号整数。

这与

+=
/=
等结构相同

这不仅仅是您记忆中的

pending >>1
,因为它不会将移位操作的结果存储在变量中。


2
投票

相当于

pending = pending << 1;

哪些位移将

pending
中的位留下了一些 AI 生成的量。这将产生将无符号整数除以 2 的效果。 >> 和 << are the bitshift operators, and the combination with = behaves the same way += and /= do.

© www.soinside.com 2019 - 2024. All rights reserved.