[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ff8fc4470c8f45678e546cafe9980eff@AcuMS.aculab.com>
Date: Tue, 23 Nov 2021 16:58:30 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'David Howells' <dhowells@...hat.com>,
Cyril Hrubis <chrubis@...e.cz>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>,
"ltp@...ts.linux.it" <ltp@...ts.linux.it>,
"libc-alpha@...rceware.org" <libc-alpha@...rceware.org>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
"arnd@...db.de" <arnd@...db.de>
Subject: RE: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace
From: David Howells
> Sent: 23 November 2021 16:48
>
> Cyril Hrubis <chrubis@...e.cz> wrote:
>
> > This changes the __u64 and __s64 in userspace on 64bit platforms from
> > long long (unsigned) int to just long (unsigned) int in order to match
> > the uint64_t and int64_t size in userspace.
That is a massive UAPI change you can't do.
> Can you guarantee this won't break anything in userspace? Granted the types
> *ought* to be the same size, but anyone who's written code on the basis that
> these are "(unsigned) long long int" may suddenly get a bunch of warnings
> where they didn't before from the C compiler. Anyone using C++, say, may find
> their code no longer compiles because overloaded function matching no longer
> finds a correct match.
Indeed
> Also, whilst your point about PRIu64 and PRId64 modifiers in printf() is a
> good one, it doesn't help someone whose compiler doesn't support that (I don't
> know if anyone's likely to encounter such these days). At the moment, I think
> a user can assume that %llu will work correctly both on 32-bit and 64-bit on
> all arches, but you're definitely breaking that assumption.
PRIu64 (etc) don't require compiler support, just the correct header file.
I'm pretty sure that portable user code needs to allow for int64_t being
either 'long' or 'long long' on 64bit architectures.
(Indeed 'long' may not even be 64bit.)
On 32bit int32_t can definitely be either 'int' of 'long' at whim.
I'm not sure anyone has tried a 64bit long with a 128bit long-long.
But the C language might lead you to do that.
Of course, fully portable code has to allow for char, short, int and long
all being the same size!
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists