这是任何一种在Linux内核code宏的? [英] Is this any kind of macro in linux kernel code?

查看:96
本文介绍了这是任何一种在Linux内核code宏的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个Linux内核code <一个href=\"http://gitorious.org/pandroid/kernel-omap/blobs/5ed7607d45b300a37dd13ad1c79adea56f6687ce/arch/arm/mach-omap2/board-omap4panda.c\" rel=\"nofollow\">http://gitorious.org/pandroid/kernel-omap/blobs/5ed7607d45b300a37dd13ad1c79adea56f6687ce/arch/arm/mach-omap2/board-omap4panda.c

i found this in linux kernel code http://gitorious.org/pandroid/kernel-omap/blobs/5ed7607d45b300a37dd13ad1c79adea56f6687ce/arch/arm/mach-omap2/board-omap4panda.c

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

我没有得到这是什么..?这是宏或结构或什么.. ???

i am not getting what is this..? is this a macro or structure or what..???

定义说:

/*
 * 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

但我不理解的是如何工作的呢?

but i am not understanding how's it work?

推荐答案

指定的结构初始化是一个GNU GCC扩展,它看起来有点怪,如果你是用ANSI C编译器。这一个雄心勃勃的宏观相结合,使得它看起来像在许多方面一门外语。扩展的源$ C ​​$ c是:

The designated structure initialization is a GNU GCC extension which looks a bit strange if you are used to ANSI C compilers. That combined with an ambitious macro makes it look like a foreign language in many respects. The expanded source code is:

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,
};

这篇关于这是任何一种在Linux内核code宏的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆