File: ttcalc.h

package info (click to toggle)
ghostscript 8.71~dfsg2-9%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 79,896 kB
  • ctags: 80,654
  • sloc: ansic: 501,432; sh: 25,689; python: 4,853; cpp: 3,633; perl: 3,597; tcl: 1,480; makefile: 1,187; lisp: 407; asm: 284; xml: 263; awk: 66; csh: 17; yacc: 15
file content (184 lines) | stat: -rw-r--r-- 4,925 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* Copyright (C) 2001-2006 Artifex Software, Inc.
   All Rights Reserved.
  
   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied, modified
   or distributed except as expressly authorized under the terms of that
   license.  Refer to licensing information at http://www.artifex.com/
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
*/

/* $Id: ttcalc.h 8022 2007-06-05 22:23:38Z giles $ */

/* Changes after FreeType: cut out the TrueType instruction interpreter. */

/*******************************************************************
 *
 *  ttcalc.h
 *
 *    Arithmetic Computations (specification).
 *
 *  Copyright 1996-1998 by
 *  David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 *  This file is part of the FreeType project, and may only be used
 *  modified and distributed under the terms of the FreeType project
 *  license, LICENSE.TXT.  By continuing to use, modify, or distribute 
 *  this file you indicate that you have read the license and
 *  understand and accept it fully.
 *
 ******************************************************************/

#ifndef TTCALC_H
#define TTCALC_H

#include "ttcommon.h"
#include "tttypes.h"

  /* IntN types:                                                        */
  /*                                                                    */
  /*   Used to guarantee the size of some specific integers.            */
  /*                                                                    */
  /*  Of course, they are equivalent to Short, UShort, Long, etc.       */
  /*  but parts of this unit could be used by different programs.       */
  /*                                                                    */

  typedef signed short    Int16;
  typedef unsigned short  Word16;

#if SIZEOF_INT == 4

  typedef signed int      Int32;
  typedef unsigned int    Word32;

#elif SIZEOF_LONG == 4

  typedef signed long     Int32;
  typedef unsigned long   Word32;

#else
#error "no 32bit type found"
#endif

#if SIZEOF_LONG == 8

/* LONG64 must be defined when a 64-bit type is available */
#define LONG64
#define INT64   long

#else

/* GCC provides the non-ANSI 'long long' 64-bit type.  You can activate */
/* by defining the _GNUC_LONG64_ macro in 'ttconfig.h'.  Note that this */
/* will produce many -ansi warnings during library compilation.         */
#ifdef _GNUC_LONG64_

#define LONG64
#define INT64   long long

#endif /* __GNUC__ */

/* Microsoft Visual C++ also supports 64-bit integers */
#ifdef _MSC_VER
#if _MSC_VER >= 1100

#define LONG64
#define INT64   __int64

#endif
#endif

#endif


#ifdef __cplusplus
  extern "C" {
#endif

#ifdef LONG64

  typedef INT64  Int64;

/* Fast muldiv */
#define FMulDiv( x, y, z )        ( (Int64)(x) * (y) / (z) )

/* Fast muldiv_round */
#define FMulDiv_Round( x, y, z )  ( ( (Int64)(x) * (y) + (z)/2 ) / (z) )

#define ADD_64( x, y, z )  ( (z) = (x) + (y) )
#define SUB_64( x, y, z )  ( (z) = (x) - (y) )
#define MUL_64( x, y, z )  ( (z) = (Int64)(x) * (y) )

#define DIV_64( x, y )     ( (x) / (y) )

#define SQRT_64( x )       Sqrt64( x )
#define SQRT_32( x )       Sqrt32( x )

  Int32  MulDiv( Int32  a, Int32  b, Int32  c );
  Int32  MulDiv_Round( Int32  a, Int32  b, Int32  c );

  Int32  Sqrt32( Int32  l );
  Int32  Sqrt64( Int64  l );

#else /* LONG64 */

  struct  _Int64
  {
    Word32  lo;
    Word32  hi;
  };

  typedef struct _Int64  Int64;

#define FMulDiv( x, y, z )        MulDiv( x, y, z )
#define FMulDiv_Round( x, y, z )  MulDiv_Round( x, y, z )

#define ADD_64( x, y, z )  Add64( &x, &y, &z )
#define SUB_64( x, y, z )  Sub64( &x, &y, &z )
#define MUL_64( x, y, z )  MulTo64( x, y, &z )

#define DIV_64( x, y )     Div64by32( &x, y )

#define SQRT_64( x )       Sqrt64( &x )
#define SQRT_32( x )       Sqrt32( x )

  Int32  MulDiv( Int32  a, Int32  b, Int32  c );
  Int32  MulDiv_Round( Int32  a, Int32  b, Int32  c );

  void  Add64( Int64*  x, Int64*  y, Int64*  z );
  void  Sub64( Int64*  x, Int64*  y, Int64*  z );

  void  MulTo64( Int32  x, Int32  y, Int64*  z );

  Int32  Div64by32( Int64*  x, Int32  y );

  Int  Order64( Int64*  z );
  Int  Order32( Int32   z );

  Int32  Sqrt32( Int32   l );
  Int32  Sqrt64( Int64*  l );

#endif /* LONG64 */


#define MUL_FIXED( a, b )      MulDiv_Round( (a), (b), 1 << 16 )
#define INT_TO_F26DOT6( x )    ( (Long)(x) << 6  )
#define INT_TO_F2DOT14( x )    ( (Long)(x) << 14 )
#define INT_TO_FIXED( x )      ( (Long)(x) << 16 )
#define F2DOT14_TO_FIXED( x )  ( (Long)(x) << 2  )
#define FLOAT_TO_FIXED( x )    ( (Long)((x) * 65536.0) )

#define ROUND_F26DOT6( x )     ( (x) >= 0 ? (   ((x) + 32) & -64) \
                                          : ( -((32 - (x)) & -64) ) )

#ifdef __cplusplus
  }
#endif

#endif /* TTCALC_H */


/* END */