web2c: Hardware and memory dumps

 
 4.3.3 Hardware and memory dumps
 -------------------------------
 
 By default, memory dump files are generally sharable between
 architectures of different types; specifically, on machines of different
 endianness (⇒(libc)Byte order).  (This is a feature of the Web2c
 implementation, and is not true of all TeX implementations.)  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 installing Web2c for use on
 LittleEndian machines only, perhaps on a PC being used only by you, you
 may wish to get maximum speed.
 
    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 all common formats (plain, LaTeX, AMSTeX,
 ...) do not 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 program always dumps the current date and
 time.  So don't be alarmed by just 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);
      }