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