[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2e6897775c5147a8a31fc6678eb01a8c@AcuMS.aculab.com>
Date: Mon, 7 Aug 2023 09:53:07 +0000
From: David Laight <David.Laight@...LAB.COM>
To: David Laight <David.Laight@...LAB.COM>,
'Zhangjin Wu' <falcon@...ylab.org>, "w@....eu" <w@....eu>
CC: "arnd@...db.de" <arnd@...db.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
"thomas@...ch.de" <thomas@...ch.de>
Subject: RE: [PATCH v3] tools/nolibc: fix up size inflate regression
From: David Laight
> Sent: 07 August 2023 09:40
....
> with (retyped so it may be wrong):
> #define is_constexpr(x) sizeof(*(0 ? (void *)((long)(x) * 0) : (int *)0)) == 1)
Bah, I know why that works and I still got is backwards :-(
Basically the compiler needs to find a type that is 'compatible'
with both the possible results.
Since '(void *)0' is a valid 'int *' value that gives 'int *'.
But '(void *)(anything_else)' requires the 'int *' be converted
to 'void *'.
Also the following seems to compile to sane code
for all types on 32bit and 64bit x86.
int errno;
#define MAXERRNO 0x4000
#define type int *
type sysret(type arg)
{
if ((unsigned long)arg < 0ul - MAXERRNO)
return arg;
errno = -(long)arg;
return (__typeof(arg))-1;
}
You do get a comparison but no sign extensions.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists