> Date: Tue, 21 Aug 2012 07:30:42 -0400 > From: Brad Smith <[email protected]> > > On Tue, Aug 21, 2012 at 01:12:28PM +0200, Martin Pieuchot wrote: > > Diff below correctly defines the CPU_TO_LE32() macro for needed for > > big-endian machines on OpenBSD. This is required to use dri on macppc. > > > > I'll do the necessary to get this upstream once it's in our tree. > > > > Tested with the r200 driver, ok? > > > > Martin > > bswap32 == swap32 for OpenBSD. > > I think it would be better if you used swap32() here.
No htole32() is better in this context. Linux and FreeBSD get away with using "swap" functions because this is in an #if BYTE_ORDER == BIG_ENDIAN block, but CPU_TO_LE32() is supposed to translate host (cpu) byte order into little endian. The code for Darwin gets this right. > > Index: src/mesa/main//compiler.h > > =================================================================== > > RCS file: /cvs/xenocara/dist/Mesa/src/mesa/main/compiler.h,v > > retrieving revision 1.3 > > diff -u -p -r1.3 compiler.h > > --- src/mesa/main//compiler.h 17 Aug 2012 13:58:17 -0000 1.3 > > +++ src/mesa/main//compiler.h 21 Aug 2012 09:10:49 -0000 > > @@ -263,6 +263,9 @@ static INLINE GLuint CPU_TO_LE32(GLuint > > ((x & 0x00ff0000) >> 8) | > > ((x & 0xff000000) >> 24)); > > } > > +#elif defined(__OpenBSD__) > > +#include <sys/types.h> > > +#define CPU_TO_LE32( x ) htole32( x ) > > #else /*__linux__ */ > > #include <sys/endian.h> > > #define CPU_TO_LE32( x ) bswap32( x )
