From 6be79c424d30f8a78e4fe4d93240ea326415b0bd Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 2 Feb 2013 20:18:41 +0000 Subject: (svn r24959) -Doc [FS#5459]: that certain parameters need to be within certain boundaries --- src/core/bitmath_func.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index bbb59c2b0..5838dd11b 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -26,6 +26,8 @@ * @param x The value to read some bits. * @param s The start position to read some bits. * @param n The number of bits to read. + * @pre n < sizeof(T) * 8 + * @pre s + n <= sizeof(T) * 8 * @return The selected bits, aligned to a LSB. */ template @@ -50,6 +52,8 @@ static inline uint GB(const T x, const uint8 s, const uint8 n) * @param s The start position for the new bits * @param n The size/window for the new bits * @param d The actually new bits to save in the defined position. + * @pre n < sizeof(T) * 8 + * @pre s + n <= sizeof(T) * 8 * @return The new value of \a x */ template @@ -72,6 +76,8 @@ static inline T SB(T &x, const uint8 s, const uint8 n, const U d) * @param x The variable to add some bits at some position * @param s The start position of the addition * @param n The size/window for the addition + * @pre n < sizeof(T) * 8 + * @pre s + n <= sizeof(T) * 8 * @param i The value to add at the given start position in the given window. * @return The new value of \a x */ @@ -92,6 +98,7 @@ static inline T AB(T &x, const uint8 s, const uint8 n, const U i) * * @param x The value to check * @param y The position of the bit to check, started from the LSB + * @pre y < sizeof(T) * 8 * @return True if the bit is set, false else. */ template @@ -109,6 +116,7 @@ static inline bool HasBit(const T x, const uint8 y) * * @param x The variable to set a bit * @param y The bit position to set + * @pre y < sizeof(T) * 8 * @return The new value of the old value with the bit set */ template @@ -138,6 +146,7 @@ static inline T SetBit(T &x, const uint8 y) * * @param x The variable to clear the bit * @param y The bit position to clear + * @pre y < sizeof(T) * 8 * @return The new value of the old value with the bit cleared */ template @@ -167,6 +176,7 @@ static inline T ClrBit(T &x, const uint8 y) * * @param x The variable to toggle the bit * @param y The bit position to toggle + * @pre y < sizeof(T) * 8 * @return The new value of the old value with the bit toggled */ template @@ -286,6 +296,7 @@ static inline bool HasAtMostOneBit(T value) * @note Assumes a byte has 8 bits * @param x The value which we want to rotate * @param n The number how many we want to rotate + * @pre n < sizeof(T) * 8 * @return A bit rotated number */ template @@ -300,6 +311,7 @@ static inline T ROL(const T x, const uint8 n) * @note Assumes a byte has 8 bits * @param x The value which we want to rotate * @param n The number how many we want to rotate + * @pre n < sizeof(T) * 8 * @return A bit rotated number */ template -- cgit v1.2.3-54-g00ecf