config_misc.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // config_misc.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. /// \file config_misc.h
  5. /// \brief Library configuration file
  6. /// \details <tt>config_misc.h</tt> provides miscellaneous defines.
  7. /// \details <tt>config.h</tt> was split into components in May 2019 to better
  8. /// integrate with Autoconf and its feature tests. The splitting occurred so
  9. /// users could continue to include <tt>config.h</tt> while allowing Autoconf
  10. /// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
  11. /// its feature tests.
  12. /// \note You should include <tt>config.h</tt> rather than <tt>config_misc.h</tt>
  13. /// directly.
  14. /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,
  15. /// Make config.h more autoconf friendly</A>,
  16. /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>
  17. /// on the Crypto++ wiki
  18. /// \since Crypto++ 8.3
  19. #ifndef CRYPTOPP_CONFIG_MISC_H
  20. #define CRYPTOPP_CONFIG_MISC_H
  21. #include "config_asm.h"
  22. #include "config_cxx.h"
  23. #include "config_os.h"
  24. #include "config_ver.h"
  25. // Define this if running on a big-endian CPU
  26. // big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not non-0
  27. #if !defined(CRYPTOPP_LITTLE_ENDIAN) && !defined(CRYPTOPP_BIG_ENDIAN) && (defined(__BIG_ENDIAN__) || (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || (defined(__m68k__) || defined(__MC68K__)) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
  28. # define CRYPTOPP_BIG_ENDIAN 1
  29. #endif
  30. // Define this if running on a little-endian CPU
  31. // big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not non-0
  32. #if !defined(CRYPTOPP_BIG_ENDIAN) && !defined(CRYPTOPP_LITTLE_ENDIAN)
  33. # define CRYPTOPP_LITTLE_ENDIAN 1
  34. #endif
  35. // Define this if you want to set a prefix for TestData/ and TestVectors/
  36. // Be sure to add the trailing slash since its simple concatenation.
  37. // After https://github.com/weidai11/cryptopp/issues/760 the library
  38. // should find the test vectors and data without much effort. It
  39. // will search in "./" and "$ORIGIN/../share/cryptopp" automatically.
  40. #ifndef CRYPTOPP_DATA_DIR
  41. # define CRYPTOPP_DATA_DIR ""
  42. #endif
  43. // Define this to disable the test suite from searching for test
  44. // vectors and data in "./" and "$ORIGIN/../share/cryptopp". The
  45. // library will still search in CRYPTOPP_DATA_DIR, regardless.
  46. // Some distros may want to disable this feature. Also see
  47. // https://github.com/weidai11/cryptopp/issues/760
  48. // #ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH
  49. // # define CRYPTOPP_DISABLE_DATA_DIR_SEARCH
  50. // #endif
  51. // Define this if you want or need the library's memcpy_s and memmove_s.
  52. // See http://github.com/weidai11/cryptopp/issues/28.
  53. // #if !defined(CRYPTOPP_WANT_SECURE_LIB)
  54. // # define CRYPTOPP_WANT_SECURE_LIB
  55. // #endif
  56. // Define this if ARMv8 shifts are slow. ARM Cortex-A53 and Cortex-A57 shift
  57. // operation perform poorly, so NEON and ASIMD code that relies on shifts
  58. // or rotates often performs worse than C/C++ code. Also see
  59. // http://github.com/weidai11/cryptopp/issues/367.
  60. #define CRYPTOPP_SLOW_ARMV8_SHIFT 1
  61. // CRYPTOPP_DEBUG enables the library's CRYPTOPP_ASSERT. CRYPTOPP_ASSERT
  62. // raises a SIGTRAP (Unix) or calls DebugBreak() (Windows). CRYPTOPP_ASSERT
  63. // is only in effect when CRYPTOPP_DEBUG, DEBUG or _DEBUG is defined. Unlike
  64. // Posix assert, CRYPTOPP_ASSERT is not affected by NDEBUG (or failure to
  65. // define it). According to the ndk-build docs, Android use NDK_DEBUG=1 to
  66. // signal a DEBUG build (and NDK_DEBUG=0 to signal non-DEBUG build).
  67. // Also see http://github.com/weidai11/cryptopp/issues/277, CVE-2016-7420 and
  68. // https://developer.android.com/ndk/guides/ndk-build
  69. #if (defined(DEBUG) || defined(_DEBUG)) || (defined(NDK_DEBUG) && (NDK_DEBUG > 0))
  70. # undef CRYPTOPP_DEBUG
  71. # define CRYPTOPP_DEBUG 1
  72. #endif
  73. // File system code to use when creating GZIP archive.
  74. // http://www.gzip.org/format.txt
  75. #if !defined(GZIP_OS_CODE)
  76. # if defined(__macintosh__)
  77. # define GZIP_OS_CODE 7
  78. # elif defined(__unix__) || defined(__linux__)
  79. # define GZIP_OS_CODE 3
  80. # else
  81. # define GZIP_OS_CODE 0
  82. # endif
  83. #endif
  84. // Try this if your CPU has 256K internal cache or a slow multiply instruction
  85. // and you want a (possibly) faster IDEA implementation using log tables
  86. // #define IDEA_LARGECACHE
  87. // Define this if, for the linear congruential RNG, you want to use
  88. // the original constants as specified in S.K. Park and K.W. Miller's
  89. // CACM paper.
  90. // #define LCRNG_ORIGINAL_NUMBERS
  91. // Define this if you want Integer's operator<< to honor std::showbase (and
  92. // std::noshowbase). If defined, Integer will use a suffix of 'b', 'o', 'h'
  93. // or '.' (the last for decimal) when std::showbase is in effect. If
  94. // std::noshowbase is set, then the suffix is not added to the Integer. If
  95. // not defined, existing behavior is preserved and Integer will use a suffix
  96. // of 'b', 'o', 'h' or '.' (the last for decimal).
  97. // #define CRYPTOPP_USE_STD_SHOWBASE
  98. // Define this if you want to decouple AlgorithmParameters and Integer
  99. // The decoupling should make it easier for the linker to remove Integer
  100. // related code for those who do not need Integer, and avoid a potential
  101. // race during AssignIntToInteger pointer initialization. Also
  102. // see http://github.com/weidai11/cryptopp/issues/389.
  103. // #define CRYPTOPP_NO_ASSIGN_TO_INTEGER
  104. // Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
  105. #if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || \
  106. (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
  107. #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
  108. #endif
  109. // Portable way to suppress warnings.
  110. // Moved from misc.h due to circular depenedencies.
  111. #ifndef CRYPTOPP_UNUSED
  112. #define CRYPTOPP_UNUSED(x) ((void)(x))
  113. #endif
  114. // how to disable inlining
  115. #if defined(_MSC_VER)
  116. # define CRYPTOPP_NOINLINE_DOTDOTDOT
  117. # define CRYPTOPP_NOINLINE __declspec(noinline)
  118. #elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__)
  119. # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
  120. # define CRYPTOPP_NOINLINE __attribute__((noinline))
  121. #elif defined(__GNUC__)
  122. # define CRYPTOPP_NOINLINE_DOTDOTDOT
  123. # define CRYPTOPP_NOINLINE __attribute__((noinline))
  124. #else
  125. # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
  126. # define CRYPTOPP_NOINLINE
  127. #endif
  128. // http://stackoverflow.com/a/13867690/608639
  129. #if defined(CRYPTOPP_CXX11_CONSTEXPR)
  130. # define CRYPTOPP_STATIC_CONSTEXPR static constexpr
  131. # define CRYPTOPP_CONSTEXPR constexpr
  132. #else
  133. # define CRYPTOPP_STATIC_CONSTEXPR static
  134. # define CRYPTOPP_CONSTEXPR
  135. #endif // CRYPTOPP_CXX11_CONSTEXPR
  136. #if defined(CRYPTOPP_DOXYGEN_PROCESSING)
  137. # define CRYPTOPP_CONSTANT(x) static const int x
  138. #elif defined(CRYPTOPP_CXX11_STRONG_ENUM)
  139. # define CRYPTOPP_CONSTANT(x) enum : int { x }
  140. #elif defined(CRYPTOPP_CXX11_CONSTEXPR)
  141. # define CRYPTOPP_CONSTANT(x) constexpr static int x
  142. #else
  143. # define CRYPTOPP_CONSTANT(x) static const int x
  144. #endif
  145. // Warnings
  146. #ifdef _MSC_VER
  147. // 4127: conditional expression is constant
  148. // 4512: assignment operator not generated
  149. // 4661: no suitable definition provided for explicit template instantiation request
  150. // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
  151. # pragma warning(disable: 4127 4512 4661 4910)
  152. // _MSC_VER 1920 is VS2019
  153. # if _MSC_VER >= 1920
  154. // 5054: operator '|': deprecated between enumerations of different types
  155. # pragma warning(disable: 5054)
  156. # endif
  157. // Security related, possible defects
  158. // http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx
  159. # pragma warning(once: 4191 4242 4263 4264 4266 4302 4826 4905 4906 4928)
  160. #endif
  161. #ifdef __BORLANDC__
  162. // 8037: non-const function called for const object. needed to work around BCB2006 bug
  163. # pragma warn -8037
  164. #endif
  165. // [GCC Bug 53431] "C++ preprocessor ignores #pragma GCC diagnostic". Clang honors it.
  166. #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
  167. # pragma GCC diagnostic ignored "-Wunknown-pragmas"
  168. # pragma GCC diagnostic ignored "-Wunused-function"
  169. #endif
  170. #endif // CRYPTOPP_CONFIG_MISC_H