From 493f71a98a508e5a996012504126da360e263fb6 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 8 Sep 2013 10:39:27 -0700 Subject: [PATCH] Use autoconf to possibly define CPU_ALIGNED_ACCESS_REQUIRED --- configure.ac | 8 ++++++++ .../poly1305/donna/portable-jane.h | 6 ------ .../aes256estream/hongjun/aes256-ctr.c | 16 ---------------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 268d5457..34cfea4f 100644 --- a/configure.ac +++ b/configure.ac @@ -353,6 +353,14 @@ __asm__("movl %ebx,%esi\n" AM_CONDITIONAL([HAVE_CPUID], [test $HAVE_CPUID_V = 1]) AC_SUBST(HAVE_CPUID_V) +AS_CASE([$host_cpu], + [i*86 | x86_64 | powerpc* | s390*], + [AC_MSG_NOTICE([data alignment is not required on this target])], + [*], + [AC_MSG_NOTICE([data alignment is required on this target]) + AC_DEFINE([CPU_ALIGNED_ACCESS_REQUIRED], [1], [data alignment is required])] +) + dnl Checks for functions and headers AC_CHECK_FUNC(clock_gettime, , [AC_CHECK_LIB(rt, clock_gettime)]) diff --git a/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h b/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h index fd2636a9..75db292f 100644 --- a/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h +++ b/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h @@ -285,12 +285,6 @@ # define CPU_Z390 #endif -#if defined(CPU_X86) || defined(CPU_X86_64) || defined(CPU_PPC) || defined(CPU_Z390) -# undef CPU_ALIGNED_ACCESS_REQUIRED -#else -# define CPU_ALIGNED_ACCESS_REQUIRED -#endif - /* 0400-endian-100-be.h */ #if defined(CPU_BE) && !defined(CPU_ALIGNED_ACCESS_REQUIRED) diff --git a/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c b/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c index 24c40c4b..4259ac35 100644 --- a/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c +++ b/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c @@ -117,22 +117,6 @@ partial_precompute_tworounds(ECRYPT_ctx* ctx) /* ------------------------------------------------------------------------- */ -#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__ ) || defined(_M_X64) -# define CPU_X86_64 -#elif defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) -# define CPU_X86 -#elif defined(powerpc) || defined(__PPC__) || defined(__ppc__) || defined(_ARCH_PPC) || defined(__powerpc__) || defined(__powerpc) || defined(POWERPC) || defined(_M_PPC) -# define CPU_PPC -#elif defined(__s390__) || defined(__zarch__) || defined(__SYSC_ZARCH__) -# define CPU_Z390 -#endif - -#if defined(CPU_X86) || defined(CPU_X86_64) || defined(CPU_PPC) || defined(CPU_Z390) -# undef CPU_ALIGNED_ACCESS_REQUIRED -#else -# define CPU_ALIGNED_ACCESS_REQUIRED -#endif - #ifndef CPU_ALIGNED_ACCESS_REQUIRED # define UNALIGNED_U32_READ(P, I) (((const u32 *)(const void *) (P))[(I)]) #else