[PATCH] powerpc/align: Use #ifdef __BIG_ENDIAN__ #else for REG_BYTE

Michael Ellerman mpe at ellerman.id.au
Fri Jun 17 15:35:52 AEST 2016


On Thu, 2016-06-16 at 15:05 +0200, Arnd Bergmann wrote:
> On Thursday, June 16, 2016 10:33:41 PM CEST Michael Ellerman wrote:
> > From: Daniel Axtens <dja at axtens.net>
> > 
> > Sparse complains that it doesn't know what REG_BYTE is:
> > 
> >   arch/powerpc/kernel/align.c:313:29: error: undefined identifier 'REG_BYTE'
> > 
> > REG_BYTE is defined differently based on whether we're compiling for
> > LE, BE32 or BE64. Sparse apparently doesn't provide __BIG_ENDIAN__ or
> > __LITTLE_ENDIAN__, which means we get no definition.
> > 
> > Rather than check for __BIG_ENDIAN__ and then separately for
> > __LITTLE_ENDIAN__, just switch the #ifdef to check for __BIG_ENDIAN__
> > and then #else we define the little endian version. Technically that's
> > dicey because PDP_ENDIAN is also a possibility, but we already do it in
> > a lot of places so one more hardly matters.
> > 
> > Signed-off-by: Daniel Axtens <dja at axtens.net>
> > Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
> 
> That makes the code less robust for the cases that accidentally we
> have neither or both of __LITTLE_ENDIAN__/__BIG_ENDIAN__ set during
> an actual compilation.
 
True, but I already count ~30 locations where we do the #if/else check. So any
compiler that defines both or neither has zero chance of building the kernel
already, and is clearly broken IMHO.

> It would be better to fix the sparse compilation so the same endianess
> is set that you get when calling gcc.

Agree, but I don't want us to get road-blocked on that.

cheers



More information about the Linuxppc-dev mailing list