1 | /**************************************************************************** |
2 | * |
3 | * config/integer-types.h |
4 | * |
5 | * FreeType integer types definitions. |
6 | * |
7 | * Copyright (C) 1996-2023 by |
8 | * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 | * |
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. |
15 | * |
16 | */ |
17 | #ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_ |
18 | #define FREETYPE_CONFIG_INTEGER_TYPES_H_ |
19 | |
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. */ |
24 | /* */ |
25 | /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */ |
26 | /* `char` type. */ |
27 | |
28 | #ifndef FT_CHAR_BIT |
29 | #define FT_CHAR_BIT CHAR_BIT |
30 | #endif |
31 | |
32 | #ifndef FT_SIZEOF_INT |
33 | |
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 ) |
41 | #else |
42 | #error "Unsupported size of `int' type!" |
43 | #endif |
44 | |
45 | #endif /* !defined(FT_SIZEOF_INT) */ |
46 | |
47 | #ifndef FT_SIZEOF_LONG |
48 | |
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 ) |
57 | #else |
58 | #error "Unsupported size of `long' type!" |
59 | #endif |
60 | |
61 | #endif /* !defined(FT_SIZEOF_LONG) */ |
62 | |
63 | #ifndef FT_SIZEOF_LONG_LONG |
64 | |
65 | /* The size of a `long long` type if available */ |
66 | #if defined( FT_ULLONG_MAX ) && FT_ULLONG_MAX >= 0xFFFFFFFFFFFFFFFFULL |
67 | #define FT_SIZEOF_LONG_LONG ( 64 / FT_CHAR_BIT ) |
68 | #else |
69 | #define FT_SIZEOF_LONG_LONG 0 |
70 | #endif |
71 | |
72 | #endif /* !defined(FT_SIZEOF_LONG_LONG) */ |
73 | |
74 | |
75 | /************************************************************************** |
76 | * |
77 | * @section: |
78 | * basic_types |
79 | * |
80 | */ |
81 | |
82 | |
83 | /************************************************************************** |
84 | * |
85 | * @type: |
86 | * FT_Int16 |
87 | * |
88 | * @description: |
89 | * A typedef for a 16bit signed integer type. |
90 | */ |
91 | typedef signed short FT_Int16; |
92 | |
93 | |
94 | /************************************************************************** |
95 | * |
96 | * @type: |
97 | * FT_UInt16 |
98 | * |
99 | * @description: |
100 | * A typedef for a 16bit unsigned integer type. |
101 | */ |
102 | typedef unsigned short FT_UInt16; |
103 | |
104 | /* */ |
105 | |
106 | |
107 | /* this #if 0 ... #endif clause is for documentation purposes */ |
108 | #if 0 |
109 | |
110 | /************************************************************************** |
111 | * |
112 | * @type: |
113 | * FT_Int32 |
114 | * |
115 | * @description: |
116 | * A typedef for a 32bit signed integer type. The size depends on the |
117 | * configuration. |
118 | */ |
119 | typedef signed XXX FT_Int32; |
120 | |
121 | |
122 | /************************************************************************** |
123 | * |
124 | * @type: |
125 | * FT_UInt32 |
126 | * |
127 | * A typedef for a 32bit unsigned integer type. The size depends on the |
128 | * configuration. |
129 | */ |
130 | typedef unsigned XXX FT_UInt32; |
131 | |
132 | |
133 | /************************************************************************** |
134 | * |
135 | * @type: |
136 | * FT_Int64 |
137 | * |
138 | * A typedef for a 64bit signed 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). |
141 | */ |
142 | typedef signed XXX FT_Int64; |
143 | |
144 | |
145 | /************************************************************************** |
146 | * |
147 | * @type: |
148 | * FT_UInt64 |
149 | * |
150 | * A typedef for a 64bit unsigned integer type. The size depends on the |
151 | * configuration. Only defined if there is real 64bit support; |
152 | * otherwise, it gets emulated with a structure (if necessary). |
153 | */ |
154 | typedef unsigned XXX FT_UInt64; |
155 | |
156 | /* */ |
157 | |
158 | #endif |
159 | |
160 | #if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT ) |
161 | |
162 | typedef signed int FT_Int32; |
163 | typedef unsigned int FT_UInt32; |
164 | |
165 | #elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT ) |
166 | |
167 | typedef signed long FT_Int32; |
168 | typedef unsigned long FT_UInt32; |
169 | |
170 | #else |
171 | #error "no 32bit type found -- please check your configuration files" |
172 | #endif |
173 | |
174 | |
175 | /* look up an integer type that is at least 32~bits */ |
176 | #if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT ) |
177 | |
178 | typedef int FT_Fast; |
179 | typedef unsigned int FT_UFast; |
180 | |
181 | #elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT ) |
182 | |
183 | typedef long FT_Fast; |
184 | typedef unsigned long FT_UFast; |
185 | |
186 | #endif |
187 | |
188 | |
189 | /* determine whether we have a 64-bit integer type */ |
190 | #if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT ) |
191 | |
192 | #define FT_INT64 long |
193 | #define FT_UINT64 unsigned long |
194 | |
195 | #elif FT_SIZEOF_LONG_LONG >= ( 64 / FT_CHAR_BIT ) |
196 | |
197 | #define FT_INT64 long long int |
198 | #define FT_UINT64 unsigned long long int |
199 | |
200 | /************************************************************************** |
201 | * |
202 | * A 64-bit data type may create compilation problems if you compile in |
203 | * strict ANSI mode. To avoid them, we disable other 64-bit data types if |
204 | * `__STDC__` is defined. You can however ignore this rule by defining the |
205 | * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro. |
206 | */ |
207 | #elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) |
208 | |
209 | #if defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ |
210 | |
211 | /* this compiler provides the `__int64` type */ |
212 | #define FT_INT64 __int64 |
213 | #define FT_UINT64 unsigned __int64 |
214 | |
215 | #elif defined( __BORLANDC__ ) /* Borland C++ */ |
216 | |
217 | /* XXXX: We should probably check the value of `__BORLANDC__` in order */ |
218 | /* to test the compiler version. */ |
219 | |
220 | /* this compiler provides the `__int64` type */ |
221 | #define FT_INT64 __int64 |
222 | #define FT_UINT64 unsigned __int64 |
223 | |
224 | #elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1100 /* Watcom C++ */ |
225 | |
226 | #define FT_INT64 long long int |
227 | #define FT_UINT64 unsigned long long int |
228 | |
229 | #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ |
230 | |
231 | #define FT_INT64 long long int |
232 | #define FT_UINT64 unsigned long long int |
233 | |
234 | #elif defined( __GNUC__ ) |
235 | |
236 | /* GCC provides the `long long` type */ |
237 | #define FT_INT64 long long int |
238 | #define FT_UINT64 unsigned long long int |
239 | |
240 | #endif /* !__STDC__ */ |
241 | |
242 | #endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */ |
243 | |
244 | #ifdef FT_INT64 |
245 | typedef FT_INT64 FT_Int64; |
246 | typedef FT_UINT64 FT_UInt64; |
247 | #endif |
248 | |
249 | |
250 | #endif /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */ |
251 | |