libtomcrypt icon indicating copy to clipboard operation
libtomcrypt copied to clipboard

Endianness not detected for ARM UWP build

Open mabuchner opened this issue 3 years ago • 3 comments

Building libtomcrypt for Windows ARM (UWP) using Visual Studio 2019 fails with the following error

Cannot detect endianness

emitted from

https://github.com/libtom/libtomcrypt/blob/v1.18.2/src/headers/tomcrypt_cfg.h#L191

mabuchner avatar Dec 10 '21 05:12 mabuchner

This website is helpful for finding appropriate preprocessor defines for detecting the CPU architecture.

mabuchner avatar Dec 10 '21 05:12 mabuchner

Here Microsoft lists their preprocessor defines.

_M_ARM and _M_ARM64 look like good candidates for detecting 32-bit and 64-bit ARM.

mabuchner avatar Dec 10 '21 06:12 mabuchner

I've added this block of code to tomcrypt_cfg.h

/* detect ARM 32-bit */
#if defined(_M_ARM)
   #define ENDIAN_LITTLE
   #define ENDIAN_32BITWORD
#endif

/* detect ARM 64-bit */
#if defined(_M_ARM64)
   #define ENDIAN_LITTLE
   #define ENDIAN_64BITWORD
#endif

and now the error is gone.

mabuchner avatar Dec 10 '21 06:12 mabuchner

Can you please check whether #626 correctly fixes this?

sjaeckel avatar Aug 07 '23 13:08 sjaeckel

Sorry, but I can't really test it anymore. Unfortunately, I had to find a new employer. Now I have neither access to my ex-employers codebase nor a Windows system.

I don't know, if LTC_FAST should also be defined for ARM. Apart from that the change looks fine to me.

Thanks for taking the time to fix this issue. I'm sure it will benefit other developers.

mabuchner avatar Aug 07 '23 14:08 mabuchner