summaryrefslogtreecommitdiff
path: root/config_align.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-05-17 15:18:17 -0400
committerGitHub <noreply@github.com>2019-05-17 15:18:17 -0400
commitc51f0ecbfd21b1eb29cfd26ea870b175d92db6c6 (patch)
tree87f0f2dbe92e25d2816ab6077e93714b2e69d863 /config_align.h
parentb25b6f0892ebab5cc8a5e8c494c0db69057e1ba8 (diff)
downloadcryptopp-git-c51f0ecbfd21b1eb29cfd26ea870b175d92db6c6.tar.gz
Make config.h more Autoconf friendly (GH #835, PR #836)
Diffstat (limited to 'config_align.h')
-rw-r--r--config_align.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/config_align.h b/config_align.h
new file mode 100644
index 00000000..7477e289
--- /dev/null
+++ b/config_align.h
@@ -0,0 +1,61 @@
+// config_align.h - written and placed in public domain by Jeffrey Walton
+// the bits that make up this source file are from the
+// library's monolithic config.h.
+
+/// \file config_align.h
+/// \brief Library configuration file
+/// \details <tt>config.h</tt> was split into components in May 2019 to better
+/// integrate with Autoconf and its feature tests. The splitting occured so
+/// users could continue to include <tt>config.h</tt> while allowing Autoconf
+/// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
+/// its feature tests.
+/// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835</A>
+/// \since Crypto++ 8.3
+
+#ifndef CRYPTOPP_CONFIG_ALIGN_H
+#define CRYPTOPP_CONFIG_ALIGN_H
+
+#include "config_cpu.h"
+#include "config_cxx.h"
+#include "config_ver.h"
+
+// Nearly all Intel's and AMD's have SSE. Enable it independent of SSE ASM and intrinscs
+#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) && !defined(CRYPTOPP_DISABLE_ASM)
+ #define CRYPTOPP_BOOL_ALIGN16 1
+#else
+ #define CRYPTOPP_BOOL_ALIGN16 0
+#endif
+
+// How to allocate 16-byte aligned memory (for SSE2)
+// posix_memalign see https://forum.kde.org/viewtopic.php?p=66274
+#if defined(_MSC_VER)
+ #define CRYPTOPP_MM_MALLOC_AVAILABLE
+#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
+ #define CRYPTOPP_MEMALIGN_AVAILABLE
+#elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+ #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
+#elif (defined(_GNU_SOURCE) || ((_XOPEN_SOURCE + 0) >= 600)) && (_POSIX_ADVISORY_INFO > 0)
+ #define CRYPTOPP_POSIX_MEMALIGN_AVAILABLE
+#else
+ #define CRYPTOPP_NO_ALIGNED_ALLOC
+#endif
+
+// Sun Studio Express 3 (December 2006) provides GCC-style attributes.
+// IBM XL C/C++ alignment modifier per Optimization Guide, pp. 19-20.
+// __IBM_ATTRIBUTES per XLC 12.1 AIX Compiler Manual, p. 473.
+// CRYPTOPP_ALIGN_DATA may not be reliable on AIX.
+#ifndef CRYPTOPP_ALIGN_DATA
+ #if defined(CRYPTOPP_CXX11_ALIGNAS)
+ #define CRYPTOPP_ALIGN_DATA(x) alignas(x)
+ #elif defined(_MSC_VER)
+ #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
+ #elif defined(__GNUC__) || defined(__clang__) || (__SUNPRO_CC >= 0x5100)
+ #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
+ #elif defined(__xlc__) || defined(__xlC__)
+ #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
+ #else
+ #define CRYPTOPP_ALIGN_DATA(x)
+ #endif
+#endif
+
+#endif // CRYPTOPP_CONFIG_ALIGN_H