What does !!(x) mean in C (esp. the Linux kernel)?

后端 未结 3 902
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 07:49

I\'ve been reading through the Linux kernel (specifically, 2.6.11). I came across the following definition:

#define unlikely(x)     __builtin_expect(!!(x), 0)         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 08:10

    !!(x) forces it to be either 0 or 1. 0 remains 0, but any non-zero value (which would be 'true' in a boolean context) becomes 1.

提交回复
热议问题