1 /***************************************************************************/
   2 /*                                                                         */
   3 /*  ftconfig.h                                                             */
   4 /*                                                                         */
   5 /*    ANSI-specific configuration file (specification only).               */
   6 /*                                                                         */
   7 /*  Copyright 1996-2018 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 `builds/<system>', and contains        */
  31   /* system-specific files that are always included first when building    */
  32   /* the library.                                                          */
  33   /*                                                                       */
  34   /* This ANSI version should stay in `include/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   /* `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   /* Fix compiler warning with sgi compiler */
 147 #if defined( __sgi ) && !defined( __GNUC__ )
 148 #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
 149 #pragma set woff 3505
 150 #endif
 151 #endif
 152 
 153 
 154   /*************************************************************************/
 155   /*                                                                       */
 156   /* <Section>                                                             */
 157   /*    basic_types                                                        */
 158   /*                                                                       */
 159   /*************************************************************************/
 160 
 161 
 162   /*************************************************************************/
 163   /*                                                                       */
 164   /* <Type>                                                                */
 165   /*    FT_Int16                                                           */
 166   /*                                                                       */
 167   /* <Description>                                                         */
 168   /*    A typedef for a 16bit signed integer type.                         */
 169   /*                                                                       */
 170   typedef signed short  FT_Int16;
 171 
 172 
 173   /*************************************************************************/
 174   /*                                                                       */
 175   /* <Type>                                                                */
 176   /*    FT_UInt16                                                          */
 177   /*                                                                       */
 178   /* <Description>                                                         */
 179   /*    A typedef for a 16bit unsigned integer type.                       */
 180   /*                                                                       */
 181   typedef unsigned short  FT_UInt16;
 182 
 183   /* */
 184 
 185 
 186   /* this #if 0 ... #endif clause is for documentation purposes */
 187 #if 0
 188 
 189   /*************************************************************************/
 190   /*                                                                       */
 191   /* <Type>                                                                */
 192   /*    FT_Int32                                                           */
 193   /*                                                                       */
 194   /* <Description>                                                         */
 195   /*    A typedef for a 32bit signed integer type.  The size depends on    */
 196   /*    the configuration.                                                 */
 197   /*                                                                       */
 198   typedef signed XXX  FT_Int32;
 199 
 200 
 201   /*************************************************************************/
 202   /*                                                                       */
 203   /* <Type>                                                                */
 204   /*    FT_UInt32                                                          */
 205   /*                                                                       */
 206   /*    A typedef for a 32bit unsigned integer type.  The size depends on  */
 207   /*    the configuration.                                                 */
 208   /*                                                                       */
 209   typedef unsigned XXX  FT_UInt32;
 210 
 211 
 212   /*************************************************************************/
 213   /*                                                                       */
 214   /* <Type>                                                                */
 215   /*    FT_Int64                                                           */
 216   /*                                                                       */
 217   /*    A typedef for a 64bit signed integer type.  The size depends on    */
 218   /*    the configuration.  Only defined if there is real 64bit support;   */
 219   /*    otherwise, it gets emulated with a structure (if necessary).       */
 220   /*                                                                       */
 221   typedef signed XXX  FT_Int64;
 222 
 223 
 224   /*************************************************************************/
 225   /*                                                                       */
 226   /* <Type>                                                                */
 227   /*    FT_UInt64                                                          */
 228   /*                                                                       */
 229   /*    A typedef for a 64bit unsigned integer type.  The size depends on  */
 230   /*    the configuration.  Only defined if there is real 64bit support;   */
 231   /*    otherwise, it gets emulated with a structure (if necessary).       */
 232   /*                                                                       */
 233   typedef unsigned XXX  FT_UInt64;
 234 
 235   /* */
 236 
 237 #endif
 238 
 239 #if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT )
 240 
 241   typedef signed int      FT_Int32;
 242   typedef unsigned int    FT_UInt32;
 243 
 244 #elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
 245 
 246   typedef signed long     FT_Int32;
 247   typedef unsigned long   FT_UInt32;
 248 
 249 #else
 250 #error "no 32bit type found -- please check your configuration files"
 251 #endif
 252 
 253 
 254   /* look up an integer type that is at least 32 bits */
 255 #if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT )
 256 
 257   typedef int            FT_Fast;
 258   typedef unsigned int   FT_UFast;
 259 
 260 #elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT )
 261 
 262   typedef long           FT_Fast;
 263   typedef unsigned long  FT_UFast;
 264 
 265 #endif
 266 
 267 
 268   /* determine whether we have a 64-bit int type for platforms without */
 269   /* Autoconf                                                          */
 270 #if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
 271 
 272   /* FT_LONG64 must be defined if a 64-bit type is available */
 273 #define FT_LONG64
 274 #define FT_INT64   long
 275 #define FT_UINT64  unsigned long
 276 
 277   /*************************************************************************/
 278   /*                                                                       */
 279   /* A 64-bit data type may create compilation problems if you compile     */
 280   /* in strict ANSI mode.  To avoid them, we disable other 64-bit data     */
 281   /* types if __STDC__ is defined.  You can however ignore this rule       */
 282   /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro.     */
 283   /*                                                                       */
 284 #elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
 285 
 286 #if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
 287 
 288 #define FT_LONG64
 289 #define FT_INT64   long long int
 290 #define FT_UINT64  unsigned long long int
 291 
 292 #elif defined( _MSC_VER ) && _MSC_VER >= 900  /* Visual C++ (and Intel C++) */
 293 
 294   /* this compiler provides the __int64 type */
 295 #define FT_LONG64
 296 #define FT_INT64   __int64
 297 #define FT_UINT64  unsigned __int64
 298 
 299 #elif defined( __BORLANDC__ )  /* Borland C++ */
 300 
 301   /* XXXX: We should probably check the value of __BORLANDC__ in order */
 302   /*       to test the compiler version.                               */
 303 
 304   /* this compiler provides the __int64 type */
 305 #define FT_LONG64
 306 #define FT_INT64   __int64
 307 #define FT_UINT64  unsigned __int64
 308 
 309 #elif defined( __WATCOMC__ )   /* Watcom C++ */
 310 
 311   /* Watcom doesn't provide 64-bit data types */
 312 
 313 #elif defined( __MWERKS__ )    /* Metrowerks CodeWarrior */
 314 
 315 #define FT_LONG64
 316 #define FT_INT64   long long int
 317 #define FT_UINT64  unsigned long long int
 318 
 319 #elif defined( __GNUC__ )
 320 
 321   /* GCC provides the `long long' type */
 322 #define FT_LONG64
 323 #define FT_INT64   long long int
 324 #define FT_UINT64  unsigned long long int
 325 
 326 #endif /* __STDC_VERSION__ >= 199901L */
 327 
 328 #endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
 329 
 330 #ifdef FT_LONG64
 331   typedef FT_INT64   FT_Int64;
 332   typedef FT_UINT64  FT_UInt64;
 333 #endif
 334 
 335 
 336 #ifdef _WIN64
 337   /* only 64bit Windows uses the LLP64 data model, i.e., */
 338   /* 32bit integers, 64bit pointers                      */
 339 #define FT_UINT_TO_POINTER( x ) (void*)(unsigned __int64)(x)
 340 #else
 341 #define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
 342 #endif
 343 
 344 
 345   /*************************************************************************/
 346   /*                                                                       */
 347   /* miscellaneous                                                         */
 348   /*                                                                       */
 349   /*************************************************************************/
 350 
 351 
 352 #define FT_BEGIN_STMNT  do {
 353 #define FT_END_STMNT    } while ( 0 )
 354 #define FT_DUMMY_STMNT  FT_BEGIN_STMNT FT_END_STMNT
 355 
 356 
 357   /* typeof condition taken from gnulib's `intprops.h' header file */
 358 #if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 )                       || \
 359       ( defined( __IBMC__ ) && __IBMC__ >= 1210 &&                      \
 360         defined( __IBM__TYPEOF__ ) )                                 || \
 361       ( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) )
 362 #define FT_TYPEOF( type )  ( __typeof__ ( type ) )
 363 #else
 364 #define FT_TYPEOF( type )  /* empty */
 365 #endif
 366 
 367 
 368   /* Use FT_LOCAL and FT_LOCAL_DEF to declare and define, respectively, */
 369   /* a function that gets used only within the scope of a module.       */
 370   /* Normally, both the header and source code files for such a         */
 371   /* function are within a single module directory.                     */
 372   /*                                                                    */
 373   /* Intra-module arrays should be tagged with FT_LOCAL_ARRAY and       */
 374   /* FT_LOCAL_ARRAY_DEF.                                                */
 375   /*                                                                    */
 376 #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
 377 
 378 #define FT_LOCAL( x )      static  x
 379 #define FT_LOCAL_DEF( x )  static  x
 380 
 381 #else
 382 
 383 #ifdef __cplusplus
 384 #define FT_LOCAL( x )      extern "C"  x
 385 #define FT_LOCAL_DEF( x )  extern "C"  x
 386 #else
 387 #define FT_LOCAL( x )      extern  x
 388 #define FT_LOCAL_DEF( x )  x
 389 #endif
 390 
 391 #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
 392 
 393 #define FT_LOCAL_ARRAY( x )      extern const  x
 394 #define FT_LOCAL_ARRAY_DEF( x )  const  x
 395 
 396 
 397   /* Use FT_BASE and FT_BASE_DEF to declare and define, respectively, */
 398   /* functions that are used in more than a single module.  In the    */
 399   /* current setup this implies that the declaration is in a header   */
 400   /* file in the `include/freetype/internal' directory, and the       */
 401   /* function body is in a file in `src/base'.                        */
 402   /*                                                                  */
 403 #ifndef FT_BASE
 404 
 405 #ifdef __cplusplus
 406 #define FT_BASE( x )  extern "C"  x
 407 #else
 408 #define FT_BASE( x )  extern  x
 409 #endif
 410 
 411 #endif /* !FT_BASE */
 412 
 413 
 414 #ifndef FT_BASE_DEF
 415 
 416 #ifdef __cplusplus
 417 #define FT_BASE_DEF( x )  x
 418 #else
 419 #define FT_BASE_DEF( x )  x
 420 #endif
 421 
 422 #endif /* !FT_BASE_DEF */
 423 
 424 
 425   /*   When compiling FreeType as a DLL or DSO with hidden visibility      */
 426   /*   some systems/compilers need a special attribute in front OR after   */
 427   /*   the return type of function declarations.                           */
 428   /*                                                                       */
 429   /*   Two macros are used within the FreeType source code to define       */
 430   /*   exported library functions: FT_EXPORT and FT_EXPORT_DEF.            */
 431   /*                                                                       */
 432   /*     FT_EXPORT( return_type )                                          */
 433   /*                                                                       */
 434   /*       is used in a function declaration, as in                        */
 435   /*                                                                       */
 436   /*         FT_EXPORT( FT_Error )                                         */
 437   /*         FT_Init_FreeType( FT_Library*  alibrary );                    */
 438   /*                                                                       */
 439   /*                                                                       */
 440   /*     FT_EXPORT_DEF( return_type )                                      */
 441   /*                                                                       */
 442   /*       is used in a function definition, as in                         */
 443   /*                                                                       */
 444   /*         FT_EXPORT_DEF( FT_Error )                                     */
 445   /*         FT_Init_FreeType( FT_Library*  alibrary )                     */
 446   /*         {                                                             */
 447   /*           ... some code ...                                           */
 448   /*           return FT_Err_Ok;                                           */
 449   /*         }                                                             */
 450   /*                                                                       */
 451   /*   You can provide your own implementation of FT_EXPORT and            */
 452   /*   FT_EXPORT_DEF here if you want.                                     */
 453   /*                                                                       */
 454   /*   To export a variable, use FT_EXPORT_VAR.                            */
 455   /*                                                                       */
 456 #ifndef FT_EXPORT
 457 
 458 #ifdef FT2_BUILD_LIBRARY
 459 
 460 #if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
 461 #define FT_EXPORT( x )  __declspec( dllexport )  x
 462 #elif defined( __GNUC__ ) && __GNUC__ >= 4
 463 #define FT_EXPORT( x )  __attribute__(( visibility( "default" ) ))  x
 464 #elif defined( __cplusplus )
 465 #define FT_EXPORT( x )  extern "C"  x
 466 #else
 467 #define FT_EXPORT( x )  extern  x
 468 #endif
 469 
 470 #else
 471 
 472 #if defined( FT2_DLLIMPORT )
 473 #define FT_EXPORT( x )  __declspec( dllimport )  x
 474 #elif defined( __cplusplus )
 475 #define FT_EXPORT( x )  extern "C"  x
 476 #else
 477 #define FT_EXPORT( x )  extern  x
 478 #endif
 479 
 480 #endif
 481 
 482 #endif /* !FT_EXPORT */
 483 
 484 
 485 #ifndef FT_EXPORT_DEF
 486 
 487 #ifdef __cplusplus
 488 #define FT_EXPORT_DEF( x )  extern "C"  x
 489 #else
 490 #define FT_EXPORT_DEF( x )  extern  x
 491 #endif
 492 
 493 #endif /* !FT_EXPORT_DEF */
 494 
 495 
 496 #ifndef FT_EXPORT_VAR
 497 
 498 #ifdef __cplusplus
 499 #define FT_EXPORT_VAR( x )  extern "C"  x
 500 #else
 501 #define FT_EXPORT_VAR( x )  extern  x
 502 #endif
 503 
 504 #endif /* !FT_EXPORT_VAR */
 505 
 506 
 507   /* The following macros are needed to compile the library with a   */
 508   /* C++ compiler and with 16bit compilers.                          */
 509   /*                                                                 */
 510 
 511   /* This is special.  Within C++, you must specify `extern "C"' for */
 512   /* functions which are used via function pointers, and you also    */
 513   /* must do that for structures which contain function pointers to  */
 514   /* assure C linkage -- it's not possible to have (local) anonymous */
 515   /* functions which are accessed by (global) function pointers.     */
 516   /*                                                                 */
 517   /*                                                                 */
 518   /* FT_CALLBACK_DEF is used to _define_ a callback function,        */
 519   /* located in the same source code file as the structure that uses */
 520   /* it.                                                             */
 521   /*                                                                 */
 522   /* FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare   */
 523   /* and define a callback function, respectively, in a similar way  */
 524   /* as FT_BASE and FT_BASE_DEF work.                                */
 525   /*                                                                 */
 526   /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
 527   /* contains pointers to callback functions.                        */
 528   /*                                                                 */
 529   /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable   */
 530   /* that contains pointers to callback functions.                   */
 531   /*                                                                 */
 532   /*                                                                 */
 533   /* Some 16bit compilers have to redefine these macros to insert    */
 534   /* the infamous `_cdecl' or `__fastcall' declarations.             */
 535   /*                                                                 */
 536 #ifndef FT_CALLBACK_DEF
 537 #ifdef __cplusplus
 538 #define FT_CALLBACK_DEF( x )  extern "C"  x
 539 #else
 540 #define FT_CALLBACK_DEF( x )  static  x
 541 #endif
 542 #endif /* FT_CALLBACK_DEF */
 543 
 544 #ifndef FT_BASE_CALLBACK
 545 #ifdef __cplusplus
 546 #define FT_BASE_CALLBACK( x )      extern "C"  x
 547 #define FT_BASE_CALLBACK_DEF( x )  extern "C"  x
 548 #else
 549 #define FT_BASE_CALLBACK( x )      extern  x
 550 #define FT_BASE_CALLBACK_DEF( x )  x
 551 #endif
 552 #endif /* FT_BASE_CALLBACK */
 553 
 554 #ifndef FT_CALLBACK_TABLE
 555 #ifdef __cplusplus
 556 #define FT_CALLBACK_TABLE      extern "C"
 557 #define FT_CALLBACK_TABLE_DEF  extern "C"
 558 #else
 559 #define FT_CALLBACK_TABLE      extern
 560 #define FT_CALLBACK_TABLE_DEF  /* nothing */
 561 #endif
 562 #endif /* FT_CALLBACK_TABLE */
 563 
 564 
 565 FT_END_HEADER
 566 
 567 
 568 #endif /* FTCONFIG_H_ */
 569 
 570 
 571 /* END */