summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/tex/dumpdata.h
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-04-04 13:55:46 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-04-04 13:55:46 +0000
commitf372862c42d234710b6057449b46818e63181c90 (patch)
treea9ebec66dd31ac37aed442502ebd1b9fe76245ec /Build/source/texk/web2c/luatexdir/tex/dumpdata.h
parent2dad291ab056f30816e0aea61970f38033c2f6a5 (diff)
import luatex 0.60.0 (with small local changes, see luatexdir/ChangeLog)
and do an autoreconf git-svn-id: svn://tug.org/texlive/trunk@17680 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/tex/dumpdata.h')
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/dumpdata.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/luatexdir/tex/dumpdata.h b/Build/source/texk/web2c/luatexdir/tex/dumpdata.h
new file mode 100644
index 00000000000..810424b6a40
--- /dev/null
+++ b/Build/source/texk/web2c/luatexdir/tex/dumpdata.h
@@ -0,0 +1,115 @@
+/* dumpdata.h
+
+ Copyright 2009 Taco Hoekwater <taco@luatex.org>
+
+ This file is part of LuaTeX.
+
+ LuaTeX is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ LuaTeX is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
+
+/* $Id: dumpdata.h 3388 2010-01-26 10:59:04Z taco $ */
+
+#ifndef DUMPDATA_H
+# define DUMPDATA_H
+
+extern str_number format_ident;
+extern str_number format_name; /* principal file name */
+extern FILE *fmt_file; /* for input or output of format information */
+
+extern void store_fmt_file(void);
+extern boolean load_fmt_file(const char *);
+
+/* (Un)dumping. These are called from the change file. */
+# define dump_things(base, len) \
+ do_zdump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
+# define undump_things(base, len) \
+ do_zundump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
+
+extern void do_zdump(char *, int, int, FILE *);
+extern void do_zundump(char *, int, int, FILE *);
+
+/* Like do_undump, but check each value against LOW and HIGH. The
+ slowdown isn't significant, and this improves the chances of
+ detecting incompatible format files. In fact, Knuth himself noted
+ this problem with Web2c some years ago, so it seems worth fixing. We
+ can't make this a subroutine because then we lose the type of BASE. */
+# define undump_checked_things(low, high, base, len) \
+ do { \
+ unsigned i; \
+ undump_things (base, len); \
+ for (i = 0; i < (len); i++) { \
+ if ((&(base))[i] < (low) || (&(base))[i] > (high)) { \
+ FATAL5 ("Item %u (=%ld) of .fmt array at %lx <%ld or >%ld", \
+ i, (unsigned long) (&(base))[i], (unsigned long) &(base), \
+ (unsigned long) low, (unsigned long) high); \
+ } \
+ } \
+ } while (0)
+
+/* Like undump_checked_things, but only check the upper value. We use
+ this when the base type is unsigned, and thus all the values will be
+ greater than zero by definition. */
+# define undump_upper_check_things(high, base, len) \
+ do { \
+ unsigned i; \
+ undump_things (base, len); \
+ for (i = 0; i < (len); i++) { \
+ if ((&(base))[i] > (high)) { \
+ FATAL4 ("Item %u (=%ld) of .fmt array at %lx >%ld", \
+ i, (unsigned long) (&(base))[i], (unsigned long) &(base), \
+ (unsigned long) high); \
+ } \
+ } \
+ } while (0)
+
+/* Use the above for all the other dumping and undumping. */
+# define generic_dump(x) dump_things (x, 1)
+# define generic_undump(x) undump_things (x, 1)
+
+# define dump_wd generic_dump
+# define dump_hh generic_dump
+# define dump_qqqq generic_dump
+# define undump_wd generic_undump
+# define undump_hh generic_undump
+# define undump_qqqq generic_undump
+
+/* `dump_int' is called with constant integers, so we put them into a
+ variable first. */
+# define dump_int(x) \
+ do \
+ { \
+ int x_val = (x); \
+ generic_dump (x_val); \
+ } \
+ while (0)
+
+/* web2c/regfix puts variables in the format file loading into
+ registers. Some compilers aren't willing to take addresses of such
+ variables. So we must kludge. */
+# if defined(REGFIX) || defined(WIN32)
+# define undump_int(x) \
+ do \
+ { \
+ int x_val; \
+ generic_undump (x_val); \
+ x = x_val; \
+ } \
+ while (0)
+# else
+# define undump_int generic_undump
+# endif /* not (REGFIX || WIN32) */
+
+
+
+
+#endif