"Fossies" - the Fresh Open Source Software Archive

Member "src/Crypto/config.h" (10 Oct 2018, 8069 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "config.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef CRYPTOPP_CONFIG_H
    2 #define CRYPTOPP_CONFIG_H
    3 
    4 #ifdef __GNUC__
    5     #define VC_INLINE   static inline __attribute__((always_inline))
    6 #elif defined (_MSC_VER)
    7     #define VC_INLINE   __forceinline
    8 #else
    9     #define VC_INLINE   static inline
   10 #endif
   11 
   12 // Clang pretends to be VC++, too.
   13 //   See http://github.com/weidai11/cryptopp/issues/147
   14 #if defined(_MSC_VER) && defined(__clang__) && !defined(_DCSPKG_ANALYZE)
   15 # error: "Unsupported configuration"
   16 #endif
   17 
   18 #ifdef __GNUC__
   19     #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
   20 #endif
   21 
   22 
   23 // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
   24 #if defined(__clang__ ) && !defined(__apple_build_version__) && !defined(_DCSPKG_ANALYZE) 
   25     #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
   26     #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
   27 #elif defined(__clang__ ) && defined(__apple_build_version__) && !defined(_DCSPKG_ANALYZE)
   28     #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
   29     #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
   30 #endif
   31 
   32 // Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232
   33 //   TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes.
   34 #if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && CRYPTOPP_LLVM_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
   35     #define CRYPTOPP_DISABLE_INTEL_ASM 1
   36 #endif
   37 
   38 #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
   39     // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
   40     // Also see http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size.
   41     #if defined(_M_X64) || defined(__x86_64__) || (__ILP32__ >= 1)
   42         #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
   43     #else
   44         // L1 cache line size is 32 on Pentium III and earlier
   45         #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
   46     #endif
   47 #endif
   48 
   49 #if defined(_MSC_VER) && (_MSC_VER > 1200)
   50     #define CRYPTOPP_MSVC6PP_OR_LATER
   51 #endif
   52 
   53 #ifndef CRYPTOPP_ALIGN_DATA
   54     #if defined(_MSC_VER)
   55         #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
   56     #elif defined(__GNUC__)
   57         #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
   58     #else
   59         #define CRYPTOPP_ALIGN_DATA(x)
   60     #endif
   61 #endif
   62 
   63 #ifndef CRYPTOPP_SECTION_ALIGN16
   64     #if defined(__GNUC__) && !defined(__APPLE__)
   65         // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
   66         #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
   67     #else
   68         #define CRYPTOPP_SECTION_ALIGN16
   69     #endif
   70 #endif
   71 
   72 #if defined(_MSC_VER) || defined(__fastcall)
   73     #define CRYPTOPP_FASTCALL __fastcall
   74 #else
   75     #define CRYPTOPP_FASTCALL
   76 #endif
   77 
   78 #ifdef CRYPTOPP_DISABLE_X86ASM      // for backwards compatibility: this macro had both meanings
   79 #define CRYPTOPP_DISABLE_ASM
   80 #define CRYPTOPP_DISABLE_SSE2
   81 #endif
   82 
   83 // Apple's Clang prior to 5.0 cannot handle SSE2 (and Apple does not use LLVM Clang numbering...)
   84 #if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
   85 # define CRYPTOPP_DISABLE_ASM
   86 #endif
   87 
   88 #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
   89     // C++Builder 2010 does not allow "call label" where label is defined within inline assembly
   90     #define CRYPTOPP_X86_ASM_AVAILABLE
   91 
   92     #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
   93         #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
   94     #else
   95         #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
   96     #endif
   97 
   98     // SSE3 was actually introduced in GNU as 2.17, which was released 6/23/2006, but we can't tell what version of binutils is installed.
   99     // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version. Also see the output of
  100     // `gcc -dM -E -march=native - < /dev/null | grep -i SSE` for preprocessor defines available.
  101     #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102 || defined(__SSSE3__) || defined(__SSE3__))
  102         #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
  103     #else
  104         #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
  105     #endif
  106 #endif
  107 
  108 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
  109     #define CRYPTOPP_X64_MASM_AVAILABLE
  110 #endif
  111 
  112 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
  113     #define CRYPTOPP_X64_ASM_AVAILABLE
  114 #endif
  115 
  116 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) && !defined(_M_ARM)
  117     #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
  118 #else
  119     #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
  120 #endif
  121 
  122 #if !defined(CRYPTOPP_DISABLE_SSSE3) && !defined(CRYPTOPP_DISABLE_AESNI) && CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && (CRYPTOPP_GCC_VERSION >= 40400 || _MSC_FULL_VER >= 150030729 || __INTEL_COMPILER >= 1110 || defined(__AES__))
  123     #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
  124 #else
  125     #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
  126 #endif
  127 
  128 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
  129     #define CRYPTOPP_BOOL_ALIGN16 1
  130 #else
  131     #define CRYPTOPP_BOOL_ALIGN16 0
  132 #endif
  133 
  134 #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE && (defined(__SSE4_1__) || defined(__INTEL_COMPILER) || defined(_MSC_VER))
  135     #define CRYPTOPP_BOOL_SSE41_INTRINSICS_AVAILABLE 1
  136 #else
  137     #define CRYPTOPP_BOOL_SSE41_INTRINSICS_AVAILABLE 0
  138 #endif
  139 
  140 // how to allocate 16-byte aligned memory (for SSE2)
  141 #if defined(_MSC_VER)
  142     #define CRYPTOPP_MM_MALLOC_AVAILABLE
  143 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
  144     #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
  145 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
  146     #define CRYPTOPP_MEMALIGN_AVAILABLE
  147 #else
  148     #define CRYPTOPP_NO_ALIGNED_ALLOC
  149 #endif
  150 
  151 // how to declare class constants
  152 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
  153 #   define CRYPTOPP_CONSTANT(x) enum {x};
  154 #else
  155 #   define CRYPTOPP_CONSTANT(x) static const int x;
  156 #endif
  157 
  158 // Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
  159 // Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than
  160 // the System V ABI specs calls out, like on just about any 32-bit system with Clang.
  161 #if ((__ILP32__ >= 1) || (_ILP32 >= 1)) && defined(__x86_64__)
  162     #define CRYPTOPP_BOOL_X32 1
  163 #else
  164     #define CRYPTOPP_BOOL_X32 0
  165 #endif
  166 
  167 // see http://predef.sourceforge.net/prearch.html
  168 #if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
  169     #define CRYPTOPP_BOOL_X86 1
  170 #else
  171     #define CRYPTOPP_BOOL_X86 0
  172 #endif
  173 
  174 #if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
  175     #define CRYPTOPP_BOOL_X64 1
  176 #else
  177     #define CRYPTOPP_BOOL_X64 0
  178 #endif
  179 
  180 // Undo the ASM and Intrinsic related defines due to X32.
  181 #if CRYPTOPP_BOOL_X32
  182 # undef CRYPTOPP_BOOL_X64
  183 # undef CRYPTOPP_X64_ASM_AVAILABLE
  184 # undef CRYPTOPP_X64_MASM_AVAILABLE
  185 #endif
  186 
  187 #if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS)
  188 #if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || defined(__powerpc__) || (__ARM_FEATURE_UNALIGNED >= 1))
  189     #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
  190 #endif
  191 #endif
  192 
  193 // this version of the macro is fastest on Pentium 3 and Pentium 4 with MSVC 6 SP5 w/ Processor Pack
  194 #define GETBYTE(x, y) (unsigned int)((unsigned char)((x)>>(8*(y))))
  195 // these may be faster on other CPUs/compilers
  196 // #define GETBYTE(x, y) (unsigned int)(((x)>>(8*(y)))&255)
  197 // #define GETBYTE(x, y) (((byte *)&(x))[y])
  198 
  199 #define CRYPTOPP_GET_BYTE_AS_BYTE(x, y) ((byte)((x)>>(8*(y))))
  200 
  201 #endif