Linux宏:__ASSEMBLY__


汇编:assembly

猜测:所以这个宏跟汇编有关?!

引用:某些常量宏会同时被C和asm引用,而C与asm在对立即数符号的处理上是不同的。asm中通过指令来区分其操作数是有符号还是无符号的,而不是通过操作数。而C中是通过变量的属性,而不是通过操作符。C中如果要指明常量有无符号,必须为常量添加后缀,而asm则通过使用不同的指令来指明。如此,当一个常量被C和asm同时包含时,必须做不同的处理。故KBUILD_AFLAGS中将添加一项D__ASSEMBLY__,来告知预处理器此时是asm。

/* linux-3.08/include/linux/const.h */

/* const.h: Macros for dealing with constants.  */

#ifndef _LINUX_CONST_H
#define _LINUX_CONST_H

/* Some constant macros are used in both assembler and
 * C code.  Therefore we cannot annotate them always with
 * 'UL' and other type specifiers unilaterally.  We
 * use the following macros to deal with this.
 *
 * Similarly, _AT() will cast an expression with a type in C, but
 * leave it unchanged in asm.
 */

/*
* 上边的注释说:一些常量宏同时在汇编和C中使用,然而,我们不能像注释C的常量宏那样加一个“UL”或其他后缀。所以我们需要使用以下的宏解决这个问题。
* 例如调用:#define DEMO_MACRO _AT(1, UL):在C中会被解释为 #define DEMO_MACRO 1UL; 而在汇编中什么都不做,就是: #define DEMO_MACRO 1
*/
#ifdef __ASSEMBLY__
#define _AC(X,Y) X #define _AT(T,X) X #else #define __AC(X,Y) (X##Y) #define _AC(X,Y) __AC(X,Y) #define _AT(T,X) ((T)(X)) #endif #endif /* !(_LINUX_CONST_H) */

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM