Debian Codegraph @

texk/web2c/texmfmem.h

raw
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 The halfword fields are four bytes if we are building a big TeX or MF;
12 this leads to further complications:
13
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
18
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
23
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.
26
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.)
32
33 In the old four-byte memory structure (something more needs to be
34 done to handle >256 fonts):
35
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
40
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
45
46 In Aleph, quarterwords are two octets, so the picture becomes simpler:
47
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---------
53
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---------
59
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.
63 */
64
65 /* Aleph is sufficiently different to separate the definition. */
66 /* upTeX and e-upTeX define max_quarterword=@"FFFF,
67 so a similar memory structure is applicable. */
68 #if !defined(Aleph) && !defined(eupTeX) && !defined(upTeX)
69
70 typedef union
71 {
72 struct
73 {
74 #ifdef WORDS_BIGENDIAN
75 halfword RH, LH;
76 #else
77 halfword LH, RH;
78 #endif
79 } v;
80
81 struct
82 { /* Make B0,B1 overlap the most significant bytes of LH. */
83 #ifdef WORDS_BIGENDIAN
84 halfword junk;
85 short B0, B1;
86 #else /* not WORDS_BIGENDIAN */
87 /* If 32-bit memory words, have to do something. */
88 #if defined (SMALLTeX) || defined (SMALLMF) || defined (SMALLMP)
89 fixme
90 #else
91 short B1, B0;
92 #endif /* big memory words */
93 #endif /* LittleEndian */
94 } u;
95 } twohalves;
96
97 typedef struct
98 {
99 struct
100 {
101 #ifdef WORDS_BIGENDIAN
102 quarterword B0, B1, B2, B3;
103 #else
104 quarterword B3, B2, B1, B0;
105 #endif
106 } u;
107 } fourquarters;
108
109 typedef union
110 {
111 #ifdef TeX
112 glueratio gr;
113 twohalves hh;
114 #else
115 twohalves hhfield;
116 #endif
117 #ifdef XeTeX
118 voidpointer ptr;
119 #endif
120 #ifdef WORDS_BIGENDIAN
121 integer cint;
122 fourquarters qqqq;
123 #else /* not WORDS_BIGENDIAN */
124 struct
125 {
126 #if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
127 halfword junk;
128 #endif /* big {TeX,MF,MP} */
129 integer CINT;
130 } u;
131
132 struct
133 {
134 #ifndef XeTeX
135 #if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
136 halfword junk;
137 #endif /* big {TeX,MF,MP} */
138 #endif
139 fourquarters QQQQ;
140 } v;
141 #endif /* not WORDS_BIGENDIAN */
142 } memoryword;
143
144
145 /* fmemory_word for font_list; needs to be only four bytes. This saves
146 significant space in the .fmt files. (Not true in XeTeX, actually!) */
147 typedef union
148 {
149 #ifdef WORDS_BIGENDIAN
150 integer cint;
151 fourquarters qqqq;
152 #else /* not WORDS_BIGENDIAN */
153 struct
154 {
155 #ifdef XeTeX
156 halfword junk; /* quarterword is really 16 bits in XeTeX, so integer does not fill the union */
157 #endif
158 integer CINT;
159 } u;
160
161 struct
162 {
163 fourquarters QQQQ;
164 } v;
165 #endif /* not WORDS_BIGENDIAN */
166 } fmemoryword;
167
168 /* To keep the original structure accesses working, we must go through
169 the extra names C forced us to introduce. */
170 #define b0 u.B0
171 #define b1 u.B1
172 #define b2 u.B2
173 #define b3 u.B3
174
175 #define rh v.RH
176 #define lhfield v.LH
177
178 #ifndef WORDS_BIGENDIAN
179 #define cint u.CINT
180 #endif
181
182 #ifndef WORDS_BIGENDIAN
183 #define qqqq v.QQQQ
184 #endif
185
186 #else /* Aleph || eupTeX || upTeX */
187
188 typedef union
189 {
190 struct
191 {
192 #ifdef WORDS_BIGENDIAN
193 halfword RH, LH;
194 #else
195 halfword LH, RH;
196 #endif
197 } v;
198
199 struct
200 { /* Make B0,B1 overlap the most significant bytes of LH. */
201 #ifdef WORDS_BIGENDIAN
202 halfword junk;
203 quarterword B0, B1;
204 #else /* not WORDS_BIGENDIAN */
205 /* If 32-bit memory words, have to do something. */
206 #if defined (SMALLTeX) || defined (SMALLMF) || defined (SMALLMP)
207 fixme
208 #else
209 quarterword B1, B0;
210 #endif /* big memory words */
211 #endif /* LittleEndian */
212 } u;
213 } twohalves;
214
215 typedef struct
216 {
217 struct
218 {
219 #ifdef WORDS_BIGENDIAN
220 quarterword B0, B1, B2, B3;
221 #else
222 quarterword B3, B2, B1, B0;
223 #endif
224 } u;
225 } fourquarters;
226
227 typedef struct
228 {
229 #ifdef WORDS_BIGENDIAN
230 integer CINT0, CINT1;
231 #else
232 integer CINT1, CINT0;
233 #endif
234 } twoints;
235
236 typedef struct
237 {
238 glueratio GLUE;
239 } glues;
240
241 typedef union
242 {
243 twohalves hh;
244 fourquarters qqqq;
245 twoints ii;
246 glues gg;
247 } memoryword;
248
249 #define b0 u.B0
250 #define b1 u.B1
251 #define b2 u.B2
252 #define b3 u.B3
253
254 #define rh v.RH
255 #define lhfield v.LH
256
257 #define cint ii.CINT0
258 #define cint1 ii.CINT1
259
260 #define gr gg.GLUE
261
262 #endif /* Aleph || eupTeX || upTeX */