2014年2月13日 星期四
2014年1月13日 星期一
kernel里的头文件 asm 与 asm-generic
http://www.cnblogs.com/sammei/archive/2013/03/14/3295598.html
asm的路径是 arch/xxx/include/asm/
asm-generic 的路径是 include/asm-generic/
代码中包含asm/中的头文件,如果某一个架构没有自己特殊代码的话,其中会使用通用版本的头文件,即包含 asm-generic/里的对应.h文件。
代码中不会直接包含 asm-generic/ 里的.h文件
拿arm来举例
#include <asm/gpio.h> 引用的头文件是 arch/arm/include/asm/gpio.h
#include <asm-generic/gpio.h> 引用的是头文件是 include/asm-generic/gpio.h
asm的路径是 arch/xxx/include/asm/
asm-generic 的路径是 include/asm-generic/
代码中包含asm/中的头文件,如果某一个架构没有自己特殊代码的话,其中会使用通用版本的头文件,即包含 asm-generic/里的对应.h文件。
代码中不会直接包含 asm-generic/ 里的.h文件
拿arm来举例
#include <asm/gpio.h> 引用的头文件是 arch/arm/include/asm/gpio.h
#include <asm-generic/gpio.h> 引用的是头文件是 include/asm-generic/gpio.h
Linux driver函式指標的型別檢查
static int key_probe() // should be key_probe(struct platform_device *) { printk( KERN_ALERT "[key_probe]\n" ); return 0; } static int key_remove( float f ) // should be key_remove(struct platform_device *) { return 0; } static struct platform_driver key_driver = { .probe = key_probe, // function pointer DO NOT check argument .remove = key_remove, // function pointer DO NOT check argument .driver = { .name = "push-button", .owner = THIS_MODULE, }, }; static int key_init() { struct platform_device* a; ... key_driver.probe(a); // DO NOT MATCH arguement of function pointer key_driver.remove(a); // DO NOT MATCH arguement of function pointer ... } static void key_exit() { } module_init(key_init) module_exit(key_exit)編譯通過,但執行時發生錯誤。顯示GCC對Linux driver在platform_driver與實際呼叫(key_driver.probe(a),key_driver.remove(a))時型別檢查,但是對於函式指標(function pointer)的指定部分並沒有,到了實際執行時才會發生錯誤。
訂閱:
文章 (Atom)