Back to index

tetex-bin  3.0
texmfmem.h
Go to the documentation of this file.
00001 /* texmfmem.h: the memory_word type, which is too hard to translate
00002    automatically from Pascal.  We have to make sure the byte-swapping
00003    that the (un)dumping routines do suffices to put things in the right
00004    place in memory.
00005 
00006    A memory_word can be broken up into a `twohalves' or a
00007    `fourquarters', and a `twohalves' can be further broken up.  Here is
00008    a picture.  ..._M = most significant byte, ..._L = least significant
00009    byte.
00010    
00011    The halfword fields are four bytes if we are building a big TeX or MF;
00012    this leads to further complications:
00013    
00014    BigEndian:
00015    twohalves.v:  RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
00016    twohalves.u:  ---------JUNK----------  B0         B1
00017    fourquarters:   B0    B1    B2    B3
00018 
00019    LittleEndian:
00020    twohalves.v:  LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
00021    twohalves.u:  B1          B0
00022    fourquarters: ---------JUNK----------  B3    B2    B1    B0
00023 
00024    I guess TeX and Metafont never refer to the B1 and B0 in the
00025    fourquarters structure as the B1 and B0 in the twohalves.u structure.
00026    
00027    The B0 and B1 fields are declared short instead of quarterword,
00028    because they are used in character nodes to store a font number and a
00029    character.  If left as a quarterword (which is a single byte), we
00030    couldn't support more than 256 fonts. (If shorts aren't two bytes,
00031    this will lose.)
00032    
00033    In the old four-byte memory structure (something more needs to be
00034    done to handle >256 fonts):
00035    
00036    If BigEndian:
00037    twohalves.v:  RH_M  RH_L  LH_M  LH_L
00038    twohalves.u:  JNK1  JNK2    B0    B1
00039    fourquarters:   B0    B1    B2    B3
00040    
00041    If LittleEndian:
00042    twohalves.v:  LH_L  LH_M  RH_L  RH_M
00043    twohalves.u:    B1    B0  JNK1  JNK2
00044    fourquarters:   B3    B2    B1    B0
00045    
00046    In Omega, quarterwords are two octets, so the picture becomes simpler:
00047    
00048    BigEndian:
00049    twohalves.v:  RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
00050    twohalves.u:  ---------JUNK---------- ----B0----- ----B1-----
00051    fourquarters: ----B0----- ----B1----- ----B2----- ----B3-----
00052    twoints:      ---------CINT0--------- ---------CINT1---------
00053    
00054    LittleEndian:
00055    twohalves.v:  LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
00056    twohalves.u:  ----B1----- ----B0-----
00057    fourquarters: ----B3----- ----B2----- ----B1----- ----B0-----
00058    twoints:      ---------CINT1--------- ---------CINT0---------
00059    
00060    This file can't be part of texmf.h, because texmf.h gets included by
00061    {tex,mf,mp}d.h before the `halfword' etc. types are defined.  So we
00062    include it from the change file instead.
00063 */
00064 
00065 /* Omega is sufficiently different to separate the definition. */
00066 #if !defined(Omega) && !defined(eOmega) && !defined(Aleph)
00067 
00068 typedef union
00069 {
00070   struct
00071   {
00072 #ifdef WORDS_BIGENDIAN
00073     halfword RH, LH;
00074 #else
00075     halfword LH, RH;
00076 #endif
00077   } v;
00078 
00079   struct
00080   { /* Make B0,B1 overlap the most significant bytes of LH.  */
00081 #ifdef WORDS_BIGENDIAN
00082     halfword junk;
00083     short B0, B1;
00084 #else /* not WORDS_BIGENDIAN */
00085   /* If 32-bit memory words, have to do something.  */
00086 #if defined (SMALLTeX) || defined (SMALLMF) || defined (SMALLMP)
00087     fixme
00088 #else
00089     short B1, B0;
00090 #endif /* big memory words */
00091 #endif /* LittleEndian */
00092   } u;
00093 } twohalves;
00094 
00095 typedef struct
00096 {
00097   struct
00098   {
00099 #ifdef WORDS_BIGENDIAN
00100     quarterword B0, B1, B2, B3;
00101 #else
00102     quarterword B3, B2, B1, B0;
00103 #endif
00104   } u;
00105 } fourquarters;
00106 
00107 typedef union
00108 {
00109 #ifdef TeX
00110   glueratio gr;
00111   twohalves hh;
00112 #else
00113   twohalves hhfield;
00114 #endif
00115 #ifdef WORDS_BIGENDIAN
00116   integer cint;
00117   fourquarters qqqq;
00118 #else /* not WORDS_BIGENDIAN */
00119   struct
00120   {
00121 #if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
00122     halfword junk;
00123 #endif /* big {TeX,MF,MP} */
00124     integer CINT;
00125   } u;
00126 
00127   struct
00128   {
00129 #if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
00130     halfword junk;
00131 #endif /* big {TeX,MF,MP} */
00132     fourquarters QQQQ;
00133   } v;
00134 #endif /* not WORDS_BIGENDIAN */
00135 } memoryword;
00136 
00137 
00138 /* fmemory_word for font_list; needs to be only four bytes.  This saves
00139    significant space in the .fmt files. */
00140 
00141 typedef union
00142 {
00143 #ifdef WORDS_BIGENDIAN
00144   integer cint;
00145   fourquarters qqqq;
00146 #else /* not WORDS_BIGENDIAN */
00147   struct
00148   {
00149     integer CINT;
00150   } u;
00151 
00152   struct
00153   {
00154     fourquarters QQQQ;
00155   } v;
00156 #endif /* not WORDS_BIGENDIAN */
00157 } fmemoryword;
00158 
00159 /* To keep the original structure accesses working, we must go through
00160    the extra names C forced us to introduce.  */
00161 #define       b0 u.B0
00162 #define       b1 u.B1
00163 #define       b2 u.B2
00164 #define       b3 u.B3
00165 
00166 #define rh v.RH
00167 #define lhfield      v.LH
00168 
00169 #ifndef WORDS_BIGENDIAN
00170 #define cint u.CINT
00171 #define qqqq v.QQQQ
00172 #endif
00173 
00174 #else /* Omega || eOmega || Aleph */
00175 
00176 typedef union
00177 {
00178   struct
00179   {
00180 #ifdef WORDS_BIGENDIAN
00181     halfword RH, LH;
00182 #else
00183     halfword LH, RH;
00184 #endif
00185   } v;
00186 
00187   struct
00188   { /* Make B0,B1 overlap the most significant bytes of LH.  */
00189 #ifdef WORDS_BIGENDIAN
00190     halfword junk;
00191     quarterword B0, B1;
00192 #else /* not WORDS_BIGENDIAN */
00193   /* If 32-bit memory words, have to do something.  */
00194 #if defined (SMALLTeX) || defined (SMALLMF) || defined (SMALLMP)
00195     fixme
00196 #else
00197     quarterword B1, B0;
00198 #endif /* big memory words */
00199 #endif /* LittleEndian */
00200   } u;
00201 } twohalves;
00202 
00203 typedef struct
00204 {
00205   struct
00206   {
00207 #ifdef WORDS_BIGENDIAN
00208     quarterword B0, B1, B2, B3;
00209 #else
00210     quarterword B3, B2, B1, B0;
00211 #endif
00212   } u;
00213 } fourquarters;
00214 
00215 typedef struct
00216 {
00217 #ifdef WORDS_BIGENDIAN
00218   integer CINT0, CINT1;
00219 #else
00220   integer CINT1, CINT0;
00221 #endif
00222 } twoints;
00223   
00224 typedef struct
00225 {
00226   glueratio GLUE;
00227 } glues;
00228 
00229 typedef union
00230 {
00231   twohalves hh;
00232   fourquarters qqqq;
00233   twoints ii;
00234   glues gg;
00235 } memoryword;
00236 
00237 #define b0 u.B0
00238 #define b1 u.B1
00239 #define b2 u.B2
00240 #define b3 u.B3
00241 
00242 #define rh v.RH
00243 #define lhfield v.LH
00244 
00245 #define cint ii.CINT0
00246 #define cint1 ii.CINT1
00247 
00248 #define gr gg.GLUE
00249 
00250 #endif /* Omega || eOmega || Aleph */