BLI_bitmap: typecheck maco

This commit is contained in:
Campbell Barton 2014-06-06 16:00:53 +10:00
parent 341fd67fbf
commit a427fa5261
2 changed files with 27 additions and 17 deletions

@ -153,10 +153,12 @@ static BLI_bitmap *multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden,
/* If prev_hidden is available, copy it to
* subd, except when the equivalent element in
* lo_hidden is different */
if (lo_val != prev_hidden[hi_ndx])
if (lo_val != prev_hidden[hi_ndx]) {
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
else
}
else {
BLI_BITMAP_MODIFY(subd, hi_ndx, prev_hidden[hi_ndx]);
}
}
else {
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);

@ -37,17 +37,17 @@ typedef unsigned int BLI_bitmap;
/* internal use */
/* 2^5 = 32 (bits) */
#define BLI_BITMAP_POWER 5
#define _BITMAP_POWER 5
/* 0b11111 */
#define BLI_BITMAP_MASK 31
#define _BITMAP_MASK 31
/* number of blocks needed to hold '_tot' bits */
#define BLI_BITMAP_NUM_BLOCKS(_tot) \
(((_tot) >> BLI_BITMAP_POWER) + 1)
#define _BITMAP_NUM_BLOCKS(_tot) \
(((_tot) >> _BITMAP_POWER) + 1)
/* size (in bytes) used to hold '_tot' bits */
#define BLI_BITMAP_SIZE(_tot) \
(BLI_BITMAP_NUM_BLOCKS(_tot) * sizeof(unsigned int))
(_BITMAP_NUM_BLOCKS(_tot) * sizeof(unsigned int))
/* allocate memory for a bitmap with '_tot' bits; free
* with MEM_freeN() */
@ -61,33 +61,41 @@ typedef unsigned int BLI_bitmap;
/* get the value of a single bit at '_index' */
#define BLI_BITMAP_GET(_bitmap, _index) \
((_bitmap)[(_index) >> BLI_BITMAP_POWER] & \
(1u << ((_index) & BLI_BITMAP_MASK)))
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
((_bitmap)[(_index) >> _BITMAP_POWER] & \
(1u << ((_index) & _BITMAP_MASK))))
#define BLI_BITMAP_GET_BOOL(_bitmap, _index) \
(BLI_BITMAP_GET(_bitmap, _index) != 0)
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
(BLI_BITMAP_GET(_bitmap, _index) != 0))
/* set the value of a single bit at '_index' */
#define BLI_BITMAP_SET(_bitmap, _index) \
((_bitmap)[(_index) >> BLI_BITMAP_POWER] |= \
(1u << ((_index) & BLI_BITMAP_MASK)))
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
((_bitmap)[(_index) >> _BITMAP_POWER] |= \
(1u << ((_index) & _BITMAP_MASK))))
/* clear the value of a single bit at '_index' */
#define BLI_BITMAP_CLEAR(_bitmap, _index) \
((_bitmap)[(_index) >> BLI_BITMAP_POWER] &= \
~(1u << ((_index) & BLI_BITMAP_MASK)))
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
((_bitmap)[(_index) >> _BITMAP_POWER] &= \
~(1u << ((_index) & _BITMAP_MASK))))
/* set or clear the value of a single bit at '_index' */
#define BLI_BITMAP_MODIFY(_bitmap, _index, _set) \
do { \
{ \
CHECK_TYPE(_bitmap, BLI_bitmap *); \
if (_set) \
BLI_BITMAP_SET(_bitmap, _index); \
else \
BLI_BITMAP_CLEAR(_bitmap, _index); \
} while (0)
} (void)0
/* resize bitmap to have space for '_tot' bits */
#define BLI_BITMAP_RESIZE(_bitmap, _tot) \
(_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot))
{ \
CHECK_TYPE(_bitmap, BLI_bitmap *); \
(_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \
} (void)0
#endif