aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-29 13:31:36 +0000
committerlloyd <[email protected]>2010-06-29 13:31:36 +0000
commit50a3fbc9fffbb9a6d9b7940f519726f71067503d (patch)
tree984384488d69614bf8e3ed2bef218b2c43284cfe /src/utils
parente25bbc9b8ff24931b34507a10fe08fe3dd592b17 (diff)
Make round_up and round_down templates instead of fixed to use u32bits
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/rounding.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/utils/rounding.h b/src/utils/rounding.h
index 11ab90b8d..c77ab9b52 100644
--- a/src/utils/rounding.h
+++ b/src/utils/rounding.h
@@ -12,20 +12,28 @@
namespace Botan {
-/*
-* Round up n to multiple of align_to
+/**
+* Round up
+* @param n an integer
+* @param align_to the alignment boundary
+* @return n rounded up to a multiple of align_to
*/
-inline u32bit round_up(u32bit n, u32bit align_to)
+template<typename T>
+inline T round_up(T n, T align_to)
{
if(n % align_to || n == 0)
n += align_to - (n % align_to);
return n;
}
-/*
-* Round down n to multiple of align_to
+/**
+* Round down
+* @param n an integer
+* @param align_to the alignment boundary
+* @return n rounded down to a multiple of align_to
*/
-inline u32bit round_down(u32bit n, u32bit align_to)
+template<typename T>
+inline T round_down(T n, T align_to)
{
return (n - (n % align_to));
}