Messages in this thread | | | From | Rusty Russell <> | Subject | Re: Strange code in include/linux/cpumask.h | Date | Thu, 26 Mar 2009 09:14:46 +1030 |
| |
On Wednesday 25 March 2009 17:14:30 Nikanth Karthikesan wrote: > On Wednesday 25 March 2009 10:41:11 Rusty Russell wrote: > > Yes, except that this insists that bitmap be an unsigned long * or you'll > > get a warning. Otherwise the macro could be used on anything. And it > > needs to be a macro to use it as a static initializer. > > Ah, got it. Thanks a lot for the explanation. May be a comment could be added > to the source.
Well, it's not that unusual a trick in the kernel, but an explanation might help.
> Also looks like, this is not being used as a static initializer anywhere. > i.e., Using my type-checking only version didn't trigger any error/warnings!
It will. cpu_all_mask uses to_cpumask, and it's replacing CPU_MASK_ALL.
> Being a deprecated interface, no new users are expected? Or is gcc smart, not > complaining when used as static initializer, as it would always evaluate to > (struct cpumask *)(bitmap)?
Yes, it seems to be. AFAICT though, using a function in an initializer is not valid C.
> Can the sizeof constification be removed?
Possibly, but it makes me nervous to rely on it.
Thanks, Rusty.
> > Thanks > Nikanth >
| |