[Ksummit-discuss] [TECH TOPIC] How to encourage driver authors to annotate integer endianness properly

Josh Triplett josh at joshtriplett.org
Wed Oct 25 16:16:56 UTC 2017


On Wed, Oct 25, 2017 at 03:11:48PM +0200, David Woodhouse wrote:
> On Wed, 2017-10-25 at 14:40 +0200, Alexey Dobriyan wrote:
> > On 10/25/17, Bart Van Assche <Bart.VanAssche at wdc.com> wrote:
> > > 
> > > I think we need a way to encourage driver authors
> > > to pay attention to endianness annotations,
> > typedef struct {
> >         uint32_t _;
> > } __le32;
> 
> I actually did that in JFFS2 years ago; before sparse could do it. It
> was very useful.
> 
> I'd really like to have proper compiler support for big-endian and
> little-endian integers too. We're half-way there now with
> __builtin_bswap32() et al, and compilers can optimise things properly
> (instead of the opaque inline asm we had before I cleaned that up).
> 
> But being able to just mark a given integer storage as big- or little-
> endian and have all loads and stores *automatically* do the right thing
> would be extremely useful in many cases.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59852 for a proposal to
implement Sparse's __attribute__((bitwise)) in GCC. The GCC developers
are amenable, if someone's willing to write a patch.


More information about the Ksummit-discuss mailing list