Previous: Data encoding, Up: Data encoding
Data types are either atomic or conglomerate. Atomic types map to the
standard C types of int
, double
, unsigned int
.
Integers are assumed to be have 32 bits. Conglomerate types are
composed of atomic types or nested conglomerate types, and are mapped
onto C structures. The set of available data types is fixed; it can be
extended only by recompilation of the bpipe
library. Data types
are specified by user programs via a set of enum
constants.
For each data type, bpipe
keeps track of its size, and, if it's a
conglomerate type, the sizes and offsets of its constituent types. When
data is written to a bpipe
stream, conglomerate types are
resolved into their representative atomic types. Only the actual data
is written to the stream – any padding which arises from the C
structure representation of the data type is ignored. When data is
read, any such padding is restored. Since the amount of padding is
determined at compile time for each platform, the data stream is immune
from the vagaries of internal structure alignment. The arrangement of
elements of conglomerate types has been done to minimize the amount of
internal padding in the C structure. This reduces the number of copy
operations, as copies of adjacent memory locations are collapsed into a
single copy operation.
The tables which define the sizes and offsets of the data types can be
found in datatypes_info.h. Note that this file is automatically
created by the program mkdt
, which parses a restricted form of
structure definitions (see datatypes.h).