Enable 128-bit arithmetic if __int128 is available

This commit is contained in:
Frank Denis 2015-11-15 18:16:15 +01:00
parent 347464d3fd
commit eb8119d65c

View File

@ -446,21 +446,26 @@ AC_SUBST(HAVE_AVX_ASM_V)
AC_MSG_CHECKING(for 128-bit arithmetic) AC_MSG_CHECKING(for 128-bit arithmetic)
HAVE_TI_MODE_V=0 HAVE_TI_MODE_V=0
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef __GNUC__ #if !defined(__GNUC__) && !defined(__SIZEOF_INT128__)
# error mode(TI) is a gcc extension # error mode(TI) is a gcc extension, and __int128 is not available
#endif #endif
#if defined(__clang__) && !defined(__x86_64__) #if defined(__clang__) && !defined(__x86_64__)
# error clang does not properly compile smult_curve25519_donna_c64.c # error clang does not properly handle the 128-bit type on 32-bit systems
#endif #endif
#ifndef NATIVE_LITTLE_ENDIAN #ifndef NATIVE_LITTLE_ENDIAN
# error donna_c64 currently requires a little endian CPU # error libsodium currently expects a little endian CPU for the 128-bit type
#endif #endif
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
# error emscripten currently supports only shift operations on integers \ # error emscripten currently supports only shift operations on integers \
# larger than 64 bits # larger than 64 bits
#endif #endif
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
#if defined(__SIZEOF_INT128__)
typedef unsigned __int128 uint128_t;
#else
typedef unsigned uint128_t __attribute__((mode(TI))); typedef unsigned uint128_t __attribute__((mode(TI)));
#endif
void fcontract(uint128_t *t) { void fcontract(uint128_t *t) {
*t += 0x8000000000000 - 1; *t += 0x8000000000000 - 1;
} }