31.07.2013 Views

RAPL 3 - Reference Guide. - Phoenix Goucher

RAPL 3 - Reference Guide. - Phoenix Goucher

RAPL 3 - Reference Guide. - Phoenix Goucher

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.

30 Data Types and Variables<br />

Unions<br />

Unions (like unions in C) are possible.<br />

union<br />

field_list<br />

end union<br />

Where field_list is a list of declarations which can include int, float, string[], cloc,<br />

ploc, or a complex type like struct or union.<br />

union<br />

int a<br />

float b<br />

end union xxx<br />

typedef omega union<br />

int a<br />

float b<br />

end union<br />

Unions are referenced like structures, but have one important difference. All of<br />

the fields of a structure are located in distinct locations in memory, allowing all<br />

fields of a structure to hold values at the same time. However, in unions, all<br />

fields are located at the same memory location. Hence in variable xxx above,<br />

writing into field a of the union also alters the value of field b. Unions are<br />

typically used where a block of information may hold more than one kind of data.

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

Saved successfully!

Ooh no, something went wrong!