diff --git a/configure.in b/configure.in index c81709e6..5618b3a2 100644 --- a/configure.in +++ b/configure.in @@ -247,6 +247,10 @@ AC_TRY_COMPILE([#include AC_C_BIGENDIAN([AC_DEFINE(CPU_BIG_ENDIAN)], [AC_DEFINE(CPU_LITTLE_ENDIAN)], [AC_MSG_ERROR([Cannot determine CPU endianity.])]) +AC_CHECK_SIZEOF(unsigned int) +AC_CHECK_SIZEOF(unsigned long) +AC_CHECK_SIZEOF(unsigned long long) + BIRD_CHECK_INTEGERS BIRD_CHECK_STRUCT_ALIGN BIRD_CHECK_TIME_T diff --git a/lib/sha512.c b/lib/sha512.c index becb91b9..88343875 100644 --- a/lib/sha512.c +++ b/lib/sha512.c @@ -20,7 +20,13 @@ #include "lib/sha512.h" #include "lib/unaligned.h" -#define U64_C(c) (c ## UL) /* Maybe is system dependent */ +#if SIZEOF_UNSIGNED_INT == 8 + #define U64_C(c) (c ## U) +#elif SIZEOF_UNSIGNED_LONG == 8 + #define U64_C(c) (c ## UL) +#elif SIZEOF_UNSIGNED_LONG_LONG == 8 + #define U64_C(c) (c ## ULL) +#endif static uint sha512_transform(void *context, const byte *data, size_t nblks); diff --git a/sysdep/autoconf.h.in b/sysdep/autoconf.h.in index a9e46e27..25729849 100644 --- a/sysdep/autoconf.h.in +++ b/sysdep/autoconf.h.in @@ -66,4 +66,13 @@ /* We have stdint.h */ #undef HAVE_STDINT_H +/* The size of `unsigned int', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_INT + +/* The size of `unsigned long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG + +/* The size of `unsigned long long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG_LONG + #define CONFIG_PATH ? diff --git a/sysdep/config.h b/sysdep/config.h index 08c15fe9..800118e9 100644 --- a/sysdep/config.h +++ b/sysdep/config.h @@ -15,6 +15,18 @@ /* Include OS configuration file as chosen in autoconf.h */ #include SYSCONF_INCLUDE +/* The AC_CHECK_SIZEOF() in configure fails for some machines. + * we provide some fallback values here */ +#ifndef SIZEOF_UNSIGNED_INT +# define SIZEOF_UNSIGNED_INT 4 +#endif +#ifndef SIZEOF_UNSIGNED_LONG +# define SIZEOF_UNSIGNED_LONG 4 +#endif +#ifndef SIZEOF_UNSIGNED_LONG_LONG +# define SIZEOF_UNSIGNED_LONG_LONG 8 +#endif + #ifndef MACROS_ONLY /*