~ubuntu-branches/ubuntu/jaunty/luatex/jaunty

« back to all changes in this revision

Viewing changes to src/texk/web2c/texmfmem.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2007-09-24 12:56:11 UTC
  • Revision ID: james.westby@ubuntu.com-20070924125611-a8ge689azbptxvla
Tags: upstream-0.11.2
ImportĀ upstreamĀ versionĀ 0.11.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 Omega, 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
/* Omega is sufficiently different to separate the definition. */
 
66
#if !defined(Omega) && !defined(eOmega) && !defined(Aleph) && !defined(luaTeX)
 
67
 
 
68
typedef union
 
69
{
 
70
  struct
 
71
  {
 
72
#ifdef WORDS_BIGENDIAN
 
73
    halfword RH, LH;
 
74
#else
 
75
    halfword LH, RH;
 
76
#endif
 
77
  } v;
 
78
 
 
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;
 
94
 
 
95
typedef struct
 
96
{
 
97
  struct
 
98
  {
 
99
#ifdef WORDS_BIGENDIAN
 
100
    quarterword B0, B1, B2, B3;
 
101
#else
 
102
    quarterword B3, B2, B1, B0;
 
103
#endif
 
104
  } u;
 
105
} fourquarters;
 
106
 
 
107
typedef union
 
108
{
 
109
#ifdef TeX
 
110
  glueratio gr;
 
111
  twohalves hh;
 
112
#else
 
113
  twohalves hhfield;
 
114
#endif
 
115
#ifdef WORDS_BIGENDIAN
 
116
#ifdef XeTeX
 
117
  struct
 
118
  {
 
119
    integer CINT;
 
120
    integer CINT1;
 
121
  } x;
 
122
#else
 
123
  integer cint;
 
124
#endif
 
125
  fourquarters qqqq;
 
126
#else /* not WORDS_BIGENDIAN */
 
127
#ifdef XeTeX
 
128
  struct
 
129
  {
 
130
    integer CINT1;
 
131
    integer CINT;
 
132
  } x;
 
133
#else
 
134
  struct
 
135
  {
 
136
#if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
 
137
    halfword junk;
 
138
#endif /* big {TeX,MF,MP} */
 
139
    integer CINT;
 
140
  } u;
 
141
#endif
 
142
 
 
143
  struct
 
144
  {
 
145
#ifndef XeTeX
 
146
#if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
 
147
    halfword junk;
 
148
#endif /* big {TeX,MF,MP} */
 
149
#endif
 
150
    fourquarters QQQQ;
 
151
  } v;
 
152
#endif /* not WORDS_BIGENDIAN */
 
153
} memoryword;
 
154
 
 
155
 
 
156
/* fmemory_word for font_list; needs to be only four bytes.  This saves
 
157
   significant space in the .fmt files. */
 
158
 
 
159
typedef union
 
160
{
 
161
#ifdef WORDS_BIGENDIAN
 
162
#ifdef XeTeX
 
163
  struct
 
164
  {
 
165
    integer CINT;
 
166
  } x;
 
167
#else
 
168
  integer cint;
 
169
#endif
 
170
  fourquarters qqqq;
 
171
#else /* not WORDS_BIGENDIAN */
 
172
#ifdef XeTeX
 
173
  struct
 
174
  {
 
175
    halfword junk;
 
176
    integer CINT;
 
177
  } x;
 
178
#else
 
179
  struct
 
180
  {
 
181
    integer CINT;
 
182
  } u;
 
183
#endif
 
184
 
 
185
  struct
 
186
  {
 
187
    fourquarters QQQQ;
 
188
  } v;
 
189
#endif /* not WORDS_BIGENDIAN */
 
190
} fmemoryword;
 
191
 
 
192
/* To keep the original structure accesses working, we must go through
 
193
   the extra names C forced us to introduce.  */
 
194
#define b0 u.B0
 
195
#define b1 u.B1
 
196
#define b2 u.B2
 
197
#define b3 u.B3
 
198
 
 
199
#define rh v.RH
 
200
#define lhfield v.LH
 
201
 
 
202
#ifdef XeTeX
 
203
#define cint  x.CINT
 
204
#define cint1 x.CINT1
 
205
#else
 
206
#ifndef WORDS_BIGENDIAN
 
207
#define cint u.CINT
 
208
#endif
 
209
#endif /* XeTeX */
 
210
 
 
211
#ifndef WORDS_BIGENDIAN
 
212
#define qqqq v.QQQQ
 
213
#endif
 
214
 
 
215
#else /* Omega || eOmega || Aleph */
 
216
 
 
217
typedef union
 
218
{
 
219
  struct
 
220
  {
 
221
#ifdef WORDS_BIGENDIAN
 
222
    halfword RH, LH;
 
223
#else
 
224
    halfword LH, RH;
 
225
#endif
 
226
  } v;
 
227
 
 
228
  struct
 
229
  { /* Make B0,B1 overlap the most significant bytes of LH.  */
 
230
#ifdef WORDS_BIGENDIAN
 
231
    halfword junk;
 
232
    quarterword B0, B1;
 
233
#else /* not WORDS_BIGENDIAN */
 
234
  /* If 32-bit memory words, have to do something.  */
 
235
#if defined (SMALLTeX) || defined (SMALLMF) || defined (SMALLMP)
 
236
    fixme
 
237
#else
 
238
    quarterword B1, B0;
 
239
#endif /* big memory words */
 
240
#endif /* LittleEndian */
 
241
  } u;
 
242
} twohalves;
 
243
 
 
244
typedef struct
 
245
{
 
246
  struct
 
247
  {
 
248
#ifdef WORDS_BIGENDIAN
 
249
    quarterword B0, B1, B2, B3;
 
250
#else
 
251
    quarterword B3, B2, B1, B0;
 
252
#endif
 
253
  } u;
 
254
} fourquarters;
 
255
 
 
256
typedef struct
 
257
{
 
258
#ifdef WORDS_BIGENDIAN
 
259
  integer CINT0, CINT1;
 
260
#else
 
261
  integer CINT1, CINT0;
 
262
#endif
 
263
} twoints;
 
264
  
 
265
typedef struct
 
266
{
 
267
  glueratio GLUE;
 
268
} glues;
 
269
 
 
270
typedef union
 
271
{
 
272
  twohalves hh;
 
273
  fourquarters qqqq;
 
274
  twoints ii;
 
275
  glues gg;
 
276
} memoryword;
 
277
 
 
278
#define b0 u.B0
 
279
#define b1 u.B1
 
280
#define b2 u.B2
 
281
#define b3 u.B3
 
282
 
 
283
#define rh v.RH
 
284
#define lhfield v.LH
 
285
 
 
286
#define cint ii.CINT0
 
287
#define cint1 ii.CINT1
 
288
 
 
289
#define gr gg.GLUE
 
290
 
 
291
#endif /* Omega || eOmega || Aleph */
 
292
 
 
293
#if defined(luaTeX)
 
294
#define memory_word memoryword
 
295
#define two_halves twohalves
 
296
#define four_quarters fourquarters
 
297
 
 
298
#define strnumber str_number
 
299
#define poolpointer pool_pointer
 
300
#define packedASCIIcode packed_ASCII_code
 
301
#define internalfontnumber internal_font_number
 
302
#endif