~ubuntu-branches/ubuntu/saucy/luatex/saucy

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/tex/dumpdata.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2009-12-25 09:47:05 UTC
  • mfrom: (1.1.9 upstream) (4.2.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091225094705-y33rpflo8t4u9nag
Tags: 0.50.0-1
* new upstream release
* disable fix-hurd-ftbfs patch, included upstream
* disable upstram-fixes, included upstream
* disable ubuntu_libpoppler-0.11, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* dumpdata.h
 
2
   
 
3
   Copyright 2009 Taco Hoekwater <taco@luatex.org>
 
4
 
 
5
   This file is part of LuaTeX.
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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/>. */
 
19
 
 
20
/* $Id: dumpdata.h 3261 2009-12-18 11:38:21Z taco $ */
 
21
 
 
22
#ifndef DUMPDATA_H
 
23
#  define DUMPDATA_H
 
24
 
 
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 */
 
28
 
 
29
extern void store_fmt_file(void);
 
30
extern boolean load_fmt_file(char *);
 
31
 
 
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)
 
37
 
 
38
extern void do_zdump(char *, int, int, FILE *);
 
39
extern void do_zundump(char *, int, int, FILE *);
 
40
 
 
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)                   \
 
47
    do {                                                                \
 
48
      unsigned i;                                                       \
 
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);                     \
 
55
      }                                                                 \
 
56
    }                                                                   \
 
57
  } while (0)
 
58
 
 
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)                    \
 
63
    do {                                                                \
 
64
      unsigned i;                                                       \
 
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);                                  \
 
71
      }                                                                 \
 
72
    }                                                                   \
 
73
  } while (0)
 
74
 
 
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)
 
78
 
 
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
 
85
 
 
86
/* `dump_int' is called with constant integers, so we put them into a
 
87
   variable first.  */
 
88
#  define       dump_int(x)                                                     \
 
89
  do                                                                    \
 
90
    {                                                                   \
 
91
      int x_val = (x);                                                  \
 
92
      generic_dump (x_val);                                             \
 
93
    }                                                                   \
 
94
  while (0)
 
95
 
 
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)                                                       \
 
101
  do                                                                    \
 
102
    {                                                                   \
 
103
      int x_val;                                                        \
 
104
      generic_undump (x_val);                                           \
 
105
      x = x_val;                                                        \
 
106
    }                                                                   \
 
107
  while (0)
 
108
#  else
 
109
#    define     undump_int generic_undump
 
110
#  endif                        /* not (REGFIX || WIN32) */
 
111
 
 
112
 
 
113
 
 
114
 
 
115
#endif