summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-02-02 20:18:41 +0000
committerrubidium <rubidium@openttd.org>2013-02-02 20:18:41 +0000
commit6be79c424d30f8a78e4fe4d93240ea326415b0bd (patch)
tree94b0efb9eb6e3bab1d61cd535285ab82df5024bc
parenta6ae4ea8a22929137a7bc009a71f0807dfff7a9e (diff)
downloadopenttd-6be79c424d30f8a78e4fe4d93240ea326415b0bd.tar.xz
(svn r24959) -Doc [FS#5459]: that certain parameters need to be within certain boundaries
-rw-r--r--src/core/bitmath_func.hpp12
1 files changed, 12 insertions, 0 deletions
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 <typename T>
@@ -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 <typename T, typename U>
@@ -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 <typename T>
@@ -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 <typename T>
@@ -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 <typename T>
@@ -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 <typename T>
@@ -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 <typename T>
@@ -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 <typename T>