Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2602281
  • 博文数量: 333
  • 博客积分: 4817
  • 博客等级: 上校
  • 技术积分: 4413
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-28 10:51
文章分类

全部博文(333)

文章存档

2017年(20)

2016年(57)

2015年(27)

2014年(20)

2013年(21)

2012年(164)

2011年(24)

分类: LINUX

2012-06-01 09:05:00

在网络驱动程序中,分配net_device和sizeof_priv的内存空间,用到以下算法:

alloc_size = sizeof(struct net_device);

if (sizeof_priv) {
       /* ensure 32-byte alignment of private area */
       alloc_size = (alloc_size + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST;
       alloc_size += sizeof_priv;
}

#define NETDEV_ALIGN        32
#define NETDEV_ALIGN_CONST  (NETDEV_ALIGN - 1)

阅读(1918) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~