zoukankan      html  css  js  c++  java
  • 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) */
  • 相关阅读:
    matplotlib 学习总结
    数据获取,解析,存储等知识的学习总结
    python学习总结
    Mybatis Plus各种查询方法
    centos启动Nginx提示nginx: [emerg] still could not bind()
    vue只能本地跨域,线上跨域要后端弄
    小程序图片懒加载
    html直接引入vue.js
    vue监听浏览器关闭
    【算法】归并排序算法的编码和优化
  • 原文地址:https://www.cnblogs.com/ronnydm/p/5756237.html
Copyright © 2011-2022 走看看