[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d9a795a-7c6a-3889-af31-2223dc216d15@gmail.com>
Date: Tue, 4 May 2021 21:59:06 +0200
From: "Alejandro Colomar (man-pages)" <alx.manpages@...il.com>
To: Florian Weimer <fweimer@...hat.com>
Cc: Zack Weinberg <zackw@...ix.com>,
Greg KH <gregkh@...uxfoundation.org>,
Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
"Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>,
linux-man <linux-man@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
glibc <libc-alpha@...rceware.org>, GCC <gcc-patches@....gnu.org>,
bpf <bpf@...r.kernel.org>,
Joseph Myers <joseph@...esourcery.com>,
David Laight <David.Laight@...lab.com>
Subject: Re: [RFC v2] bpf.2: Use standard types and attributes
Hi Florian,
On 5/4/21 9:45 PM, Florian Weimer wrote:
> * Alejandro Colomar:
>
>> The thing is, in all of those threads, the only reasons to avoid
>> <stdint.h> types in the kernel (at least, the only explicitly
>> mentioned ones) are (a bit simplified, but this is the general idea of
>> those threads):
>>
>> * Possibly breaking something in such a big automated change.
>> * Namespace collision with userspace (the C standard allows defining
>> uint32_t for nefarious purposes as long as you don't include
>> <stdint.h>. POSIX prohibits that, though)
>> * Uglier
>
> __u64 can't be formatted with %llu on all architectures. That's not
> true for uint64_t, where you have to use %lu on some architectures to
> avoid compiler warnings (and technically undefined behavior). There are
> preprocessor macros to get the expected format specifiers, but they are
> clunky. I don't know if the problem applies to uint32_t. It does
> happen with size_t and ptrdiff_t on 32-bit targets (both vary between
> int and long).
>
Hmmm, that's interesting. It looks like Linux always uses long long for
64 bit types, while glibc uses 'long' as long as it's possible, and only
uses 'long long' when necessary. Assignment is still 100% valid both
ways and binary compatibility also 100% (AFAIK), given they're the same
length and signedness, but pointers are incompatible. That's something
to note, even though in this case there are no pointers involved, so no
incompatibilities. Maybe the kernel and glibc could use the same rules
to improve compatibility, but that's out of the scope of this.
Thanks,
Alex
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
Powered by blists - more mailing lists