ftconfig.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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. /* This header file contains a number of macro definitions that are used */
  20. /* by the rest of the engine. Most of the macros here are automatically */
  21. /* determined at compile time, and you should not need to change it to */
  22. /* port FreeType, except to compile the library with a non-ANSI */
  23. /* compiler. */
  24. /* */
  25. /* Note however that if some specific modifications are needed, we */
  26. /* advise you to place a modified copy in your build directory. */
  27. /* */
  28. /* The build directory is usually `freetype/builds/<system>', and */
  29. /* contains system-specific files that are always included first when */
  30. /* building the library. */
  31. /* */
  32. /* This ANSI version should stay in `include/freetype/config'. */
  33. /* */
  34. /*************************************************************************/
  35. #ifndef __FTCONFIG_H__
  36. #define __FTCONFIG_H__
  37. #include <ft2build.h>
  38. #include FT_CONFIG_OPTIONS_H
  39. #include FT_CONFIG_STANDARD_LIBRARY_H
  40. FT_BEGIN_HEADER
  41. /*************************************************************************/
  42. /* */
  43. /* PLATFORM-SPECIFIC CONFIGURATION MACROS */
  44. /* */
  45. /* These macros can be toggled to suit a specific system. The current */
  46. /* ones are defaults used to compile FreeType in an ANSI C environment */
  47. /* (16bit compilers are also supported). Copy this file to your own */
  48. /* `freetype/builds/<system>' directory, and edit it to port the engine. */
  49. /* */
  50. /*************************************************************************/
  51. /* There are systems (like the Texas Instruments 'C54x) where a `char' */
  52. /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */
  53. /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */
  54. /* is probably unexpected. */
  55. /* */
  56. /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */
  57. /* `char' type. */
  58. #ifndef FT_CHAR_BIT
  59. #define FT_CHAR_BIT CHAR_BIT
  60. #endif
  61. /* The size of an `int' type. */
  62. #if FT_UINT_MAX == 0xFFFFUL
  63. #define FT_SIZEOF_INT (16 / FT_CHAR_BIT)
  64. #elif FT_UINT_MAX == 0xFFFFFFFFUL
  65. #define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
  66. #elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
  67. #define FT_SIZEOF_INT (64 / FT_CHAR_BIT)
  68. #else
  69. #error "Unsupported size of `int' type!"
  70. #endif
  71. /* The size of a `long' type. A five-byte `long' (as used e.g. on the */
  72. /* DM642) is recognized but avoided. */
  73. #if FT_ULONG_MAX == 0xFFFFFFFFUL
  74. #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
  75. #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
  76. #define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
  77. #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
  78. #define FT_SIZEOF_LONG (64 / FT_CHAR_BIT)
  79. #else
  80. #error "Unsupported size of `long' type!"
  81. #endif
  82. /* Preferred alignment of data */
  83. #define FT_ALIGNMENT 8
  84. /* FT_UNUSED is a macro used to indicate that a given parameter is not */
  85. /* used -- this is only used to get rid of unpleasant compiler warnings */
  86. #ifndef FT_UNUSED
  87. #define FT_UNUSED( arg ) ( (arg) = (arg) )
  88. #endif
  89. /*************************************************************************/
  90. /* */
  91. /* AUTOMATIC CONFIGURATION MACROS */
  92. /* */
  93. /* These macros are computed from the ones defined above. Don't touch */
  94. /* their definition, unless you know precisely what you are doing. No */
  95. /* porter should need to mess with them. */
  96. /* */
  97. /*************************************************************************/
  98. /*************************************************************************/
  99. /* */
  100. /* Mac support */
  101. /* */
  102. /* This is the only necessary change, so it is defined here instead */
  103. /* providing a new configuration file. */
  104. /* */
  105. #if ( defined( __APPLE__ ) && !defined( DARWIN_NO_CARBON ) ) || \
  106. ( defined( __MWERKS__ ) && defined( macintosh ) )
  107. /* no Carbon frameworks for 64bit 10.4.x */
  108. /* AvailabilityMacros.h is available since Mac OS X 10.2, */
  109. /* so guess the system version by maximum errno before inclusion */
  110. #include <errno.h>
  111. #ifdef ECANCELED /* defined since 10.2 */
  112. #include "AvailabilityMacros.h"
  113. #endif
  114. #if defined( __LP64__ ) && \
  115. ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
  116. #define DARWIN_NO_CARBON 1
  117. #else
  118. #define FT_MACINTOSH 1
  119. #endif
  120. #elif defined( __SC__ ) || defined( __MRC__ )
  121. /* Classic MacOS compilers */
  122. #include "ConditionalMacros.h"
  123. #if TARGET_OS_MAC
  124. #define FT_MACINTOSH 1
  125. #endif
  126. #endif
  127. /*************************************************************************/
  128. /* */
  129. /* <Section> */
  130. /* basic_types */
  131. /* */
  132. /*************************************************************************/
  133. /*************************************************************************/
  134. /* */
  135. /* <Type> */
  136. /* FT_Int16 */
  137. /* */
  138. /* <Description> */
  139. /* A typedef for a 16bit signed integer type. */
  140. /* */
  141. typedef signed short FT_Int16;
  142. /*************************************************************************/
  143. /* */
  144. /* <Type> */
  145. /* FT_UInt16 */
  146. /* */
  147. /* <Description> */
  148. /* A typedef for a 16bit unsigned integer type. */
  149. /* */
  150. typedef unsigned short FT_UInt16;
  151. /* */
  152. /* this #if 0 ... #endif clause is for documentation purposes */
  153. #if 0
  154. /*************************************************************************/
  155. /* */
  156. /* <Type> */
  157. /* FT_Int32 */
  158. /* */
  159. /* <Description> */
  160. /* A typedef for a 32bit signed integer type. The size depends on */
  161. /* the configuration. */
  162. /* */
  163. typedef signed XXX FT_Int32;
  164. /*************************************************************************/
  165. /* */
  166. /* <Type> */
  167. /* FT_UInt32 */
  168. /* */
  169. /* A typedef for a 32bit unsigned integer type. The size depends on */
  170. /* the configuration. */
  171. /* */
  172. typedef unsigned XXX FT_UInt32;
  173. /* */
  174. #endif
  175. #if FT_SIZEOF_INT == (32 / FT_CHAR_BIT)
  176. typedef signed int FT_Int32;
  177. typedef unsigned int FT_UInt32;
  178. #elif FT_SIZEOF_LONG == (32 / FT_CHAR_BIT)
  179. typedef signed long FT_Int32;
  180. typedef unsigned long FT_UInt32;
  181. #else
  182. #error "no 32bit type found -- please check your configuration files"
  183. #endif
  184. /* look up an integer type that is at least 32 bits */
  185. #if FT_SIZEOF_INT >= (32 / FT_CHAR_BIT)
  186. typedef int FT_Fast;
  187. typedef unsigned int FT_UFast;
  188. #elif FT_SIZEOF_LONG >= (32 / FT_CHAR_BIT)
  189. typedef long FT_Fast;
  190. typedef unsigned long FT_UFast;
  191. #endif
  192. /* determine whether we have a 64-bit int type for platforms without */
  193. /* Autoconf */
  194. #if FT_SIZEOF_LONG == (64 / FT_CHAR_BIT)
  195. /* FT_LONG64 must be defined if a 64-bit type is available */
  196. #define FT_LONG64
  197. #define FT_INT64 long
  198. #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
  199. /* this compiler provides the __int64 type */
  200. #define FT_LONG64
  201. #define FT_INT64 __int64
  202. #elif defined( __BORLANDC__ ) /* Borland C++ */
  203. /* XXXX: We should probably check the value of __BORLANDC__ in order */
  204. /* to test the compiler version. */
  205. /* this compiler provides the __int64 type */
  206. #define FT_LONG64
  207. #define FT_INT64 __int64
  208. #elif defined( __WATCOMC__ ) /* Watcom C++ */
  209. /* Watcom doesn't provide 64-bit data types */
  210. #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
  211. #define FT_LONG64
  212. #define FT_INT64 long long int
  213. #elif defined( __GNUC__ )
  214. /* GCC provides the `long long' type */
  215. #define FT_LONG64
  216. #define FT_INT64 long long int
  217. #endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
  218. /*************************************************************************/
  219. /* */
  220. /* A 64-bit data type will create compilation problems if you compile */
  221. /* in strict ANSI mode. To avoid them, we disable its use if __STDC__ */
  222. /* is defined. You can however ignore this rule by defining the */
  223. /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
  224. /* */
  225. #if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 )
  226. #ifdef __STDC__
  227. /* undefine the 64-bit macros in strict ANSI compilation mode */
  228. #undef FT_LONG64
  229. #undef FT_INT64
  230. #endif /* __STDC__ */
  231. #endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */
  232. #define FT_BEGIN_STMNT do {
  233. #define FT_END_STMNT } while ( 0 )
  234. #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
  235. #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
  236. /* Provide assembler fragments for performance-critical functions. */
  237. /* These must be defined `static __inline__' with GCC. */
  238. #if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */
  239. #define FT_MULFIX_ASSEMBLER FT_MulFix_arm
  240. /* documentation is in freetype.h */
  241. static __inline FT_Int32
  242. FT_MulFix_arm( FT_Int32 a,
  243. FT_Int32 b )
  244. {
  245. register FT_Int32 t, t2;
  246. __asm
  247. {
  248. smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
  249. mov a, t, asr #31 /* a = (hi >> 31) */
  250. add a, a, #0x8000 /* a += 0x8000 */
  251. adds t2, t2, a /* t2 += a */
  252. adc t, t, #0 /* t += carry */
  253. mov a, t2, lsr #16 /* a = t2 >> 16 */
  254. orr a, a, t, lsl #16 /* a |= t << 16 */
  255. }
  256. return a;
  257. }
  258. #endif /* __CC_ARM || __ARMCC__ */
  259. #ifdef __GNUC__
  260. #if defined( __arm__ ) && !defined( __thumb__ ) && \
  261. !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
  262. #define FT_MULFIX_ASSEMBLER FT_MulFix_arm
  263. /* documentation is in freetype.h */
  264. static __inline__ FT_Int32
  265. FT_MulFix_arm( FT_Int32 a,
  266. FT_Int32 b )
  267. {
  268. register FT_Int32 t, t2;
  269. __asm__ __volatile__ (
  270. "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
  271. "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
  272. "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
  273. "adds %1, %1, %0\n\t" /* %1 += %0 */
  274. "adc %2, %2, #0\n\t" /* %2 += carry */
  275. "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */
  276. "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
  277. : "=r"(a), "=&r"(t2), "=&r"(t)
  278. : "r"(a), "r"(b) );
  279. return a;
  280. }
  281. #endif /* __arm__ && !__thumb__ && !( __CC_ARM || __ARMCC__ ) */
  282. #if defined( __i386__ )
  283. #define FT_MULFIX_ASSEMBLER FT_MulFix_i386
  284. /* documentation is in freetype.h */
  285. static __inline__ FT_Int32
  286. FT_MulFix_i386( FT_Int32 a,
  287. FT_Int32 b )
  288. {
  289. register FT_Int32 result;
  290. __asm__ __volatile__ (
  291. "imul %%edx\n"
  292. "movl %%edx, %%ecx\n"
  293. "sarl $31, %%ecx\n"
  294. "addl $0x8000, %%ecx\n"
  295. "addl %%ecx, %%eax\n"
  296. "adcl $0, %%edx\n"
  297. "shrl $16, %%eax\n"
  298. "shll $16, %%edx\n"
  299. "addl %%edx, %%eax\n"
  300. : "=a"(result), "=d"(b)
  301. : "a"(a), "d"(b)
  302. : "%ecx", "cc" );
  303. return result;
  304. }
  305. #endif /* i386 */
  306. #endif /* __GNUC__ */
  307. #ifdef _MSC_VER /* Visual C++ */
  308. #ifdef _M_IX86
  309. #define FT_MULFIX_ASSEMBLER FT_MulFix_i386
  310. /* documentation is in freetype.h */
  311. static __inline FT_Int32
  312. FT_MulFix_i386( FT_Int32 a,
  313. FT_Int32 b )
  314. {
  315. register FT_Int32 result;
  316. __asm
  317. {
  318. mov eax, a
  319. mov edx, b
  320. imul edx
  321. mov ecx, edx
  322. sar ecx, 31
  323. add ecx, 8000h
  324. add eax, ecx
  325. adc edx, 0
  326. shr eax, 16
  327. shl edx, 16
  328. add eax, edx
  329. mov result, eax
  330. }
  331. return result;
  332. }
  333. #endif /* _M_IX86 */
  334. #endif /* _MSC_VER */
  335. #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
  336. #ifdef FT_CONFIG_OPTION_INLINE_MULFIX
  337. #ifdef FT_MULFIX_ASSEMBLER
  338. #define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER
  339. #endif
  340. #endif
  341. #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
  342. #define FT_LOCAL( x ) static x
  343. #define FT_LOCAL_DEF( x ) static x
  344. #else
  345. #ifdef __cplusplus
  346. #define FT_LOCAL( x ) extern "C" x
  347. #define FT_LOCAL_DEF( x ) extern "C" x
  348. #else
  349. #define FT_LOCAL( x ) extern x
  350. #define FT_LOCAL_DEF( x ) x
  351. #endif
  352. #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
  353. #ifndef FT_BASE
  354. #ifdef __cplusplus
  355. #define FT_BASE( x ) extern "C" x
  356. #else
  357. #define FT_BASE( x ) extern x
  358. #endif
  359. #endif /* !FT_BASE */
  360. #ifndef FT_BASE_DEF
  361. #ifdef __cplusplus
  362. #define FT_BASE_DEF( x ) x
  363. #else
  364. #define FT_BASE_DEF( x ) x
  365. #endif
  366. #endif /* !FT_BASE_DEF */
  367. #ifndef FT_EXPORT
  368. #ifdef __cplusplus
  369. #define FT_EXPORT( x ) extern "C" x
  370. #else
  371. #define FT_EXPORT( x ) extern x
  372. #endif
  373. #endif /* !FT_EXPORT */
  374. #ifndef FT_EXPORT_DEF
  375. #ifdef __cplusplus
  376. #define FT_EXPORT_DEF( x ) extern "C" x
  377. #else
  378. #define FT_EXPORT_DEF( x ) extern x
  379. #endif
  380. #endif /* !FT_EXPORT_DEF */
  381. #ifndef FT_EXPORT_VAR
  382. #ifdef __cplusplus
  383. #define FT_EXPORT_VAR( x ) extern "C" x
  384. #else
  385. #define FT_EXPORT_VAR( x ) extern x
  386. #endif
  387. #endif /* !FT_EXPORT_VAR */
  388. /* The following macros are needed to compile the library with a */
  389. /* C++ compiler and with 16bit compilers. */
  390. /* */
  391. /* This is special. Within C++, you must specify `extern "C"' for */
  392. /* functions which are used via function pointers, and you also */
  393. /* must do that for structures which contain function pointers to */
  394. /* assure C linkage -- it's not possible to have (local) anonymous */
  395. /* functions which are accessed by (global) function pointers. */
  396. /* */
  397. /* */
  398. /* FT_CALLBACK_DEF is used to _define_ a callback function. */
  399. /* */
  400. /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
  401. /* contains pointers to callback functions. */
  402. /* */
  403. /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
  404. /* that contains pointers to callback functions. */
  405. /* */
  406. /* */
  407. /* Some 16bit compilers have to redefine these macros to insert */
  408. /* the infamous `_cdecl' or `__fastcall' declarations. */
  409. /* */
  410. #ifndef FT_CALLBACK_DEF
  411. #ifdef __cplusplus
  412. #define FT_CALLBACK_DEF( x ) extern "C" x
  413. #else
  414. #define FT_CALLBACK_DEF( x ) static x
  415. #endif
  416. #endif /* FT_CALLBACK_DEF */
  417. #ifndef FT_CALLBACK_TABLE
  418. #ifdef __cplusplus
  419. #define FT_CALLBACK_TABLE extern "C"
  420. #define FT_CALLBACK_TABLE_DEF extern "C"
  421. #else
  422. #define FT_CALLBACK_TABLE extern
  423. #define FT_CALLBACK_TABLE_DEF /* nothing */
  424. #endif
  425. #endif /* FT_CALLBACK_TABLE */
  426. FT_END_HEADER
  427. #endif /* __FTCONFIG_H__ */
  428. /* END */