git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Is detecting endianness at compile-time unworkable?

From
MFMichael Felt <aixtools@felt.demon.nl>
Date
Jul 31, 2018, 12:32 UTC
Message-ID
<73cd8ad3-f093-b82e-9726-b27f2214629d@felt.demon.nl>
In-Reply-To
<87wotdt649.fsf@evledraar.gmail.com>
On 7/30/2018 11:39 AM, Ævar Arnfjörð Bjarmason wrote:
> The reason we're in this hole is because we use this
> sha1collisiondetection library to do SHA-1, and the reason we have
> issues with it specifically (not OpenSSL et al) is because its only
> method of detecting endianness is at compile time.
When using gcc (no xlc available for Linux on Power)

POWER6 (Big Endian by definition) root@x068:[/data/httpd/gcc]gcc -dM -E - < /dev/null | grep -i end #define __ORDER_LITTLE_ENDIAN__ 1234 #define __BIG_ENDIAN__ 1 #define __FLOAT_WORD_ORDER__ __ORDER_BIG_ENDIAN__ #define __ORDER_PDP_ENDIAN__ 3412 #define _BIG_ENDIAN 1 #define __ORDER_BIG_ENDIAN__ 4321 #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__

SLES12 on POWER8 suse12test:~ # gcc -dM -E - < /dev/null | grep -i end #define __ORDER_LITTLE_ENDIAN__ 1234 #define _LITTLE_ENDIAN 1 #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __ORDER_PDP_ENDIAN__ 3412 #define __LITTLE_ENDIAN__ 1 #define __ORDER_BIG_ENDIAN__ 4321 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__

*So, for compile time tests, when gcc is the compiler it seems the following defines are available** **__BIG_ENDIAN__, _BIG_ENDIAN,  __LITTLE__ENDIAN__, _LITTLE_ENDIAN** **or something based on the value of __BYTE_ORDER__*

I'll see if I can find something similar for xlc, but will only be able to test xlc on AIX.

Show 8 quoted lines
>
> This didn't use to be the case, it was changed in this commit:
> https://github.com/cr-marcstevens/sha1collisiondetection/commit/d597672
>
> Dan Shumow: Since the commit message doesn't say why, can you elaborate
> a bit on why this was done, i.e. is determining this at runtime harmful
> for performance? If not, perhaps it would be best to bring this back, at
> least as an option.
Previous: Stefan BellerNext: Michael Felt
Message 22 of 25 in “git broken for AIX somewhere between 2.13.2 and 2.13.3”
  1. MichaelJul 29, 2018
  2. brian m. carlsonJul 29, 2018
  3. MichaelJul 29, 2018
  4. Ævar Arnfjörð BjarmasonJul 29, 2018
  5. Andreas SchwabJul 29, 2018
  6. MichaelJul 30, 2018
  7. MichaelJul 29, 2018
  8. brian m. carlsonJul 29, 2018
  9. MichaelJul 29, 2018
  10. Is detecting endianness at compile-time unworkable?Ævar Arnfjörð Bjarmason, Jul 30, 2018
  11. Junio C HamanoJul 30, 2018
  12. Junio C HamanoJul 30, 2018
  13. Daniel ShumowJul 30, 2018
  14. Michael FeltJul 31, 2018
  15. Eric WongAug 1, 2018
  16. Ævar Arnfjörð BjarmasonAug 1, 2018
  17. Michael FeltJul 31, 2018
  18. Ævar Arnfjörð BjarmasonAug 1, 2018
  19. sha1dc: update from upstreamÆvar Arnfjörð Bjarmason, Aug 2, 2018
  20. Michael Felt (aixtools)Aug 2, 2018
  21. Stefan BellerAug 2, 2018
  22. Michael FeltJul 31, 2018
  23. Michael FeltJul 31, 2018
  24. Ævar Arnfjörð BjarmasonJul 31, 2018
  25. MichaelJul 31, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.