diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-08 21:58:18 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-08 22:00:07 +0300 |
commit | edd1a53a55b940bea66f38dd9f05229879e69736 (patch) | |
tree | 3e3cd971a1d1c275cc4cbd97efa1a971f8468e6e /storage/innobase/include/ut0ut.h | |
parent | 1e7ad5bb1c69dba8c7d721a2cfbbe98c7e900015 (diff) | |
parent | 937ec3c48d2068dfb76d47cb409eb19d38677da1 (diff) | |
download | mariadb-git-edd1a53a55b940bea66f38dd9f05229879e69736.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'storage/innobase/include/ut0ut.h')
-rw-r--r-- | storage/innobase/include/ut0ut.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 6ca661378b1..65c5d63953c 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -127,26 +128,23 @@ Calculates fast the remainder of n/m when m is a power of two. @param n in: numerator @param m in: denominator, must be a power of two @return the remainder of n/m */ -#define ut_2pow_remainder(n, m) ((n) & ((m) - 1)) +template <typename T> inline T ut_2pow_remainder(T n, T m){return n & (m - 1);} /*************************************************************//** Calculates the biggest multiple of m that is not bigger than n when m is a power of two. In other words, rounds n down to m * k. @param n in: number to round down @param m in: alignment, must be a power of two @return n rounded down to the biggest possible integer multiple of m */ -#define ut_2pow_round(n, m) ((n) & ~((m) - 1)) -/** Align a number down to a multiple of a power of two. -@param n in: number to round down -@param m in: alignment, must be a power of two -@return n rounded down to the biggest possible integer multiple of m */ -#define ut_calc_align_down(n, m) ut_2pow_round(n, m) +template <typename T> inline T ut_2pow_round(T n, T m) { return n & ~(m - 1); } /********************************************************//** Calculates the smallest multiple of m that is not smaller than n when m is a power of two. In other words, rounds n up to m * k. @param n in: number to round up @param m in: alignment, must be a power of two @return n rounded up to the smallest possible integer multiple of m */ -#define ut_calc_align(n, m) (((n) + ((m) - 1)) & ~((m) - 1)) +#define UT_CALC_ALIGN(n, m) ((n + m - 1) & ~(m - 1)) +template <typename T> inline T ut_calc_align(T n, T m) +{ return UT_CALC_ALIGN(n, m); } /*************************************************************//** Calculates fast the 2-logarithm of a number, rounded upward to an |