Re: [patch 1/4] mempolicy: convert MPOL constants to enum

From: Paul Jackson
Date: Tue Feb 12 2008 - 20:28:54 EST


Christoph wrote:
> We usually do that with unsigned XXX and constants. You may want to check
> multiple flags at once or do other fancy things.

Both are common in the kernel. I see 241 ":1" bit fields in include/linux/*.h.

One can do Boolean expressions with either form, bitfields or defines.

For example:

struct {
int foo:1;
int goo:1;
} x;

if (x.foo && ! x.goo)
blah blah ...;

Doing (x.flags & FLAG_FOO) is simple enough, but it is still
not as simple as (x.foo). Where possible, I encourage keeping
extraneous detail out of mainline code.

Sometimes, such as in task struct flags, one has to do such Boolean
combinations in performance critical code paths, and then one must do
what one must do, with the defined constants.

Sometimes, such as with the GFP_* flags, one has to name various
combinations, and then one needs again to use defined constants.

I see no evidence that either of those situations applies here.

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@xxxxxxx> 1.940.382.4214
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/