Portability of variable-length datatypes, compounds etc.

Hello,

Does anyone here know about the portability of variable-length data items, particularly when in a compound?

If standard datatypes are used in the fields of a compound, they can be read across platforms even if the layout of the compound didn't directly fit the layout of a C structure on a target platform. For variable-length fields, however, the space occupied on the compound layout is the size of hvl_t struct which may vary from platform to platform:

typedef struct {
    size_t len; /* Length of VL data (in base type units) */
    void *p; /* Pointer to VL data */
} hvl_t;

For example, the "void *" field could be 32 bits or 64 bits. Is there some special arrangement whereby the variable-length fields of compound datatypes are made portable or are they simply non-portable?

How about variable-length elements in an array, are they portable or do they have the same problem?

Thanks in advance for any knowledge shared.

Best Regards,
  Vesa

Vesa,

Variable-length datatypes are 100% portable. The hvl_t struct exists only in memory; the equivalent structures stored in the file (the "pointers" in the actual dataset data) are always little-endian and their size is determined by the "size of offsets" in the file superblock. The HDF5 library will automatically translate between this on-disk format and whatever form in memory the hvl_t struct takes on your machine.

When a variable-length datatype is present in a compound datatype, the compound on disk is automatically resized and repacked to account for possible changes in the size of the variable-length data "pointer". Vlens in arrays are portable as well (even vlens in vlens). In short, you so not need to worry about exactly how the data is stored on disk, as the HDF5 library will handle any and all conversions necessary.

Let me know if you have any other questions.

Thanks,
Neil Fortner
The HDF Group

Vesa Paatero wrote:

···

Hello,

Does anyone here know about the portability of variable-length data items, particularly when in a compound?

If standard datatypes are used in the fields of a compound, they can be read across platforms even if the layout of the compound didn't directly fit the layout of a C structure on a target platform. For variable-length fields, however, the space occupied on the compound layout is the size of hvl_t struct which may vary from platform to platform:

typedef struct {

    size_t len; /* Length of VL data (in base type units) */

    void *p; /* Pointer to VL data */

} hvl_t;

For example, the "void *" field could be 32 bits or 64 bits. Is there some special arrangement whereby the variable-length fields of compound datatypes are made portable or are they simply non-portable?

How about variable-length elements in an array, are they portable or do they have the same problem?

Thanks in advance for any knowledge shared.

Best Regards,

  Vesa

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.