lkml.org 
[lkml]   [2012]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [patch 3.5-rc3] mm, mempolicy: fix mbind() to do synchronous migration
On Thu, Jun 21, 2012 at 6:45 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> And casts to/from bool, perhaps.  To squish the warning we'd do things
> like a_bool = !!a_int.  That generates extra code, but gcc internally
> generates extra code for a_bool = a_int anyway, and a quick test here
> indicates that the generated code is identical (testl/setne).

It *has* to generate extra code. A cast to Bool is very much not at
all like a normal cast. All the traditional C casts just do a pure bit
truncate (or zero/sign extension) keeping the same value.

A cast to bool is totally different. It is exactly the same as "test
against zero" - so it in no way acts like a traditional integer cast
to a one-bit integer.

I'm not 100% sure the use of "bool" is a great idea, and people who
use pointers to bools are crazy mf's (you can break the fundamental
property of bools by assigning random values through the pointer), but
_Bool certainly ahs the _potential_ to be a good thing. The reason I'm
nervous about it is exactly that people get it wrong so easily because
they do *not* act like any other C type (the whole pointer-to-bool
thing being one example of people doing bad things - I personally
would be much happier if _Bool acted more like a one-bit bitfield and
could not have its address taken).

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-06-22 04:41    [W:0.086 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site