aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/bit_ops.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-03-30 18:27:18 +0000
committerlloyd <[email protected]>2009-03-30 18:27:18 +0000
commit96d6eb6f29c55e16a37cf11899547886f735b065 (patch)
tree9f13901e9b44c98d58b2589c9b09c6a7443eb7cd /src/utils/bit_ops.h
parent3cc3dd72c5f87b76852a55c1f2d1821dba967d8c (diff)
Thomas Moschny passed along a request from the Fedora packagers which came
up during the Fedora submission review, that each source file include some text about the license. One handy Perl script later and each file now has the line Distributed under the terms of the Botan license after the copyright notices. While I was in there modifying every file anyway, I also stripped out the remainder of the block comments (lots of astericks before and after the text); this is stylistic thing I picked up when I was first learning C++ but in retrospect it is not a good style as the structure makes it harder to modify comments (with the result that comments become fewer, shorter and are less likely to be updated, which are not good things).
Diffstat (limited to 'src/utils/bit_ops.h')
-rw-r--r--src/utils/bit_ops.h46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/utils/bit_ops.h b/src/utils/bit_ops.h
index c876e6f14..c02ec536f 100644
--- a/src/utils/bit_ops.h
+++ b/src/utils/bit_ops.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Bit/Word Operations Header File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* Bit/Word Operations
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_BIT_OPS_H__
#define BOTAN_BIT_OPS_H__
@@ -10,20 +12,20 @@
namespace Botan {
-/*************************************************
-* Return true iff arg is 2**n for some n > 0 *
-* T should be an unsigned integer type *
-*************************************************/
+/*
+* Return true iff arg is 2**n for some n > 0
+* T should be an unsigned integer type
+*/
template<typename T>
inline bool power_of_2(T arg)
{
return ((arg != 0 && arg != 1) && ((arg & (arg-1)) == 0));
}
-/*************************************************
+/*
* Return the index of the highest set bit
* T is an unsigned integer type
-*************************************************/
+*/
template<typename T>
inline u32bit high_bit(T n)
{
@@ -33,9 +35,9 @@ inline u32bit high_bit(T n)
return 0;
}
-/*************************************************
-* Return the index of the lowest set bit *
-*************************************************/
+/*
+* Return the index of the lowest set bit
+*/
template<typename T>
inline u32bit low_bit(T n)
{
@@ -45,9 +47,9 @@ inline u32bit low_bit(T n)
return 0;
}
-/*************************************************
-* Return the number of significant bytes in n *
-*************************************************/
+/*
+* Return the number of significant bytes in n
+*/
template<typename T>
inline u32bit significant_bytes(T n)
{
@@ -57,9 +59,9 @@ inline u32bit significant_bytes(T n)
return 0;
}
-/*************************************************
-* Return the Hamming weight of n *
-*************************************************/
+/*
+* Return the Hamming weight of n
+*/
template<typename T>
inline u32bit hamming_weight(T n)
{
@@ -72,9 +74,9 @@ inline u32bit hamming_weight(T n)
return weight;
}
-/*************************************************
-* Count the trailing zero bits in n *
-*************************************************/
+/*
+* Count the trailing zero bits in n
+*/
template<typename T>
inline u32bit ctz(T n)
{