3
Copyright 2009 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/>. */
20
/* $Id: dumpdata.h 3261 2009-12-18 11:38:21Z taco $ */
25
extern str_number format_ident;
26
extern str_number format_name; /* principal file name */
27
extern FILE *fmt_file; /* for input or output of format information */
29
extern void store_fmt_file(void);
30
extern boolean load_fmt_file(char *);
32
/* (Un)dumping. These are called from the change file. */
33
# define dump_things(base, len) \
34
do_zdump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
35
# define undump_things(base, len) \
36
do_zundump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
38
extern void do_zdump(char *, int, int, FILE *);
39
extern void do_zundump(char *, int, int, FILE *);
41
/* Like do_undump, but check each value against LOW and HIGH. The
42
slowdown isn't significant, and this improves the chances of
43
detecting incompatible format files. In fact, Knuth himself noted
44
this problem with Web2c some years ago, so it seems worth fixing. We
45
can't make this a subroutine because then we lose the type of BASE. */
46
# define undump_checked_things(low, high, base, len) \
49
undump_things (base, len); \
50
for (i = 0; i < (len); i++) { \
51
if ((&(base))[i] < (low) || (&(base))[i] > (high)) { \
52
FATAL5 ("Item %u (=%ld) of .fmt array at %lx <%ld or >%ld", \
53
i, (unsigned long) (&(base))[i], (unsigned long) &(base), \
54
(unsigned long) low, (unsigned long) high); \
59
/* Like undump_checked_things, but only check the upper value. We use
60
this when the base type is unsigned, and thus all the values will be
61
greater than zero by definition. */
62
# define undump_upper_check_things(high, base, len) \
65
undump_things (base, len); \
66
for (i = 0; i < (len); i++) { \
67
if ((&(base))[i] > (high)) { \
68
FATAL4 ("Item %u (=%ld) of .fmt array at %lx >%ld", \
69
i, (unsigned long) (&(base))[i], (unsigned long) &(base), \
70
(unsigned long) high); \
75
/* Use the above for all the other dumping and undumping. */
76
# define generic_dump(x) dump_things (x, 1)
77
# define generic_undump(x) undump_things (x, 1)
79
# define dump_wd generic_dump
80
# define dump_hh generic_dump
81
# define dump_qqqq generic_dump
82
# define undump_wd generic_undump
83
# define undump_hh generic_undump
84
# define undump_qqqq generic_undump
86
/* `dump_int' is called with constant integers, so we put them into a
88
# define dump_int(x) \
92
generic_dump (x_val); \
96
/* web2c/regfix puts variables in the format file loading into
97
registers. Some compilers aren't willing to take addresses of such
98
variables. So we must kludge. */
99
# if defined(REGFIX) || defined(WIN32)
100
# define undump_int(x) \
104
generic_undump (x_val); \
109
# define undump_int generic_undump
110
# endif /* not (REGFIX || WIN32) */