tron@2186: /* $Id$ */ tron@2186: belugas@6201: /** @file macros.h */ belugas@6201: truelight@0: #ifndef MACROS_H truelight@0: #define MACROS_H truelight@0: rubidium@7326: /** rubidium@7326: * Fetch n bits from x, started at bit s. rubidium@7326: * truelight@7837: * This function can be used to fetch n bits from the value x. The rubidium@7326: * s value set the startposition to read. The startposition is rubidium@7326: * count from the LSB and starts at 0. The result starts at a rubidium@7326: * LSB, as this isn't just an and-bitmask but also some rubidium@7326: * bit-shifting operations. GB(0xFF, 2, 1) will so rubidium@7326: * return 0x01 (0000 0001) instead of rubidium@7326: * 0x04 (0000 0100). rubidium@7326: * rubidium@7326: * @param x The value to read some bits. rubidium@7326: * @param s The startposition to read some bits. rubidium@7326: * @param n The number of bits to read. rubidium@7326: * @return The selected bits, aligned to a LSB. rubidium@7326: */ truelight@7837: template static inline uint GB(const T x, const uint8 s, const uint8 n) truelight@7837: { truelight@7837: return (x >> s) & ((1U << n) - 1); truelight@7837: } rubidium@7326: rubidium@7326: /** Set n bits from x starting at bit s to d rubidium@7326: * truelight@7837: * This function sets n bits from x which started as bit s to the value of rubidium@7326: * d. The parameters x, s and n works the same as the parameters of rubidium@7326: * #GB. The result is saved in x again. Unused bits in the window rubidium@7326: * provided by n are set to 0 if the value of b isn't "big" enough. rubidium@7326: * This is not a bug, its a feature. rubidium@7326: * rubidium@7326: * @note Parameter x must be a variable as the result is saved there. rubidium@7326: * @note To avoid unexpecting results the value of b should not use more rubidium@7326: * space as the provided space of n bits (log2) rubidium@7326: * @param x The variable to change some bits rubidium@7326: * @param s The startposition for the new bits rubidium@7326: * @param n The size/window for the new bits rubidium@7326: * @param d The actually new bits to save in the defined position. rubidium@7326: * @return The new value of x rubidium@7326: */ truelight@7837: template static inline T SB(T& x, const uint8 s, const uint8 n, const U d) truelight@7837: { truelight@7837: x &= (T)(~(((1U << n) - 1) << s)); truelight@7837: x |= (T)(d << s); truelight@7837: return x; truelight@7837: } rubidium@7326: rubidium@7326: /** Add i to n bits of x starting at bit s. rubidium@7326: * rubidium@7326: * This add the value of i on n bits of x starting at bit s. The parameters x, rubidium@7326: * s, i are similar to #GB besides x must be a variable as the result are rubidium@7326: * saved there. An overflow does not affect the following bits of the given rubidium@7326: * bit window and is simply ignored. rubidium@7326: * rubidium@7326: * @note Parameter x must be a variable as the result is saved there. rubidium@7326: * @param x The variable to add some bits at some position rubidium@7326: * @param s The startposition of the addition rubidium@7326: * @param n The size/window for the addition rubidium@7326: * @param i The value to add at the given startposition in the given window. rubidium@7326: * @return The new value of x rubidium@7326: */ truelight@7837: template static inline T AB(T& x, const uint8 s, const uint8 n, const U i) truelight@7837: { truelight@7837: const T tmp = (T)(((1U << n) - 1) << s); truelight@7837: x &= ~tmp; truelight@7837: x |= (T)((x + (i << s)) & tmp); truelight@7837: return x; truelight@7837: } tron@2663: truelight@193: #ifdef min truelight@0: #undef min truelight@0: #endif truelight@0: truelight@0: #ifdef max truelight@0: #undef max truelight@0: #endif truelight@0: rubidium@7326: /** rubidium@7326: * Returns the maximum of two values. rubidium@7326: * rubidium@7326: * This function returns the greater value of two given values. rubidium@7326: * If they are equal the value of a is returned. rubidium@7326: * rubidium@7326: * @param a The first value rubidium@7326: * @param b The second value rubidium@7326: * @return The greater value or a if equals rubidium@7326: */ truelight@7819: template static inline T max(const T a, const T b) celestar@5603: { celestar@5603: return a >= b ? a : b; celestar@5603: } celestar@5601: rubidium@7326: /** rubidium@7326: * Returns the minimum of two values. rubidium@7326: * rubidium@7326: * This function returns the smaller value of two given values. rubidium@7326: * If they are equal the value of b is returned. rubidium@7326: * rubidium@7326: * @param a The first value rubidium@7326: * @param b The second value rubidium@7326: * @return The smaller value or b if equals rubidium@7326: */ truelight@7819: template static inline T min(const T a, const T b) rubidium@6957: { rubidium@6957: return a < b ? a : b; rubidium@6957: } rubidium@6957: rubidium@7326: /** rubidium@7326: * Returns the minimum of two integer. rubidium@7326: * rubidium@7326: * This function returns the smaller value of two given integers. rubidium@7326: * rubidium@7326: * @param a The first integer rubidium@7326: * @param b The second integer rubidium@7326: * @return The smaller value rubidium@7326: */ truelight@7819: static inline int min(const int a, const int b) truelight@7819: { truelight@7827: return a <= b ? a : b; truelight@7819: } truelight@0: rubidium@7326: /** rubidium@7326: * Returns the minimum of two unsigned integers. rubidium@7326: * rubidium@7326: * This function returns the smaller value of two given unsigned integers. rubidium@7326: * rubidium@7326: * @param a The first unsigned integer rubidium@7326: * @param b The second unsigned integer rubidium@7326: * @return The smaller value rubidium@7326: */ truelight@7819: static inline uint minu(const uint a, const uint b) truelight@7819: { truelight@7827: return a <= b ? a : b; truelight@7819: } truelight@0: rubidium@7326: /** rubidium@7326: * Clamp an integer between an interval. rubidium@7326: * rubidium@7326: * This function returns a value which is between the given interval of rubidium@7326: * min and max. If the given value is in this interval the value itself rubidium@7326: * is returned otherwise the border of the interval is returned, according rubidium@7326: * which side of the interval was 'left'. rubidium@7326: * rubidium@7326: * @note The min value must be less or equal of max or you get some rubidium@7326: * unexpected results. rubidium@7326: * @param a The value to clamp/truncate. rubidium@7326: * @param min The minimum of the interval. rubidium@7326: * @param max the maximum of the interval. rubidium@7326: * @returns A value between min and max which is closest to a. rubidium@7326: * @see clampu(uint, uint, uint) rubidium@7326: */ truelight@7819: static inline int clamp(const int a, const int min, const int max) tron@1400: { tron@1400: if (a <= min) return min; tron@1400: if (a >= max) return max; tron@1400: return a; tron@1400: } truelight@0: rubidium@7326: /** rubidium@7326: * Clamp an unsigned integer between an interval. rubidium@7326: * rubidium@7326: * This function returns a value which is between the given interval of rubidium@7326: * min and max. If the given value is in this interval the value itself rubidium@7326: * is returned otherwise the border of the interval is returned, according rubidium@7326: * which side of the interval was 'left'. rubidium@7326: * rubidium@7326: * @note The min value must be less or equal of max or you get some rubidium@7326: * unexpected results. rubidium@7326: * @param a The value to clamp/truncate. rubidium@7326: * @param min The minimum of the interval. rubidium@7326: * @param max the maximum of the interval. rubidium@7326: * @returns A value between min and max which is closest to a. rubidium@7326: * @see clamp(int, int, int) rubidium@7326: */ truelight@7819: static inline uint clampu(const uint a, const uint min, const uint max) Darkvater@3352: { Darkvater@3352: if (a <= min) return min; Darkvater@3352: if (a >= max) return max; Darkvater@3352: return a; Darkvater@3352: } truelight@0: rubidium@7326: /** rubidium@7326: * Reduce a signed 64-bit int to a signed 32-bit one rubidium@7326: * rubidium@7326: * This function clamps a 64-bit integer to a 32-bit integer. rubidium@7326: * If the 64-bit value is smaller than the smallest 32-bit integer rubidium@7326: * value 0x80000000 this value is returned (the left one bit is the sign bit). rubidium@7326: * If the 64-bit value is greater than the greatest 32-bit integer value 0x7FFFFFFF rubidium@7326: * this value is returned. In all other cases the 64-bit value 'fits' in a rubidium@7326: * 32-bits integer field and so the value is casted to int32 and returned. rubidium@7326: * rubidium@7326: * @param a The 64-bit value to clamps rubidium@7326: * @return The 64-bit value reduced to a 32-bit value rubidium@7326: * @see clamp(int, int, int) rubidium@7326: */ truelight@7819: static inline int32 ClampToI32(const int64 a) rubidium@6990: { rubidium@6990: if (a <= (int32)0x80000000) return 0x80000000; rubidium@6990: if (a >= (int32)0x7FFFFFFF) return 0x7FFFFFFF; rubidium@6990: return (int32)a; rubidium@6990: } rubidium@6990: rubidium@7326: /** rubidium@7326: * Multiply two integer values and shift the results to right. rubidium@7326: * rubidium@7326: * This function multiplies two integer values. The result is rubidium@7326: * shifted by the amount of shift to right. rubidium@7326: * rubidium@7326: * @param a The first integer rubidium@7326: * @param b The second integer rubidium@7326: * @param shift The amount to shift the value to right. rubidium@7326: * @return The shifted result rubidium@7326: */ truelight@7827: static inline int32 BIGMULSS(const int32 a, const int32 b, const uint8 shift) tron@6110: { tron@6110: return (int32)((int64)a * (int64)b >> shift); truelight@0: } truelight@0: rubidium@7326: /** rubidium@7326: * Multiply two unsigned integers and shift the results to right. rubidium@7326: * rubidium@7326: * This function multiplies two unsigned integers. The result is rubidium@7326: * shifted by the amount of shift to right. rubidium@7326: * rubidium@7326: * @param a The first unsigned integer rubidium@7326: * @param b The second unsigned integer rubidium@7326: * @param shift The amount to shift the value to right. rubidium@7326: * @return The shifted result rubidium@7326: */ truelight@7827: static inline uint32 BIGMULUS(const uint32 a, const uint32 b, const uint8 shift) tron@6110: { tron@6110: return (uint32)((uint64)a * (uint64)b >> shift); truelight@0: } truelight@0: rubidium@7326: /** rubidium@7326: * Checks if a bit in a value is set. rubidium@7326: * rubidium@7326: * This function checks if a bit inside a value is set or not. rubidium@7326: * The y value specific the position of the bit, started at the rubidium@7326: * LSB and count from 0. rubidium@7326: * rubidium@7326: * @param x The value to check rubidium@7326: * @param y The position of the bit to check, started from the LSB rubidium@7326: * @return True if the bit is set, false else. rubidium@7326: */ truelight@7827: template static inline bool HASBIT(const T x, const uint8 y) celestar@6010: { truelight@7819: return (x & ((T)1U << y)) != 0; celestar@6010: } truelight@0: rubidium@7326: /** rubidium@7326: * Set a bit in a variable. rubidium@7326: * rubidium@7326: * This function sets a bit in a variable. The variable is changed rubidium@7326: * and the value is also returned. Parameter y defines the bit and rubidium@7326: * starts at the LSB with 0. rubidium@7326: * rubidium@7326: * @param x The variable to set a bit rubidium@7326: * @param y The bit position to set rubidium@7326: * @return The new value of the old value with the bit set rubidium@7326: */ truelight@7827: template static inline T SETBIT(T& x, const uint8 y) celestar@6010: { truelight@7819: return x |= (T)1U << y; celestar@6010: } celestar@6010: rubidium@7326: /** rubidium@7326: * Clears a bit in a variable. rubidium@7326: * rubidium@7326: * This function clears a bit in a variable. The variable is rubidium@7326: * changed and the value is also returned. Parameter y defines the bit rubidium@7326: * to clear and starts at the LSB with 0. rubidium@7326: * rubidium@7326: * @param x The variable to clear the bit rubidium@7326: * @param y The bit position to clear rubidium@7326: * @return The new value of the old value with the bit cleared rubidium@7326: */ truelight@7827: template static inline T CLRBIT(T& x, const uint8 y) celestar@6010: { truelight@7819: return x &= ~((T)1U << y); celestar@6010: } celestar@6010: rubidium@7326: /** rubidium@7326: * Toggles a bit in a variable. rubidium@7326: * rubidium@7326: * This function toggles a bit in a variable. The variable is rubidium@7326: * changed and the value is also returned. Parameter y defines the bit rubidium@7326: * to toggle and starts at the LSB with 0. rubidium@7326: * rubidium@7326: * @param x The varliable to toggle the bit rubidium@7326: * @param y The bit position to toggle rubidium@7326: * @return The new value of the old value with the bit toggled rubidium@7326: */ truelight@7827: template static inline T TOGGLEBIT(T& x, const uint8 y) celestar@6010: { truelight@7819: return x ^= (T)1U << y; celestar@6010: } celestar@6010: truelight@0: belugas@6201: /* checking more bits. Maybe unneccessary, but easy to use */ rubidium@7326: /** rubidium@7326: * Check several bits in a value. rubidium@7326: * rubidium@7326: * This macro checks if a value contains at least one bit of an other rubidium@7326: * value. rubidium@7326: * rubidium@7326: * @param x The first value rubidium@7326: * @param y The second value rubidium@7326: * @return True if at least one bit is set in both values, false else. rubidium@7326: */ rubidium@6491: #define HASBITS(x, y) ((x) & (y)) rubidium@7326: rubidium@7326: /** rubidium@7326: * Sets several bits in a variable. rubidium@7326: * rubidium@7326: * This macro sets several bits in a variable. The bits to set are provided rubidium@7326: * by a value. The new value is also returned. rubidium@7326: * rubidium@7326: * @param x The variable to set some bits rubidium@7326: * @param y The value with set bits for setting them in the variable rubidium@7326: * @return The new value of x rubidium@7326: */ rubidium@6491: #define SETBITS(x, y) ((x) |= (y)) rubidium@7326: rubidium@7326: /** rubidium@7326: * Clears several bits in a variable. rubidium@7326: * rubidium@7326: * This macro clears several bits in a variable. The bits to clear are rubidium@7326: * provided by a value. The new value is also returned. rubidium@7326: * rubidium@7326: * @param x The variable to clear some bits rubidium@7326: * @param y The value with set bits for clearing them in the variable rubidium@7326: * @return The new value of x rubidium@7326: */ rubidium@6491: #define CLRBITS(x, y) ((x) &= ~(y)) truelight@0: peter1138@5668: #define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START) peter1138@5668: #define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner])) truelight@0: maedhros@7619: /** maedhros@7619: * Whether a sprite comes from the original graphics files or a new grf file maedhros@7619: * (either supplied by OpenTTD or supplied by the user). maedhros@7619: * maedhros@7619: * @param sprite The sprite to check maedhros@7619: * @return True if it is a new sprite, or false if it is original. maedhros@7619: */ maedhros@7619: #define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE) maedhros@7619: truelight@7833: extern const byte _ffb_64[64]; rubidium@7326: rubidium@7326: /** rubidium@7326: * Returns the first occure of a bit in a 6-bit value (from right). rubidium@7326: * rubidium@7326: * Returns the position of the first bit that is not zero, counted from the rubidium@7326: * LSB. Ie, 110100 returns 2, 000001 returns 0, etc. When x == 0 returns darkvater@22: * 0. rubidium@7326: * rubidium@7326: * @param x The 6-bit value to check the first zero-bit rubidium@7326: * @return The first position of a bit started from the LSB or 0 if x is 0. darkvater@22: */ truelight@0: #define FIND_FIRST_BIT(x) _ffb_64[(x)] rubidium@7326: rubidium@7326: /** rubidium@7326: * Finds the position of the first bit in an integer. rubidium@7326: * rubidium@7326: * This function returns the position of the first bit set in the rubidium@7326: * integer. It does only check the bits of the bitmask rubidium@7326: * 0x3F3F (0011111100111111) and checks only the rubidium@7326: * bits of the bitmask 0x3F00 if and only if the rubidium@7326: * lower part 0x00FF is 0. This results the bits at 0x00C0 must rubidium@7326: * be also zero to check the bits at 0x3F00. rubidium@7326: * rubidium@7326: * @param value The value to check the first bits rubidium@7326: * @return The position of the first bit which is set rubidium@7326: * @see FIND_FIRST_BIT rubidium@7326: */ tron@500: static inline int FindFirstBit2x64(int value) truelight@0: { truelight@7837: if ((value & 0xFF) == 0) { truelight@7837: return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8; matthijs@1247: } else { truelight@7837: return FIND_FIRST_BIT(value & 0x3F); matthijs@1247: } truelight@0: } truelight@0: rubidium@7326: /** rubidium@7326: * Clear the first bit in an integer. rubidium@7326: * rubidium@7326: * This function returns a value where the first bit (from LSB) truelight@7833: * is cleared. truelight@7833: * So, 110100 returns 110000, 000001 returns 000000, etc. rubidium@7326: * rubidium@7326: * @param value The value to clear the first bit rubidium@7326: * @return The new value with the first bit cleared rubidium@7326: */ truelight@7833: template static inline T KillFirstBit(T value) matthijs@1247: { truelight@7833: return value &= (T)(value - 1); matthijs@1247: } truelight@0: rubidium@7326: /** rubidium@7516: * Counts the number of set bits in a variable. rubidium@7516: * rubidium@7516: * @param value the value to count the number of bits in. rubidium@7516: * @return the number of bits. rubidium@7516: */ truelight@7832: template static inline uint CountBits(T value) rubidium@7516: { truelight@7837: uint num; rubidium@7516: rubidium@7516: /* This loop is only called once for every bit set by clearing the lowest rubidium@7516: * bit in each loop. The number of bits is therefore equal to the number of rubidium@7516: * times the loop was called. It was found at the following website: rubidium@7516: * http://graphics.stanford.edu/~seander/bithacks.html */ rubidium@7516: rubidium@7516: for (num = 0; value != 0; num++) { rubidium@7516: value &= (T)(value - 1); rubidium@7516: } rubidium@7516: rubidium@7516: return num; rubidium@7516: } rubidium@7516: rubidium@7516: /** truelight@7837: * Checks if a value is between a window started at some base point. truelight@7837: * truelight@7837: * This function checks if the value x is between the value of base truelight@7837: * and base+size. If x equals base this returns true. If x equals truelight@7837: * base+size this returns false. truelight@7837: * truelight@7837: * @param x The value to check truelight@7837: * @param base The base value of the interval truelight@7837: * @param size The size of the interval truelight@7837: * @return True if the value is in the interval, false else. truelight@7837: */ truelight@7837: template static inline bool IS_INSIDE_1D(const T x, const int base, const uint size) truelight@7837: { truelight@7837: return (uint)(x - base) < size; truelight@7837: } truelight@7837: truelight@7837: /** rubidium@7326: * Checks if a byte is in an interval. rubidium@7326: * rubidium@7326: * This macro returns true if a byte value is in the interval of [min, max). rubidium@7326: * rubidium@7326: * @param a The byte value to check rubidium@7326: * @param min The minimum of the interval rubidium@7326: * @param max The maximum of the interval rubidium@7326: * @see IS_INSIDE_1D rubidium@7326: */ rubidium@6491: #define IS_BYTE_INSIDE(a, min, max) ((byte)((a) - (min)) < (byte)((max) - (min))) rubidium@7326: rubidium@7326: /** rubidium@7326: * Checks if an int is in an interval. rubidium@7326: * rubidium@7326: * This macro returns true if a integer value is in the interval of [min, max). rubidium@7326: * rubidium@7326: * @param a The integer value to check rubidium@7326: * @param min The minimum of the interval rubidium@7326: * @param max The maximum of the interval rubidium@7326: * @see IS_INSIDE_1D rubidium@7326: */ rubidium@6491: #define IS_INT_INSIDE(a, min, max) ((uint)((a) - (min)) < (uint)((max) - (min))) truelight@0: rubidium@7326: /** rubidium@7326: * Flips a coin with a given probability. rubidium@7326: * rubidium@7326: * This macro can be used to get true or false randomized according to a rubidium@7326: * given probability. The parameter a and b create a percent value with rubidium@7326: * (a/b). The macro returns true in (a/b) percent. rubidium@7326: * rubidium@7326: * @param a The numerator of the fraction rubidium@7326: * @param b The denominator of the fraction, must of course not be null rubidium@7326: * @return True in (a/b) percent rubidium@7326: */ rubidium@7326: #define CHANCE16(a, b) ((uint16)Random() <= (uint16)((65536 * (a)) / (b))) truelight@0: rubidium@7326: /** rubidium@7326: * Flips a coin with a given probability and saves the randomize-number in a variable. rubidium@7326: * rubidium@7326: * This macro uses the same parameters as the CHANCE16 marco. The third parameter rubidium@7326: * must be a variable the randomize-number from Random() is saved in. rubidium@7326: * rubidium@7326: * @param a The numerator of the fraction, see CHANCE16 rubidium@7326: * @param b The denominator of the fraction, see CHANCE16 rubidium@7326: * @param r The variable to save the randomize-number from Random() rubidium@7326: * @return True in (a/b) percent rubidium@7326: */ rubidium@6491: #define CHANCE16R(a, b, r) ((uint16)(r = Random()) <= (uint16)((65536 * (a)) / (b))) rubidium@7326: rubidium@7326: /** rubidium@7326: * Checks if a given randomize-number is below a given probability. rubidium@7326: * rubidium@7326: * This macro is used to check if the given probability by the fraction of (a/b) rubidium@7326: * is greater than the given randomize-number v. rubidium@7326: * rubidium@7326: * @param a The numerator of the fraction, see CHANCE16 rubidium@7326: * @param b The denominator of the fraction, see CHANCE16 truelight@7837: * @param r The given randomize-number rubidium@7326: * @return True if v is less or equals (a/b) rubidium@7326: */ truelight@7837: static inline bool CHANCE16I(const uint a, const uint b, const uint32 r) truelight@7837: { truelight@7837: return (uint16)r <= (uint16)((65536 * a) / b); truelight@7837: } truelight@0: truelight@0: tron@2952: #define for_each_bit(_i, _b) \ tron@2952: for (_i = 0; _b != 0; _i++, _b >>= 1) \ tron@2952: if (_b & 1) truelight@0: truelight@0: #define abs myabs truelight@0: truelight@0: Darkvater@2966: static inline uint16 ReadLE16Aligned(const void* x) Darkvater@2966: { Darkvater@2966: return FROM_LE16(*(const uint16*)x); Darkvater@2966: } truelight@0: Darkvater@2966: static inline uint16 ReadLE16Unaligned(const void* x) Darkvater@2966: { Darkvater@2966: #ifdef OTTD_ALIGNMENT Darkvater@2966: return ((const byte*)x)[0] | ((const byte*)x)[1] << 8; Darkvater@2966: #else Darkvater@2966: return FROM_LE16(*(const uint16*)x); truelight@0: #endif Darkvater@2966: } Darkvater@2966: truelight@0: tron@2086: /** truelight@7837: * ROtate x Left by n truelight@7837: * tron@2086: * @note Assumes a byte has 8 bits truelight@7837: * @param x The value which we want to rotate truelight@7837: * @param n The number how many we waht to rotate truelight@7837: * @return A bit rotated number tron@2086: */ truelight@7837: template static inline T ROL(const T x, const uint8 n) truelight@7837: { truelight@7837: return (T)(x << n | x >> (sizeof(x) * 8 - n)); truelight@7837: } truelight@7837: truelight@7837: /** truelight@7837: * ROtate x Right by n truelight@7837: * truelight@7837: * @note Assumes a byte has 8 bits truelight@7837: * @param x The value which we want to rotate truelight@7837: * @param n The number how many we waht to rotate truelight@7837: * @return A bit rotated number truelight@7837: */ truelight@7837: template static inline T ROR(const T x, const uint8 n) truelight@7837: { truelight@7837: return (T)(x >> n | x << (sizeof(x) * 8 - n)); truelight@7837: } tron@1852: tron@2398: /** tron@2398: * Return the smallest multiple of n equal or greater than x truelight@7837: * tron@2398: * @note n must be a power of 2 truelight@7837: * @param x The min value truelight@7837: * @param n The base of the number we are searching truelight@7837: * @return The smallest multiple of n equal or greater than x tron@2398: */ truelight@7837: template static inline T ALIGN(const T x, uint n) { truelight@7837: n--; truelight@7837: return (T)((x + n) & ~(n)); truelight@7837: } tron@2398: truelight@4300: /** return the largest value that can be entered in a variable. truelight@4300: */ truelight@4300: #define MAX_UVALUE(type) ((type)~(type)0) truelight@4300: truelight@0: #endif /* MACROS_H */