Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/42357 )

Change subject: base: Make the functions in intmath.hh constexpr.
......................................................................

base: Make the functions in intmath.hh constexpr.

These simple functions can potentially be evaluated at compile time, and
marking them constexpr makes them available in more contexts.

Change-Id: I9cf39c517e7c53c276883f311739c1b153ccfd44
---
M src/base/intmath.hh
1 file changed, 7 insertions(+), 7 deletions(-)



diff --git a/src/base/intmath.hh b/src/base/intmath.hh
index 473f0e3..acf7681 100644
--- a/src/base/intmath.hh
+++ b/src/base/intmath.hh
@@ -39,7 +39,7 @@
 /**
  * @ingroup api_base_utils
  */
-inline uint64_t
+static constexpr uint64_t
 power(uint32_t n, uint32_t e)
 {
     uint64_t result = 1;
@@ -59,7 +59,7 @@
  * @ingroup api_base_utils
  */
 template <class T>
-inline typename std::enable_if_t<std::is_integral<T>::value, int>
+static constexpr std::enable_if_t<std::is_integral<T>::value, int>
 floorLog2(T x)
 {
     assert(x > 0);
@@ -84,7 +84,7 @@
  * @ingroup api_base_utils
  */
 template <class T>
-inline int
+static constexpr int
 ceilLog2(const T& n)
 {
     assert(n > 0);
@@ -98,7 +98,7 @@
  * @ingroup api_base_utils
  */
 template <class T>
-inline bool
+static constexpr bool
 isPowerOf2(const T& n)
 {
     // If n is non-zero, and subtracting one borrows all the way to the MSB
@@ -110,7 +110,7 @@
  * @ingroup api_base_utils
  */
 template <class T, class U>
-inline T
+static constexpr T
 divCeil(const T& a, const U& b)
 {
     return (a + b - 1) / b;
@@ -127,7 +127,7 @@
  * @ingroup api_base_utils
  */
 template <class T, class U>
-inline T
+static constexpr T
 roundUp(const T& val, const U& align)
 {
     assert(isPowerOf2(align));
@@ -146,7 +146,7 @@
  * @ingroup api_base_utils
  */
 template <class T, class U>
-inline T
+static constexpr T
 roundDown(const T& val, const U& align)
 {
     assert(isPowerOf2(align));

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42357
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9cf39c517e7c53c276883f311739c1b153ccfd44
Gerrit-Change-Number: 42357
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to