Mikolaj Kucharski <miko...@kucharski.name> writes:

> On Mon, Oct 05, 2015 at 01:40:16PM +0200, Jrmie Courr??ges-Anglas wrote:
>> Mikolaj: note that upstream already has AC_C_BIGENDIAN in its
>> configure.ac and already uses it... *except* when the system has an
>> <endian.h> include file.  That special case is where the bug was
>> introduced; what was the reason for this special case?
>
> Okay, I've looked at all this again and I think I know what you mean.
> That part of the code which I think you are referring to (#if
> HAVE_ENDIAN_H in par2cmdline.h) didn't change. There was par2cmdline 0.4
> in OpenBSD 5.5 and exactly the same version is in OpenBSD 5.6 and
> __BYTE_ORDER define stopped to be defined properly in 5.6.
>
> Your question pointed me to look at endian.h detection under OpenBSD 5.5
> and 5.6 for par2cmdline 0.4 (as update to 0.6.14 is unrelated to
> endianess problem) and bingo:

Yup.

[...]

> However, I'm still not sure how to answer your question, about why they
> wrote par2cmdline.h the way it's written, if it's that what you are actually
> asking for, Jeremie.

No idea either.  Maybe this code is from a time where AC_C_BIGENDIAN
didn't properly check endian.h (eg. only sys/param.h).

But now it does, and the code could probably be simplified to check only
WORDS_BIGENDIAN, not the presence of endian.h.  Something like that in
par2cmdline.h:

#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN    4321
#define __PDP_ENDIAN    3412
#if WORDS_BIGENDIAN
#  define __BYTE_ORDER __BIG_ENDIAN
#else
#  define __BYTE_ORDER __LITTLE_ENDIAN
#endif

Further simplification is possible, as well as avoiding the use of these
implementation-specific macros:

#if WORDS_BIGENDIAN
#  define PAR2_BIGENDIAN 1
#else
#  define PAR2_BIGENDIAN 0
#endif

Then use only #if PAR2_BIGENDIAN in the rest of the code.  Other places
which define __BYTE_ORDER in par2cmdline.h should be adapted too, of
course.  If you want to discuss this with upstream...

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to