OSDN Git Service

get rid of tex.pool.
[putex/putex.git] / src / texsourc / texmfmem.h
1 /* Copyright 1992 Karl Berry
2    Copyright 2007 TeX Users Group
3    Copyright 2014 Clerk Ma
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301 USA.  */
19
20 /* texmfmem.h: the memory_word type, which is too hard to translate
21    automatically from Pascal.  We have to make sure the byte-swapping
22    that the (un)dumping routines do suffices to put things in the right
23    place in memory.
24
25    A memory_word can be broken up into a `twohalves' or a
26    `fourquarters', and a `twohalves' can be further broken up.  Here is
27    a picture.  ..._M = most significant byte, ..._L = least significant
28    byte.
29    
30    If BigEndian:
31    twohalves.v:  RH_M  RH_L  LH_M  LH_L
32    twohalves.u:  JNK1  JNK2    B0    B1
33    fourquarters:   B0    B1    B2    B3
34    
35    If LittleEndian:
36    twohalves.v:  LH_L  LH_M  RH_L  RH_M
37    twohalves.u:    B1    B0  JNK1  JNK2
38    fourquarters:   B3    B2    B1    B0
39    
40    The halfword fields are four bytes if we are building a TeX or MF;
41    this leads to further complications:
42    
43    BigEndian:
44    twohalves.v:  RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
45    twohalves.u:  ---------JUNK----------  B0    B1
46    fourquarters:   B0    B1    B2    B3
47
48    LittleEndian:
49    twohalves.v:  LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
50    twohalves.u:  junkx junky  B1    B0
51    fourquarters: ---------JUNK----------  B3    B2    B1    B0
52
53    I guess TeX and Metafont never refer to the B1 and B0 in the
54    fourquarters structure as the B1 and B0 in the twohalves.u structure.
55    
56    This file can't be part of texmf.h, because texmf.h gets included by
57    {tex,mf}d.h before the `halfword' etc. types are defined.  So we
58    include it from the change file instead.
59 */
60
61 typedef union
62 {
63   struct
64   {
65 #ifdef WORDS_BIGENDIAN
66     halfword RH, LH;
67 #else
68     halfword LH, RH;
69 #endif
70   } v;
71
72   struct
73   { /* Make B0,B1 overlap the most significant bytes of LH.  */
74 #ifdef WORDS_BIGENDIAN
75     halfword junk;
76     quarterword B0, B1;
77 #else /* not WORDS_BIGENDIAN */
78   /* If 32-bit TeX/MF, have to have an extra two bytes of junk.
79      I would like to break this line, but I'm afraid that some
80      preprocessors don't properly handle backslash-newline in # commands.  */
81 #if (defined (TeX) && !defined (SMALLTeX)) || !defined (TeX) && !defined (SMALLMF)
82     quarterword junkx, junky;
83 #endif /* big TeX or big MF */
84     quarterword B1, B0;
85 #endif /* not WORDS_BIGENDIAN */
86   } u;
87 } twohalves;
88
89 /* new in Y&Y TeX 1.3 1996/Jan/18 used for hash [...] if SHORTHASH defined */
90 typedef struct {
91   struct
92   {
93 #ifdef WORDS_BIGENDIAN
94     quarterword RH, LH;
95 #else
96     quarterword LH, RH;
97 #endif
98   } v;
99 } htwohalves;
100
101 typedef struct
102 {
103   struct
104   {
105 #ifdef WORDS_BIGENDIAN
106     quarterword B0, B1, B2, B3;
107 #else
108     quarterword B3, B2, B1, B0;
109 #endif
110   } u;
111 } fourquarters;
112
113
114 typedef union
115 {
116 #ifdef TeX
117   glueratio gr;
118   twohalves hh;
119 #else
120   twohalves hhfield;
121 #endif
122 #ifdef WORDS_BIGENDIAN
123   integer cint;
124   fourquarters qqqq;
125 #else /* not WORDS_BIGENDIAN */
126   struct
127   {
128 #if defined (TeX) && !defined (SMALLTeX) || !defined (TeX) && !defined (SMALLMF)
129     halfword junk;
130 #endif /* big TeX or big MF */
131     integer CINT;
132   } u;
133
134   struct
135   {
136 #if defined (TeX) && !defined (SMALLTeX) || !defined (TeX) && !defined (SMALLMF)
137     halfword junk;
138 #endif /* big TeX or big MF */
139     fourquarters QQQQ;
140   } v;
141 #endif /* not WORDS_BIGENDIAN */
142 } memory_word;
143
144 /* Attempt to reduce size of font_info array ... (and hence format files) */
145
146 typedef unsigned char unsignedchar;
147
148 typedef struct
149 {
150   struct
151   {
152 #ifdef WORDS_BIGENDIAN
153     unsignedchar B0, B1, B2, B3;
154 #else
155     unsignedchar B3, B2, B1, B0;
156 #endif
157   } u;
158 } ffourquarters; /* was fourunsignedchars; */
159
160 #define fquarterword unsigned char
161
162 typedef union {
163   integer cint ;
164 /*  fourunsignedchars qqqq; */
165   ffourquarters qqqq;
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 #define qqqq v.QQQQ
181 #endif