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