math/f25519.c: Implementation for arithmetic in GF(2^255 - 19).
[catacomb] / configure.ac
index 1802a8a..bd2c3b5 100644 (file)
@@ -172,6 +172,40 @@ case $CPUFAM in
 esac
 
 dnl--------------------------------------------------------------------------
+dnl CPU-specific assembler features.
+
+AC_LANG([CPPAS])
+
+case $CPUFAM in
+  armel)
+    AC_CACHE_CHECK(
+      [whether the assembler understands ARMv8 crypto extensions],
+      [mdw_cv_as_armv8_crypto],
+      [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+       .arch   armv8-a
+       .fpu    crypto-neon-fp-armv8
+
+       .text
+       .globl  foo
+foo:
+       vldmia  r0, {d0-d3}
+       aese.8  q0, q1
+       aesmc.8 q0, q0
+       vstmia  r0, {d0, d1}
+       bx      r14]])],
+        [mdw_cv_as_armv8_crypto=yes],
+        [mdw_cv_as_armv8_crypto=no])])
+    ;;
+esac
+
+: ${mdw_cv_as_armv8_crypto=no}
+AM_CONDITIONAL([HAVE_AS_ARMV8_CRYPTO], [test $mdw_cv_as_armv8_crypto = yes])
+if test $mdw_cv_as_armv8_crypto = yes; then
+  AC_DEFINE([HAVE_AS_ARMV8_CRYPTO], [1],
+    [Define to 1 if your ARM assembler supports the ARMv8 crypto instructions.])
+fi
+
+dnl--------------------------------------------------------------------------
 dnl C programming environment.
 
 AC_LANG([C])
@@ -182,10 +216,19 @@ dnl Find out if we're cross-compiling.
 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
 
 dnl Various standard types.
-AC_CHECK_TYPE([pid_t], [int])
+AC_CHECK_TYPE([pid_t], [],
+  [AC_DEFINE([pid_t], [int],
+     [Define to `int' if <sys/types.h> does not define])])
 AC_TYPE_UID_T
-AC_CHECK_TYPE([ssize_t], [int])
-AC_CHECK_TYPE([socklen_t], [int])
+AC_CHECK_TYPE([ssize_t], [],
+  [AC_DEFINE([ssize_t], [int],
+     [Define to `int' if <sys/types.h> does not define])])
+AC_CHECK_TYPE([socklen_t], [],
+  [AC_DEFINE([socklen_t], [int],
+     [Define to `int' if <sys/socket.h> does not define])],
+  [AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+])
 
 dnl The maths library.
 mdw_ORIG_LIBS=$LIBS LIBS=
@@ -197,7 +240,7 @@ LIBS=$mdw_ORIG_LIBS
 dnl Find out whether very long integer types are available.
 AC_CHECK_HEADERS([stdint.h])
 AC_SUBST([have_stdint_h])
-AC_C_LONG_LONG
+AX_C_LONG_LONG
 
 dnl Some equipment wanted for checking CPU features at runtime.
 AC_CHECK_HEADERS([asm/hwcap.h])
@@ -264,6 +307,21 @@ fi
 catacomb_LIMIT([SIZET],                [=0],           [~(size_t)0])
 AC_SUBST([limits])
 
+dnl Figure out other aspects of the implementation's arithmetic.
+AC_CACHE_CHECK([whether negative numbers use two's complement],
+       [catacomb_cv_neg_twoc],
+[AC_TRY_COMPILE(
+[#include <limits.h>],
+[int check[2*!!(-INT_MAX == INT_MIN + 1) - 1];],
+[catacomb_cv_neg_twoc=yes],
+[catacomb_cv_neg_twoc=no])])
+case $catacomb_cv_neg_twoc in
+  yes)
+    AC_DEFINE([NEG_TWOC], [1],
+     [Define if signed numbers are represented in two's complement.])
+    ;;
+esac
+
 dnl Functions used for noise-gathering.
 AC_CHECK_FUNCS([setgroups])
 AC_CHECK_HEADERS([linux/random.h])