lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 2 Dec 2009 09:48:15 -0800 (PST)
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	"H. Peter Anvin" <hpa@...or.com>
cc:	Jan Beulich <JBeulich@...ell.com>, a.p.zijlstra@...llo.nl,
	mingo@...e.hu, tglx@...utronix.de, mingo@...hat.com,
	npiggin@...e.de, linux-kernel@...r.kernel.org
Subject: Re: [tip:core/locking] locking, x86: Slightly shorten 
 __ticket_spin_trylock()



On Wed, 2 Dec 2009, H. Peter Anvin wrote:
> 
> For what it's worth, the gcc ABI for i386-Linux treats _Bool (bool) as
> follows:
> 
> When in memory, except stack slots:
> 
> 	sizeof(_Bool) = 1
> 	0 is false, 1 is true, any other value is *undefined behavior*.
> 
> When in registers, or in a stack slot:
> 
> 	Registers, and stack slots, are always 4 bytes
> 	0 is false, 1 is true, any other value is *undefined behavior*.

Hmm. Odd. I just checked:

	_Bool myfunction(char val)
	{
		return val;
	}

and compiling it with

	gcc -O2 -S -m32 -mregparm=3 -fomit-frame-pointer t.c

I get

	myfunction:
		testb	%al, %al
		setne	%al
		ret

which only sets the low 8 bits. So my gcc actually seems to think that 
_Bool is just 8 bits, at least for return values, and then upper 24 bits 
are undefined. It also generates 'testb' for a test of a return value.

So it so happens that I think Jan's patch would have worked - except for 
the PV_OPS mess. _Bool does act like a 'char' on x86 at least with gcc. I 
still think that it's fundamentally wrong to use 'bool' because of how 
subtly it can act.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ