Changes between Version 4 and Version 5 of PortableRrdFormat


Ignore:
Timestamp:
Jun 20, 2007, 10:14:12 PM (15 years ago)
Author:
oetiker
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PortableRrdFormat

    v4 v5  
    115115}}}
    116116
    117 == Data alignment differences ==
     117== Data Alignment ==
    118118
    119119Most of today's workstations run either 32 or 64 bit. This also has an influence on the data layout. The classic RRDtool data format heavily relies on doubles and longs, bundled into structs. This is a challenging mix for portability:
     
    123123 * struct members are aligned to either 32 bit or 64 bit boundaries.
    124124
    125 Below is an example of a the memory layout of several simple structs, made up from integers(32bit) and doubles(64bit).
     125Below is an example of a the memory layout of several simple structs, made up from integers (32 bit) and doubles (64 bit).
    126126
    127127{{{
    128 32 Bit (16 Byte) : IIII.DDDD.DDDD.IIII
    129 64 Bit (24 Byte) : IIII ~~~~.DDDD DDDD.IIII ~~~~
     12832 bit (16 byte) : IIII.DDDD.DDDD.IIII
     12964 bit (24 byte) : IIII ~~~~.DDDD DDDD.IIII ~~~~
    130130
    131 32 Bit (12 Byte) : IIII.IIII.IIII
    132 64 Bit (12 Byte) : IIII IIII.IIII
     13132 bit (12 byte) : IIII.IIII.IIII
     13264 bit (12 byte) : IIII IIII.IIII
    133133
    134 32 Bit (16 Byte) : IIII.IIII.DDDD.DDDD.IIII.IIII
    135 64 Bit (24 Byte) : IIII IIII.DDDD DDDD.IIII IIII
     13432 bit (16 byte) : IIII.IIII.DDDD.DDDD.IIII.IIII
     13564 bit (24 byte) : IIII IIII.DDDD DDDD.IIII IIII
    136136}}}
    137137
    138 This means, that in order to produce a portable data format, structs must be layed out such that they are aligned the same, on 32 and 64 bit systems.
     138This means, that in order to produce a portable data format, structs must be laid out such that they are aligned the same, on 32 and 64 bit systems.
     139
     140== Longs and Integers ==
     141
     142On 32 bit architectures, integers and longs are 32 bit wide. While longs are normally 64 bit wide on 64 bit architectures. Since the RRDtool data format uses a lot of longs, this also has to be addressed in a portable format. Fortunately, there are datatypes that are less architecture dependent, defined in the inttypes header.
     143
     144{{{
     145#include <inttypes.h>
     146uint8_t  unsigned_8_bit_integer;
     147uint32_t unsigned_32_bit_integer;
     148int64_t  signed_64_bit_integer;
     149/* and so on */
     150}}}
     151
     152== Conclusion ==
     153
     154Based on this information a portable RRDtool data format that works at least on
     155PPC, x86 and SPARC will be not all that difficult to design.
     156
     157Information on other architectures is welcome: Alpha, PA-RISC, Itanium, MIPS.

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.