beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / tex / memoryword.h
blob5db2bb8cb36477524f698a751586f648e39e65be
1 /* memoryword.h
3 Copyright 2009-2010 Taco Hoekwater <taco@luatex.org>
5 This file is part of LuaTeX.
7 LuaTeX is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
12 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License along
18 with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
21 /* This header file is extra special because it is read in from
22 within the pascal source */
24 #ifndef MEMORYWORD_H
25 # define MEMORYWORD_H
27 /* texmfmem.h: the memory_word type, which is too hard to translate
28 automatically from Pascal. We have to make sure the byte-swapping
29 that the (un)dumping routines do suffices to put things in the right
30 place in memory.
32 A memory_word can be broken up into a `twohalves' or a
33 `fourquarters', and a `twohalves' can be further broken up. Here is
34 a picture. ..._M = most significant byte, ..._L = least significant
35 byte.
38 BigEndian:
39 twohalves.v: RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
40 twohalves.u: ---------JUNK---------- ----B0----- ----B1-----
41 fourquarters: ----B0----- ----B1----- ----B2----- ----B3-----
42 twoints: ---------CINT0--------- ---------CINT1---------
44 LittleEndian:
45 twohalves.v: LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
46 twohalves.u: ----B1----- ----B0-----
47 fourquarters: ----B3----- ----B2----- ----B1----- ----B0-----
48 twoints: ---------CINT1--------- ---------CINT0---------
53 typedef union {
54 struct {
55 # ifdef WORDS_BIGENDIAN
56 halfword RH, LH;
57 # else
58 halfword LH, RH;
59 # endif
60 } v;
62 struct { /* Make B0,B1 overlap the most significant bytes of LH. */
63 # ifdef WORDS_BIGENDIAN
64 halfword junk;
65 quarterword B0, B1;
66 # else /* not WORDS_BIGENDIAN */
67 /* If 32-bit memory words, have to do something. */
68 quarterword B1, B0;
69 # endif /* LittleEndian */
70 } u;
71 } two_halves;
73 typedef struct {
74 struct {
75 # ifdef WORDS_BIGENDIAN
76 quarterword B0, B1, B2, B3;
77 # else
78 quarterword B3, B2, B1, B0;
79 # endif
80 } u;
81 } four_quarters;
83 typedef struct {
84 # ifdef WORDS_BIGENDIAN
85 int CINT0, CINT1;
86 # else
87 int CINT1, CINT0;
88 # endif
89 } two_ints;
91 typedef struct {
92 glue_ratio GLUE;
93 } glues;
95 typedef union {
96 two_halves hh;
97 four_quarters qqqq;
98 two_ints ii;
99 glues gg;
100 } memory_word;
102 # define b0 u.B0
103 # define b1 u.B1
104 # define b2 u.B2
105 # define b3 u.B3
107 # define rh v.RH
108 # define lhfield v.LH
110 # define cint ii.CINT0
111 # define cint1 ii.CINT1
113 # define gr gg.GLUE
115 /* the next five defines are needed for the prototypes in web2c's coerce.h */
117 # define memoryword memory_word
118 # define strnumber str_number
119 # define packedASCIIcode packed_ASCII_code
120 # define poolpointer pool_pointer
122 typedef FILE *word_file;
124 # ifdef DEBUG
125 extern void print_word(memory_word w);
126 # endif
128 #endif