[lkml]   [2006]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [patch 1/1] consolidate TRUE and FALSE
>Isn't there a runtime cost converting all "non-false" values to a unique "true" (i.e. converting non-zero values to one) ?

Somewhat. The answer is "yes, but depends on usage". If you just

_Bool x = filthy_action();

Then the compiler is smart enough to optimize 'x' away if it is not used
somewhere else, therefore we do not pay a price for converting the return
type of filthy_action (=int) to a _Bool.

The asm output for storing the result of filthy_action() [requires
'volatile int x' in this small example]

call strxcmp
mov [ebp-4], eax

While making that a 'volatile _Bool x' makes it:

call strxcmp
test eax, eax
setnz al
mov [ebp-1], al

Makes me prefer typedef int bool over _Bool.

Jan Engelhardt
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-03-18 23:00    [W:0.061 / U:6.312 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site