Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:54

0001 // config_align.h - written and placed in public domain by Jeffrey Walton

0002 //                  the bits that make up this source file are from the

0003 //                  library's monolithic config.h.

0004 
0005 /// \file config_align.h

0006 /// \brief Library configuration file

0007 /// \details <tt>config_align.h</tt> provides defines for aligned memory

0008 ///  allocations.

0009 /// \details <tt>config.h</tt> was split into components in May 2019 to better

0010 ///  integrate with Autoconf and its feature tests. The splitting occurred so

0011 ///  users could continue to include <tt>config.h</tt> while allowing Autoconf

0012 ///  to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using

0013 ///  its feature tests.

0014 /// \note You should include <tt>config.h</tt> rather than <tt>config_align.h</tt>

0015 ///  directly.

0016 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,

0017 ///  Make config.h more autoconf friendly</A>,

0018 ///  <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>

0019 ///  on the Crypto++ wiki

0020 /// \since Crypto++ 8.3

0021 
0022 #ifndef CRYPTOPP_CONFIG_ALIGN_H
0023 #define CRYPTOPP_CONFIG_ALIGN_H
0024 
0025 #include "config_asm.h"  // CRYPTOPP_DISABLE_ASM
0026 #include "config_cpu.h"  // X86, X32, X64, ARM32, ARM64, etc
0027 #include "config_cxx.h"  // CRYPTOPP_CXX11_ALIGNAS
0028 #include "config_ver.h"  // Compiler versions
0029 
0030 // Nearly all Intel's and AMD's have SSE. Enable it independent of SSE ASM and intrinsics.

0031 // ARM NEON and ARMv8 ASIMD only need natural alignment of an element in the vector.

0032 // Altivec through POWER7 need vector alignment. POWER8 and POWER9 relax the requirement.

0033 #if defined(CRYPTOPP_DISABLE_ASM)
0034     #define CRYPTOPP_BOOL_ALIGN16 0
0035 #elif (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || \
0036        CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
0037     #define CRYPTOPP_BOOL_ALIGN16 1
0038 #else
0039     #define CRYPTOPP_BOOL_ALIGN16 0
0040 #endif
0041 
0042 // How to allocate 16-byte aligned memory (for SSE2)

0043 // posix_memalign see https://forum.kde.org/viewtopic.php?p=66274

0044 #if defined(CRYPTOPP_MSC_VERSION)
0045     #define CRYPTOPP_MM_MALLOC_AVAILABLE
0046 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
0047     #define CRYPTOPP_MEMALIGN_AVAILABLE
0048 #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
0049     #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
0050 #elif (defined(_GNU_SOURCE) || ((_XOPEN_SOURCE + 0) >= 600)) && (_POSIX_ADVISORY_INFO > 0)
0051     #define CRYPTOPP_POSIX_MEMALIGN_AVAILABLE
0052 #else
0053     #define CRYPTOPP_NO_ALIGNED_ALLOC
0054 #endif
0055 
0056 // Sun Studio Express 3 (December 2006) provides GCC-style attributes.

0057 // IBM XL C/C++ alignment modifier per Optimization Guide, pp. 19-20.

0058 // __IBM_ATTRIBUTES per XLC 12.1 AIX Compiler Manual, p. 473.

0059 // CRYPTOPP_ALIGN_DATA may not be reliable on AIX.

0060 #if defined(CRYPTOPP_CXX11_ALIGNAS)
0061     #define CRYPTOPP_ALIGN_DATA(x) alignas(x)
0062 #elif defined(CRYPTOPP_MSC_VERSION)
0063     #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
0064 #elif defined(__GNUC__) || defined(__clang__) || (__SUNPRO_CC >= 0x5100)
0065     #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
0066 #elif defined(__xlc__) || defined(__xlC__)
0067     #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
0068 #else
0069     #define CRYPTOPP_ALIGN_DATA(x)
0070 #endif
0071 
0072 #endif  // CRYPTOPP_CONFIG_ALIGN_H