From: Denys Vlasenko <vda.linux@googlemail.com>
To: musl <musl@lists.openwall.com>
Cc: Aboriginal Linux <aboriginal@lists.landley.net>
Subject: Re: Re: musl and kernel headers [was Re: system-images 1.4.2: od is broken; bzip2 is missing]
Date: Tue, 13 Oct 2015 20:02:47 +0200 [thread overview]
Message-ID: <CAK1hOcMXN2k7MVnSE44dDshP8jRLSE=rwiragf8etgAXrw_TJQ@mail.gmail.com> (raw)
In-Reply-To: <20151013150525.GP8645@brightrain.aerifal.cx>
On Tue, Oct 13, 2015 at 5:05 PM, Rich Felker <dalias@aerifal.cx> wrote:
>> > > This would address the case where the kernel header is included first,
>> > > but it's not a case I or most of the musl community wants to support,
>> > > because there's no guarantee that the kernel's definitions of these
>> > > structures will actually be compatible with use elsewhere in the libc
>> > > headers, etc.
>> >
>> > If kernel's definition does not match yours, there is a much
>> > bigger problem than "includes do not compile":
>> > kernel and userspace definitions of these structs *must* match
>> > (modulo harmless things like different typedef names for field types).
>> >
>> > So in this case either kernel or libc would need to be fixed.
>>
>> why?
>>
>> in practice most types are c abi compatible with the kernel
>> because translating the types at the syscall boundary is
>> painful/impossible.
>>
>> but even with compatible binary representation there is
>> plenty space for disagreement between kernel and libc on
>> the source level. (of course code that includes both libc
>> and kernel headers might not care about posix namespace
>> violations or undefined behaviour in kernel headers..)
>>
>> and libc-compat does not cover all conflicting cases
>> (i assume they just add workarouds when somebody hits
>> a conflict), e.g. sys/inotify.h and linux/inotify.h are
>> in conflict (and linux/inotify.h is not even standard c).
>
> Indeed the problem here is source compatibility, not binary
> compatibility. Issues like names of types, choice of distinct types
> that have the same size and representation but which are not
> compatible types (which make problems if you take the address of the
> member, including possibly aliasing problems which are real-world
> bugs), etc.
It's not that bad in practice.
In C, typedefs are not new types. uint16_t, u16 and __u16
are all just aliases to "unsigned short".
You won't get a conflict because different typedefs
were used to declare a struct member whose address you are
taking and passing to some function.
If signedness and width match, then it will work without casts
or compiler errors.
next prev parent reply other threads:[~2015-10-13 18:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAK1hOcNm-rwGdr1_THZoHA-TTxOjpzUU=Lnraqt6mj+JmBdvFw@mail.gmail.com>
[not found] ` <5612925A.4070402@landley.net>
2015-10-06 1:44 ` Rich Felker
2015-10-06 2:24 ` Rob Landley
2015-10-06 11:01 ` Szabolcs Nagy
2015-10-06 14:30 ` Rich Felker
2015-10-06 16:05 ` Denys Vlasenko
2015-10-06 16:09 ` Denys Vlasenko
2015-10-08 16:58 ` Rich Felker
2015-10-09 19:11 ` Denys Vlasenko
2015-10-09 19:46 ` Rich Felker
2015-10-10 4:56 ` Rob Landley
2015-10-13 12:10 ` Denys Vlasenko
2015-10-13 14:16 ` Ruben Winistörfer
2015-10-13 14:53 ` Szabolcs Nagy
2015-10-13 15:05 ` Rich Felker
2015-10-13 18:02 ` Denys Vlasenko [this message]
2015-10-13 18:56 ` Rich Felker
2015-10-13 15:10 ` Rich Felker
2015-10-13 21:55 ` Isaac Dunham
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='CAK1hOcMXN2k7MVnSE44dDshP8jRLSE=rwiragf8etgAXrw_TJQ@mail.gmail.com' \
--to=vda.linux@googlemail.com \
--cc=aboriginal@lists.landley.net \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).