1/***************************************************************************/ 2/* */ 3/* ftconfig.h */ 4/* */ 5/* ANSI-specific configuration file (specification only). */ 6/* */ 7/* Copyright 1996-2004, 2006-2008, 2010-2011, 2013 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 "ftoption.h" 43#include "ftstdlib.h" 44 45 46FT_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 /* */ 206 /* <Type> */ 207 /* FT_Int64 */ 208 /* */ 209 /* A typedef for a 64bit signed integer type. The size depends on */ 210 /* the configuration. Only defined if there is real 64bit support; */ 211 /* otherwise, it gets emulated with a structure (if necessary). */ 212 /* */ 213 typedef signed XXX FT_Int64; 214 215 216 /*************************************************************************/ 217 /* */ 218 /* <Type> */ 219 /* FT_UInt64 */ 220 /* */ 221 /* A typedef for a 64bit unsigned integer type. The size depends on */ 222 /* the configuration. Only defined if there is real 64bit support; */ 223 /* otherwise, it gets emulated with a structure (if necessary). */ 224 /* */ 225 typedef unsigned XXX FT_UInt64; 226 227 /* */ 228 229#endif 230 231#if FT_SIZEOF_INT == (32 / FT_CHAR_BIT) 232 233 typedef signed int FT_Int32; 234 typedef unsigned int FT_UInt32; 235 236#elif FT_SIZEOF_LONG == (32 / FT_CHAR_BIT) 237 238 typedef signed long FT_Int32; 239 typedef unsigned long FT_UInt32; 240 241#else 242#error "no 32bit type found -- please check your configuration files" 243#endif 244 245 246 /* look up an integer type that is at least 32 bits */ 247#if FT_SIZEOF_INT >= (32 / FT_CHAR_BIT) 248 249 typedef int FT_Fast; 250 typedef unsigned int FT_UFast; 251 252#elif FT_SIZEOF_LONG >= (32 / FT_CHAR_BIT) 253 254 typedef long FT_Fast; 255 typedef unsigned long FT_UFast; 256 257#endif 258 259 260 /* determine whether we have a 64-bit int type for platforms without */ 261 /* Autoconf */ 262#if FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) 263 264 /* FT_LONG64 must be defined if a 64-bit type is available */ 265#define FT_LONG64 266#define FT_INT64 long 267#define FT_UINT64 unsigned long 268 269#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ 270 271 /* this compiler provides the __int64 type */ 272#define FT_LONG64 273#define FT_INT64 __int64 274#define FT_UINT64 unsigned __int64 275 276#elif defined( __BORLANDC__ ) /* Borland C++ */ 277 278 /* XXXX: We should probably check the value of __BORLANDC__ in order */ 279 /* to test the compiler version. */ 280 281 /* this compiler provides the __int64 type */ 282#define FT_LONG64 283#define FT_INT64 __int64 284#define FT_UINT64 unsigned __int64 285 286#elif defined( __WATCOMC__ ) /* Watcom C++ */ 287 288 /* Watcom doesn't provide 64-bit data types */ 289 290#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ 291 292#define FT_LONG64 293#define FT_INT64 long long int 294#define FT_UINT64 unsigned long long int 295 296#elif defined( __GNUC__ ) 297 298 /* GCC provides the `long long' type */ 299#define FT_LONG64 300#define FT_INT64 long long int 301#define FT_UINT64 unsigned long long int 302 303#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */ 304 305 306 /*************************************************************************/ 307 /* */ 308 /* A 64-bit data type will create compilation problems if you compile */ 309 /* in strict ANSI mode. To avoid them, we disable its use if __STDC__ */ 310 /* is defined. You can however ignore this rule by defining the */ 311 /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ 312 /* */ 313#if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 ) 314 315#ifdef __STDC__ 316 317 /* undefine the 64-bit macros in strict ANSI compilation mode */ 318#undef FT_LONG64 319#undef FT_INT64 320 321#endif /* __STDC__ */ 322 323#endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */ 324 325#ifdef FT_LONG64 326 typedef FT_INT64 FT_Int64; 327 typedef FT_UINT64 FT_UInt64; 328#endif 329 330 331#define FT_BEGIN_STMNT do { 332#define FT_END_STMNT } while ( 0 ) 333#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT 334 335 336#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER 337 /* Provide assembler fragments for performance-critical functions. */ 338 /* These must be defined `static __inline__' with GCC. */ 339 340 /**Johnson add !defined( __thumb__ )*/ 341#if (defined( __CC_ARM ) || defined( __ARMCC__ ))&& !defined( __thumb__ ) /* RVCT */ 342#define FT_MULFIX_ASSEMBLER FT_MulFix_arm 343 344 /* documentation is in freetype.h */ 345 346 static __inline FT_Int32 347 FT_MulFix_arm( FT_Int32 a, 348 FT_Int32 b ) 349 { 350 register FT_Int32 t, t2; 351 352 353 __asm 354 { 355 smull t2, t, b, a /* (lo=t2,hi=t) = a*b */ 356 mov a, t, asr #31 /* a = (hi >> 31) */ 357 add a, a, #0x8000 /* a += 0x8000 */ 358 adds t2, t2, a /* t2 += a */ 359 adc t, t, #0 /* t += carry */ 360 mov a, t2, lsr #16 /* a = t2 >> 16 */ 361 orr a, a, t, lsl #16 /* a |= t << 16 */ 362 } 363 return a; 364 } 365 366#endif /* __CC_ARM || __ARMCC__ */ 367 368 369#ifdef __GNUC__ 370 371#if defined( __arm__ ) && !defined( __thumb__ ) && \ 372 !( defined( __CC_ARM ) || defined( __ARMCC__ ) ) 373#define FT_MULFIX_ASSEMBLER FT_MulFix_arm 374 375 /* documentation is in freetype.h */ 376 377 static __inline__ FT_Int32 378 FT_MulFix_arm( FT_Int32 a, 379 FT_Int32 b ) 380 { 381 register FT_Int32 t, t2; 382 383 384 __asm__ __volatile__ ( 385 "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */ 386 "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */ 387 "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ 388 "adds %1, %1, %0\n\t" /* %1 += %0 */ 389 "adc %2, %2, #0\n\t" /* %2 += carry */ 390 "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */ 391 "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */ 392 : "=r"(a), "=&r"(t2), "=&r"(t) 393 : "r"(a), "r"(b) 394 : "cc" ); 395 return a; 396 } 397 398#endif /* __arm__ && !__thumb__ && !( __CC_ARM || __ARMCC__ ) */ 399 400#if defined( __i386__ ) 401#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 402 403 /* documentation is in freetype.h */ 404 405 static __inline__ FT_Int32 406 FT_MulFix_i386( FT_Int32 a, 407 FT_Int32 b ) 408 { 409 register FT_Int32 result; 410 411 412 __asm__ __volatile__ ( 413 "imul %%edx\n" 414 "movl %%edx, %%ecx\n" 415 "sarl $31, %%ecx\n" 416 "addl $0x8000, %%ecx\n" 417 "addl %%ecx, %%eax\n" 418 "adcl $0, %%edx\n" 419 "shrl $16, %%eax\n" 420 "shll $16, %%edx\n" 421 "addl %%edx, %%eax\n" 422 : "=a"(result), "=d"(b) 423 : "a"(a), "d"(b) 424 : "%ecx", "cc" ); 425 return result; 426 } 427 428#endif /* i386 */ 429 430#endif /* __GNUC__ */ 431 432 433#ifdef _MSC_VER /* Visual C++ */ 434 435#ifdef _M_IX86 436 437#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 438 439 /* documentation is in freetype.h */ 440 441 static __inline FT_Int32 442 FT_MulFix_i386( FT_Int32 a, 443 FT_Int32 b ) 444 { 445 register FT_Int32 result; 446 447 __asm 448 { 449 mov eax, a 450 mov edx, b 451 imul edx 452 mov ecx, edx 453 sar ecx, 31 454 add ecx, 8000h 455 add eax, ecx 456 adc edx, 0 457 shr eax, 16 458 shl edx, 16 459 add eax, edx 460 mov result, eax 461 } 462 return result; 463 } 464 465#endif /* _M_IX86 */ 466 467#endif /* _MSC_VER */ 468 469#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ 470 471 472#ifdef FT_CONFIG_OPTION_INLINE_MULFIX 473#ifdef FT_MULFIX_ASSEMBLER 474#define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER 475#endif 476#endif 477 478 479#ifdef FT_MAKE_OPTION_SINGLE_OBJECT 480 481#define FT_LOCAL( x ) static x 482#define FT_LOCAL_DEF( x ) static x 483 484#else 485 486#ifdef __cplusplus 487#define FT_LOCAL( x ) extern "C" x 488#define FT_LOCAL_DEF( x ) extern "C" x 489#else 490#define FT_LOCAL( x ) extern x 491#define FT_LOCAL_DEF( x ) x 492#endif 493 494#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ 495 496 497#ifndef FT_BASE 498 499#ifdef __cplusplus 500#define FT_BASE( x ) extern "C" x 501#else 502#define FT_BASE( x ) extern x 503#endif 504 505#endif /* !FT_BASE */ 506 507 508#ifndef FT_BASE_DEF 509 510#ifdef __cplusplus 511#define FT_BASE_DEF( x ) x 512#else 513#define FT_BASE_DEF( x ) x 514#endif 515 516#endif /* !FT_BASE_DEF */ 517 518 519#ifndef FT_EXPORT 520 521#ifdef __cplusplus 522#define FT_EXPORT( x ) extern "C" x 523#else 524#define FT_EXPORT( x ) extern x 525#endif 526 527#endif /* !FT_EXPORT */ 528 529 530#ifndef FT_EXPORT_DEF 531 532#ifdef __cplusplus 533#define FT_EXPORT_DEF( x ) extern "C" x 534#else 535#define FT_EXPORT_DEF( x ) extern x 536#endif 537 538#endif /* !FT_EXPORT_DEF */ 539 540 541#ifndef FT_EXPORT_VAR 542 543#ifdef __cplusplus 544#define FT_EXPORT_VAR( x ) extern "C" x 545#else 546#define FT_EXPORT_VAR( x ) extern x 547#endif 548 549#endif /* !FT_EXPORT_VAR */ 550 551 /* The following macros are needed to compile the library with a */ 552 /* C++ compiler and with 16bit compilers. */ 553 /* */ 554 555 /* This is special. Within C++, you must specify `extern "C"' for */ 556 /* functions which are used via function pointers, and you also */ 557 /* must do that for structures which contain function pointers to */ 558 /* assure C linkage -- it's not possible to have (local) anonymous */ 559 /* functions which are accessed by (global) function pointers. */ 560 /* */ 561 /* */ 562 /* FT_CALLBACK_DEF is used to _define_ a callback function. */ 563 /* */ 564 /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */ 565 /* contains pointers to callback functions. */ 566 /* */ 567 /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */ 568 /* that contains pointers to callback functions. */ 569 /* */ 570 /* */ 571 /* Some 16bit compilers have to redefine these macros to insert */ 572 /* the infamous `_cdecl' or `__fastcall' declarations. */ 573 /* */ 574#ifndef FT_CALLBACK_DEF 575#ifdef __cplusplus 576#define FT_CALLBACK_DEF( x ) extern "C" x 577#else 578#define FT_CALLBACK_DEF( x ) static x 579#endif 580#endif /* FT_CALLBACK_DEF */ 581 582#ifndef FT_CALLBACK_TABLE 583#ifdef __cplusplus 584#define FT_CALLBACK_TABLE extern "C" 585#define FT_CALLBACK_TABLE_DEF extern "C" 586#else 587#define FT_CALLBACK_TABLE extern 588#define FT_CALLBACK_TABLE_DEF /* nothing */ 589#endif 590#endif /* FT_CALLBACK_TABLE */ 591 592 593FT_END_HEADER 594 595 596#endif /* __FTCONFIG_H__ */ 597 598 599/* END */ 600