On Sun, 11 Dec 2022 at 12:07, Szabolcs Nagy <nsz@port70.net> wrote:
* Rich Felker <dalias@libc.org> [2022-12-11 00:53:35 -0500]:
> On Tue, Dec 06, 2022 at 11:36:24AM +0100, Yuriy Chernyshov wrote:
> > The following workaround helps, but looks quite ugly:
> >
> > --- arch/generic/bits/ioctl.h (b4624b83eafbdd5f2e2c37374d62426c27687f35)
> > > +++ arch/generic/bits/ioctl.h (d545cbc1ae3f5c9132eb26b176bef3638c9d8063)
> > > @@ -1,3 +1,9 @@
> > > +#undef _IO
> > > +#undef _IOC
> > > +#undef _IOR
> > > +#undef _IOW
> > > +#undef _IOWR
> > > +
> > >  #define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) )
> > >  #define _IOC_NONE  0U
> > >  #define _IOC_WRITE 1U
> > >
> >
> > Is it possible to get official solution for the macro conflict?
>
> It's explicitly unsupported to include linux/* headers that might
> produce conflicting definitions *before* the libc headers they might
> conflict with. Does the same problem happen if you put the linux/*
> headers after?

i don't think reordering can fix the conflict as linux defines the
macros unconditionally. (and glibc relies on the linux definitions)

Indeed, the reording was the first thing I have tried.
I have failed to find a working solution.

> > NB: we have to use linux/fs.h in order to get BLKGETSIZE64 constant defined
> > which is missing in sys/ioctl.h.

musl defines that in sys/mount.h (just like glibc)

This would have been a solution for BLKGETSIZE64, but once I have started to refactor things, I got more problems.
Our code also depends on BLKDISCARD, which is not defined by neither musl nor glibc.
Is it possible to add this define into musl codebase?