这是 Linux 内核代码中的任何一种宏吗?

3

我在Linux内核代码中找到了这个:http://gitorious.org/pandroid/kernel-omap/blobs/5ed7607d45b300a37dd13ad1c79adea56f6687ce/arch/arm/mach-omap2/board-omap4panda.c

该链接指向的是OMAP4 Panda开发板的驱动程序。
MACHINE_START(OMAP4_PANDA, "OMAP4430 Panda Board")
    .phys_io    = 0x48000000,
    .io_pg_offst    = ((0xfa000000) >> 18) & 0xfffc,
    .boot_params    = 0x80000100,
    .map_io     = omap_panda_map_io,
    .init_irq   = omap_panda_init_irq,
    .init_machine   = omap_panda_init,
    .timer      = &omap_timer,
MACHINE_END

我不明白这是什么?这是一个宏还是结构体或其他什么东西..??
定义如下:
/*
 * Set of macros to define architecture features.  This is built into
 * a table by the linker.
 */
#define MACHINE_START(_type,_name)          \
static const struct machine_desc __mach_desc_##_type    \
 __used                         \
 __attribute__((__section__(".arch.info.init"))) = {    \
    .nr     = MACH_TYPE_##_type,        \
    .name       = _name,

#define MACHINE_END             \
};

#endif

但我不明白它是如何工作的?


4
寻找“#define MACHINE_START”的时间需要多久? - Damien_The_Unbeliever
1
@Damien_The_Unbeliever "约有19,100个结果(0.30秒)" ;-)) - Christian.K
3
你应该学习如何获取源代码的预处理形式。在编译命令中用 gcc -C -E 替换 gcc,然后你就可以在 stdout 上获得预处理形式了。 - Basile Starynkevitch
3个回答

5

指定结构初始化是GNU GCC的扩展功能,如果您习惯了ANSI C编译器,可能会感到有些奇怪。再加上一个宏,使其在许多方面看起来像一种外语。展开后的源代码如下:

static const struct machine_desc __mach_desc_OMAP4_PANDA
 __used  __attribute__((__section__(".arch.info.init"))) = {
    .nr     = MACH_TYPE_OMAP4_PANDA,
    .name         = "OMAP4430 Panda Board",
    .phys_io      = 0x48000000,
    .io_pg_offst  = ((0xfa000000) >> 18) & 0xfffc,
    .boot_params  = 0x80000100,
    .map_io       = omap_panda_map_io,
    .init_irq     = omap_panda_init_irq,
    .init_machine = omap_panda_init,
    .timer        = &omap_timer,
};

2

0

这是一种指定初始化程序,它用于初始化结构对象。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接