1 /* ftconfig.h. Generated from ftconfig.in by configure. */
2 /***************************************************************************/
6 /* UNIX-specific configuration file (specification only). */
8 /* Copyright 1996-2004, 2006-2009, 2011, 2013 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
11 /* This file is part of the FreeType project, and may only be used, */
12 /* modified, and distributed under the terms of the FreeType project */
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 /* this file you indicate that you have read the license and */
15 /* understand and accept it fully. */
17 /***************************************************************************/
20 /*************************************************************************/
22 /* This header file contains a number of macro definitions that are used */
23 /* by the rest of the engine. Most of the macros here are automatically */
24 /* determined at compile time, and you should not need to change it to */
25 /* port FreeType, except to compile the library with a non-ANSI */
28 /* Note however that if some specific modifications are needed, we */
29 /* advise you to place a modified copy in your build directory. */
31 /* The build directory is usually `freetype/builds/<system>', and */
32 /* contains system-specific files that are always included first when */
33 /* building the library. */
35 /*************************************************************************/
38 #ifndef __FTCONFIG_H__
39 #define __FTCONFIG_H__
42 #include FT_CONFIG_OPTIONS_H
43 #include FT_CONFIG_STANDARD_LIBRARY_H
49 /*************************************************************************/
51 /* PLATFORM-SPECIFIC CONFIGURATION MACROS */
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. */
58 /*************************************************************************/
61 #define HAVE_UNISTD_H 1
62 #define HAVE_FCNTL_H 1
63 #define HAVE_STDINT_H 1
66 /* There are systems (like the Texas Instruments 'C54x) where a `char' */
67 /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */
68 /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */
69 /* is probably unexpected. */
71 /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */
75 #define FT_CHAR_BIT CHAR_BIT
79 /* #undef FT_USE_AUTOCONF_SIZEOF_TYPES */
80 #ifdef FT_USE_AUTOCONF_SIZEOF_TYPES
84 #define FT_SIZEOF_INT SIZEOF_INT
85 #define FT_SIZEOF_LONG SIZEOF_LONG
87 #else /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
89 /* Following cpp computation of the bit length of int and long */
90 /* is copied from default include/freetype/config/ftconfig.h. */
91 /* If any improvement is required for this file, it should be */
92 /* applied to the original header file for the builders that */
93 /* does not use configure script. */
95 /* The size of an `int' type. */
96 #if FT_UINT_MAX == 0xFFFFUL
97 #define FT_SIZEOF_INT (16 / FT_CHAR_BIT)
98 #elif FT_UINT_MAX == 0xFFFFFFFFUL
99 #define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
100 #elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
101 #define FT_SIZEOF_INT (64 / FT_CHAR_BIT)
103 #error "Unsupported size of `int' type!"
106 /* The size of a `long' type. A five-byte `long' (as used e.g. on the */
107 /* DM642) is recognized but avoided. */
108 #if FT_ULONG_MAX == 0xFFFFFFFFUL
109 #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
110 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
111 #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
112 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
113 #define FT_SIZEOF_LONG (64 / FT_CHAR_BIT)
115 #error "Unsupported size of `long' type!"
118 #endif /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
121 /* FT_UNUSED is a macro used to indicate that a given parameter is not */
122 /* used -- this is only used to get rid of unpleasant compiler warnings */
124 #define FT_UNUSED( arg ) ( (arg) = (arg) )
128 /*************************************************************************/
130 /* AUTOMATIC CONFIGURATION MACROS */
132 /* These macros are computed from the ones defined above. Don't touch */
133 /* their definition, unless you know precisely what you are doing. No */
134 /* porter should need to mess with them. */
136 /*************************************************************************/
139 /*************************************************************************/
143 /* This is the only necessary change, so it is defined here instead */
144 /* providing a new configuration file. */
146 #if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
147 /* no Carbon frameworks for 64bit 10.4.x */
148 /* AvailabilityMacros.h is available since Mac OS X 10.2, */
149 /* so guess the system version by maximum errno before inclusion */
151 #ifdef ECANCELED /* defined since 10.2 */
152 #include "AvailabilityMacros.h"
154 #if defined( __LP64__ ) && \
155 ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
159 #elif defined( __SC__ ) || defined( __MRC__ )
160 /* Classic MacOS compilers */
161 #include "ConditionalMacros.h"
163 #define FT_MACINTOSH 1
169 /* Fix compiler warning with sgi compiler */
170 #if defined( __sgi ) && !defined( __GNUC__ )
171 #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
172 #pragma set woff 3505
177 /*************************************************************************/
182 /*************************************************************************/
185 /*************************************************************************/
191 /* A typedef for a 16bit signed integer type. */
193 typedef signed short FT_Int16;
196 /*************************************************************************/
202 /* A typedef for a 16bit unsigned integer type. */
204 typedef unsigned short FT_UInt16;
209 /* this #if 0 ... #endif clause is for documentation purposes */
212 /*************************************************************************/
218 /* A typedef for a 32bit signed integer type. The size depends on */
219 /* the configuration. */
221 typedef signed XXX FT_Int32;
224 /*************************************************************************/
229 /* A typedef for a 32bit unsigned integer type. The size depends on */
230 /* the configuration. */
232 typedef unsigned XXX FT_UInt32;
235 /*************************************************************************/
240 /* A typedef for a 64bit signed integer type. The size depends on */
241 /* the configuration. Only defined if there is real 64bit support; */
242 /* otherwise, it gets emulated with a structure (if necessary). */
244 typedef signed XXX FT_Int64;
250 #if FT_SIZEOF_INT == 4
252 typedef signed int FT_Int32;
253 typedef unsigned int FT_UInt32;
255 #elif FT_SIZEOF_LONG == 4
257 typedef signed long FT_Int32;
258 typedef unsigned long FT_UInt32;
261 #error "no 32bit type found -- please check your configuration files"
265 /* look up an integer type that is at least 32 bits */
266 #if FT_SIZEOF_INT >= 4
269 typedef unsigned int FT_UFast;
271 #elif FT_SIZEOF_LONG >= 4
273 typedef long FT_Fast;
274 typedef unsigned long FT_UFast;
279 /* determine whether we have a 64-bit int type for platforms without */
281 #if FT_SIZEOF_LONG == 8
283 /* FT_LONG64 must be defined if a 64-bit type is available */
285 #define FT_INT64 long
287 #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
289 /* this compiler provides the __int64 type */
291 #define FT_INT64 __int64
293 #elif defined( __BORLANDC__ ) /* Borland C++ */
295 /* XXXX: We should probably check the value of __BORLANDC__ in order */
296 /* to test the compiler version. */
298 /* this compiler provides the __int64 type */
300 #define FT_INT64 __int64
302 #elif defined( __WATCOMC__ ) /* Watcom C++ */
304 /* Watcom doesn't provide 64-bit data types */
306 #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
309 #define FT_INT64 long long int
311 #elif defined( __GNUC__ )
313 /* GCC provides the `long long' type */
315 #define FT_INT64 long long int
317 #endif /* FT_SIZEOF_LONG == 8 */
320 /*************************************************************************/
322 /* A 64-bit data type will create compilation problems if you compile */
323 /* in strict ANSI mode. To avoid them, we disable its use if __STDC__ */
324 /* is defined. You can however ignore this rule by defining the */
325 /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
327 #if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 )
331 /* Undefine the 64-bit macros in strict ANSI compilation mode. */
332 /* Since `#undef' doesn't survive in configuration header files */
333 /* we use the postprocessing facility of AC_CONFIG_HEADERS to */
334 /* replace the leading `/' with `#'. */
338 #endif /* __STDC__ */
340 #endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */
343 typedef FT_INT64 FT_Int64;
347 #define FT_BEGIN_STMNT do {
348 #define FT_END_STMNT } while ( 0 )
349 #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
352 #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
353 /* Provide assembler fragments for performance-critical functions. */
354 /* These must be defined `static __inline__' with GCC. */
356 #if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */
357 #define FT_MULFIX_ASSEMBLER FT_MulFix_arm
359 /* documentation is in freetype.h */
361 static __inline FT_Int32
362 FT_MulFix_arm( FT_Int32 a,
365 register FT_Int32 t, t2;
370 smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
371 mov a, t, asr #31 /* a = (hi >> 31) */
372 add a, a, #0x8000 /* a += 0x8000 */
373 adds t2, t2, a /* t2 += a */
374 adc t, t, #0 /* t += carry */
375 mov a, t2, lsr #16 /* a = t2 >> 16 */
376 orr a, a, t, lsl #16 /* a |= t << 16 */
381 #endif /* __CC_ARM || __ARMCC__ */
386 #if defined( __arm__ ) && !defined( __thumb__ ) && \
387 !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
388 #define FT_MULFIX_ASSEMBLER FT_MulFix_arm
390 /* documentation is in freetype.h */
392 static __inline__ FT_Int32
393 FT_MulFix_arm( FT_Int32 a,
396 register FT_Int32 t, t2;
399 __asm__ __volatile__ (
400 "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
401 "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
402 "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
403 "adds %1, %1, %0\n\t" /* %1 += %0 */
404 "adc %2, %2, #0\n\t" /* %2 += carry */
405 "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */
406 "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
407 : "=r"(a), "=&r"(t2), "=&r"(t)
413 #endif /* __arm__ && !__thumb__ && !( __CC_ARM || __ARMCC__ ) */
415 #if defined( __i386__ )
416 #define FT_MULFIX_ASSEMBLER FT_MulFix_i386
418 /* documentation is in freetype.h */
420 static __inline__ FT_Int32
421 FT_MulFix_i386( FT_Int32 a,
424 register FT_Int32 result;
427 __asm__ __volatile__ (
429 "movl %%edx, %%ecx\n"
431 "addl $0x8000, %%ecx\n"
432 "addl %%ecx, %%eax\n"
436 "addl %%edx, %%eax\n"
437 : "=a"(result), "=d"(b)
445 #endif /* __GNUC__ */
448 #ifdef _MSC_VER /* Visual C++ */
452 #define FT_MULFIX_ASSEMBLER FT_MulFix_i386
454 /* documentation is in freetype.h */
456 static __inline FT_Int32
457 FT_MulFix_i386( FT_Int32 a,
460 register FT_Int32 result;
482 #endif /* _MSC_VER */
484 #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
487 #ifdef FT_CONFIG_OPTION_INLINE_MULFIX
488 #ifdef FT_MULFIX_ASSEMBLER
489 #define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER
494 #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
496 #define FT_LOCAL( x ) static x
497 #define FT_LOCAL_DEF( x ) static x
502 #define FT_LOCAL( x ) extern "C" x
503 #define FT_LOCAL_DEF( x ) extern "C" x
505 #define FT_LOCAL( x ) extern x
506 #define FT_LOCAL_DEF( x ) x
509 #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
515 #define FT_BASE( x ) extern "C" x
517 #define FT_BASE( x ) extern x
520 #endif /* !FT_BASE */
526 #define FT_BASE_DEF( x ) x
528 #define FT_BASE_DEF( x ) x
531 #endif /* !FT_BASE_DEF */
537 #define FT_EXPORT( x ) extern "C" x
539 #define FT_EXPORT( x ) extern x
542 #endif /* !FT_EXPORT */
545 #ifndef FT_EXPORT_DEF
548 #define FT_EXPORT_DEF( x ) extern "C" x
550 #define FT_EXPORT_DEF( x ) extern x
553 #endif /* !FT_EXPORT_DEF */
556 #ifndef FT_EXPORT_VAR
559 #define FT_EXPORT_VAR( x ) extern "C" x
561 #define FT_EXPORT_VAR( x ) extern x
564 #endif /* !FT_EXPORT_VAR */
566 /* The following macros are needed to compile the library with a */
567 /* C++ compiler and with 16bit compilers. */
570 /* This is special. Within C++, you must specify `extern "C"' for */
571 /* functions which are used via function pointers, and you also */
572 /* must do that for structures which contain function pointers to */
573 /* assure C linkage -- it's not possible to have (local) anonymous */
574 /* functions which are accessed by (global) function pointers. */
577 /* FT_CALLBACK_DEF is used to _define_ a callback function. */
579 /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
580 /* contains pointers to callback functions. */
582 /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
583 /* that contains pointers to callback functions. */
586 /* Some 16bit compilers have to redefine these macros to insert */
587 /* the infamous `_cdecl' or `__fastcall' declarations. */
589 #ifndef FT_CALLBACK_DEF
591 #define FT_CALLBACK_DEF( x ) extern "C" x
593 #define FT_CALLBACK_DEF( x ) static x
595 #endif /* FT_CALLBACK_DEF */
597 #ifndef FT_CALLBACK_TABLE
599 #define FT_CALLBACK_TABLE extern "C"
600 #define FT_CALLBACK_TABLE_DEF extern "C"
602 #define FT_CALLBACK_TABLE extern
603 #define FT_CALLBACK_TABLE_DEF /* nothing */
605 #endif /* FT_CALLBACK_TABLE */
611 #endif /* __FTCONFIG_H__ */