1 /***************************************************************************/
5 /* UNIX-specific configuration file (specification only). */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 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 /* Preferred alignment of data */
121 #define FT_ALIGNMENT 8
124 /* FT_UNUSED is a macro used to indicate that a given parameter is not */
125 /* used -- this is only used to get rid of unpleasant compiler warnings */
127 #define FT_UNUSED( arg ) ( (arg) = (arg) )
131 /*************************************************************************/
133 /* AUTOMATIC CONFIGURATION MACROS */
135 /* These macros are computed from the ones defined above. Don't touch */
136 /* their definition, unless you know precisely what you are doing. No */
137 /* porter should need to mess with them. */
139 /*************************************************************************/
142 /*************************************************************************/
146 /* This is the only necessary change, so it is defined here instead */
147 /* providing a new configuration file. */
149 #if ( defined( __APPLE__ ) && !defined( DARWIN_NO_CARBON ) ) || \
150 ( defined( __MWERKS__ ) && defined( macintosh ) )
151 /* no Carbon frameworks for 64bit 10.4.x */
152 #include "AvailabilityMacros.h"
153 #if defined( __LP64__ ) && \
154 ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
155 #define DARWIN_NO_CARBON 1
157 #define FT_MACINTOSH 1
160 #elif defined( __SC__ ) || defined( __MRC__ )
161 /* Classic MacOS compilers */
162 #include "ConditionalMacros.h"
164 #define FT_MACINTOSH 1
170 /* Fix compiler warning with sgi compiler */
171 #if defined( __sgi ) && !defined( __GNUC__ )
172 #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
173 #pragma set woff 3505
178 /*************************************************************************/
182 /* Used to guarantee the size of some specific integers. */
184 typedef signed short FT_Int16;
185 typedef unsigned short FT_UInt16;
187 #if FT_SIZEOF_INT == 4
189 typedef signed int FT_Int32;
190 typedef unsigned int FT_UInt32;
192 #elif FT_SIZEOF_LONG == 4
194 typedef signed long FT_Int32;
195 typedef unsigned long FT_UInt32;
198 #error "no 32bit type found -- please check your configuration files"
202 /* look up an integer type that is at least 32 bits */
203 #if FT_SIZEOF_INT >= 4
206 typedef unsigned int FT_UFast;
208 #elif FT_SIZEOF_LONG >= 4
210 typedef long FT_Fast;
211 typedef unsigned long FT_UFast;
216 /* determine whether we have a 64-bit int type for platforms without */
218 #if FT_SIZEOF_LONG == 8
220 /* FT_LONG64 must be defined if a 64-bit type is available */
222 #define FT_INT64 long
224 #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
226 /* this compiler provides the __int64 type */
228 #define FT_INT64 __int64
230 #elif defined( __BORLANDC__ ) /* Borland C++ */
232 /* XXXX: We should probably check the value of __BORLANDC__ in order */
233 /* to test the compiler version. */
235 /* this compiler provides the __int64 type */
237 #define FT_INT64 __int64
239 #elif defined( __WATCOMC__ ) /* Watcom C++ */
241 /* Watcom doesn't provide 64-bit data types */
243 #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
246 #define FT_INT64 long long int
248 #elif defined( __GNUC__ )
250 /* GCC provides the `long long' type */
252 #define FT_INT64 long long int
254 #endif /* FT_SIZEOF_LONG == 8 */
257 /*************************************************************************/
259 /* A 64-bit data type will create compilation problems if you compile */
260 /* in strict ANSI mode. To avoid them, we disable its use if __STDC__ */
261 /* is defined. You can however ignore this rule by defining the */
262 /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
264 #if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 )
268 /* Undefine the 64-bit macros in strict ANSI compilation mode. */
269 /* Since `#undef' doesn't survive in configuration header files */
270 /* we use the postprocessing facility of AC_CONFIG_HEADERS to */
271 /* replace the leading `/' with `#'. */
275 #endif /* __STDC__ */
277 #endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */
280 #define FT_BEGIN_STMNT do {
281 #define FT_END_STMNT } while ( 0 )
282 #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
285 #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
286 /* Provide assembler fragments for performance-critical functions. */
287 /* These must be defined `static __inline__' with GCC. */
291 #if defined( __arm__ ) && !defined( __thumb__ )
292 #define FT_MULFIX_ASSEMBLER FT_MulFix_arm
294 static __inline__ FT_Int32
295 FT_MulFix_arm( FT_Int32 a,
298 register FT_Int32 t, t2;
301 __asm__ __volatile__ (
302 "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
303 "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
304 "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
305 "adds %1, %1, %0\n\t" /* %1 += %0 */
306 "adc %2, %2, #0\n\t" /* %2 += carry */
307 "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */
308 "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
309 : "=r"(a), "=&r"(t2), "=&r"(t)
314 #endif /* __arm__ && !__thumb__ */
317 #define FT_MULFIX_ASSEMBLER FT_MulFix_i386
319 static __inline__ FT_Int32
320 FT_MulFix_i386( FT_Int32 a,
323 register FT_Int32 result;
326 __asm__ __volatile__ (
328 "movl %%edx, %%ecx\n"
330 "addl $0x8000, %%ecx\n"
331 "addl %%ecx, %%eax\n"
335 "addl %%edx, %%eax\n"
336 : "=a"(result), "+d"(b)
344 #endif /* __GNUC__ */
346 #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
349 #ifdef FT_CONFIG_OPTION_INLINE_MULFIX
350 #ifdef FT_MULFIX_ASSEMBLER
351 #define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER
356 #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
358 #define FT_LOCAL( x ) static x
359 #define FT_LOCAL_DEF( x ) static x
364 #define FT_LOCAL( x ) extern "C" x
365 #define FT_LOCAL_DEF( x ) extern "C" x
367 #define FT_LOCAL( x ) extern x
368 #define FT_LOCAL_DEF( x ) x
371 #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
377 #define FT_BASE( x ) extern "C" x
379 #define FT_BASE( x ) extern x
382 #endif /* !FT_BASE */
388 #define FT_BASE_DEF( x ) x
390 #define FT_BASE_DEF( x ) x
393 #endif /* !FT_BASE_DEF */
399 #define FT_EXPORT( x ) extern "C" x
401 #define FT_EXPORT( x ) extern x
404 #endif /* !FT_EXPORT */
407 #ifndef FT_EXPORT_DEF
410 #define FT_EXPORT_DEF( x ) extern "C" x
412 #define FT_EXPORT_DEF( x ) extern x
415 #endif /* !FT_EXPORT_DEF */
418 #ifndef FT_EXPORT_VAR
421 #define FT_EXPORT_VAR( x ) extern "C" x
423 #define FT_EXPORT_VAR( x ) extern x
426 #endif /* !FT_EXPORT_VAR */
428 /* The following macros are needed to compile the library with a */
429 /* C++ compiler and with 16bit compilers. */
432 /* This is special. Within C++, you must specify `extern "C"' for */
433 /* functions which are used via function pointers, and you also */
434 /* must do that for structures which contain function pointers to */
435 /* assure C linkage -- it's not possible to have (local) anonymous */
436 /* functions which are accessed by (global) function pointers. */
439 /* FT_CALLBACK_DEF is used to _define_ a callback function. */
441 /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
442 /* contains pointers to callback functions. */
444 /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
445 /* that contains pointers to callback functions. */
448 /* Some 16bit compilers have to redefine these macros to insert */
449 /* the infamous `_cdecl' or `__fastcall' declarations. */
451 #ifndef FT_CALLBACK_DEF
453 #define FT_CALLBACK_DEF( x ) extern "C" x
455 #define FT_CALLBACK_DEF( x ) static x
457 #endif /* FT_CALLBACK_DEF */
459 #ifndef FT_CALLBACK_TABLE
461 #define FT_CALLBACK_TABLE extern "C"
462 #define FT_CALLBACK_TABLE_DEF extern "C"
464 #define FT_CALLBACK_TABLE extern
465 #define FT_CALLBACK_TABLE_DEF /* nothing */
467 #endif /* FT_CALLBACK_TABLE */
473 #endif /* __FTCONFIG_H__ */