linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* detecting integer constant expressions in macros
@ 2018-03-20 22:13 Uecker, Martin
  2018-03-20 23:07 ` Uecker, Martin
  2018-03-20 23:08 ` Linus Torvalds
  0 siblings, 2 replies; 11+ messages in thread
From: Uecker, Martin @ 2018-03-20 22:13 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel


Hi Linus,

here is an idea:

a test for integer constant expressions which returns an
integer constant expression itself which should be suitable
for passing to __builtin_choose_expr might be:

#define ICE_P(x) (sizeof(int) == sizeof(*(1 ? ((void*)((x) * 0l)) :
(int*)1)))

This also does not evaluate x itself on gcc although this is
not guaranteed by the standard. (And I haven't tried any older
gcc.)

Best,
Martin

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-03-21 22:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20 22:13 detecting integer constant expressions in macros Uecker, Martin
2018-03-20 23:07 ` Uecker, Martin
2018-03-20 23:09   ` Linus Torvalds
2018-03-20 23:08 ` Linus Torvalds
2018-03-21  0:10   ` Uecker, Martin
2018-03-21  0:30     ` Linus Torvalds
2018-03-21  9:51       ` Uecker, Martin
2018-03-21 10:22         ` Uecker, Martin
2018-03-21 10:35           ` David Laight
2018-03-21 21:10   ` Rasmus Villemoes
2018-03-21 22:27     ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).