1 /***************************************************************************/
5 /* UNIX-specific configuration file (specification only). */
7 /* Copyright 1996-2004, 2006-2009, 2011 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 /***************************************************************************/
19 /*************************************************************************/
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 */
27 /* Note however that if some specific modifications are needed, we */
28 /* advise you to place a modified copy in your build directory. */
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. */
34 /*************************************************************************/
37 #ifndef __FTCONFIG_H__
38 #define __FTCONFIG_H__
41 #include FT_CONFIG_OPTIONS_H
42 #include FT_CONFIG_STANDARD_LIBRARY_H
48 /*************************************************************************/
50 /* PLATFORM-SPECIFIC CONFIGURATION MACROS */
52 /* These macros can be toggled to suit a specific system. The current */
53 /* ones are defaults used to compile FreeType in an ANSI C environment */
54 /* (16bit compilers are also supported). Copy this file to your own */
55 /* `freetype/builds/<system>' directory, and edit it to port the engine. */
57 /*************************************************************************/
65 /* There are systems (like the Texas Instruments 'C54x) where a `char' */
66 /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */
67 /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */
68 /* is probably unexpected. */
70 /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */
74 #define FT_CHAR_BIT CHAR_BIT
78 #undef FT_USE_AUTOCONF_SIZEOF_TYPES
79 #ifdef FT_USE_AUTOCONF_SIZEOF_TYPES
83 #define FT_SIZEOF_INT SIZEOF_INT
84 #define FT_SIZEOF_LONG SIZEOF_LONG
86 #else /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
88 /* Following cpp computation of the bit length of int and long */
89 /* is copied from default include/freetype/config/ftconfig.h. */
90 /* If any improvement is required for this file, it should be */
91 /* applied to the original header file for the builders that */
92 /* does not use configure script. */
94 /* The size of an `int' type. */
95 #if FT_UINT_MAX == 0xFFFFUL
96 #define FT_SIZEOF_INT (16 / FT_CHAR_BIT)
97 #elif FT_UINT_MAX == 0xFFFFFFFFUL
98 #define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
99 #elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
100 #define FT_SIZEOF_INT (64 / FT_CHAR_BIT)
102 #error "Unsupported size of `int' type!"
105 /* The size of a `long' type. A five-byte `long' (as used e.g. on the */
106 /* DM642) is recognized but avoided. */
107 #if FT_ULONG_MAX == 0xFFFFFFFFUL
108 #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
109 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
110 #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
111 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
112 #define FT_SIZEOF_LONG (64 / FT_CHAR_BIT)
114 #error "Unsupported size of `long' type!"
117 #endif /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
120 /* FT_UNUSED is a macro used to indicate that a given parameter is not */
121 /* used -- this is only used to get rid of unpleasant compiler warnings */
123 #define FT_UNUSED( arg ) ( (arg) = (arg) )
127 /*************************************************************************/
129 /* AUTOMATIC CONFIGURATION MACROS */
131 /* These macros are computed from the ones defined above. Don't touch */
132 /* their definition, unless you know precisely what you are doing. No */
133 /* porter should need to mess with them. */
135 /*************************************************************************/
138 /*************************************************************************/
142 /* This is the only necessary change, so it is defined here instead */
143 /* providing a new configuration file. */
145 #if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
146 /* no Carbon frameworks for 64bit 10.4.x */
147 /* AvailabilityMacros.h is available since Mac OS X 10.2, */
148 /* so guess the system version by maximum errno before inclusion */
150 #ifdef ECANCELED /* defined since 10.2 */
151 #include "AvailabilityMacros.h"
153 #if defined( __LP64__ ) && \
154 ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
158 #elif defined( __SC__ ) || defined( __MRC__ )
159 /* Classic MacOS compilers */
160 #include "ConditionalMacros.h"
162 #define FT_MACINTOSH 1
168 /* Fix compiler warning with sgi compiler */
169 #if defined( __sgi ) && !defined( __GNUC__ )
170 #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
171 #pragma set woff 3505
176 /*************************************************************************/
180 /* Used to guarantee the size of some specific integers. */
182 typedef signed short FT_Int16;
183 typedef unsigned short FT_UInt16;
185 #if FT_SIZEOF_INT == 4
187 typedef signed int FT_Int32;
188 typedef unsigned int FT_UInt32;
190 #elif FT_SIZEOF_LONG == 4
192 typedef signed long FT_Int32;
193 typedef unsigned long FT_UInt32;
196 #error "no 32bit type found -- please check your configuration files"
200 /* look up an integer type that is at least 32 bits */
201 #if FT_SIZEOF_INT >= 4
204 typedef unsigned int FT_UFast;
206 #elif FT_SIZEOF_LONG >= 4
208 typedef long FT_Fast;
209 typedef unsigned long FT_UFast;
214 /* determine whether we have a 64-bit int type for platforms without */
216 #if FT_SIZEOF_LONG == 8
218 /* FT_LONG64 must be defined if a 64-bit type is available */
220 #define FT_INT64 long
222 #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
224 /* this compiler provides the __int64 type */
226 #define FT_INT64 __int64
228 #elif defined( __BORLANDC__ ) /* Borland C++ */
230 /* XXXX: We should probably check the value of __BORLANDC__ in order */
231 /* to test the compiler version. */
233 /* this compiler provides the __int64 type */
235 #define FT_INT64 __int64
237 #elif defined( __WATCOMC__ ) /* Watcom C++ */
239 /* Watcom doesn't provide 64-bit data types */
241 #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
244 #define FT_INT64 long long int
246 #elif defined( __GNUC__ )
248 /* GCC provides the `long long' type */
250 #define FT_INT64 long long int
252 #endif /* FT_SIZEOF_LONG == 8 */
255 /*************************************************************************/
257 /* A 64-bit data type will create compilation problems if you compile */
258 /* in strict ANSI mode. To avoid them, we disable its use if __STDC__ */
259 /* is defined. You can however ignore this rule by defining the */
260 /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
262 #if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 )
266 /* Undefine the 64-bit macros in strict ANSI compilation mode. */
267 /* Since `#undef' doesn't survive in configuration header files */
268 /* we use the postprocessing facility of AC_CONFIG_HEADERS to */
269 /* replace the leading `/' with `#'. */
273 #endif /* __STDC__ */
275 #endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */
278 #define FT_BEGIN_STMNT do {
279 #define FT_END_STMNT } while ( 0 )
280 #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
283 #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
284 /* Provide assembler fragments for performance-critical functions. */
285 /* These must be defined `static __inline__' with GCC. */
287 #if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */
288 #define FT_MULFIX_ASSEMBLER FT_MulFix_arm
290 /* documentation is in freetype.h */
292 static __inline FT_Int32
293 FT_MulFix_arm( FT_Int32 a,
296 register FT_Int32 t, t2;
301 smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
302 mov a, t, asr #31 /* a = (hi >> 31) */
303 add a, a, #0x8000 /* a += 0x8000 */
304 adds t2, t2, a /* t2 += a */
305 adc t, t, #0 /* t += carry */
306 mov a, t2, lsr #16 /* a = t2 >> 16 */
307 orr a, a, t, lsl #16 /* a |= t << 16 */
312 #endif /* __CC_ARM || __ARMCC__ */
317 #if defined( __arm__ ) && !defined( __thumb__ ) && \
318 !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
319 #define FT_MULFIX_ASSEMBLER FT_MulFix_arm
321 /* documentation is in freetype.h */
323 static __inline__ FT_Int32
324 FT_MulFix_arm( FT_Int32 a,
327 register FT_Int32 t, t2;
330 __asm__ __volatile__ (
331 "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
332 "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
333 "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
334 "adds %1, %1, %0\n\t" /* %1 += %0 */
335 "adc %2, %2, #0\n\t" /* %2 += carry */
336 "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */
337 "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
338 : "=r"(a), "=&r"(t2), "=&r"(t)
343 #endif /* __arm__ && !__thumb__ && !( __CC_ARM || __ARMCC__ ) */
345 #if defined( __i386__ )
346 #define FT_MULFIX_ASSEMBLER FT_MulFix_i386
348 /* documentation is in freetype.h */
350 static __inline__ FT_Int32
351 FT_MulFix_i386( FT_Int32 a,
354 register FT_Int32 result;
357 __asm__ __volatile__ (
359 "movl %%edx, %%ecx\n"
361 "addl $0x8000, %%ecx\n"
362 "addl %%ecx, %%eax\n"
366 "addl %%edx, %%eax\n"
367 : "=a"(result), "=d"(b)
375 #endif /* __GNUC__ */
378 #ifdef _MSC_VER /* Visual C++ */
382 #define FT_MULFIX_ASSEMBLER FT_MulFix_i386
384 /* documentation is in freetype.h */
386 static __inline FT_Int32
387 FT_MulFix_i386( FT_Int32 a,
390 register FT_Int32 result;
412 #endif /* _MSC_VER */
414 #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
417 #ifdef FT_CONFIG_OPTION_INLINE_MULFIX
418 #ifdef FT_MULFIX_ASSEMBLER
419 #define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER
424 #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
426 #define FT_LOCAL( x ) static x
427 #define FT_LOCAL_DEF( x ) static x
432 #define FT_LOCAL( x ) extern "C" x
433 #define FT_LOCAL_DEF( x ) extern "C" x
435 #define FT_LOCAL( x ) extern x
436 #define FT_LOCAL_DEF( x ) x
439 #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
445 #define FT_BASE( x ) extern "C" x
447 #define FT_BASE( x ) extern x
450 #endif /* !FT_BASE */
456 #define FT_BASE_DEF( x ) x
458 #define FT_BASE_DEF( x ) x
461 #endif /* !FT_BASE_DEF */
467 #define FT_EXPORT( x ) extern "C" x
469 #define FT_EXPORT( x ) extern x
472 #endif /* !FT_EXPORT */
475 #ifndef FT_EXPORT_DEF
478 #define FT_EXPORT_DEF( x ) extern "C" x
480 #define FT_EXPORT_DEF( x ) extern x
483 #endif /* !FT_EXPORT_DEF */
486 #ifndef FT_EXPORT_VAR
489 #define FT_EXPORT_VAR( x ) extern "C" x
491 #define FT_EXPORT_VAR( x ) extern x
494 #endif /* !FT_EXPORT_VAR */
496 /* The following macros are needed to compile the library with a */
497 /* C++ compiler and with 16bit compilers. */
500 /* This is special. Within C++, you must specify `extern "C"' for */
501 /* functions which are used via function pointers, and you also */
502 /* must do that for structures which contain function pointers to */
503 /* assure C linkage -- it's not possible to have (local) anonymous */
504 /* functions which are accessed by (global) function pointers. */
507 /* FT_CALLBACK_DEF is used to _define_ a callback function. */
509 /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
510 /* contains pointers to callback functions. */
512 /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
513 /* that contains pointers to callback functions. */
516 /* Some 16bit compilers have to redefine these macros to insert */
517 /* the infamous `_cdecl' or `__fastcall' declarations. */
519 #ifndef FT_CALLBACK_DEF
521 #define FT_CALLBACK_DEF( x ) extern "C" x
523 #define FT_CALLBACK_DEF( x ) static x
525 #endif /* FT_CALLBACK_DEF */
527 #ifndef FT_CALLBACK_TABLE
529 #define FT_CALLBACK_TABLE extern "C"
530 #define FT_CALLBACK_TABLE_DEF extern "C"
532 #define FT_CALLBACK_TABLE extern
533 #define FT_CALLBACK_TABLE_DEF /* nothing */
535 #endif /* FT_CALLBACK_TABLE */
541 #endif /* __FTCONFIG_H__ */