summaryrefslogtreecommitdiff
path: root/src/macros.h
diff options
context:
space:
mode:
authorskidd13 <skidd13@openttd.org>2007-12-03 09:19:19 +0000
committerskidd13 <skidd13@openttd.org>2007-12-03 09:19:19 +0000
commit82913a21348a741eaacee6c81a57eba9a2c00250 (patch)
treeffda3073f527cfcef5eb31264655b305398d87ab /src/macros.h
parent1a43c6a6f6d78c1bbdebe8278ac67b6c2d5a8854 (diff)
downloadopenttd-82913a21348a741eaacee6c81a57eba9a2c00250.tar.xz
(svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
Diffstat (limited to 'src/macros.h')
-rw-r--r--src/macros.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/macros.h b/src/macros.h
index 51329ab19..5ec7b96e0 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -20,10 +20,20 @@
*/
#define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE)
-
-#define for_each_bit(_i, _b) \
- for (_i = 0; _b != 0; _i++, _b >>= 1) \
- if (_b & 1)
+/**
+ * Do an operation for each set set bit in a value.
+ *
+ * This macros is used to do an operation for each set
+ * bit in a variable. The first variable can be reused
+ * in the operation due to it's the bit position counter.
+ * The second variable will be cleared during the usage
+ *
+ * @param i The position counter
+ * @param b The value which we check for set bits
+ */
+#define FOR_EACH_SET_BIT(i, b) \
+ for (i = 0; b != 0; i++, b >>= 1) \
+ if (b & 1)
static inline uint16 ReadLE16Aligned(const void* x)