diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/bit_ops.h | 30 | ||||
-rw-r--r-- | src/utils/get_byte.h | 7 | ||||
-rw-r--r-- | src/utils/time.cpp | 4 | ||||
-rw-r--r-- | src/utils/time.h | 13 |
4 files changed, 41 insertions, 13 deletions
diff --git a/src/utils/bit_ops.h b/src/utils/bit_ops.h index c02ec536f..36bac9f73 100644 --- a/src/utils/bit_ops.h +++ b/src/utils/bit_ops.h @@ -12,9 +12,10 @@ namespace Botan { -/* -* Return true iff arg is 2**n for some n > 0 -* T should be an unsigned integer type +/** +* Power of 2 test. T should be an unsigned integer type +* @param arg an integer value +* @return true iff arg is 2^n for some n > 0 */ template<typename T> inline bool power_of_2(T arg) @@ -22,9 +23,11 @@ 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 +* @param n an integer value +* @return index of the highest set bit in n */ template<typename T> inline u32bit high_bit(T n) @@ -35,8 +38,11 @@ inline u32bit high_bit(T n) return 0; } -/* +/** * Return the index of the lowest set bit +* T is an unsigned integer type +* @param n an integer value +* @return index of the lowest set bit in n */ template<typename T> inline u32bit low_bit(T n) @@ -47,8 +53,10 @@ inline u32bit low_bit(T n) return 0; } -/* +/** * Return the number of significant bytes in n +* @param n an integer value +* @return number of significant bytes in n */ template<typename T> inline u32bit significant_bytes(T n) @@ -59,8 +67,10 @@ inline u32bit significant_bytes(T n) return 0; } -/* -* Return the Hamming weight of n +/** +* Compute Hamming weights +* @param n an integer value +* @return number of bits in n set to 1 */ template<typename T> inline u32bit hamming_weight(T n) @@ -74,8 +84,10 @@ inline u32bit hamming_weight(T n) return weight; } -/* +/** * Count the trailing zero bits in n +* @param n an integer value +* @return maximum x st 2^x divides n */ template<typename T> inline u32bit ctz(T n) diff --git a/src/utils/get_byte.h b/src/utils/get_byte.h index fce87af83..7eedbd783 100644 --- a/src/utils/get_byte.h +++ b/src/utils/get_byte.h @@ -12,8 +12,11 @@ namespace Botan { -/* -* Byte Extraction Function +/** +* Byte extraction +* @param byte_num which byte to extract, 0 == highest byte +* @param input the value to extract from +* @return byte byte_num of input */ template<typename T> inline byte get_byte(u32bit byte_num, T input) { diff --git a/src/utils/time.cpp b/src/utils/time.cpp index db535f316..65e808c04 100644 --- a/src/utils/time.cpp +++ b/src/utils/time.cpp @@ -35,7 +35,7 @@ namespace Botan { namespace { -/** +/* * Combine a two time values into a single one */ u64bit combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz) @@ -67,7 +67,7 @@ std::tm do_gmtime(time_t time_val) } -/** +/* * Get the system clock */ u64bit system_time() diff --git a/src/utils/time.h b/src/utils/time.h index fa1e379a7..56d15513c 100644 --- a/src/utils/time.h +++ b/src/utils/time.h @@ -18,11 +18,24 @@ namespace Botan { */ struct BOTAN_DLL calendar_point { + /** The year */ u32bit year; + + /** The month, 1 through 12 for Jan to Dec */ byte month; + + /** The day of the month, 1 through 31 (or 28 or 30 based on month */ byte day; + + /** Hour in 24-hour form, 0 to 23 */ byte hour; + + /** Minutes in the hour, 0 to 60 */ byte minutes; + + /** Seconds in the minute, 0 to 60, but might be slightly + larger to deal with leap seconds on some systems + */ byte seconds; /** |