/src/compiler/android-ndk/jni/freetype/include/freetype/config/ftconfig.h

http://ftk.googlecode.com/ · C++ Header · 528 lines · 232 code · 133 blank · 163 comment · 24 complexity · 91d1d42f04472659d392304376be3599 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftconfig.h */
  4. /* */
  5. /* ANSI-specific configuration file (specification only). */
  6. /* */
  7. /* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010 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. #include "AvailabilityMacros.h"
  109. #if defined( __LP64__ ) && \
  110. ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
  111. #define DARWIN_NO_CARBON 1
  112. #else
  113. #define FT_MACINTOSH 1
  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, %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. #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
  303. #ifdef FT_CONFIG_OPTION_INLINE_MULFIX
  304. #ifdef FT_MULFIX_ASSEMBLER
  305. #define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER
  306. #endif
  307. #endif
  308. #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
  309. #define FT_LOCAL( x ) static x
  310. #define FT_LOCAL_DEF( x ) static x
  311. #else
  312. #ifdef __cplusplus
  313. #define FT_LOCAL( x ) extern "C" x
  314. #define FT_LOCAL_DEF( x ) extern "C" x
  315. #else
  316. #define FT_LOCAL( x ) extern x
  317. #define FT_LOCAL_DEF( x ) x
  318. #endif
  319. #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
  320. #ifndef FT_BASE
  321. #ifdef __cplusplus
  322. #define FT_BASE( x ) extern "C" x
  323. #else
  324. #define FT_BASE( x ) extern x
  325. #endif
  326. #endif /* !FT_BASE */
  327. #ifndef FT_BASE_DEF
  328. #ifdef __cplusplus
  329. #define FT_BASE_DEF( x ) x
  330. #else
  331. #define FT_BASE_DEF( x ) x
  332. #endif
  333. #endif /* !FT_BASE_DEF */
  334. #ifndef FT_EXPORT
  335. #ifdef __cplusplus
  336. #define FT_EXPORT( x ) extern "C" x
  337. #else
  338. #define FT_EXPORT( x ) extern x
  339. #endif
  340. #endif /* !FT_EXPORT */
  341. #ifndef FT_EXPORT_DEF
  342. #ifdef __cplusplus
  343. #define FT_EXPORT_DEF( x ) extern "C" x
  344. #else
  345. #define FT_EXPORT_DEF( x ) extern x
  346. #endif
  347. #endif /* !FT_EXPORT_DEF */
  348. #ifndef FT_EXPORT_VAR
  349. #ifdef __cplusplus
  350. #define FT_EXPORT_VAR( x ) extern "C" x
  351. #else
  352. #define FT_EXPORT_VAR( x ) extern x
  353. #endif
  354. #endif /* !FT_EXPORT_VAR */
  355. /* The following macros are needed to compile the library with a */
  356. /* C++ compiler and with 16bit compilers. */
  357. /* */
  358. /* This is special. Within C++, you must specify `extern "C"' for */
  359. /* functions which are used via function pointers, and you also */
  360. /* must do that for structures which contain function pointers to */
  361. /* assure C linkage -- it's not possible to have (local) anonymous */
  362. /* functions which are accessed by (global) function pointers. */
  363. /* */
  364. /* */
  365. /* FT_CALLBACK_DEF is used to _define_ a callback function. */
  366. /* */
  367. /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
  368. /* contains pointers to callback functions. */
  369. /* */
  370. /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
  371. /* that contains pointers to callback functions. */
  372. /* */
  373. /* */
  374. /* Some 16bit compilers have to redefine these macros to insert */
  375. /* the infamous `_cdecl' or `__fastcall' declarations. */
  376. /* */
  377. #ifndef FT_CALLBACK_DEF
  378. #ifdef __cplusplus
  379. #define FT_CALLBACK_DEF( x ) extern "C" x
  380. #else
  381. #define FT_CALLBACK_DEF( x ) static x
  382. #endif
  383. #endif /* FT_CALLBACK_DEF */
  384. #ifndef FT_CALLBACK_TABLE
  385. #ifdef __cplusplus
  386. #define FT_CALLBACK_TABLE extern "C"
  387. #define FT_CALLBACK_TABLE_DEF extern "C"
  388. #else
  389. #define FT_CALLBACK_TABLE extern
  390. #define FT_CALLBACK_TABLE_DEF /* nothing */
  391. #endif
  392. #endif /* FT_CALLBACK_TABLE */
  393. FT_END_HEADER
  394. #endif /* __FTCONFIG_H__ */
  395. /* END */