├── .clang-tidy
├── .gcov
└── make
│ ├── make_gcov_01_generic.gmk
│ ├── make_gcov_02_files.gmk
│ └── make_gcov_03_flags.gmk
├── .github
├── toolchains
│ └── gcc.cmake
└── workflows
│ ├── CodeQL.yml
│ ├── wide_integer.yml
│ ├── wide_integer_codecov.yml
│ ├── wide_integer_fuzzing.yml
│ └── wide_integer_sonar.yml
├── .gitignore
├── .props
└── Directory.Build.props
├── .tidy
└── make
│ ├── make_tidy_01_generic.gmk
│ ├── make_tidy_02_files.gmk
│ └── make_tidy_03_flags.gmk
├── CMakeLists.txt
├── LICENSE_1_0.txt
├── README.md
├── boost
└── multiprecision
│ └── uintwide_t_backend.hpp
├── codecov.yml
├── examples
├── CMakeLists.txt
├── build
│ └── test_examples.sh
├── example000_numeric_limits.cpp
├── example000a_builtin_convert.cpp
├── example001_mul_div.cpp
├── example001a_div_mod.cpp
├── example002_shl_shr.cpp
├── example003_sqrt.cpp
├── example003a_cbrt.cpp
├── example004_rootk_pow.cpp
├── example005_powm.cpp
├── example005a_pow_factors_of_p99.cpp
├── example006_gcd.cpp
├── example007_random_generator.cpp
├── example008_miller_rabin_prime.cpp
├── example008a_miller_rabin_prime.cpp
├── example009_timed_mul.cpp
├── example009a_timed_mul_4_by_4.cpp
├── example009b_timed_mul_8_by_8.cpp
├── example010_uint48_t.cpp
├── example011_uint24_t.cpp
├── example012_rsa_crypto.cpp
├── example013_ecdsa_sign_verify.cpp
├── example014_pi_spigot_wide.cpp
└── example_uintwide_t.h
├── math
└── wide_integer
│ └── uintwide_t.h
├── run_fuzzing.sh
├── sonar-project.properties
├── target
├── build
│ └── test_examples_emulator.gdb
└── micros
│ └── stm32f429
│ └── make
│ ├── single
│ └── crt.cpp
│ └── stm32f429.ld
├── test
├── CMakeLists.txt
├── coverity.c
├── fuzzing
│ ├── test_fuzzing_add.cpp
│ ├── test_fuzzing_div.cpp
│ ├── test_fuzzing_mul.cpp
│ ├── test_fuzzing_powm.cpp
│ ├── test_fuzzing_prime.cpp
│ ├── test_fuzzing_sdiv.cpp
│ ├── test_fuzzing_sqrt.cpp
│ └── test_fuzzing_sub.cpp
├── parallel_for.h
├── stopwatch.h
├── test.cpp
├── test.hpp
├── test_arithmetic.hpp
├── test_uintwide_t.h
├── test_uintwide_t_boost_backend.cpp
├── test_uintwide_t_boost_backend_via_test_arithmetic.cpp
├── test_uintwide_t_edge_cases.cpp
├── test_uintwide_t_examples.cpp
├── test_uintwide_t_float_convert.cpp
├── test_uintwide_t_int_convert.cpp
├── test_uintwide_t_n_base.cpp
├── test_uintwide_t_n_base.h
├── test_uintwide_t_n_binary_ops_base.cpp
├── test_uintwide_t_n_binary_ops_base.h
├── test_uintwide_t_n_binary_ops_mul_div_4_by_4_template.h
├── test_uintwide_t_n_binary_ops_mul_n_by_m_template.h
├── test_uintwide_t_n_binary_ops_template.h
├── test_uintwide_t_n_binary_ops_template_signed.h
├── test_uintwide_t_n_number_theory_funcs_template.h
├── test_uintwide_t_spot_values.cpp
└── test_uintwide_t_xtra_from_issue_335.cpp
├── util
└── utility
│ └── util_pseudorandom_time_point_seed.h
├── wide_integer.sln
├── wide_integer.vcxproj
├── wide_integer.vcxproj.filters
├── wide_integer_vs2022.sln
├── wide_integer_vs2022.vcxproj
└── wide_integer_vs2022.vcxproj.filters
/.gcov/make/make_gcov_01_generic.gmk:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022 - 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | PATH_MAKE = $(CURDIR)
9 | PATH_PRJ = $(PATH_MAKE)/../..
10 | PATH_SRC = $(PATH_PRJ)
11 | PATH_BIN = $(PATH_MAKE)/bin
12 | PATH_ERR = $(PATH_MAKE)/err
13 | PATH_OBJ = $(PATH_MAKE)/obj
14 |
15 | CAT = cat
16 | GNUECHO = echo
17 | LS = ls
18 | MKDIR = mkdir
19 | GCOV = gcov
20 | LCOV = lcov
21 | GENHTML = genhtml
22 | RM = rm
23 | SED = sed
24 |
25 | include make_gcov_02_files.gmk
26 | include make_gcov_03_flags.gmk
27 |
28 | FILES_ALL = $(FILES_PRJ)
29 | FILES_O = $(addprefix $(PATH_OBJ)/, $(notdir $(addsuffix .o, $(FILES_ALL))))
30 | FILES_GCOV = $(addprefix $(PATH_OBJ)/, $(notdir $(addsuffix .gcov, $(FILES_ALL))))
31 |
32 | # ------------------------------------------------------------------------------
33 | # VPATH definition: VPATH is required for make to find the source files.
34 | # ------------------------------------------------------------------------------
35 | VPATH := $(sort $(dir $(FILES_ALL)))
36 |
37 |
38 | # ------------------------------------------------------------------------------
39 | # Executable file:
40 | # ------------------------------------------------------------------------------
41 |
42 | .PHONY: $(PATH_BIN)/wide_integer.exe
43 | $(PATH_BIN)/wide_integer.exe: $(FILES_O)
44 | # Link coverage-instrumented executable
45 | @$(GNUECHO) +++ link object files to $(PATH_BIN)/wide_integer.exe
46 | @$(CC) -x none $(CXXFLAGS) $(FILES_O) -o $(PATH_BIN)/wide_integer.exe
47 | @$(GNUECHO)
48 |
49 |
50 | # ------------------------------------------------------------------------------
51 | # Main dependency:
52 | # Compile all files and link them.
53 | # Run gcov and get results.
54 | # (See also https://github.com/codecov/example-cpp11-cmake)
55 | # ------------------------------------------------------------------------------
56 |
57 | .PHONY: gcov
58 | gcov: $(PATH_BIN)/wide_integer.exe
59 | # Obtain results
60 | @$(GNUECHO) +++ execute $(PATH_BIN)/wide_integer.exe
61 | @$(PATH_BIN)/wide_integer.exe
62 | @$(GNUECHO)
63 | @$(GNUECHO) +++ running gcov
64 | @$(GCOV) $(GCOV_FLAGS) $(addsuffix .cpp,$(FILES_PRJ))
65 | @$(GNUECHO)
66 | @$(GNUECHO) +++ running lcov
67 | @$(LCOV) $(LCOV_BRANCH) -c --directory obj --output-file coverage_unfiltered.info
68 | @$(LCOV) $(LCOV_BRANCH) --remove coverage_unfiltered.info $(LCOV_REMOVES) --output-file coverage.info
69 | @$(GNUECHO)
70 | @$(GNUECHO) +++ running genhtml
71 | @$(GENHTML) coverage.info $(LCOV_BRANCH) --demangle-cpp --output-directory $(PATH_BIN)/report
72 | @$(GNUECHO)
73 |
74 | # ------------------------------------------------------------------------------
75 | # Clean temporary files.
76 | # ------------------------------------------------------------------------------
77 |
78 | .PHONY: clean
79 | clean:
80 | # creating output directories
81 | @$(GNUECHO) +++ cleaning output directories
82 | @-$(RM) -rf $(PATH_BIN)* || uname -r
83 | @-$(RM) -rf $(PATH_ERR)* || uname -r
84 | @-$(RM) -rf $(PATH_OBJ)* || uname -r
85 | @-$(RM) -f *.gcov || uname -r
86 | @-$(RM) -f coverage* || uname -r
87 | @$(GNUECHO)
88 |
89 |
90 | # ------------------------------------------------------------------------------
91 | # Prepare the gcov build.
92 | # ------------------------------------------------------------------------------
93 |
94 | .PHONY: prepare
95 | prepare: clean
96 | @$(GNUECHO) +++ creating output directories
97 | @-$(MKDIR) -p $(PATH_BIN)
98 | @-$(MKDIR) -p $(PATH_ERR)
99 | @-$(MKDIR) -p $(PATH_OBJ)
100 | @$(GNUECHO)
101 | @$(GNUECHO) +++ print gcov version
102 | @$(GCOV) --version
103 | @$(GNUECHO)
104 | @$(GNUECHO) +++ print include paths
105 | @$(GNUECHO) $(C_INCLUDES)
106 | @$(GNUECHO)
107 |
108 | # ------------------------------------------------------------------------------
109 | # pattern rule for compilation of cpp-files
110 | # ------------------------------------------------------------------------------
111 | $(PATH_OBJ)/%.o : %.cpp
112 | @-$(GNUECHO) +++ compiling: $(notdir $<) to $(notdir $(PATH_OBJ)/$(basename $(@F)).o)
113 | @-$(CC) $(CXXFLAGS) -x c++ -c $(C_INCLUDES) $(C_DEFINES) $< -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err
114 | @-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err
115 |
--------------------------------------------------------------------------------
/.gcov/make/make_gcov_02_files.gmk:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | FILES_PRJ = $(PATH_SRC)/test/test \
9 | $(PATH_SRC)/test/test_uintwide_t_boost_backend \
10 | $(PATH_SRC)/test/test_uintwide_t_edge_cases \
11 | $(PATH_SRC)/test/test_uintwide_t_examples \
12 | $(PATH_SRC)/test/test_uintwide_t_float_convert \
13 | $(PATH_SRC)/test/test_uintwide_t_int_convert \
14 | $(PATH_SRC)/test/test_uintwide_t_n_base \
15 | $(PATH_SRC)/test/test_uintwide_t_n_binary_ops_base \
16 | $(PATH_SRC)/test/test_uintwide_t_spot_values \
17 | $(PATH_SRC)/examples/example000a_builtin_convert \
18 | $(PATH_SRC)/examples/example000_numeric_limits \
19 | $(PATH_SRC)/examples/example001_mul_div \
20 | $(PATH_SRC)/examples/example001a_div_mod \
21 | $(PATH_SRC)/examples/example002_shl_shr \
22 | $(PATH_SRC)/examples/example003_sqrt \
23 | $(PATH_SRC)/examples/example003a_cbrt \
24 | $(PATH_SRC)/examples/example004_rootk_pow \
25 | $(PATH_SRC)/examples/example005_powm \
26 | $(PATH_SRC)/examples/example005a_pow_factors_of_p99 \
27 | $(PATH_SRC)/examples/example006_gcd \
28 | $(PATH_SRC)/examples/example007_random_generator \
29 | $(PATH_SRC)/examples/example008_miller_rabin_prime \
30 | $(PATH_SRC)/examples/example008a_miller_rabin_prime \
31 | $(PATH_SRC)/examples/example009_timed_mul \
32 | $(PATH_SRC)/examples/example009a_timed_mul_4_by_4 \
33 | $(PATH_SRC)/examples/example009b_timed_mul_8_by_8 \
34 | $(PATH_SRC)/examples/example010_uint48_t \
35 | $(PATH_SRC)/examples/example011_uint24_t \
36 | $(PATH_SRC)/examples/example012_rsa_crypto \
37 | $(PATH_SRC)/examples/example013_ecdsa_sign_verify \
38 | $(PATH_SRC)/examples/example014_pi_spigot_wide
39 |
--------------------------------------------------------------------------------
/.gcov/make/make_gcov_03_flags.gmk:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022 - 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | BOOST_ROOT_FOR_GCOV = /mnt/c/boost/boost_1_85_0
9 | CC = g++
10 | STD = c++14
11 | ALL_COV = 0
12 |
13 | ifneq ($(MY_BOOST_ROOT),)
14 | BOOST_ROOT_FOR_GCOV := $(MY_BOOST_ROOT)
15 | endif
16 |
17 | ifneq ($(MY_CC),)
18 | CC := $(MY_CC)
19 | endif
20 |
21 | ifneq ($(MY_STD),)
22 | STD := $(MY_STD)
23 | endif
24 |
25 | ifneq ($(MY_STD),)
26 | STD := $(MY_STD)
27 | endif
28 |
29 | ifneq ($(MY_ALL_COV),)
30 | ALL_COV := $(MY_ALL_COV)
31 | endif
32 |
33 | CXXFLAGS = -march=native \
34 | -mtune=native \
35 | -O2 \
36 | -Wall \
37 | -Wextra \
38 | -Wconversion \
39 | -Wsign-conversion \
40 | -std=$(STD) \
41 | -pthread \
42 | -lpthread \
43 | -fno-inline-functions \
44 | -fprofile-arcs \
45 | -ftest-coverage
46 |
47 | C_DEFINES = WIDE_INTEGER_HAS_COVERAGE \
48 | WIDE_INTEGER_HAS_LIMB_TYPE_UINT64 \
49 | WIDE_INTEGER_HAS_MUL_8_BY_8_UNROLL
50 |
51 | C_INCLUDES = $(PATH_SRC) \
52 | $(BOOST_ROOT_FOR_GCOV)
53 |
54 | C_DEFINES :=$(addprefix -D,$(C_DEFINES))
55 | C_INCLUDES :=$(addprefix -I,$(C_INCLUDES))
56 |
57 | GCOV_FLAGS = --object-directory obj \
58 | --demangled-names
59 |
60 |
61 | # ------------------------------------------------------------------------------
62 | # All gcov flags: The GCOV_FLAGS below are equivalent to -abcfu
63 | # ------------------------------------------------------------------------------
64 |
65 | ifneq ($(ALL_COV),0)
66 | GCOV_FLAGS := $(GCOV_FLAGS) \
67 | --all-blocks \
68 | --branch-counts \
69 | --branch-probabilities \
70 | --function-summaries \
71 | --unconditional-branches
72 | endif
73 |
74 | LCOV_BRANCH =
75 |
76 | ifneq ($(ALL_COV),0)
77 | LCOV_BRANCH := --rc lcov_branch_coverage=1
78 | endif
79 |
80 | LCOV_REMOVES = '/usr/*' \
81 | '*boost/*'
82 |
--------------------------------------------------------------------------------
/.github/toolchains/gcc.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_CXX_FLAGS_INIT "-Wall -Wconversion -Werror -Wextra -Wno-psabi -Wpedantic -Wshadow -Wundef")
2 |
--------------------------------------------------------------------------------
/.github/workflows/CodeQL.yml:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022 - 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | name: CodeQL
9 | on:
10 | push:
11 | branches:
12 | - '**'
13 | pull_request:
14 | types: [opened, synchronize, reopened]
15 | jobs:
16 | analyze:
17 | name: Analyze
18 | runs-on: ubuntu-latest
19 | permissions:
20 | actions: read
21 | contents: read
22 | security-events: write
23 | strategy:
24 | fail-fast: false
25 | matrix:
26 | language: [ cpp ]
27 |
28 | steps:
29 | - name: Checkout
30 | uses: actions/checkout@v4
31 |
32 | - name: clone-submods-bootstrap-headers-boost-develop
33 | run: |
34 | git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
35 | cd ../boost-root
36 | git submodule update --init tools
37 | git submodule update --init libs/config
38 | git submodule update --init libs/multiprecision
39 | ./bootstrap.sh
40 | ./b2 headers
41 |
42 | - name: Configure (cpp)
43 | if: ${{ matrix.language == 'cpp' }}
44 | run: echo configure_command_empty
45 |
46 | - name: Initialize CodeQL
47 | uses: github/codeql-action/init@v3
48 | with:
49 | languages: ${{ matrix.language }}
50 | queries: +security-and-quality
51 |
52 | - name: Build cpp
53 | if: ${{ matrix.language == 'cpp' }}
54 | run: |
55 | echo 'build application on the command line'
56 | g++ -fno-exceptions -fno-rtti -finline-functions -m64 -O2 -Werror -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++14 -DWIDE_INTEGER_HAS_LIMB_TYPE_UINT64 -I. -I../boost-root -pthread -lpthread test/test.cpp test/test_uintwide_t_boost_backend.cpp test/test_uintwide_t_edge_cases.cpp test/test_uintwide_t_examples.cpp test/test_uintwide_t_float_convert.cpp test/test_uintwide_t_int_convert.cpp test/test_uintwide_t_n_base.cpp test/test_uintwide_t_n_binary_ops_base.cpp test/test_uintwide_t_spot_values.cpp examples/example000_numeric_limits.cpp examples/example000a_builtin_convert.cpp examples/example001_mul_div.cpp examples/example001a_div_mod.cpp examples/example002_shl_shr.cpp examples/example003_sqrt.cpp examples/example003a_cbrt.cpp examples/example004_rootk_pow.cpp examples/example005_powm.cpp examples/example005a_pow_factors_of_p99.cpp examples/example006_gcd.cpp examples/example007_random_generator.cpp examples/example008_miller_rabin_prime.cpp examples/example008a_miller_rabin_prime.cpp examples/example009_timed_mul.cpp examples/example009a_timed_mul_4_by_4.cpp examples/example009b_timed_mul_8_by_8.cpp examples/example010_uint48_t.cpp examples/example011_uint24_t.cpp examples/example012_rsa_crypto.cpp examples/example013_ecdsa_sign_verify.cpp examples/example014_pi_spigot_wide.cpp -o wide_integer.exe
57 |
58 | - name: Perform CodeQL Analysis
59 | uses: github/codeql-action/analyze@v3
60 | with:
61 | category: "/language:${{ matrix.language }}"
62 |
--------------------------------------------------------------------------------
/.github/workflows/wide_integer_codecov.yml:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022 - 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | name: wide_integer_codecov
9 | on:
10 | push:
11 | branches:
12 | - master
13 | pull_request:
14 | types: [opened, synchronize, reopened]
15 | jobs:
16 | gnumake-gcc-gcov-native:
17 | runs-on: ubuntu-latest
18 | defaults:
19 | run:
20 | shell: bash
21 | strategy:
22 | fail-fast: false
23 | matrix:
24 | standard: [ c++14 ]
25 | compiler: [ g++ ]
26 | steps:
27 | - uses: actions/checkout@v4
28 | with:
29 | fetch-depth: '0'
30 | - name: update-tools
31 | run: sudo apt install lcov
32 | - name: clone-submods-bootstrap-headers-boost-develop
33 | run: |
34 | git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
35 | cd ../boost-root
36 | git submodule update --init tools
37 | git submodule update --init libs/config
38 | git submodule update --init libs/multiprecision
39 | ./bootstrap.sh
40 | ./b2 headers
41 | - name: gnumake-gcc-gcov-native
42 | run: |
43 | grep BOOST_VERSION ../boost-root/boost/version.hpp
44 | cd .gcov/make
45 | echo "build and run gcov/lcov/genhtml"
46 | echo "make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}"
47 | echo
48 | make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}
49 | echo
50 | echo "make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}"
51 | echo
52 | make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}
53 | echo
54 | echo "return to wide-integer root directory"
55 | cd ../..
56 | - name: upload-codecov
57 | uses: codecov/codecov-action@v4
58 | with:
59 | plugin: gcov
60 | file: ${{ runner.workspace }}/wide-integer/.gcov/make/coverage.info
61 | token: ${{ secrets.CODECOV_TOKEN }}
62 | fail_ci_if_error: true
63 | verbose: false
64 |
--------------------------------------------------------------------------------
/.github/workflows/wide_integer_fuzzing.yml:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | name: wide_integer_fuzzing
9 | on:
10 | push:
11 | branches:
12 | - '**'
13 | pull_request:
14 | schedule:
15 | - cron: '0 2 * * *' # run at 2:00 AM UTC
16 | jobs:
17 | clang-fuzzing:
18 | runs-on: ubuntu-latest
19 | defaults:
20 | run:
21 | shell: bash
22 | strategy:
23 | fail-fast: false
24 | matrix:
25 | compiler: [ clang++ ]
26 | steps:
27 | - uses: actions/checkout@v4
28 | with:
29 | fetch-depth: '0'
30 | - name: update-tools
31 | run: sudo apt install llvm lld
32 | - name: clone-submods-bootstrap-headers-boost-develop
33 | run: |
34 | git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
35 | cd ../boost-root
36 | git submodule update --init tools
37 | git submodule update --init libs/config
38 | git submodule update --init libs/multiprecision
39 | ./bootstrap.sh
40 | ./b2 headers
41 | - name: clang-fuzzing
42 | run: |
43 | grep BOOST_VERSION ../boost-root/boost/version.hpp
44 | ${{ matrix.compiler }} -v
45 | echo "run fuzzing test"
46 | ./run_fuzzing.sh
47 |
--------------------------------------------------------------------------------
/.github/workflows/wide_integer_sonar.yml:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022 - 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | name: wide_integer_sonar
9 | on:
10 | push:
11 | branches:
12 | - master
13 | pull_request:
14 | types: [opened, synchronize, reopened]
15 | jobs:
16 | build:
17 | name: sonar-gcc-native
18 | runs-on: ubuntu-latest
19 | env:
20 | SONAR_SCANNER_VERSION: 5.0.1.3006
21 | SONAR_SERVER_URL: "https://sonarcloud.io"
22 | BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
23 | steps:
24 | - uses: actions/checkout@v4
25 | with:
26 | fetch-depth: 0
27 | - name: clone-submods-bootstrap-headers-boost-develop
28 | run: |
29 | git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
30 | cd ../boost-root
31 | git submodule update --init tools
32 | git submodule update --init libs/config
33 | git submodule update --init libs/multiprecision
34 | ./bootstrap.sh
35 | ./b2 headers
36 | - name: Set up JDK 17
37 | uses: actions/setup-java@v4
38 | with:
39 | distribution: 'temurin'
40 | java-version: '17'
41 | overwrite-settings: true
42 | - name: Download and set up sonar-scanner
43 | env:
44 | SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
45 | run: |
46 | mkdir -p $HOME/.sonar
47 | curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
48 | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
49 | echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
50 | - name: Download and set up build-wrapper
51 | env:
52 | BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
53 | run: |
54 | curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
55 | unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
56 | echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
57 | - name: Run build-wrapper
58 | run: |
59 | java -version
60 | build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} g++ -finline-functions -m64 -O3 -Werror -Wall -Wextra -Wconversion -Wsign-conversion -std=c++14 -DWIDE_INTEGER_HAS_LIMB_TYPE_UINT64 -DWIDE_INTEGER_HAS_MUL_8_BY_8_UNROLL -I. -I../boost-root -pthread -lpthread test/test.cpp test/test_uintwide_t_boost_backend.cpp test/test_uintwide_t_edge_cases.cpp test/test_uintwide_t_examples.cpp test/test_uintwide_t_float_convert.cpp test/test_uintwide_t_int_convert.cpp test/test_uintwide_t_n_base.cpp test/test_uintwide_t_n_binary_ops_base.cpp test/test_uintwide_t_spot_values.cpp examples/example000_numeric_limits.cpp examples/example000a_builtin_convert.cpp examples/example001_mul_div.cpp examples/example001a_div_mod.cpp examples/example002_shl_shr.cpp examples/example003_sqrt.cpp examples/example003a_cbrt.cpp examples/example004_rootk_pow.cpp examples/example005_powm.cpp examples/example005a_pow_factors_of_p99.cpp examples/example006_gcd.cpp examples/example007_random_generator.cpp examples/example008_miller_rabin_prime.cpp examples/example008a_miller_rabin_prime.cpp examples/example009_timed_mul.cpp examples/example009a_timed_mul_4_by_4.cpp examples/example009b_timed_mul_8_by_8.cpp examples/example010_uint48_t.cpp examples/example011_uint24_t.cpp examples/example012_rsa_crypto.cpp examples/example013_ecdsa_sign_verify.cpp examples/example014_pi_spigot_wide.cpp -o wide_integer.exe
61 | - name: Run sonar-scanner
62 | env:
63 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
65 | run: |
66 | java -version
67 | sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
68 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs/
2 | wide_integer.vcxproj.user
3 | x64/
4 | wide_integer_vs2022.vcxproj.user
5 |
--------------------------------------------------------------------------------
/.props/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.tidy/make/make_tidy_01_generic.gmk:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | PATH_MAKE = $(CURDIR)
9 | PATH_PRJ = $(PATH_MAKE)/../..
10 | PATH_SRC = $(PATH_PRJ)
11 | PATH_TMP = $(PATH_MAKE)/tmp
12 | PATH_ERR = $(PATH_MAKE)/err
13 |
14 | CAT = cat
15 | GNUECHO = echo
16 | LS = ls
17 | MKDIR = mkdir
18 | TIDY = clang-tidy
19 | RM = rm
20 | SED = sed
21 |
22 | include make_tidy_02_files.gmk
23 | include make_tidy_03_flags.gmk
24 |
25 | FILES_ALL = $(FILES_PRJ)
26 | FILES_TIDY_TXT = $(addprefix $(PATH_TMP)/, $(notdir $(addsuffix .tidy_txt, $(FILES_ALL))))
27 |
28 | # ------------------------------------------------------------------------------
29 | # VPATH definition: VPATH is required for make to find the source files.
30 | # ------------------------------------------------------------------------------
31 | VPATH := $(sort $(dir $(FILES_ALL)))
32 |
33 | # ------------------------------------------------------------------------------
34 | # Main dependency: Run clang-tidy on all files and tidy tidy results.
35 | # ------------------------------------------------------------------------------
36 |
37 | .PHONY: tidy
38 | tidy: $(FILES_TIDY_TXT)
39 | # Summarize tidy results
40 | @$(GNUECHO) +++ summarize clang-tidy results
41 | @$(GNUECHO) +++ concatenate $(PATH_TMP)/*.tidy_txt to $(PATH_TMP)/all.tidy_txt
42 | @$(CAT) $(PATH_TMP)/*.tidy_txt > $(PATH_TMP)/all.tidy_txt
43 | @$(GNUECHO)
44 | @$(GNUECHO) +++ verify existence of $(PATH_TMP)/all.tidy_txt
45 | @$(LS) -la $(PATH_TMP)/all.tidy_txt
46 | @$(GNUECHO)
47 | @$(GNUECHO) +++ print summary of tidy from $(PATH_TMP)/all.tidy_txt:
48 | @-$(SED) -n l $(PATH_TMP)/all.tidy_txt
49 | @$(GNUECHO)
50 |
51 |
52 | # ------------------------------------------------------------------------------
53 | # Clean temporary files.
54 | # ------------------------------------------------------------------------------
55 |
56 | .PHONY: prepare
57 | prepare:
58 | # creating output directories
59 | @$(GNUECHO) +++ creating output directories
60 | @-$(MKDIR) -p $(PATH_ERR)
61 | @-$(MKDIR) -p $(PATH_TMP)
62 | @$(GNUECHO)
63 | @$(GNUECHO) +++ cleaning output directories
64 | @-$(RM) -rf $(PATH_ERR)/*.tidy_err
65 | @-$(RM) -rf $(PATH_TMP)/*.tidy_txt
66 | @$(GNUECHO)
67 | @$(GNUECHO) +++ print clang-tidy version
68 | @$(TIDY) --version
69 | @$(GNUECHO)
70 | @$(GNUECHO) +++ print include paths
71 | @$(GNUECHO) $(C_INCLUDES)
72 | @$(GNUECHO)
73 |
74 | # ------------------------------------------------------------------------------
75 | # pattern rule for clang-tidy analysis of cpp-files
76 | # ------------------------------------------------------------------------------
77 | $(PATH_TMP)/%.tidy_txt : %.cpp
78 | @-$(GNUECHO) +++ tidying: $<
79 | @-$(TIDY) $(TIDY_FLAGS) $< -- $(CXX_FLAGS) $(C_INCLUDES) $(C_DEFINES) > $(PATH_TMP)/$(basename $(@F)).tidy_txt 2> $(PATH_ERR)/$(basename $(@F)).tidy_err
80 | @-$(GNUECHO)
81 | @-$(GNUECHO) +++ print $(PATH_ERR)/$(basename $(@F)).tidy_err
82 | @-$(SED) -n l $(PATH_ERR)/$(basename $(@F)).tidy_err
83 | @-$(GNUECHO)
84 |
--------------------------------------------------------------------------------
/.tidy/make/make_tidy_02_files.gmk:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022 - 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | FILES_PRJ = $(PATH_SRC)/test/test_uintwide_t_edge_cases \
9 | $(PATH_SRC)/test/test_uintwide_t_examples \
10 | $(PATH_SRC)/test/test_uintwide_t_float_convert \
11 | $(PATH_SRC)/test/test_uintwide_t_int_convert \
12 | $(PATH_SRC)/test/test_uintwide_t_n_base \
13 | $(PATH_SRC)/test/test_uintwide_t_n_binary_ops_base \
14 | $(PATH_SRC)/test/test_uintwide_t_spot_values \
15 | $(PATH_SRC)/examples/example000a_builtin_convert \
16 | $(PATH_SRC)/examples/example000_numeric_limits \
17 | $(PATH_SRC)/examples/example001_mul_div \
18 | $(PATH_SRC)/examples/example001a_div_mod \
19 | $(PATH_SRC)/examples/example002_shl_shr \
20 | $(PATH_SRC)/examples/example003_sqrt \
21 | $(PATH_SRC)/examples/example003a_cbrt \
22 | $(PATH_SRC)/examples/example004_rootk_pow \
23 | $(PATH_SRC)/examples/example005_powm \
24 | $(PATH_SRC)/examples/example005a_pow_factors_of_p99 \
25 | $(PATH_SRC)/examples/example006_gcd \
26 | $(PATH_SRC)/examples/example007_random_generator \
27 | $(PATH_SRC)/examples/example008_miller_rabin_prime \
28 | $(PATH_SRC)/examples/example008a_miller_rabin_prime \
29 | $(PATH_SRC)/examples/example009_timed_mul \
30 | $(PATH_SRC)/examples/example009a_timed_mul_4_by_4 \
31 | $(PATH_SRC)/examples/example009b_timed_mul_8_by_8 \
32 | $(PATH_SRC)/examples/example010_uint48_t \
33 | $(PATH_SRC)/examples/example011_uint24_t \
34 | $(PATH_SRC)/examples/example012_rsa_crypto \
35 | $(PATH_SRC)/examples/example013_ecdsa_sign_verify \
36 | $(PATH_SRC)/examples/example014_pi_spigot_wide
37 |
--------------------------------------------------------------------------------
/.tidy/make/make_tidy_03_flags.gmk:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------
2 | # Copyright Christopher Kormanyos 2022 - 2024.
3 | # Distributed under the Boost Software License,
4 | # Version 1.0. (See accompanying file LICENSE_1_0.txt
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | # ------------------------------------------------------------------------------
7 |
8 | BOOST_ROOT_FOR_TIDY = /mnt/c/boost/boost_1_78_0
9 | CC = clang++
10 | STD = c++14
11 |
12 | ifneq ($(MY_BOOST_ROOT),)
13 | BOOST_ROOT_FOR_TIDY := $(MY_BOOST_ROOT)
14 | endif
15 |
16 | ifneq ($(MY_CC),)
17 | CC := $(MY_CC)
18 | endif
19 |
20 | ifneq ($(MY_STD),)
21 | STD := $(MY_STD)
22 | endif
23 |
24 | CXX_FLAGS = $(CC) \
25 | -march=native \
26 | -mtune=native \
27 | -O3 \
28 | -Wall \
29 | -Wextra \
30 | -Wconversion \
31 | -Wsign-conversion \
32 | -std=$(STD)
33 |
34 | C_DEFINES = WIDE_INTEGER_HAS_MUL_8_BY_8_UNROLL
35 |
36 | C_INCLUDES = $(PATH_SRC) \
37 | $(BOOST_ROOT_FOR_TIDY)
38 |
39 | C_DEFINES :=$(addprefix -D,$(C_DEFINES))
40 | C_INCLUDES :=$(addprefix -I,$(C_INCLUDES))
41 |
42 |
43 | TIDY_CHECKS = "*, \
44 | -cert-dcl58-cpp, \
45 | -cppcoreguidelines-rvalue-reference-param-not-moved, \
46 | -cppcoreguidelines-avoid-do-while, \
47 | -modernize-type-traits, \
48 | -modernize-use-constraints, \
49 | -misc-header-include-cycle, \
50 | -misc-include-cleaner, \
51 | -misc-const-correctness, \
52 | -performance-avoid-endl, \
53 | -readability-identifier-length, \
54 | -readability-redundant-casting, \
55 | -altera-struct-pack-align, \
56 | -altera-unroll-loops, \
57 | -fuchsia-*, \
58 | -llvmlibc-*"
59 |
60 | TIDY_FLAGS = --extra-arg-before=--driver-mode=g++ \
61 | --header-filter=uintwide_t \
62 | -warnings-as-errors=* \
63 | -checks=$(TIDY_CHECKS)
64 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(wide-integer)
2 |
3 | cmake_minimum_required(VERSION 3.16.3)
4 |
5 | find_package(Boost)
6 | if (Boost_FOUND)
7 | include(CTest)
8 |
9 | add_subdirectory("examples")
10 | add_subdirectory("test")
11 | endif()
12 |
13 | add_library(WideInteger INTERFACE)
14 | target_compile_features(WideInteger INTERFACE cxx_std_14)
15 |
16 | target_include_directories(
17 | WideInteger SYSTEM INTERFACE
18 | $
19 | $)
20 |
21 | install(TARGETS WideInteger EXPORT WideIntegerTargets)
22 | install(
23 | FILES math/wide_integer/uintwide_t.h
24 | DESTINATION include/math/wide_integer/)
25 | install(EXPORT WideIntegerTargets
26 | FILE WideIntegerConfig.cmake
27 | NAMESPACE WideInteger::
28 | DESTINATION lib/cmake/wide-integer)
29 |
--------------------------------------------------------------------------------
/LICENSE_1_0.txt:
--------------------------------------------------------------------------------
1 |
2 | Boost Software License - Version 1.0 - August 17th, 2003
3 |
4 | Permission is hereby granted, free of charge, to any person or organization
5 | obtaining a copy of the software and accompanying documentation covered by
6 | this license (the "Software") to use, reproduce, display, distribute,
7 | execute, and transmit the Software, and to prepare derivative works of the
8 | Software, and to permit third-parties to whom the Software is furnished to
9 | do so, all subject to the following:
10 |
11 | The copyright notices in the Software and this entire statement, including
12 | the above license grant, this restriction and the following disclaimer,
13 | must be included in all copies of the Software, in whole or in part, and
14 | all derivative works of the Software, unless such copies or derivative
15 | works are solely in the form of machine-executable object code generated by
16 | a source language processor.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 | DEALINGS IN THE SOFTWARE.
25 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | codecov:
2 | require_ci_to_pass: yes
3 |
4 | coverage:
5 | precision: 1
6 | round: up
7 | range: '50...100'
8 | status:
9 | project:
10 | default: # This can be anything, but it needs to exist as the name
11 | # basic settings
12 | target: 90%
13 | threshold: 3%
14 | if_ci_failed: error #success, failure, error, ignore
15 | only_pulls: false
16 | patch:
17 | default:
18 | target: 75%
19 | threshold: 25%
20 |
21 | parsers:
22 | gcov:
23 | branch_detection:
24 | conditional: no
25 | loop: no
26 | method: no
27 | macro: no
28 |
29 | comment:
30 | layout: 'reach,diff,flags,files,footer'
31 | behavior: default
32 | require_changes: no
33 |
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(Examples
2 | example000_numeric_limits.cpp
3 | example000a_builtin_convert.cpp
4 | example001_mul_div.cpp
5 | example001a_div_mod.cpp
6 | example002_shl_shr.cpp
7 | example003_sqrt.cpp
8 | example003a_cbrt.cpp
9 | example004_rootk_pow.cpp
10 | example005_powm.cpp
11 | example005a_pow_factors_of_p99.cpp
12 | example006_gcd.cpp
13 | example007_random_generator.cpp
14 | example008_miller_rabin_prime.cpp
15 | example008a_miller_rabin_prime.cpp
16 | example009_timed_mul.cpp
17 | example009a_timed_mul_4_by_4.cpp
18 | example009b_timed_mul_8_by_8.cpp
19 | example010_uint48_t.cpp
20 | example011_uint24_t.cpp
21 | example012_rsa_crypto.cpp
22 | example013_ecdsa_sign_verify.cpp
23 | example014_pi_spigot_wide.cpp)
24 | target_compile_features(Examples PRIVATE cxx_std_20)
25 | target_include_directories(Examples PRIVATE ${PROJECT_SOURCE_DIR})
26 | target_include_directories(Examples SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
27 |
--------------------------------------------------------------------------------
/examples/example000a_builtin_convert.cpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////
2 | // Copyright Christopher Kormanyos 2021 - 2024. //
3 | // Distributed under the Boost Software License, //
4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt //
5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) //
6 | ///////////////////////////////////////////////////////////////////
7 |
8 | #include
9 | #include