1 /****************************************************************************
3 * config/integer-types.h
5 * FreeType integer types definitions.
7 * Copyright (C) 1996-2020 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.
17 #ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_
18 #define FREETYPE_CONFIG_INTEGER_TYPES_H_
20 /* There are systems (like the Texas Instruments 'C54x) where a `char` */
21 /* has 16~bits. ANSI~C says that `sizeof(char)` is always~1. Since an */
22 /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which */
23 /* is probably unexpected. */
25 /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */
29 #define FT_CHAR_BIT CHAR_BIT
34 /* The size of an `int` type. */
35 #if FT_UINT_MAX == 0xFFFFUL
36 #define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT )
37 #elif FT_UINT_MAX == 0xFFFFFFFFUL
38 #define FT_SIZEOF_INT ( 32 / FT_CHAR_BIT )
39 #elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
40 #define FT_SIZEOF_INT ( 64 / FT_CHAR_BIT )
42 #error "Unsupported size of `int' type!"
45 #endif /* !defined(FT_SIZEOF_INT) */
47 #ifndef FT_SIZEOF_LONG
49 /* The size of a `long` type. A five-byte `long` (as used e.g. on the */
50 /* DM642) is recognized but avoided. */
51 #if FT_ULONG_MAX == 0xFFFFFFFFUL
52 #define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
53 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
54 #define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
55 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
56 #define FT_SIZEOF_LONG ( 64 / FT_CHAR_BIT )
58 #error "Unsupported size of `long' type!"
61 #endif /* !defined(FT_SIZEOF_LONG) */
63 /**************************************************************************
71 /**************************************************************************
77 * A typedef for a 16bit signed integer type.
79 typedef signed short FT_Int16;
82 /**************************************************************************
88 * A typedef for a 16bit unsigned integer type.
90 typedef unsigned short FT_UInt16;
95 /* this #if 0 ... #endif clause is for documentation purposes */
98 /**************************************************************************
104 * A typedef for a 32bit signed integer type. The size depends on the
107 typedef signed XXX FT_Int32;
110 /**************************************************************************
115 * A typedef for a 32bit unsigned integer type. The size depends on the
118 typedef unsigned XXX FT_UInt32;
121 /**************************************************************************
126 * A typedef for a 64bit signed integer type. The size depends on the
127 * configuration. Only defined if there is real 64bit support;
128 * otherwise, it gets emulated with a structure (if necessary).
130 typedef signed XXX FT_Int64;
133 /**************************************************************************
138 * A typedef for a 64bit unsigned integer type. The size depends on the
139 * configuration. Only defined if there is real 64bit support;
140 * otherwise, it gets emulated with a structure (if necessary).
142 typedef unsigned XXX FT_UInt64;
148 #if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT )
150 typedef signed int FT_Int32;
151 typedef unsigned int FT_UInt32;
153 #elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
155 typedef signed long FT_Int32;
156 typedef unsigned long FT_UInt32;
159 #error "no 32bit type found -- please check your configuration files"
163 /* look up an integer type that is at least 32~bits */
164 #if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT )
167 typedef unsigned int FT_UFast;
169 #elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT )
171 typedef long FT_Fast;
172 typedef unsigned long FT_UFast;
177 /* determine whether we have a 64-bit `int` type for platforms without */
179 #if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
181 /* `FT_LONG64` must be defined if a 64-bit type is available */
183 #define FT_INT64 long
184 #define FT_UINT64 unsigned long
186 /**************************************************************************
188 * A 64-bit data type may create compilation problems if you compile in
189 * strict ANSI mode. To avoid them, we disable other 64-bit data types if
190 * `__STDC__` is defined. You can however ignore this rule by defining the
191 * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro.
193 #elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
195 #if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
198 #define FT_INT64 long long int
199 #define FT_UINT64 unsigned long long int
201 #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
203 /* this compiler provides the `__int64` type */
205 #define FT_INT64 __int64
206 #define FT_UINT64 unsigned __int64
208 #elif defined( __BORLANDC__ ) /* Borland C++ */
210 /* XXXX: We should probably check the value of `__BORLANDC__` in order */
211 /* to test the compiler version. */
213 /* this compiler provides the `__int64` type */
215 #define FT_INT64 __int64
216 #define FT_UINT64 unsigned __int64
218 #elif defined( __WATCOMC__ ) /* Watcom C++ */
220 /* Watcom doesn't provide 64-bit data types */
222 #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
225 #define FT_INT64 long long int
226 #define FT_UINT64 unsigned long long int
228 #elif defined( __GNUC__ )
230 /* GCC provides the `long long` type */
232 #define FT_INT64 long long int
233 #define FT_UINT64 unsigned long long int
235 #endif /* __STDC_VERSION__ >= 199901L */
237 #endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
240 typedef FT_INT64 FT_Int64;
241 typedef FT_UINT64 FT_UInt64;
245 #endif /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */