Debian Codegraph @

texk/seetexk/types.h

raw
1 /* Copyright (c) 1987, 1989, 2012 University of Maryland Department of
2 Computer Science.
3
4 Permission is hereby granted, free of charge, to any person obtaining
5 a copy of this software and associated documentation files (the
6 "Software"), to deal in the Software without restriction, including
7 without limitation, the rights to use, copy, modify, merge, publish,
8 distribute, sublicense, and/or sell copies of the Software, and to
9 permit persons to whom the Software is furnished to do so, subject to
10 the following conditions: The above copyright notice, this permission
11 notice and the disclaimer statement shall be included in all copies
12 or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23 /*
24 * MC-TeX types and macros (system dependent).
25 * Check to make sure they are correct for your system.
26 */
27
28 #ifndef _MCTEX_TYPES_
29 #define _MCTEX_TYPES_
30
31 #ifdef KPATHSEA
32
33 #include <kpathsea/config.h>
34 #include <kpathsea/c-memstr.h>
35
36 #define BLOCK_COPY(from, to, len) memmove(to, from, len)
37
38 #else
39
40 #if defined(WIN32) && !defined(__MINGW32__)
41 #include <win32lib.h> /* not KPATHSEA */
42 #undef index
43 #endif
44
45 /*
46 * Define BSD_FILE_SYSTEM if you have the BSD file system `stat'
47 * structure (with the st_blksize field). Otherwise, MakeSeekable()
48 * will be slower than necessary.
49 */
50 #undef BSD_FILE_SYSTEM
51
52 /*
53 * Define this as the name of a routine that handles overlapping block
54 * copies, if there is such a routine. Usually it will be called memmove()
55 * but on 4.3BSD it is called bcopy(). Note that the 4.2BSD bcopy() does
56 * not handle overlap, and must not be used here. If there is no routine,
57 * or if its overlap handling is uncertain, leave BLOCK_COPY undefined.
58 *
59 * (The bcopy provided in lib/bcopy.c does handle overlap.)
60 */
61 /* #define BLOCK_COPY(from, to, len) memmove(to, from, len) */
62 #define BLOCK_COPY(from, to, len) memmove(to, from, len)
63
64 /*
65 * Define void as int if your compiler does not support void,
66 * or if there are bugs in its support (e.g., 4.1BSD).
67 */
68 /* #define void int */
69
70 #endif /* KPATHSEA */
71
72 /*
73 * Conflicting WIN32 declarations.
74 */
75 #undef DT_RIGHT
76 #define EndPage DviEndPage
77
78 /*
79 * Define the following types and macros as required by your system.
80 */
81
82 typedef int16_t i16; /* a 16 bit integer (signed) */
83
84 typedef int32_t i32; /* a 32 bit integer (signed) */
85 typedef uint32_t ui32; /* a 32 bit integer (unsigned) */
86
87 /* macros to sign extend quantities that are less than 32 bits long */
88
89 /* these compilers mishandle (int)(char)(constant), but a subterfuge works */
90 #if defined(sun) || defined(hp300)
91 #define Sign8(n) ((i32)(char)(int)(n))
92 #endif
93
94 /* these have signed characters and (int)(char)(constant) works */
95 #if defined(vax) || defined(mips)
96 #define Sign8(n) ((i32)(char)(n))
97 #endif
98
99 /* this works everywhere, but may be slow */
100 #ifndef Sign8
101 #define Sign8(n) ((n) & 0x80 ? ((n) | ~0xff) : (n))
102 #endif
103
104 /* this should work everywhere */
105 #ifndef Sign16
106 #define Sign16(n) ((i32)(i16)(n))
107 #endif
108
109 /* this works where int is 32 bits, and >> sign extents and is fast */
110 #if defined(vax) || defined(mips)
111 #define Sign24(n) (((n) << 8) >> 8)
112 #endif
113
114 /* this works everywhere, but may be slow */
115 #ifndef Sign24
116 #define Sign24(n) ((n) & 0x800000 ? ((n) | ~0xffffff) : (n))
117 #endif
118
119 /* macros to truncate quantites that may be signed */
120 #define UnSign8(n) ((i32)(n) & 0xff)
121 #define UnSign16(n) ((i32)(n) & 0xffff)
122 #define UnSign24(n) ((i32)(n) & 0xffffff)
123
124 #endif /* _MCTEX_TYPES_ */