Crypto++ 8.9 Free C++ class library of cryptographic schemes

config_align.h
Go to the documentation of this file.
1 // config_align.h - written and placed in public domain by Jeffrey Walton
2 // the bits that make up this source file are from the
3 // library's monolithic config.h.
4
5 /// \file config_align.h
6 /// \brief Library configuration file
7 /// \details <tt>config_align.h</tt> provides defines for aligned memory
8 /// allocations.
9 /// \details <tt>config.h</tt> was split into components in May 2019 to better
10 /// integrate with Autoconf and its feature tests. The splitting occurred so
11 /// users could continue to include <tt>config.h</tt> while allowing Autoconf
12 /// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
13 /// its feature tests.
14 /// \note You should include <tt>config.h</tt> rather than <tt>config_align.h</tt>
15 /// directly.
16 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,
17 /// Make config.h more autoconf friendly</A>,
18 /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>
19 /// on the Crypto++ wiki
20 /// \since Crypto++ 8.3
21
22 #ifndef CRYPTOPP_CONFIG_ALIGN_H
23 #define CRYPTOPP_CONFIG_ALIGN_H
24
25 #include "config_asm.h" // CRYPTOPP_DISABLE_ASM
26 #include "config_cpu.h" // X86, X32, X64, ARM32, ARM64, etc
27 #include "config_cxx.h" // CRYPTOPP_CXX11_ALIGNAS
28 #include "config_ver.h" // Compiler versions
29
30 // Nearly all Intel's and AMD's have SSE. Enable it independent of SSE ASM and intrinsics.
31 // ARM NEON and ARMv8 ASIMD only need natural alignment of an element in the vector.
32 // Altivec through POWER7 need vector alignment. POWER8 and POWER9 relax the requirement.
33 #if defined(CRYPTOPP_DISABLE_ASM)
34 #define CRYPTOPP_BOOL_ALIGN16 0
35 #elif (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || \
36 CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
37 #define CRYPTOPP_BOOL_ALIGN16 1
38 #else
39 #define CRYPTOPP_BOOL_ALIGN16 0
40 #endif
41
42 // How to allocate 16-byte aligned memory (for SSE2)
43 // posix_memalign see https://forum.kde.org/viewtopic.php?p=66274
44 #if defined(CRYPTOPP_MSC_VERSION)
45 #define CRYPTOPP_MM_MALLOC_AVAILABLE
46 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
47 #define CRYPTOPP_MEMALIGN_AVAILABLE
48 #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
49 #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
50 #elif (defined(_GNU_SOURCE) || ((_XOPEN_SOURCE + 0) >= 600)) && (_POSIX_ADVISORY_INFO > 0)
51 #define CRYPTOPP_POSIX_MEMALIGN_AVAILABLE
52 #else
53 #define CRYPTOPP_NO_ALIGNED_ALLOC
54 #endif
55
56 // Sun Studio Express 3 (December 2006) provides GCC-style attributes.
57 // IBM XL C/C++ alignment modifier per Optimization Guide, pp. 19-20.
58 // __IBM_ATTRIBUTES per XLC 12.1 AIX Compiler Manual, p. 473.
59 // CRYPTOPP_ALIGN_DATA may not be reliable on AIX.
60 #if defined(CRYPTOPP_CXX11_ALIGNAS)
61 #define CRYPTOPP_ALIGN_DATA(x) alignas(x)
62 #elif defined(CRYPTOPP_MSC_VERSION)
63 #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
64 #elif defined(__GNUC__) || defined(__clang__) || (__SUNPRO_CC >= 0x5100)
65 #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
66 #elif defined(__xlc__) || defined(__xlC__)
67 #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
68 #else
69 #define CRYPTOPP_ALIGN_DATA(x)
70 #endif
71
72 #endif // CRYPTOPP_CONFIG_ALIGN_H
config_asm.h
Library configuration file.
config_cpu.h
Library configuration file.
config_cxx.h
Library configuration file.
config_ver.h
Library configuration file.