打印

linux 内核中的 bitmap

[复制链接]
211|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
白鹭hu|  楼主 | 2018-8-22 10:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

396

主题

396

帖子

0

粉丝