From: David Laight <David.Laight@ACULAB.COM>
To: David Laight <David.Laight@ACULAB.COM>,
'Zhangjin Wu' <falcon@tinylab.org>, "w@1wt.eu" <w@1wt.eu>
Cc: "arnd@arndb.de" <arnd@arndb.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"thomas@t-8ch.de" <thomas@t-8ch.de>
Subject: RE: [PATCH v3] tools/nolibc: fix up size inflate regression
Date: Mon, 7 Aug 2023 09:53:07 +0000 [thread overview]
Message-ID: <2e6897775c5147a8a31fc6678eb01a8c@AcuMS.aculab.com> (raw)
In-Reply-To: <f51e54bcf470451ea36f24640f000e61@AcuMS.aculab.com>
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)
next prev parent reply other threads:[~2023-08-07 9:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 5:57 Zhangjin Wu
2023-08-07 8:40 ` David Laight
2023-08-07 9:53 ` David Laight [this message]
2023-08-07 14:12 ` Zhangjin Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2e6897775c5147a8a31fc6678eb01a8c@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=arnd@arndb.de \
--cc=falcon@tinylab.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=thomas@t-8ch.de \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®