Browse Source

Improve ILP32 detection

This should fix https://github.com/DCIT/perl-CryptX/issues/117

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 7 months ago
parent
commit
cda7d42647
3 changed files with 8 additions and 6 deletions
  1. 5 3
      src/headers/tomcrypt_cfg.h
  2. 2 2
      src/headers/tomcrypt_private.h
  3. 1 1
      tests/multi_test.c

+ 5 - 3
src/headers/tomcrypt_cfg.h

@@ -91,9 +91,6 @@ LTC_EXPORT int   LTC_CALL XSTRCMP(const char *s1, const char *s2);
    #define ENDIAN_LITTLE
    #define ENDIAN_64BITWORD
    #define LTC_FAST
-   #if defined(_ILP32) || defined(__ILP32__)
-      #define ENDIAN_64BITWORD_X32
-   #endif
 #endif
 
 /* detect PPC32 */
@@ -178,6 +175,11 @@ LTC_EXPORT int   LTC_CALL XSTRCMP(const char *s1, const char *s2);
    #define LTC_FAST
 #endif
 
+/* Detect ILP32, commonly known as x32 on Linux and also possible on AIX */
+#if defined(_ILP32) || defined(__ILP32__)
+   #define ENDIAN_64BITWORD_ILP32
+#endif
+
 /* endianness fallback */
 #if !defined(ENDIAN_BIG) && !defined(ENDIAN_LITTLE)
   #if defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN || \

+ 2 - 2
src/headers/tomcrypt_private.h

@@ -12,8 +12,8 @@
 
 #define LTC_PAD_MASK       (0xF000U)
 
-/* only real 64bit, not x32 */
-#if defined(ENDIAN_64BITWORD) && !defined(ENDIAN_64BITWORD_X32)
+/* only real 64bit, not ILP32 */
+#if defined(ENDIAN_64BITWORD) && !defined(ENDIAN_64BITWORD_ILP32)
    #define CONSTPTR(n) CONST64(n)
 #else
    #define CONSTPTR(n) n ## uL

+ 1 - 1
tests/multi_test.c

@@ -15,7 +15,7 @@ int multi_test(void)
 
 /* HASH testing */
    len = sizeof(buf[0]);
-#if defined(ENDIAN_32BITWORD) || defined(_WIN32) || defined(ENDIAN_64BITWORD_X32)
+#if defined(ENDIAN_32BITWORD) || defined(_WIN32) || defined(ENDIAN_64BITWORD_ILP32)
    len2 = 0x80000000UL;
 #else
    /* Check against the max. input limit of SHA-1 as of RFC8017 */