[hugin-ptx] Re: Unit tests fail with libpano13-2.9.21_rc2

2021-12-13 Thread T. Modes
Thanks, I committed the necessary changes.


-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to hugin-ptx+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/2597f9ac-f5aa-415f-90c9-b140445aa212n%40googlegroups.com.


[hugin-ptx] Re: Unit tests fail with libpano13-2.9.21_rc2

2021-12-13 Thread Robert Clausecker
Hello,

The architectures I tested were armv7 and arm64 on FreeBSD 13.  The 
compiler is clang 11.0.1.
FreeBSD defines _BYTE_ORDER but not __BYTE_ORDER.  Likewise, it defines 
_BIG_ENDIAN but not __BIG_ENDIAN.
You should be able to make your code work with something like this:

#if defined(_BYTE_ORDER) && !defined(__BYTE_ORDER)
# define __BYTE_ORDER _BYTE_ORDER
#endif

I recommend patching the endianess detection code so it checks for the 
presence of the macros you want to test
in addition to using them (the C preprocessors substitutes 0 for undefined 
macros).  For example, try this:

#if !defined(__BYTE_ORDER) || !defined(__BIG_ENDIAN)
# error cannot determine byte order
#endif

Also consider checking both for big and little endian instead of just 
assuming little endian if the big endian case does not apply.
This makes the code robust against architectures where the byte order is 
neither big nor little endian.

Also consider writing endian agnostic code instead of having separate code 
paths for both endianesses.  This also has
the effect of making the code compliant with the strict aliasing rule which 
your code does not seem to be.  For example,
you can use functions like these for accessing fields in files with a 
defined endianess without having to make assumptions
about the endianess of the architecture you are programming for:

https://github.com/clausecker/memf/blob/master/src/fiddle.h

This implementation compiles to reasonable code with modern gcc and clang 
and allows you to completely avoid
having to detect and deal with host endianess.

Yours,
Robert Clausecker

T. Modes schrieb am Donnerstag, 9. Dezember 2021 um 17:39:12 UTC+1:

> fuz... schrieb am Dienstag, 7. Dezember 2021 um 00:34:10 UTC+1:
>
>> Greetings! 
>>
>> While preparing the FreeBSD port for libpano13 in preparation of the 
>> upcoming 2.9.21 release, I noticed that the unit tests fail. 
>
>
> On which architecture, which compiler? Where there warning during 
> compiling?
>
> Between 2.9.21 rc1 and rc2 there were code added to automatically deduce 
> the endianess of the system to fix test failures on different architectures.
> After searching the internet there were already special code added for 
> FreeBSD in panorama.h:
> #if defined(__GNUC__) && !defined(__MINGW32__)
> #if defined(__FreeBSD__)
> #include 
> #else
> #include 
> #endif
>
> Could you check if sys/endian.h (or files included from there) defines 
> __BYTE_ORDER  
> and __BIG_ENDIAN.
> If not, are they defined in machine/endian.h?
>
> TIA
>

-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to hugin-ptx+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/e9511f7a-82d8-4731-bc37-12cd1d7c8682n%40googlegroups.com.