04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Compiler-specific Features<br />

4.4 Type attributes<br />

The __attribute__ keyword enables you to specify special attributes of variables or<br />

structure fields, functions, and types. The keyword format is either:<br />

__attribute__ ((attribute1, attribute2, ...))<br />

__attribute__ ((__attribute1__, __attribute2__, ...))<br />

For example:<br />

void * Function_Attributes_malloc_0(int b) __attribute__ ((malloc));<br />

static int b __attribute__ ((__unused__));<br />

Table 4-4 summarizes the available type attributes.<br />

Table 4-4 Type attributes supported by the compiler and their equivalents<br />

Type attribute<br />

non-attribute equivalent<br />

__attribute__((bitband)) -<br />

__attribute__((aligned))<br />

__attribute__((packed))<br />

__align<br />

__packed a<br />

__attribute__((transparent_union)) -<br />

a. The __packed qualifier does not affect type in GNU mode.<br />

4.4.1 __attribute__((bitband))<br />

__attribute__((bitband)) is a type attribute that gives you efficient atomic access to<br />

single-bit values in SRAM and Peripheral regions of the memory architecture. It is<br />

possible to set or clear a single bit directly with a single memory access in certain<br />

memory regions, rather than having to use the traditional read, modify, write approach.<br />

It is also possible to read a single bit directly rather than having to use the traditional<br />

read then shift and mask operation. Example 4-6 illustrates the use of<br />

__attribute__((bitband)).<br />

Example 4-6 Using __attribute__((bitband))<br />

typedef struct {<br />

int i: 1;<br />

int j: 2;<br />

int k: 3;<br />

} BB __attribute__((bitband));<br />

<strong>ARM</strong> DUI 0348C Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. 4-43<br />

ID101213<br />

Non-Confidential,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!