Changes between Version 1 and Version 2 of PortableRrdFormat

Jun 20, 2007, 9:47:35 PM (15 years ago)



  • PortableRrdFormat

    v1 v2  
    99There are some provisions in RRD to detect such cross architecture access. But detection is not perfect. Some combinations are bound to even almost work. SPARC to PPC only differs in the representation of NANs.
    11 == Creating a portable RRD format ==
     11== Figuring 64bit Floating Point Numbers ==
    1313The portable RRD format works on all platforms transparently. The first Idea was to use Suns XDR format for RRD. Unfortunately, XDR does not handle NANs which are pretty essential for RRDtool. So I did some investigations into binary representation of IEEE 754 floating point data. I found that it is actually pretty simple to bridge the gap between sparc, ppc and x86 at least, so I assume it won't be rocket science todo other CPUs as well. The following program helped a lot in this task. It shows the binary representation of a few 'interesting' floating point values.
    1919typedef union INSPECTOR {
    2020    uint8_t   b[8];
     21    uint64_t  l;
    2122    double    f;
    2223} INSPECTOR;
    44 I used this to figure the floating point representation for a number of different architectures:
     45I used this to figure the binary representation of double precision floating point numbers on several architectures:
    4647SPARC 32 and 64 bit:
    8889   8.642135e+130 -> 2f 25 c0 c7  43 2b 1f 5b
     92As you can see, there is not all that much difference between the architectures (it is all IEEE 754 after all). For one there is the endianess difference and then there are the SPARCs how seem to have their own idea regarding NANs. In any event, a converter between these formats is only a few defines away.
     95#define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
     96                       (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
     97                       (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
     98                       (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
     99                       (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
     100                       (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
     101                       (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
     102                       (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
     104#define sparc2x86(A)   ((uint64_t)(A) == 0x7fffffffffffffffLL \
     105                                       ? 0x000000000000f87fLL \
     106                                       : endianflip(A))
     108#define x862sparc(A)   ((uint64_t)(A) == 0x000000000000f87fLL \
     109                                       ? 0x7fffffffffffffffLL \
     110                                       : endianflip(A))
     112#define ppc2x86(A)     endianflip(A)
     114#define x862ppc(A)     endianflip(A)
     117== Data alignment differences ==
     119Most of todays workstations run either 32 or 64 bit. This also influences the structure.

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.