Skip to content

Commit

Permalink
added CMake option USE_BOOST_INT128 to use a 128-bit integer for `M…
Browse files Browse the repository at this point in the history
…athLib:big{u}int` [skip ci]

Co-authored-by: chrchr-github <[email protected]>
  • Loading branch information
firewave and chrchr-github committed Nov 21, 2024
1 parent 9c3a1f6 commit 598582d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ endif()

if(Boost_FOUND)
add_definitions(-DHAVE_BOOST)
if(USE_BOOST_INT128)
add_definitions(-DHAVE_BOOST_INT128)
endif()
endif()

if(ENABLE_CHECK_INTERNAL)
Expand Down
1 change: 1 addition & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ endif()
option(CPPCHK_GLIBCXX_DEBUG "Usage of STL debug checks in Debug build" ON)
option(DISALLOW_THREAD_EXECUTOR "Disallow usage of ThreadExecutor for -j" OFF)
option(USE_BOOST "Usage of Boost" OFF)
option(USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF)
option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF)

if(DISALLOW_THREAD_EXECUTOR AND WIN32)
Expand Down
1 change: 1 addition & 0 deletions cmake/printInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ if(USE_BOOST)
message(STATUS "Boost_FOUND = ${Boost_FOUND}")
message(STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}")
message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
message(STATUS "USE_BOOST_INT128 = ${USE_BOOST_INT128}")
endif()
message(STATUS "USE_LIBCXX = ${USE_LIBCXX}")
message(STATUS)
Expand Down
9 changes: 9 additions & 0 deletions lib/mathlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <cstdint>
#include <string>

#if defined(HAVE_BOOST) && defined(HAVE_BOOST_INT128)
#include <boost/multiprecision/cpp_int.hpp>
#endif

/// @addtogroup Core
/// @{

Expand Down Expand Up @@ -66,8 +70,13 @@ class CPPCHECKLIB MathLib {
value shiftRight(const value &v) const;
};

#if defined(HAVE_BOOST) && defined(HAVE_BOOST_INT128)
using bigint = boost::multiprecision::int128_t;
using biguint = boost::multiprecision::uint128_t;
#else
using bigint = long long;
using biguint = unsigned long long;
#endif
static const int bigint_bits;

/** @brief for conversion of numeric literals - for atoi-like conversions please use strToInt() */
Expand Down

0 comments on commit 598582d

Please sign in to comment.