/src/freetype/include/freetype/config/ftconfig.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 563 lines · 258 code · 140 blank · 165 comment · 23 complexity · e0f2c3ccbade72118d4750a56b8031ab MD5 · raw file

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