Maybe the question is so simple…
There is an enum definition:
enum uop_flags_enum {
FICOMP = 0x001,
FLCOMP = 0x002,
FFCOMP = 0x004,
FMEM = 0x008,
FLOAD = 0x010,
FSTORE = 0x020,
FCTRL = 0x040,
FCALL = 0x080,
FRET = 0x100,
FCOND = 0x200
};
Somewhere in the code there is:
if (uop->flags & FCTRL)
When this condition is true and when it is not?
Ultimately, this code is checking if a single bit (the FCTRL flag) is turned on in the
uop->flagsvariable.But here’s some explanation:
Implicitly, the code
if(X)checks for X being a “true” value.For integers, 0 is the only “false” value and everything else is “true”.
Therefore your code is equivalent to:
if (0 != (uop->flags & FCTRL))Now, what does that mean?
The
&operator performs a “bitwise AND”, which means each bit of the left-hand-side is ANDed with the corresponding bit on the right-hand-side.So if we wrote out our two operands in binary:
In this example, if you perform an “AND” on each pair of bits, you get the result:
Which evaluates to false, and indeed in that example the
uop->flagsvalue does not have the FCTRL flag set.Now here’s another example, where the flag is set:
The corresponding ANDed result:
This result is non-zero, therefore “true”, triggering your
ifstatement.