Linux kernel代码中的c语法疑问

Samuelsun 2007-11-15 02:55:32
struct writeback_control {
struct backing_dev_info *bdi; /* If !NULL, only write back this
queue */
enum writeback_sync_modes sync_mode;
unsigned long *older_than_this; /* If !NULL, only write back inodes
older than this */
long nr_to_write; /* Write this many pages, and decrement
this for each page written */
long pages_skipped; /* Pages which were not written */

/*
* For a_ops->writepages(): is start or end are non-zero then this is
* a hint that the filesystem need only write out the pages inside that
* byterange. The byte at `end' is included in the writeout request.
*/
loff_t range_start;
loff_t range_end;

unsigned nonblocking:1; /* Don't get stuck on request queues */
unsigned encountered_congestion:1; /* An output: a queue is full */
unsigned for_kupdate:1; /* A kupdate writeback */
unsigned for_reclaim:1; /* Invoked from the page allocator */
unsigned for_writepages:1; /* This is a writepages() call */
unsigned range_cyclic:1; /* range_start is cyclic */
};
这里的:1表示什么含义啊?
谢谢各位
...全文
189 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
vigorousfish 2007-11-19
  • 打赏
  • 举报
回复
这种数据结构叫做位域,可以把一个比特分成几块用,比如一个开关变量实际只需要占用一位用1或0表示,那么就不用使用整个比特,可以定义为
struce bit
{
int a:1;
int b:1;
int c:6;
};
这里a和b占用了一位,c占用了6位,但是注意,当给成员赋值的时候,不能超过它本身的位数,也就是说bit.a和bie.b不能赋上大于1的值,bit.c不能赋上大于63的值
artszhao 2007-11-18
  • 打赏
  • 举报
回复
赞3楼的~~~

功力不够切勿强求啊。。。
stormful 2007-11-16
  • 打赏
  • 举报
回复
夸张
土豆 2007-11-16
  • 打赏
  • 举报
回复
2楼的哥们,你把这当C++的初始化成员列表了?

顶1楼的,只是位域,跟Linux无关,建议看C语言基础教程。另外建议暂时不要看Linux源码,功力不到强练内功会走火入魔的。
hefuhua 2007-11-16
  • 打赏
  • 举报
回复
该结构对象变量的初始值,定义一个结构对象后的对象变量一般默认为0,这样初值为1使用..
xtzyz 2007-11-15
  • 打赏
  • 举报
回复
位段结构,占用了其中的一个二进制位

4,441

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧