1 /***************************************************************************/
5 /* Arithmetic computations (specification). */
7 /* Copyright 1996-2000 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
22 #include <freetype/freetype.h>
23 #include <freetype/config/ftconfig.h> /* for LONG64 */
33 typedef INT64 FT_Int64;
35 #define ADD_64( x, y, z ) z = (x) + (y)
36 #define MUL_64( x, y, z ) z = (FT_Int64)(x) * (y)
38 #define DIV_64( x, y ) ( (x) / (y) )
41 #ifdef FT_CONFIG_OPTION_OLD_CALCS
43 #define SQRT_64( z ) FT_Sqrt64( z )
45 FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64 l );
47 #endif /* FT_CONFIG_OPTION_OLD_CALCS */
53 typedef struct FT_Int64_
61 #define ADD_64( x, y, z ) FT_Add64( &x, &y, &z )
62 #define MUL_64( x, y, z ) FT_MulTo64( x, y, &z )
63 #define DIV_64( x, y ) FT_Div64by32( &x, y )
66 FT_EXPORT_DEF( void ) FT_Add64( FT_Int64* x,
70 FT_EXPORT_DEF( void ) FT_MulTo64( FT_Int32 x,
74 FT_EXPORT_DEF( FT_Int32 ) FT_Div64by32( FT_Int64* x,
78 #ifdef FT_CONFIG_OPTION_OLD_CALCS
80 #define SQRT_64( z ) FT_Sqrt64( &z )
82 FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x );
84 #endif /* FT_CONFIG_OPTION_OLD_CALCS */
90 #ifndef FT_CONFIG_OPTION_OLD_CALCS
92 #define SQRT_32( x ) FT_Sqrt32( x )
94 BASE_DEF( FT_Int32 ) FT_Sqrt32( FT_Int32 x );
96 #endif /* !FT_CONFIG_OPTION_OLD_CALCS */
99 /*************************************************************************/
101 /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */
103 /*************************************************************************/
106 #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
107 #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
108 #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
109 #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
110 #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
112 #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
113 : ( -( ( 32 - (x) ) & -64 ) ) )
120 #endif /* FTCALC_H */