OSDN Git Service

bool to boolean.
[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 `two_halves' or a
26    `four_quarters', and a `two_halves' can be further broken up.  Here is
27    a picture.  ..._M = most significant byte, ..._L = least significant
28    byte.
29    
30    If BigEndian:
31    two_halves.v:  RH_M  RH_L  LH_M  LH_L
32    two_halves.u:  JNK1  JNK2    B0    B1
33    four_quarters:   B0    B1    B2    B3
34    
35    If LittleEndian:
36    two_halves.v:  LH_L  LH_M  RH_L  RH_M
37    two_halves.u:    B1    B0  JNK1  JNK2
38    four_quarters:   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    two_halves.v:  RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
45    two_halves.u:  ---------JUNK----------  B0    B1
46    four_quarters:   B0    B1    B2    B3
47
48    LittleEndian:
49    two_halves.v:  LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
50    two_halves.u:  junkx junky  B1    B0
51    four_quarters: ---------JUNK----------  B3    B2    B1    B0
52
53    I guess TeX and Metafont never refer to the B1 and B0 in the
54    four_quarters structure as the B1 and B0 in the two_halves.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 /*
62   meaning      structure                      TeX                 Y&Y TeX
63                ----------------------------------------------------------------------
64   integer      |            int            || 4: long           | 8: long long      |   min_quarterword 0
65                ---------------------------------------------------------------------- max_quarterword FFFF
66   scaled       |            sc             || 4: long           | 8: long long      |   min_halfword
67                ----------------------------------------------------------------------
68   glue_ratio   |            gr             || 4: float          | 8: double         |
69                ----------------------------------------------------------------------
70   halfword     |     lh      |     rh      || 2: unsigned short | 4: unsigned long  |
71                ----------------------------------------------------------------------
72   half+quarter |  b0  |  b1  |     rh      ||                                       |
73                ----------------------------------------------------------------------
74   quarter      |  b0  |  b1  |  b2  |  b3  || 1: unsigned char  | 2: unsigned short |
75                ----------------------------------------------------------------------
76 */
77
78 typedef struct
79 {
80 #ifdef WORDS_BIGENDIAN
81   halfword rh;
82
83   union
84   {
85     halfword lh;
86
87     struct
88     {
89       quarterword b0, b1;
90     };
91   };
92 #endif
93 } two_halves;
94
95 typedef struct
96 {
97 #ifdef WORDS_BIGENDIAN
98   quarterword b0, b1, b2, b3;
99 #else
100   quarterword b3, b2, b1, b0;
101 #endif
102 } four_quarters;
103
104 typedef union
105 {
106   glue_ratio gr;
107   two_halves hh;
108   integer cint;
109   four_quarters qqqq;
110 } memory_word;
111
112 #ifndef WORDS_BIGENDIAN
113 #define cint u.CINT
114 #define qqqq v.QQQQ
115 #endif