web2c: Hardware and memory dumps
4.3.3 Hardware and memory dumps
-------------------------------
By default, memory dump files are sharable between architectures of
different types; specifically, on machines of different endianness
(⇒(libc)Byte order) and with different word sizes (4-byte 'long'
vs. 8-byte 'long'). This is a feature of the Web2c implementation, and
is not true of all TeX implementations.
The script 'tl-check-fmtshare' in the TeX Live source tree
('Master/tlpkg/bin') provides a relatively easy way to test that a
'.fmt' built on the local host can be loaded by a TeX engine built on
some remote host.
If you specify '--disable-dump-share' to 'configure', however, memory
dumps will be endian-dependent. The reason to do this is speed. To
achieve endian-independence, the reading of memory dumps on LittleEndian
architectures, such as PC's and DEC architectures, is somewhat slowed
(all the multibyte values have to be swapped). Usually, this is not
noticeable, and the advantage of being able to share memory dumps across
all platforms at a site far outweighs the speed loss. But if you're
trying to squeeze out every possible bit of performance, you may wish to
do this.
TeXnically, even without '--disable-dump-share', sharing of '.fmt'
files cannot be guaranteed to work. Floating-point values are always
written in native format, and hence will generally not be readable
across platforms. Fortunately, TeX uses floating point only to
represent glue ratios, and none of the common formats (plain, LaTeX,
AMSTeX, ...) do any glue setting at '.fmt'-creation time. Metafont does
not use floating point in any dumped value at all.
Incidentally, different memory dump files will never compare equal
byte-for-byte, because the programs dump the current date and time. So
don't be alarmed by a few bytes difference.
If you don't know what endianness your machine is, and you're
curious, here is a little C program to tell you. (The 'configure'
script contains a similar program.) This is from the book 'C: A
Reference Manual', by Samuel P. Harbison and Guy L. Steele Jr. (⇒
References).
main ()
{
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
if (u.c[0] == 1)
printf ("LittleEndian\n");
else if (u.c[sizeof (long) - 1] == 1)
printf ("BigEndian\n");
else
printf ("unknownEndian");
exit (u.c[sizeof (long) - 1] == 1);
}
You can add 'printf("long %d\n", sizeof(long));' to see the size of
the 'long' data type.