beta-0.89.2
[luatex.git] / source / texk / web2c / texmfmem.h
blobcbe0ae95470276612e1b364eed22f474be732509
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.
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.
11 The halfword fields are four bytes if we are building a big TeX or MF;
12 this leads to further complications:
14 BigEndian:
15 twohalves.v: RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
16 twohalves.u: ---------JUNK---------- B0 B1
17 fourquarters: B0 B1 B2 B3
19 LittleEndian:
20 twohalves.v: LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
21 twohalves.u: B1 B0
22 fourquarters: ---------JUNK---------- B3 B2 B1 B0
24 I guess TeX and Metafont never refer to the B1 and B0 in the
25 fourquarters structure as the B1 and B0 in the twohalves.u structure.
27 The B0 and B1 fields are declared short instead of quarterword,
28 because they are used in character nodes to store a font number and a
29 character. If left as a quarterword (which is a single byte), we
30 couldn't support more than 256 fonts. (If shorts aren't two bytes,
31 this will lose.)
33 In the old four-byte memory structure (something more needs to be
34 done to handle >256 fonts):
36 If BigEndian:
37 twohalves.v: RH_M RH_L LH_M LH_L
38 twohalves.u: JNK1 JNK2 B0 B1
39 fourquarters: B0 B1 B2 B3
41 If LittleEndian:
42 twohalves.v: LH_L LH_M RH_L RH_M
43 twohalves.u: B1 B0 JNK1 JNK2
44 fourquarters: B3 B2 B1 B0
46 In Aleph, quarterwords are two octets, so the picture becomes simpler:
48 BigEndian:
49 twohalves.v: RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
50 twohalves.u: ---------JUNK---------- ----B0----- ----B1-----
51 fourquarters: ----B0----- ----B1----- ----B2----- ----B3-----
52 twoints: ---------CINT0--------- ---------CINT1---------
54 LittleEndian:
55 twohalves.v: LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
56 twohalves.u: ----B1----- ----B0-----
57 fourquarters: ----B3----- ----B2----- ----B1----- ----B0-----
58 twoints: ---------CINT1--------- ---------CINT0---------
60 This file can't be part of texmf.h, because texmf.h gets included by
61 {tex,mf,mp}d.h before the `halfword' etc. types are defined. So we
62 include it from the change file instead.
65 /* Aleph is sufficiently different to separate the definition. */
66 #if !defined(Aleph) && !defined(epTeX) && !defined(eupTeX) && !defined(upTeX)
68 typedef union
70 struct
72 #ifdef WORDS_BIGENDIAN
73 halfword RH, LH;
74 #else
75 halfword LH, RH;
76 #endif
77 } v;
79 struct
80 { /* Make B0,B1 overlap the most significant bytes of LH. */
81 #ifdef WORDS_BIGENDIAN
82 halfword junk;
83 short B0, B1;
84 #else /* not WORDS_BIGENDIAN */
85 /* If 32-bit memory words, have to do something. */
86 #if defined (SMALLTeX) || defined (SMALLMF) || defined (SMALLMP)
87 fixme
88 #else
89 short B1, B0;
90 #endif /* big memory words */
91 #endif /* LittleEndian */
92 } u;
93 } twohalves;
95 typedef struct
97 struct
99 #ifdef WORDS_BIGENDIAN
100 quarterword B0, B1, B2, B3;
101 #else
102 quarterword B3, B2, B1, B0;
103 #endif
104 } u;
105 } fourquarters;
107 typedef union
109 #ifdef TeX
110 glueratio gr;
111 twohalves hh;
112 #else
113 twohalves hhfield;
114 #endif
115 #ifdef XeTeX
116 voidpointer ptr;
117 #endif
118 #ifdef WORDS_BIGENDIAN
119 integer cint;
120 fourquarters qqqq;
121 #else /* not WORDS_BIGENDIAN */
122 struct
124 #if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
125 halfword junk;
126 #endif /* big {TeX,MF,MP} */
127 integer CINT;
128 } u;
130 struct
132 #ifndef XeTeX
133 #if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
134 halfword junk;
135 #endif /* big {TeX,MF,MP} */
136 #endif
137 fourquarters QQQQ;
138 } v;
139 #endif /* not WORDS_BIGENDIAN */
140 } memoryword;
143 /* fmemory_word for font_list; needs to be only four bytes. This saves
144 significant space in the .fmt files. (Not true in XeTeX, actually!) */
145 typedef union
147 #ifdef WORDS_BIGENDIAN
148 integer cint;
149 fourquarters qqqq;
150 #else /* not WORDS_BIGENDIAN */
151 struct
153 #ifdef XeTeX
154 halfword junk; /* quarterword is really 16 bits in XeTeX, so integer does not fill the union */
155 #endif
156 integer CINT;
157 } u;
159 struct
161 fourquarters QQQQ;
162 } v;
163 #endif /* not WORDS_BIGENDIAN */
164 } fmemoryword;
166 /* To keep the original structure accesses working, we must go through
167 the extra names C forced us to introduce. */
168 #define b0 u.B0
169 #define b1 u.B1
170 #define b2 u.B2
171 #define b3 u.B3
173 #define rh v.RH
174 #define lhfield v.LH
176 #ifndef WORDS_BIGENDIAN
177 #define cint u.CINT
178 #endif
180 #ifndef WORDS_BIGENDIAN
181 #define qqqq v.QQQQ
182 #endif
184 #else /* Aleph || epTeX || eupTeX || upTeX */
186 typedef union
188 struct
190 #ifdef WORDS_BIGENDIAN
191 halfword RH, LH;
192 #else
193 halfword LH, RH;
194 #endif
195 } v;
197 struct
198 { /* Make B0,B1 overlap the most significant bytes of LH. */
199 #ifdef WORDS_BIGENDIAN
200 halfword junk;
201 quarterword B0, B1;
202 #else /* not WORDS_BIGENDIAN */
203 /* If 32-bit memory words, have to do something. */
204 #if defined (SMALLTeX) || defined (SMALLMF) || defined (SMALLMP)
205 fixme
206 #else
207 quarterword B1, B0;
208 #endif /* big memory words */
209 #endif /* LittleEndian */
210 } u;
211 } twohalves;
213 typedef struct
215 struct
217 #ifdef WORDS_BIGENDIAN
218 quarterword B0, B1, B2, B3;
219 #else
220 quarterword B3, B2, B1, B0;
221 #endif
222 } u;
223 } fourquarters;
225 typedef struct
227 #ifdef WORDS_BIGENDIAN
228 integer CINT0, CINT1;
229 #else
230 integer CINT1, CINT0;
231 #endif
232 } twoints;
234 typedef struct
236 glueratio GLUE;
237 } glues;
239 typedef union
241 twohalves hh;
242 fourquarters qqqq;
243 twoints ii;
244 glues gg;
245 } memoryword;
247 #define b0 u.B0
248 #define b1 u.B1
249 #define b2 u.B2
250 #define b3 u.B3
252 #define rh v.RH
253 #define lhfield v.LH
255 #define cint ii.CINT0
256 #define cint1 ii.CINT1
258 #define gr gg.GLUE
260 #endif /* Aleph || epTeX || eupTeX || upTeX */