Linux kernel常用编码模式

struct abc {
int age;
char *name[20];
...
char placeholder[0];
}


The optional block starts with placeholder. Note that placeholder is defined as a vector of size 0. This means that when abc is allocated with the optional block, placeholder points to the beginning of the block. When no optional block is required, placeholder is just a pointer to the end of the structure;

条件语句优化
对于if判断语句,根据概率可以使用likely and unlikely 进行优化,当true的概率大时使用likely,否则使用unlikely

捕捉bug
当BUG_TRAP 的条件 为false时,kernel将会打印警告信息。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzydyg.html