Chinaunix首页 | 论坛 | 博客
  • 博客访问: 187513
  • 博文数量: 55
  • 博客积分: 1466
  • 博客等级: 上尉
  • 技术积分: 716
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-13 22:34
文章分类

全部博文(55)

文章存档

2011年(27)

2010年(28)

我的朋友

分类: LINUX

2010-10-20 20:36:48

#define __init __attribute__ ((__section__ (".init.text")))
#define __initdata __attribute__ ((__section__ (".init.data")))

#define __exitdata __attribute__ ((__section__(".exit.data")))

#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))

#ifdef MODULE

#define __exit __attribute__ ((__section__(".exit.text")))

#else

#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text")))

#endif__init和__exit标记函数,__initdata和__exitdata标记数据。

      #define __init __attribute__ ((__section__ (".init.text")))
      #define __initdata __attribute__ ((__section__ (".init.data")))

      #define __exitdata __attribute__ ((__section__(".exit.data")))

      #define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))

      #ifdef MODULE

      #define __exit __attribute__ ((__section__(".exit.text")))

      #else

      #define __exit __attribute_used__ __attribute__ ((__section__(".exit.text")))

       #endif__init和__exit标记函数,__initdata和__exitdata标记数据。
 

       此宏定义可知标记后的函数与数据其实是放到了特定的(代码或数据)段中。

        标记为初始化的函数,表明该函数供在初始化期间使用。

        在模块装载之后,模块装载就会将初始化函数扔掉。这样可以将该函数占用的内存释放出来。

       __exit修饰词标记函数只在模块卸载时使用。

        如果模块被直接编进内核则该函数就不会被调用。如果内核编译时没有包含该模块,则此标记的函数将被简单地丢弃。

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

chinaunix网友2010-10-21 10:59:24

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com