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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e806dd51b1ac4e289131297fbf30fc37@AcuMS.aculab.com>
Date: Fri, 6 Dec 2024 20:23:59 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Linus Torvalds' <torvalds@...ux-foundation.org>
CC: 'Vincent Mailhol' <vincent.mailhol@...il.com>, 'Luc Van Oostenryck'
	<luc.vanoostenryck@...il.com>, 'Nathan Chancellor' <nathan@...nel.org>,
	"'Nick Desaulniers'" <ndesaulniers@...gle.com>, 'Bill Wendling'
	<morbo@...gle.com>, 'Justin Stitt' <justinstitt@...gle.com>, 'Yury Norov'
	<yury.norov@...il.com>, 'Rasmus Villemoes' <linux@...musvillemoes.dk>, 'Kees
 Cook' <kees@...nel.org>, "'Gustavo A. R. Silva'" <gustavoars@...nel.org>,
	'Jani Nikula' <jani.nikula@...ux.intel.com>, 'Joonas Lahtinen'
	<joonas.lahtinen@...ux.intel.com>, 'Rodrigo Vivi' <rodrigo.vivi@...el.com>,
	'Tvrtko Ursulin' <tursulin@...ulin.net>, 'David Airlie' <airlied@...il.com>,
	'Simona Vetter' <simona@...ll.ch>, 'Suzuki K Poulose'
	<suzuki.poulose@....com>, 'Mike Leach' <mike.leach@...aro.org>, 'James Clark'
	<james.clark@...aro.org>, 'Alexander Shishkin'
	<alexander.shishkin@...ux.intel.com>, 'Rikard Falkeborn'
	<rikard.falkeborn@...il.com>, "'linux-sparse@...r.kernel.org'"
	<linux-sparse@...r.kernel.org>, "'linux-kernel@...r.kernel.org'"
	<linux-kernel@...r.kernel.org>, "'llvm@...ts.linux.dev'"
	<llvm@...ts.linux.dev>, "'linux-hardening@...r.kernel.org'"
	<linux-hardening@...r.kernel.org>, "'intel-gfx@...ts.freedesktop.org'"
	<intel-gfx@...ts.freedesktop.org>, "'dri-devel@...ts.freedesktop.org'"
	<dri-devel@...ts.freedesktop.org>, "'coresight@...ts.linaro.org'"
	<coresight@...ts.linaro.org>, "'linux-arm-kernel@...ts.infradead.org'"
	<linux-arm-kernel@...ts.infradead.org>, "'uecker@...raz.at'"
	<uecker@...raz.at>
Subject: RE: [PATCH 02/10] compiler.h: add is_const() as a replacement of
 __is_constexpr()

...
> > > #define const_NULL(x) _Generic(0 ? (x) : (char *)0, char *: 1, void *: 0)
> > > #define const_true(x) const_NULL((x) ? NULL : (void *)1L))
> > > #define const_expr(x) const_NULL((x) ? NULL : NULL))
> > > I send this morning.
> > > Needs 's/char/struct kjkjkjkjui/' applied.
> >
> > Oh Christ. You really are taking this whole ugly to another level.
> 
> I sort of liked that version in a perverse sort of way.
> It does give you a simple test for NULL (unless you've used 'struct kjkjkjkjui').

Except const_NULL() really doesn't work at all - so you are lucky :-)

So maybe the slightly long lines:
#define const_true(x) _Generic(0 ? (void *)((x) + 0 ? 0L : 1L) : (char *)0, char *: 1, void *: 0)
#define const_expr(x) _Generic(0 ? (void *)((x) + 0 ? 0L : 0L) : (char *)0, char *: 1, void *: 0)

I make that 98 characters.
Of course, you can remove all the spaces, only one of the constants need the L suffix
and 'int' is a shorter type name.
That cuts is down to 76:
#define const_expr(x) _Generic(0?(void*)((x)+0?0L:0):(int*)0,int*:1,void*:0)
which starts looking like the TECO commands to parse its command line!

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ