home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / web2c / lib / texmfmem.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  128 lines

  1. /* texmfmem.h: the memory_word type, which is too hard to translate
  2.    automatically from Pascal.  We have to make sure the byte-swapping
  3.    that the (un)dumping routines do suffices to put things in the right
  4.    place in memory.
  5.  
  6.    A memory_word can be broken up into a `twohalves' or a
  7.    `fourquarters', and a `twohalves' can be further broken up.  Here is
  8.    a picture.  ..._M = most significant byte, ..._L = least significant
  9.    byte.
  10.    
  11.    If BigEndian:
  12.    twohalves.v:  RH_M  RH_L  LH_M  LH_L
  13.    twohalves.u:  JNK1  JNK2    B0    B1
  14.    fourquarters:   B0    B1    B2    B3
  15.    
  16.    If LittleEndian:
  17.    twohalves.v:  LH_L  LH_M  RH_L  RH_M
  18.    twohalves.u:    B1    B0  JNK1  JNK2
  19.    fourquarters:   B3    B2    B1    B0
  20.    
  21.    The halfword fields are four bytes if we are building a TeX or MF;
  22.    this leads to further complications:
  23.    
  24.    BigEndian:
  25.    twohalves.v:  RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
  26.    twohalves.u:  ---------JUNK----------  B0    B1
  27.    fourquarters:   B0    B1    B2    B3
  28.  
  29.    LittleEndian:
  30.    twohalves.v:  LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
  31.    twohalves.u:  junkx junky  B1    B0
  32.    fourquarters: ---------JUNK----------  B3    B2    B1    B0
  33.  
  34.    I guess TeX and Metafont never refer to the B1 and B0 in the
  35.    fourquarters structure as the B1 and B0 in the twohalves.u structure.
  36.    
  37.    This file can't be part of texmf.h, because texmf.h gets included by
  38.    {tex,mf}d.h before the `halfword' etc. types are defined.  So we
  39.    include it from the change file instead.
  40. */
  41.  
  42. typedef union
  43. {
  44.   struct
  45.   {
  46. #ifdef WORDS_BIGENDIAN
  47.     halfword RH, LH;
  48. #else
  49.     halfword LH, RH;
  50. #endif
  51.   } v;
  52.  
  53.   struct
  54.   { /* Make B0,B1 overlap the most significant bytes of LH.  */
  55. #ifdef WORDS_BIGENDIAN
  56.     halfword junk;
  57.     quarterword B0, B1;
  58. #else /* not WORDS_BIGENDIAN */
  59.   /* If 32-bit TeX/MF, have to have an extra two bytes of junk.  
  60.      I would like to break this line, but I'm afraid that some
  61.      preprocessors don't properly handle backslash-newline in # commands.  */
  62. #if (defined (TeX) && !defined (SMALLTeX)) || !defined (TeX) && !defined (SMALLMF)
  63.     quarterword junkx, junky;
  64. #endif /* big TeX or big MF */
  65.     quarterword B1, B0;
  66. #endif /* not WORDS_BIGENDIAN */
  67.   } u;
  68. } twohalves;
  69.  
  70. typedef struct
  71. {
  72.   struct
  73.   {
  74. #ifdef WORDS_BIGENDIAN
  75.     quarterword B0, B1, B2, B3;
  76. #else
  77.     quarterword B3, B2, B1, B0;
  78. #endif
  79.   } u;
  80. } fourquarters;
  81.  
  82.  
  83. typedef union
  84. {
  85. #ifdef TeX
  86.   glueratio gr;
  87.   twohalves hh;
  88. #else
  89.   twohalves hhfield;
  90. #endif
  91. #ifdef WORDS_BIGENDIAN
  92.   integer cint;
  93.   fourquarters qqqq;
  94. #else /* not WORDS_BIGENDIAN */
  95.   struct
  96.   {
  97. #if defined (TeX) && !defined (SMALLTeX) || !defined (TeX) && !defined (SMALLMF)
  98.     halfword junk;
  99. #endif /* big TeX or big MF */
  100.     integer CINT;
  101.   } u;
  102.  
  103.   struct
  104.   {
  105. #if defined (TeX) && !defined (SMALLTeX) || !defined (TeX) && !defined (SMALLMF)
  106.     halfword junk;
  107. #endif /* big TeX or big MF */
  108.     fourquarters QQQQ;
  109.   } v;
  110. #endif /* not WORDS_BIGENDIAN */
  111. } memoryword;
  112.  
  113.  
  114. /* To keep the original structure accesses working, we must go through
  115.    the extra names C forced us to introduce.  */
  116. #define    b0 u.B0
  117. #define    b1 u.B1
  118. #define    b2 u.B2
  119. #define    b3 u.B3
  120.  
  121. #define rh v.RH
  122. #define lhfield    v.LH
  123.  
  124. #ifndef WORDS_BIGENDIAN
  125. #define cint u.CINT
  126. #define qqqq v.QQQQ
  127. #endif
  128.