lkml.org 
[lkml]   [2009]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Strange code in include/linux/cpumask.h
Date
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
>


\
 
 \ /
  Last update: 2009-03-25 23:49    [W:0.045 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site