1 /***************************************************************************/ |
|
2 /* */ |
|
3 /* ftconfig.h */ |
|
4 /* */ |
|
5 /* ANSI-specific configuration file (specification only). */ |
|
6 /* */ |
|
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010 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 |
|
18 |
|
19 /*************************************************************************/ |
|
20 /* */ |
|
21 /* This header file contains a number of macro definitions that are used */ |
|
22 /* by the rest of the engine. Most of the macros here are automatically */ |
|
23 /* determined at compile time, and you should not need to change it to */ |
|
24 /* port FreeType, except to compile the library with a non-ANSI */ |
|
25 /* compiler. */ |
|
26 /* */ |
|
27 /* Note however that if some specific modifications are needed, we */ |
|
28 /* advise you to place a modified copy in your build directory. */ |
|
29 /* */ |
|
30 /* The build directory is usually `freetype/builds/<system>', and */ |
|
31 /* contains system-specific files that are always included first when */ |
|
32 /* building the library. */ |
|
33 /* */ |
|
34 /* This ANSI version should stay in `include/freetype/config'. */ |
|
35 /* */ |
|
36 /*************************************************************************/ |
|
37 |
|
38 #ifndef __FTCONFIG_H__ |
|
39 #define __FTCONFIG_H__ |
|
40 |
|
41 #include <ft2build.h> |
|
42 #include FT_CONFIG_OPTIONS_H |
|
43 #include FT_CONFIG_STANDARD_LIBRARY_H |
|
44 |
|
45 |
|
46 FT_BEGIN_HEADER |
|
47 |
|
48 |
|
49 /*************************************************************************/ |
|
50 /* */ |
|
51 /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ |
|
52 /* */ |
|
53 /* These macros can be toggled to suit a specific system. The current */ |
|
54 /* ones are defaults used to compile FreeType in an ANSI C environment */ |
|
55 /* (16bit compilers are also supported). Copy this file to your own */ |
|
56 /* `freetype/builds/<system>' directory, and edit it to port the engine. */ |
|
57 /* */ |
|
58 /*************************************************************************/ |
|
59 |
|
60 |
|
61 /* There are systems (like the Texas Instruments 'C54x) where a `char' */ |
|
62 /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ |
|
63 /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ |
|
64 /* is probably unexpected. */ |
|
65 /* */ |
|
66 /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ |
|
67 /* `char' type. */ |
|
68 |
|
69 #ifndef FT_CHAR_BIT |
|
70 #define FT_CHAR_BIT CHAR_BIT |
|
71 #endif |
|
72 |
|
73 |
|
74 /* The size of an `int' type. */ |
|
75 #if FT_UINT_MAX == 0xFFFFUL |
|
76 #define FT_SIZEOF_INT (16 / FT_CHAR_BIT) |
|
77 #elif FT_UINT_MAX == 0xFFFFFFFFUL |
|
78 #define FT_SIZEOF_INT (32 / FT_CHAR_BIT) |
|
79 #elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL |
|
80 #define FT_SIZEOF_INT (64 / FT_CHAR_BIT) |
|
81 #else |
|
82 #error "Unsupported size of `int' type!" |
|
83 #endif |
|
84 |
|
85 /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ |
|
86 /* DM642) is recognized but avoided. */ |
|
87 #if FT_ULONG_MAX == 0xFFFFFFFFUL |
|
88 #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) |
|
89 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL |
|
90 #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) |
|
91 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL |
|
92 #define FT_SIZEOF_LONG (64 / FT_CHAR_BIT) |
|
93 #else |
|
94 #error "Unsupported size of `long' type!" |
|
95 #endif |
|
96 |
|
97 |
|
98 /* Preferred alignment of data */ |
|
99 #define FT_ALIGNMENT 8 |
|
100 |
|
101 |
|
102 /* FT_UNUSED is a macro used to indicate that a given parameter is not */ |
|
103 /* used -- this is only used to get rid of unpleasant compiler warnings */ |
|
104 #ifndef FT_UNUSED |
|
105 #define FT_UNUSED( arg ) ( (arg) = (arg) ) |
|
106 #endif |
|
107 |
|
108 |
|
109 /*************************************************************************/ |
|
110 /* */ |
|
111 /* AUTOMATIC CONFIGURATION MACROS */ |
|
112 /* */ |
|
113 /* These macros are computed from the ones defined above. Don't touch */ |
|
114 /* their definition, unless you know precisely what you are doing. No */ |
|
115 /* porter should need to mess with them. */ |
|
116 /* */ |
|
117 /*************************************************************************/ |
|
118 |
|
119 |
|
120 /*************************************************************************/ |
|
121 /* */ |
|
122 /* Mac support */ |
|
123 /* */ |
|
124 /* This is the only necessary change, so it is defined here instead */ |
|
125 /* providing a new configuration file. */ |
|
126 /* */ |
|
127 #if ( defined( __APPLE__ ) && !defined( DARWIN_NO_CARBON ) ) || \ |
|
128 ( defined( __MWERKS__ ) && defined( macintosh ) ) |
|
129 /* no Carbon frameworks for 64bit 10.4.x */ |
|
130 #include "AvailabilityMacros.h" |
|
131 #if defined( __LP64__ ) && \ |
|
132 ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) |
|
133 #define DARWIN_NO_CARBON 1 |
|
134 #else |
|
135 #define FT_MACINTOSH 1 |
|
136 #endif |
|
137 |
|
138 #elif defined( __SC__ ) || defined( __MRC__ ) |
|
139 /* Classic MacOS compilers */ |
|
140 #include "ConditionalMacros.h" |
|
141 #if TARGET_OS_MAC |
|
142 #define FT_MACINTOSH 1 |
|
143 #endif |
|
144 |
|
145 #endif |
|
146 |
|
147 |
|
148 /*************************************************************************/ |
|
149 /* */ |
|
150 /* <Section> */ |
|
151 /* basic_types */ |
|
152 /* */ |
|
153 /*************************************************************************/ |
|
154 |
|
155 |
|
156 /*************************************************************************/ |
|
157 /* */ |
|
158 /* <Type> */ |
|
159 /* FT_Int16 */ |
|
160 /* */ |
|
161 /* <Description> */ |
|
162 /* A typedef for a 16bit signed integer type. */ |
|
163 /* */ |
|
164 typedef signed short FT_Int16; |
|
165 |
|
166 |
|
167 /*************************************************************************/ |
|
168 /* */ |
|
169 /* <Type> */ |
|
170 /* FT_UInt16 */ |
|
171 /* */ |
|
172 /* <Description> */ |
|
173 /* A typedef for a 16bit unsigned integer type. */ |
|
174 /* */ |
|
175 typedef unsigned short FT_UInt16; |
|
176 |
|
177 /* */ |
|
178 |
|
179 |
|
180 /* this #if 0 ... #endif clause is for documentation purposes */ |
|
181 #if 0 |
|
182 |
|
183 /*************************************************************************/ |
|
184 /* */ |
|
185 /* <Type> */ |
|
186 /* FT_Int32 */ |
|
187 /* */ |
|
188 /* <Description> */ |
|
189 /* A typedef for a 32bit signed integer type. The size depends on */ |
|
190 /* the configuration. */ |
|
191 /* */ |
|
192 typedef signed XXX FT_Int32; |
|
193 |
|
194 |
|
195 /*************************************************************************/ |
|
196 /* */ |
|
197 /* <Type> */ |
|
198 /* FT_UInt32 */ |
|
199 /* */ |
|
200 /* A typedef for a 32bit unsigned integer type. The size depends on */ |
|
201 /* the configuration. */ |
|
202 /* */ |
|
203 typedef unsigned XXX FT_UInt32; |
|
204 |
|
205 /* */ |
|
206 |
|
207 #endif |
|
208 |
|
209 #if FT_SIZEOF_INT == (32 / FT_CHAR_BIT) |
|
210 |
|
211 typedef signed int FT_Int32; |
|
212 typedef unsigned int FT_UInt32; |
|
213 |
|
214 #elif FT_SIZEOF_LONG == (32 / FT_CHAR_BIT) |
|
215 |
|
216 typedef signed long FT_Int32; |
|
217 typedef unsigned long FT_UInt32; |
|
218 |
|
219 #else |
|
220 #error "no 32bit type found -- please check your configuration files" |
|
221 #endif |
|
222 |
|
223 |
|
224 /* look up an integer type that is at least 32 bits */ |
|
225 #if FT_SIZEOF_INT >= (32 / FT_CHAR_BIT) |
|
226 |
|
227 typedef int FT_Fast; |
|
228 typedef unsigned int FT_UFast; |
|
229 |
|
230 #elif FT_SIZEOF_LONG >= (32 / FT_CHAR_BIT) |
|
231 |
|
232 typedef long FT_Fast; |
|
233 typedef unsigned long FT_UFast; |
|
234 |
|
235 #endif |
|
236 |
|
237 |
|
238 /* determine whether we have a 64-bit int type for platforms without */ |
|
239 /* Autoconf */ |
|
240 #if FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) |
|
241 |
|
242 /* FT_LONG64 must be defined if a 64-bit type is available */ |
|
243 #define FT_LONG64 |
|
244 #define FT_INT64 long |
|
245 |
|
246 #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ |
|
247 |
|
248 /* this compiler provides the __int64 type */ |
|
249 #define FT_LONG64 |
|
250 #define FT_INT64 __int64 |
|
251 |
|
252 #elif defined( __BORLANDC__ ) /* Borland C++ */ |
|
253 |
|
254 /* XXXX: We should probably check the value of __BORLANDC__ in order */ |
|
255 /* to test the compiler version. */ |
|
256 |
|
257 /* this compiler provides the __int64 type */ |
|
258 #define FT_LONG64 |
|
259 #define FT_INT64 __int64 |
|
260 |
|
261 #elif defined( __WATCOMC__ ) /* Watcom C++ */ |
|
262 |
|
263 /* Watcom doesn't provide 64-bit data types */ |
|
264 |
|
265 #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ |
|
266 |
|
267 #define FT_LONG64 |
|
268 #define FT_INT64 long long int |
|
269 |
|
270 #elif defined( __GNUC__ ) |
|
271 |
|
272 /* GCC provides the `long long' type */ |
|
273 #define FT_LONG64 |
|
274 #define FT_INT64 long long int |
|
275 |
|
276 #endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */ |
|
277 |
|
278 |
|
279 /*************************************************************************/ |
|
280 /* */ |
|
281 /* A 64-bit data type will create compilation problems if you compile */ |
|
282 /* in strict ANSI mode. To avoid them, we disable its use if __STDC__ */ |
|
283 /* is defined. You can however ignore this rule by defining the */ |
|
284 /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ |
|
285 /* */ |
|
286 #if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 ) |
|
287 |
|
288 #ifdef __STDC__ |
|
289 |
|
290 /* undefine the 64-bit macros in strict ANSI compilation mode */ |
|
291 #undef FT_LONG64 |
|
292 #undef FT_INT64 |
|
293 |
|
294 #endif /* __STDC__ */ |
|
295 |
|
296 #endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */ |
|
297 |
|
298 |
|
299 #define FT_BEGIN_STMNT do { |
|
300 #define FT_END_STMNT } while ( 0 ) |
|
301 #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT |
|
302 |
|
303 |
|
304 #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER |
|
305 /* Provide assembler fragments for performance-critical functions. */ |
|
306 /* These must be defined `static __inline__' with GCC. */ |
|
307 |
|
308 #if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */ |
|
309 #define FT_MULFIX_ASSEMBLER FT_MulFix_arm |
|
310 |
|
311 /* documentation is in freetype.h */ |
|
312 |
|
313 static __inline FT_Int32 |
|
314 FT_MulFix_arm( FT_Int32 a, |
|
315 FT_Int32 b ) |
|
316 { |
|
317 register FT_Int32 t, t2; |
|
318 |
|
319 |
|
320 __asm |
|
321 { |
|
322 smull t2, t, b, a /* (lo=t2,hi=t) = a*b */ |
|
323 mov a, t, asr #31 /* a = (hi >> 31) */ |
|
324 add a, a, #0x8000 /* a += 0x8000 */ |
|
325 adds t2, t2, a /* t2 += a */ |
|
326 adc t, t, #0 /* t += carry */ |
|
327 mov a, t2, lsr #16 /* a = t2 >> 16 */ |
|
328 orr a, a, t, lsl #16 /* a |= t << 16 */ |
|
329 } |
|
330 return a; |
|
331 } |
|
332 |
|
333 #endif /* __CC_ARM || __ARMCC__ */ |
|
334 |
|
335 |
|
336 #ifdef __GNUC__ |
|
337 |
|
338 #if defined( __arm__ ) && !defined( __thumb__ ) && \ |
|
339 !( defined( __CC_ARM ) || defined( __ARMCC__ ) ) |
|
340 #define FT_MULFIX_ASSEMBLER FT_MulFix_arm |
|
341 |
|
342 /* documentation is in freetype.h */ |
|
343 // Xeli: Got this snippet from a 2.4.6 source |
|
344 |
|
345 static __inline__ FT_Int32 |
|
346 FT_MulFix_arm( FT_Int32 a, |
|
347 FT_Int32 b ) |
|
348 { |
|
349 register FT_Int32 t, t2; |
|
350 |
|
351 |
|
352 __asm__ __volatile__ ( |
|
353 "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */ |
|
354 "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */ |
|
355 "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ |
|
356 "adds %1, %1, %0\n\t" /* %1 += %0 */ |
|
357 "adc %2, %2, #0\n\t" /* %2 += carry */ |
|
358 "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */ |
|
359 "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */ |
|
360 : "=r"(a), "=&r"(t2), "=&r"(t) |
|
361 : "r"(a), "r"(b) ); |
|
362 return a; |
|
363 } |
|
364 |
|
365 #endif /* __arm__ && !__thumb__ && !( __CC_ARM || __ARMCC__ ) */ |
|
366 |
|
367 #if defined( __i386__ ) |
|
368 #define FT_MULFIX_ASSEMBLER FT_MulFix_i386 |
|
369 |
|
370 /* documentation is in freetype.h */ |
|
371 |
|
372 static __inline__ FT_Int32 |
|
373 FT_MulFix_i386( FT_Int32 a, |
|
374 FT_Int32 b ) |
|
375 { |
|
376 register FT_Int32 result; |
|
377 |
|
378 |
|
379 __asm__ __volatile__ ( |
|
380 "imul %%edx\n" |
|
381 "movl %%edx, %%ecx\n" |
|
382 "sarl $31, %%ecx\n" |
|
383 "addl $0x8000, %%ecx\n" |
|
384 "addl %%ecx, %%eax\n" |
|
385 "adcl $0, %%edx\n" |
|
386 "shrl $16, %%eax\n" |
|
387 "shll $16, %%edx\n" |
|
388 "addl %%edx, %%eax\n" |
|
389 : "=a"(result), "=d"(b) |
|
390 : "a"(a), "d"(b) |
|
391 : "%ecx", "cc" ); |
|
392 return result; |
|
393 } |
|
394 |
|
395 #endif /* i386 */ |
|
396 |
|
397 #endif /* __GNUC__ */ |
|
398 |
|
399 |
|
400 #ifdef _MSC_VER /* Visual C++ */ |
|
401 |
|
402 #ifdef _M_IX86 |
|
403 |
|
404 #define FT_MULFIX_ASSEMBLER FT_MulFix_i386 |
|
405 |
|
406 /* documentation is in freetype.h */ |
|
407 |
|
408 static __inline FT_Int32 |
|
409 FT_MulFix_i386( FT_Int32 a, |
|
410 FT_Int32 b ) |
|
411 { |
|
412 register FT_Int32 result; |
|
413 |
|
414 __asm |
|
415 { |
|
416 mov eax, a |
|
417 mov edx, b |
|
418 imul edx |
|
419 mov ecx, edx |
|
420 sar ecx, 31 |
|
421 add ecx, 8000h |
|
422 add eax, ecx |
|
423 adc edx, 0 |
|
424 shr eax, 16 |
|
425 shl edx, 16 |
|
426 add eax, edx |
|
427 mov result, eax |
|
428 } |
|
429 return result; |
|
430 } |
|
431 |
|
432 #endif /* _M_IX86 */ |
|
433 |
|
434 #endif /* _MSC_VER */ |
|
435 |
|
436 #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ |
|
437 |
|
438 |
|
439 #ifdef FT_CONFIG_OPTION_INLINE_MULFIX |
|
440 #ifdef FT_MULFIX_ASSEMBLER |
|
441 #define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER |
|
442 #endif |
|
443 #endif |
|
444 |
|
445 |
|
446 #ifdef FT_MAKE_OPTION_SINGLE_OBJECT |
|
447 |
|
448 #define FT_LOCAL( x ) static x |
|
449 #define FT_LOCAL_DEF( x ) static x |
|
450 |
|
451 #else |
|
452 |
|
453 #ifdef __cplusplus |
|
454 #define FT_LOCAL( x ) extern "C" x |
|
455 #define FT_LOCAL_DEF( x ) extern "C" x |
|
456 #else |
|
457 #define FT_LOCAL( x ) extern x |
|
458 #define FT_LOCAL_DEF( x ) x |
|
459 #endif |
|
460 |
|
461 #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ |
|
462 |
|
463 |
|
464 #ifndef FT_BASE |
|
465 |
|
466 #ifdef __cplusplus |
|
467 #define FT_BASE( x ) extern "C" x |
|
468 #else |
|
469 #define FT_BASE( x ) extern x |
|
470 #endif |
|
471 |
|
472 #endif /* !FT_BASE */ |
|
473 |
|
474 |
|
475 #ifndef FT_BASE_DEF |
|
476 |
|
477 #ifdef __cplusplus |
|
478 #define FT_BASE_DEF( x ) x |
|
479 #else |
|
480 #define FT_BASE_DEF( x ) x |
|
481 #endif |
|
482 |
|
483 #endif /* !FT_BASE_DEF */ |
|
484 |
|
485 |
|
486 #ifndef FT_EXPORT |
|
487 |
|
488 #ifdef __cplusplus |
|
489 #define FT_EXPORT( x ) extern "C" x |
|
490 #else |
|
491 #define FT_EXPORT( x ) extern x |
|
492 #endif |
|
493 |
|
494 #endif /* !FT_EXPORT */ |
|
495 |
|
496 |
|
497 #ifndef FT_EXPORT_DEF |
|
498 |
|
499 #ifdef __cplusplus |
|
500 #define FT_EXPORT_DEF( x ) extern "C" x |
|
501 #else |
|
502 #define FT_EXPORT_DEF( x ) extern x |
|
503 #endif |
|
504 |
|
505 #endif /* !FT_EXPORT_DEF */ |
|
506 |
|
507 |
|
508 #ifndef FT_EXPORT_VAR |
|
509 |
|
510 #ifdef __cplusplus |
|
511 #define FT_EXPORT_VAR( x ) extern "C" x |
|
512 #else |
|
513 #define FT_EXPORT_VAR( x ) extern x |
|
514 #endif |
|
515 |
|
516 #endif /* !FT_EXPORT_VAR */ |
|
517 |
|
518 /* The following macros are needed to compile the library with a */ |
|
519 /* C++ compiler and with 16bit compilers. */ |
|
520 /* */ |
|
521 |
|
522 /* This is special. Within C++, you must specify `extern "C"' for */ |
|
523 /* functions which are used via function pointers, and you also */ |
|
524 /* must do that for structures which contain function pointers to */ |
|
525 /* assure C linkage -- it's not possible to have (local) anonymous */ |
|
526 /* functions which are accessed by (global) function pointers. */ |
|
527 /* */ |
|
528 /* */ |
|
529 /* FT_CALLBACK_DEF is used to _define_ a callback function. */ |
|
530 /* */ |
|
531 /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */ |
|
532 /* contains pointers to callback functions. */ |
|
533 /* */ |
|
534 /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */ |
|
535 /* that contains pointers to callback functions. */ |
|
536 /* */ |
|
537 /* */ |
|
538 /* Some 16bit compilers have to redefine these macros to insert */ |
|
539 /* the infamous `_cdecl' or `__fastcall' declarations. */ |
|
540 /* */ |
|
541 #ifndef FT_CALLBACK_DEF |
|
542 #ifdef __cplusplus |
|
543 #define FT_CALLBACK_DEF( x ) extern "C" x |
|
544 #else |
|
545 #define FT_CALLBACK_DEF( x ) static x |
|
546 #endif |
|
547 #endif /* FT_CALLBACK_DEF */ |
|
548 |
|
549 #ifndef FT_CALLBACK_TABLE |
|
550 #ifdef __cplusplus |
|
551 #define FT_CALLBACK_TABLE extern "C" |
|
552 #define FT_CALLBACK_TABLE_DEF extern "C" |
|
553 #else |
|
554 #define FT_CALLBACK_TABLE extern |
|
555 #define FT_CALLBACK_TABLE_DEF /* nothing */ |
|
556 #endif |
|
557 #endif /* FT_CALLBACK_TABLE */ |
|
558 |
|
559 |
|
560 FT_END_HEADER |
|
561 |
|
562 |
|
563 #endif /* __FTCONFIG_H__ */ |
|
564 |
|
565 |
|
566 /* END */ |
|