diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenlib/BLI_bitmap.h | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenlib/BLI_bitmap.h')
-rw-r--r-- | source/blender/blenlib/BLI_bitmap.h | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h index 29742fdf789..3af25e3de1d 100644 --- a/source/blender/blenlib/BLI_bitmap.h +++ b/source/blender/blenlib/BLI_bitmap.h @@ -36,77 +36,72 @@ typedef unsigned int BLI_bitmap; #define _BITMAP_MASK 31 /* number of blocks needed to hold '_tot' bits */ -#define _BITMAP_NUM_BLOCKS(_tot) \ - (((_tot) >> _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) \ - ((size_t)(_BITMAP_NUM_BLOCKS(_tot)) * sizeof(BLI_bitmap)) +#define BLI_BITMAP_SIZE(_tot) ((size_t)(_BITMAP_NUM_BLOCKS(_tot)) * sizeof(BLI_bitmap)) /* allocate memory for a bitmap with '_tot' bits; free with MEM_freeN() */ #define BLI_BITMAP_NEW(_tot, _alloc_string) \ - ((BLI_bitmap *)MEM_callocN(BLI_BITMAP_SIZE(_tot), \ - _alloc_string)) + ((BLI_bitmap *)MEM_callocN(BLI_BITMAP_SIZE(_tot), _alloc_string)) /* allocate a bitmap on the stack */ #define BLI_BITMAP_NEW_ALLOCA(_tot) \ - ((BLI_bitmap *)memset(alloca(BLI_BITMAP_SIZE(_tot)), 0, BLI_BITMAP_SIZE(_tot))) + ((BLI_bitmap *)memset(alloca(BLI_BITMAP_SIZE(_tot)), 0, BLI_BITMAP_SIZE(_tot))) /* Allocate using given MemArena */ #define BLI_BITMAP_NEW_MEMARENA(_mem, _tot) \ - (CHECK_TYPE_INLINE(_mem, MemArena *), \ - ((BLI_bitmap *)BLI_memarena_calloc(_mem, BLI_BITMAP_SIZE(_tot)))) + (CHECK_TYPE_INLINE(_mem, MemArena *), \ + ((BLI_bitmap *)BLI_memarena_calloc(_mem, BLI_BITMAP_SIZE(_tot)))) /* get the value of a single bit at '_index' */ #define BLI_BITMAP_TEST(_bitmap, _index) \ - (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ - ((_bitmap)[(_index) >> _BITMAP_POWER] & \ - (1u << ((_index) & _BITMAP_MASK)))) + (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ + ((_bitmap)[(_index) >> _BITMAP_POWER] & (1u << ((_index)&_BITMAP_MASK)))) #define BLI_BITMAP_TEST_AND_SET_ATOMIC(_bitmap, _index) \ - (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ - (atomic_fetch_and_or_uint32((uint32_t*)&(_bitmap)[(_index) >> _BITMAP_POWER], \ - (1u << ((_index) & _BITMAP_MASK))) & \ - (1u << ((_index) & _BITMAP_MASK)))) + (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ + (atomic_fetch_and_or_uint32((uint32_t *)&(_bitmap)[(_index) >> _BITMAP_POWER], \ + (1u << ((_index)&_BITMAP_MASK))) & \ + (1u << ((_index)&_BITMAP_MASK)))) #define BLI_BITMAP_TEST_BOOL(_bitmap, _index) \ - (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ - (BLI_BITMAP_TEST(_bitmap, _index) != 0)) + (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ + (BLI_BITMAP_TEST(_bitmap, _index) != 0)) /* set the value of a single bit at '_index' */ #define BLI_BITMAP_ENABLE(_bitmap, _index) \ - (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ - ((_bitmap)[(_index) >> _BITMAP_POWER] |= \ - (1u << ((_index) & _BITMAP_MASK)))) + (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ + ((_bitmap)[(_index) >> _BITMAP_POWER] |= (1u << ((_index)&_BITMAP_MASK)))) /* clear the value of a single bit at '_index' */ #define BLI_BITMAP_DISABLE(_bitmap, _index) \ - (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ - ((_bitmap)[(_index) >> _BITMAP_POWER] &= \ - ~(1u << ((_index) & _BITMAP_MASK)))) + (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ + ((_bitmap)[(_index) >> _BITMAP_POWER] &= ~(1u << ((_index)&_BITMAP_MASK)))) /* flip the value of a single bit at '_index' */ #define BLI_BITMAP_FLIP(_bitmap, _index) \ - (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ - ((_bitmap)[(_index) >> _BITMAP_POWER] ^= \ - (1u << ((_index) & _BITMAP_MASK)))) + (CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \ + ((_bitmap)[(_index) >> _BITMAP_POWER] ^= (1u << ((_index)&_BITMAP_MASK)))) /* set or clear the value of a single bit at '_index' */ #define BLI_BITMAP_SET(_bitmap, _index, _set) \ - { \ - CHECK_TYPE(_bitmap, BLI_bitmap *); \ - if (_set) \ - BLI_BITMAP_ENABLE(_bitmap, _index); \ - else \ - BLI_BITMAP_DISABLE(_bitmap, _index); \ - } (void)0 + { \ + CHECK_TYPE(_bitmap, BLI_bitmap *); \ + if (_set) \ + BLI_BITMAP_ENABLE(_bitmap, _index); \ + else \ + BLI_BITMAP_DISABLE(_bitmap, _index); \ + } \ + (void)0 /* resize bitmap to have space for '_tot' bits */ #define BLI_BITMAP_RESIZE(_bitmap, _tot) \ - { \ - CHECK_TYPE(_bitmap, BLI_bitmap *); \ - (_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \ - } (void)0 + { \ + CHECK_TYPE(_bitmap, BLI_bitmap *); \ + (_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \ + } \ + (void)0 void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits); void BLI_bitmap_flip_all(BLI_bitmap *bitmap, size_t bits); |