Skip to content

Commit

Permalink
always inline is now a macro CBN_ALWAYS_INLINE (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
niekbouman authored Apr 11, 2018
1 parent 39512c2 commit 77e010b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
27 changes: 27 additions & 0 deletions include/ctbignum/config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// This file is part of:
//
// CTBignum
//
// C++ Library for Compile-Time and Run-Time Multi-Precision and Modular Arithmetic
//
// Copyright 2018 Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef CT_CONFIG_HPP
#define CT_CONFIG_HPP

#define CBN_ALWAYS_INLINE [[gnu::always_inline]

#endif
6 changes: 4 additions & 2 deletions include/ctbignum/montgomery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
#ifndef CT_MONTGOMERY_HPP
#define CT_MONTGOMERY_HPP

#include <cstddef> // std::size_t
#include <ctbignum/addition.hpp>
#include <ctbignum/config.hpp>
#include <ctbignum/gcd.hpp>
#include <ctbignum/mult.hpp>
#include <ctbignum/relational_ops.hpp>
#include <ctbignum/slicing.hpp>
#include <ctbignum/type_traits.hpp>

#include <cstddef> // std::size_t
#include <limits>

namespace cbn {
Expand Down Expand Up @@ -79,7 +81,7 @@ constexpr auto montgomery_reduction(big_int<N1, T> A,


template <typename T, std::size_t N, T... Modulus>
[[gnu::always_inline]]
CBN_ALWAYS_INLINE
constexpr auto montgomery_mul(big_int<N, T> x, big_int<N, T> y,
std::integer_sequence<T, Modulus...>) {
// Montgomery multiplication with compile-time modulus
Expand Down
3 changes: 2 additions & 1 deletion include/ctbignum/mult.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define CT_MULT_HPP

#include <ctbignum/bigint.hpp>
#include <ctbignum/config.hpp>
#include <ctbignum/type_traits.hpp>

#include <algorithm>
Expand All @@ -50,7 +51,7 @@ constexpr auto short_mul(big_int<N, T> a, T b) {
}

template <size_t padding_limbs = 0, size_t M, size_t N, typename T>
[[gnu::always_inline]]
CBN_ALWAYS_INLINE
constexpr auto mul(big_int<M, T> u, big_int<N, T> v) {

using TT = typename dbl_bitlen<T>::type;
Expand Down

0 comments on commit 77e010b

Please sign in to comment.