zoukankan      html  css  js  c++  java
  • CevaEclipse

    1、函数与变量的 Section Attribute

    void foobar (void) __attribute__ ((section (".CSECT mmm"))); 
    void foobar (void) 
    {...}

    上面代码,把函数foobar放置在段 .CSECT mmm中。注意,指名段是放在函数的外部声明里的。
    多重属性的指定,可以通过逗号来分隔开,

    extern int dataobj __attribute__ ((section (".DSECT ooo"), inpage));

    2、函数的 Interrupt Attribute
    把函数定义为软中断或者可屏蔽中断函数。这种函数不能被其他函数调用。

    void int0 (void) __attribute__ ((interrupt));

    如果要执行中断处理程序,应该使用下面属性:

    void nmi_int0 (void) __attribute__ ((interrupt_nmi));

    中断向量表,请参考"crt0.c - Startup Code" section of the crt0.c description


    6、Memory Block Attribute
    语法:

    <type> *<variable_name> __attribute__ ((mem_block (N))); 

    其中,N代表内存块数
    • CEVA-XC32x 0..3 (4 memory blocks)
    • CEVA-XC4210 0..7 (8 memory blocks)
    • CEVA-XC4500 0..7 (8 memory blocks)


    7、Aligned Attribut

    Syntax:
    <type> *<argument_name> __attribute__ ((aligned (N))) 
    <type> <name> __attribute__ ((aligned (N)));

    在CEVA-X/CEVA-XC编译器中,默认是所有变量都是4bytes对齐,除了整型是根据类型宽度对齐,char是1byte,short是2bytes,int是4bytes。

    例子:

    typedef struct 
    { 
        char c; 
        short a[10] __attribute__((aligned (4))); 
    }S; 
    S s __attribute__((aligned (4))); 

    下面是实际对齐的情况
    Words offset data
    0 c
    1 -- padding --
    2 -- padding --
    3 -- padding --
    4 a[0]
    5 a[1]
    6 a[2]
    7 a[3]
    8 a[4]
    9 a[5]
    10 a[6]
    11 a[7]
    12 a[8]
    13 a[9]
    14 -- padding -
    15 -- padding -

    注意,对齐并不支持局部变量!!!

    8、Cyclic Attribute
    如果指针指定了cyclic(N)属性,那么指针的值,就会在模N个bytes里循环修改。

    int arr[4] __attribute__((aligned(4*sizeof(int)))) = {1,2,3,4}; 
    int foo() 
    { 
        int* p __attribute__((cyclic(4 * sizeof(int)))); 
        int i, res = 0; 
        p = &arr[0]; 
        for(i = 0; i < 8; i++) 
        { 
            res += (*p); 
            p++; 
        }
        return res; 
    } 

    这里p会指向arr[0],arr[1],arr[2],arr[3],然后又从arr[0]到arr[1],arr[2],arr[3]这样访问。

  • 相关阅读:
    一份感动到哭的成绩单……
    永远不要、不要、不要、不要放弃
    FusionChart 保存图片 小强斋
    JfreeChart的使用 小强斋
    JFreeChart中文API 小强斋
    FusionChart 小强斋
    面试题>旋转字符串 小强斋
    Dom4j 小强斋
    FusionChart 保存图片 小强斋
    JFreeChart中文API 小强斋
  • 原文地址:https://www.cnblogs.com/McKean/p/6084263.html
Copyright © 2011-2022 走看看