1. 简介:
2. 函数解析:
DECLARE_BITMAP 宏
[cpp] view plain copy
print?<img id="aimg_ebM3O" class="zoom" width="12" height="12" file="https://code.csdn.net/assets/CODE_ico.png" border="0" alt="" /><img id="aimg_hIiv2" class="zoom" width="12" height="12" file="https://code.csdn.net/assets/ico_fork.svg" border="0" alt="" />
#define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)]
解析如下:
[cpp] view plain copy
print?<img id="aimg_dCsUE" class="zoom" width="12" height="12" file="https://code.csdn.net/assets/CODE_ico.png" border="0" alt="" /><img id="aimg_DfBbH" class="zoom" width="12" height="12" file="https://code.csdn.net/assets/ico_fork.svg" border="0" alt="" />
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) + #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -> #define BITS_TO_LONGS(nr) ((nr + 8 * sizeof(long) - 1) / 8 * sizeof(long)) == #define BITS_TO_LONGS(nr) ((nr + 64 - 1) / 64) /* 64 位的 linux 下 */ -> #define BITS_TO_LONGS(nr) ((nr + 63) / 64) nr BITS_TO_LONGS 0 | 0 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 63 | 0 64 | 1
则函数的功能如下:
DECLARE_BITMAP(name, bits) == name[bits]
其中的 bits 的取值范围是 【0,63】(64位系统)、【0,31】(32位系统)
此文持续更新中.....
linux |