ftconfig.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * ftconfig.in
4  *
5  * UNIX-specific configuration file (specification only).
6  *
7  * Copyright (C) 1996-2020 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 by
22  * 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 port
24  * FreeType, except to compile the library with a non-ANSI compiler.
25  *
26  * Note however that if some specific modifications are needed, we advise
27  * you to place a modified copy in your build directory.
28  *
29  * The build directory is usually `builds/<system>`, and contains
30  * system-specific files that are always included first when building the
31  * library.
32  *
33  */
34 
35 #ifndef FTCONFIG_H_
36 #define FTCONFIG_H_
37 
38 #include <vtkfreetype/include/ft2build.h>
39 #include FT_CONFIG_OPTIONS_H
40 #include FT_CONFIG_STANDARD_LIBRARY_H
41 
42 
43 FT_BEGIN_HEADER
44 
45 
46  /**************************************************************************
47  *
48  * PLATFORM-SPECIFIC CONFIGURATION MACROS
49  *
50  * These macros can be toggled to suit a specific system. The current ones
51  * are defaults used to compile FreeType in an ANSI C environment (16bit
52  * compilers are also supported). Copy this file to your own
53  * `builds/<system>` directory, and edit it to port the engine.
54  *
55  */
56 
57 /* XXX(kitware): use cmakedefine instead of undef */
58 #define HAVE_UNISTD_H 1
59 #define HAVE_FCNTL_H 1
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 #undef FT_USE_AUTOCONF_SIZEOF_TYPES
75 #if 1 /* XXX(kitware): Use VTK's sizes instead of the big test. */
76 #include "vtk_kwiml.h"
77 #define FT_SIZEOF_INT KWIML_ABI_SIZEOF_INT
78 #define FT_SIZEOF_LONG KWIML_ABI_SIZEOF_LONG
79 
80 #elif defined(FT_USE_AUTOCONF_SIZEOF_TYPES)
81 
82 #undef SIZEOF_INT
83 #undef SIZEOF_LONG
84 #define FT_SIZEOF_INT SIZEOF_INT
85 #define FT_SIZEOF_LONG SIZEOF_LONG
86 
87 #else /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
88 
89  /* Following cpp computation of the bit length of `int` and `long` */
90  /* is copied from default `include/freetype/config/ftconfig.h`. */
91  /* If any improvement is required for this file, it should be */
92  /* applied to the original header file for the builders that do */
93  /* not use configure script. */
94 
95  /* The size of an `int` type. */
96 #if FT_UINT_MAX == 0xFFFFUL
97 #define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT )
98 #elif FT_UINT_MAX == 0xFFFFFFFFUL
99 #define FT_SIZEOF_INT ( 32 / FT_CHAR_BIT )
100 #elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
101 #define FT_SIZEOF_INT ( 64 / FT_CHAR_BIT )
102 #else
103 #error "Unsupported size of `int' type!"
104 #endif
105 
106  /* The size of a `long` type. A five-byte `long` (as used e.g. on the */
107  /* DM642) is recognized but avoided. */
108 #if FT_ULONG_MAX == 0xFFFFFFFFUL
109 #define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
110 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
111 #define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
112 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
113 #define FT_SIZEOF_LONG ( 64 / FT_CHAR_BIT )
114 #else
115 #error "Unsupported size of `long' type!"
116 #endif
117 
118 #endif /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
119 
120  /* `FT_UNUSED` indicates that a given parameter is not used -- */
121  /* this is only used to get rid of unpleasant compiler warnings. */
122 #ifndef FT_UNUSED
123 #define FT_UNUSED( arg ) ( (arg) = (arg) )
124 #endif
125 
126 
127  /**************************************************************************
128  *
129  * AUTOMATIC CONFIGURATION MACROS
130  *
131  * These macros are computed from the ones defined above. Don't touch
132  * their definition, unless you know precisely what you are doing. No
133  * porter should need to mess with them.
134  *
135  */
136 
137 
138  /**************************************************************************
139  *
140  * Mac support
141  *
142  * This is the only necessary change, so it is defined here instead
143  * providing a new configuration file.
144  */
145 #if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
146 
147 #ifdef __APPLE__
148 #include "TargetConditionals.h"
149 #endif
150 
151 # if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
152 
153  /* No Carbon frameworks for 64bit 10.4.x. */
154  /* `AvailabilityMacros.h` is available since Mac OS X 10.2, */
155  /* so guess the system version by maximum errno before inclusion. */
156 #include <errno.h>
157 #ifdef ECANCELED /* defined since 10.2 */
158 #include "AvailabilityMacros.h"
159 #endif
160 #if defined( __LP64__ ) && \
161  ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
162 #define FT_MACINTOSH 1
163 #endif
164 
165 #elif defined( __SC__ ) || defined( __MRC__ )
166  /* Classic MacOS compilers */
167 #include "ConditionalMacros.h"
168 #if TARGET_OS_MAC
169 #define FT_MACINTOSH 1
170 #endif
171 
172 #endif
173 
174 #endif
175 
176  /* Fix compiler warning with sgi compiler. */
177 #if defined( __sgi ) && !defined( __GNUC__ )
178 #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
179 #pragma set woff 3505
180 #endif
181 #endif
182 
183 
184  /**************************************************************************
185  *
186  * @section:
187  * basic_types
188  *
189  */
190 
191 
192  /**************************************************************************
193  *
194  * @type:
195  * FT_Int16
196  *
197  * @description:
198  * A typedef for a 16bit signed integer type.
199  */
200  typedef signed short FT_Int16;
201 
202 
203  /**************************************************************************
204  *
205  * @type:
206  * FT_UInt16
207  *
208  * @description:
209  * A typedef for a 16bit unsigned integer type.
210  */
211  typedef unsigned short FT_UInt16;
212 
213  /* */
214 
215 
216  /* this #if 0 ... #endif clause is for documentation purposes */
217 #if 0
218 
219  /**************************************************************************
220  *
221  * @type:
222  * FT_Int32
223  *
224  * @description:
225  * A typedef for a 32bit signed integer type. The size depends on the
226  * configuration.
227  */
228  typedef signed XXX FT_Int32;
229 
230 
231  /**************************************************************************
232  *
233  * @type:
234  * FT_UInt32
235  *
236  * A typedef for a 32bit unsigned integer type. The size depends on the
237  * configuration.
238  */
239  typedef unsigned XXX FT_UInt32;
240 
241 
242  /**************************************************************************
243  *
244  * @type:
245  * FT_Int64
246  *
247  * A typedef for a 64bit signed integer type. The size depends on the
248  * configuration. Only defined if there is real 64bit support;
249  * otherwise, it gets emulated with a structure (if necessary).
250  */
251  typedef signed XXX FT_Int64;
252 
253 
254  /**************************************************************************
255  *
256  * @type:
257  * FT_UInt64
258  *
259  * A typedef for a 64bit unsigned integer type. The size depends on the
260  * configuration. Only defined if there is real 64bit support;
261  * otherwise, it gets emulated with a structure (if necessary).
262  */
263  typedef unsigned XXX FT_UInt64;
264 
265  /* */
266 
267 #endif
268 
269 #if FT_SIZEOF_INT == 4
270 
271  typedef signed int FT_Int32;
272  typedef unsigned int FT_UInt32;
273 
274 #elif FT_SIZEOF_LONG == 4
275 
276  typedef signed long FT_Int32;
277  typedef unsigned long FT_UInt32;
278 
279 #else
280 #error "no 32bit type found -- please check your configuration files"
281 #endif
282 
283 
284  /* look up an integer type that is at least 32~bits */
285 #if FT_SIZEOF_INT >= 4
286 
287  typedef int FT_Fast;
288  typedef unsigned int FT_UFast;
289 
290 #elif FT_SIZEOF_LONG >= 4
291 
292  typedef long FT_Fast;
293  typedef unsigned long FT_UFast;
294 
295 #endif
296 
297 
298  /* determine whether we have a 64-bit `int` type for platforms without */
299  /* Autoconf */
300 #if FT_SIZEOF_LONG == 8
301 
302  /* `FT_LONG64` must be defined if a 64-bit type is available */
303 #define FT_LONG64
304 #define FT_INT64 long
305 #define FT_UINT64 unsigned long
306 
307  /* we handle the LLP64 scheme separately for GCC and clang, */
308  /* suppressing the `long long` warning */
309 #elif ( FT_SIZEOF_LONG == 4 ) && \
310  defined( HAVE_LONG_LONG_INT ) && \
311  defined( __GNUC__ )
312 #pragma GCC diagnostic ignored "-Wlong-long"
313 #define FT_LONG64
314 #define FT_INT64 long long int
315 #define FT_UINT64 unsigned long long int
316 
317  /**************************************************************************
318  *
319  * A 64-bit data type may create compilation problems if you compile in
320  * strict ANSI mode. To avoid them, we disable other 64-bit data types if
321  * `__STDC__` is defined. You can however ignore this rule by defining the
322  * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro.
323  */
324 #elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
325 
326 #if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
327 
328 #define FT_LONG64
329 #define FT_INT64 long long int
330 #define FT_UINT64 unsigned long long int
331 
332 #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
333 
334  /* this compiler provides the `__int64` type */
335 #define FT_LONG64
336 #define FT_INT64 __int64
337 #define FT_UINT64 unsigned __int64
338 
339 #elif defined( __BORLANDC__ ) /* Borland C++ */
340 
341  /* XXXX: We should probably check the value of `__BORLANDC__` in order */
342  /* to test the compiler version. */
343 
344  /* this compiler provides the `__int64` type */
345 #define FT_LONG64
346 #define FT_INT64 __int64
347 #define FT_UINT64 unsigned __int64
348 
349 #elif defined( __WATCOMC__ ) /* Watcom C++ */
350 
351  /* Watcom doesn't provide 64-bit data types */
352 
353 #elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
354 
355 #define FT_LONG64
356 #define FT_INT64 long long int
357 #define FT_UINT64 unsigned long long int
358 
359 #elif defined( __GNUC__ )
360 
361  /* GCC provides the `long long` type */
362 #define FT_LONG64
363 #define FT_INT64 long long int
364 #define FT_UINT64 unsigned long long int
365 
366 #endif /* __STDC_VERSION__ >= 199901L */
367 
368 #endif /* FT_SIZEOF_LONG == 8 */
369 
370 #ifdef FT_LONG64
371  typedef FT_INT64 FT_Int64;
372  typedef FT_UINT64 FT_UInt64;
373 #endif
374 
375 
376 #ifdef _WIN64
377  /* only 64bit Windows uses the LLP64 data model, i.e., */
378  /* 32bit integers, 64bit pointers */
379 #define FT_UINT_TO_POINTER( x ) (void*)(unsigned __int64)(x)
380 #else
381 #define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
382 #endif
383 
384 
385  /**************************************************************************
386  *
387  * miscellaneous
388  *
389  */
390 
391 
392 #define FT_BEGIN_STMNT do {
393 #define FT_END_STMNT } while ( 0 )
394 #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
395 
396 
397  /* `typeof` condition taken from gnulib's `intprops.h` header file */
398 #if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \
399  ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \
400  defined( __IBM__TYPEOF__ ) ) || \
401  ( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) )
402 #define FT_TYPEOF( type ) ( __typeof__ ( type ) )
403 #else
404 #define FT_TYPEOF( type ) /* empty */
405 #endif
406 
407 
408  /* Use `FT_LOCAL` and `FT_LOCAL_DEF` to declare and define, */
409  /* respectively, a function that gets used only within the scope of a */
410  /* module. Normally, both the header and source code files for such a */
411  /* function are within a single module directory. */
412  /* */
413  /* Intra-module arrays should be tagged with `FT_LOCAL_ARRAY` and */
414  /* `FT_LOCAL_ARRAY_DEF`. */
415  /* */
416 #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
417 
418 #define FT_LOCAL( x ) static x
419 #define FT_LOCAL_DEF( x ) static x
420 
421 #else
422 
423 #ifdef __cplusplus
424 #define FT_LOCAL( x ) extern "C" x
425 #define FT_LOCAL_DEF( x ) extern "C" x
426 #else
427 #define FT_LOCAL( x ) extern x
428 #define FT_LOCAL_DEF( x ) x
429 #endif
430 
431 #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
432 
433 #define FT_LOCAL_ARRAY( x ) extern const x
434 #define FT_LOCAL_ARRAY_DEF( x ) const x
435 
436 
437  /* Use `FT_BASE` and `FT_BASE_DEF` to declare and define, respectively, */
438  /* functions that are used in more than a single module. In the */
439  /* current setup this implies that the declaration is in a header file */
440  /* in the `include/freetype/internal` directory, and the function body */
441  /* is in a file in `src/base`. */
442  /* */
443 #ifndef FT_BASE
444 
445 #ifdef __cplusplus
446 #define FT_BASE( x ) extern "C" x
447 #else
448 #define FT_BASE( x ) extern x
449 #endif
450 
451 #endif /* !FT_BASE */
452 
453 
454 #ifndef FT_BASE_DEF
455 
456 #ifdef __cplusplus
457 #define FT_BASE_DEF( x ) x
458 #else
459 #define FT_BASE_DEF( x ) x
460 #endif
461 
462 #endif /* !FT_BASE_DEF */
463 
464 
465  /* When compiling FreeType as a DLL or DSO with hidden visibility */
466  /* some systems/compilers need a special attribute in front OR after */
467  /* the return type of function declarations. */
468  /* */
469  /* Two macros are used within the FreeType source code to define */
470  /* exported library functions: `FT_EXPORT` and `FT_EXPORT_DEF`. */
471  /* */
472  /* - `FT_EXPORT( return_type )` */
473  /* */
474  /* is used in a function declaration, as in */
475  /* */
476  /* ``` */
477  /* FT_EXPORT( FT_Error ) */
478  /* FT_Init_FreeType( FT_Library* alibrary ); */
479  /* ``` */
480  /* */
481  /* - `FT_EXPORT_DEF( return_type )` */
482  /* */
483  /* is used in a function definition, as in */
484  /* */
485  /* ``` */
486  /* FT_EXPORT_DEF( FT_Error ) */
487  /* FT_Init_FreeType( FT_Library* alibrary ) */
488  /* { */
489  /* ... some code ... */
490  /* return FT_Err_Ok; */
491  /* } */
492  /* ``` */
493  /* */
494  /* You can provide your own implementation of `FT_EXPORT` and */
495  /* `FT_EXPORT_DEF` here if you want. */
496  /* */
497  /* To export a variable, use `FT_EXPORT_VAR`. */
498  /* */
499 #ifndef FT_EXPORT
500 
501 #ifdef FT2_BUILD_LIBRARY
502 
503 #if defined( _WIN32 ) && defined( DLL_EXPORT )
504 #define FT_EXPORT( x ) __declspec( dllexport ) x
505 #elif defined( __GNUC__ ) && __GNUC__ >= 4
506 #define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
507 #elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550
508 #define FT_EXPORT( x ) __global x
509 #elif defined( __cplusplus )
510 #define FT_EXPORT( x ) extern "C" x
511 #else
512 #define FT_EXPORT( x ) extern x
513 #endif
514 
515 #else
516 
517 #if defined( _WIN32 ) && defined( DLL_IMPORT )
518 #define FT_EXPORT( x ) __declspec( dllimport ) x
519 #elif defined( __cplusplus )
520 #define FT_EXPORT( x ) extern "C" x
521 #else
522 #define FT_EXPORT( x ) extern x
523 #endif
524 
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 
552  /* The following macros are needed to compile the library with a */
553  /* C++ compiler and with 16bit compilers. */
554  /* */
555 
556  /* This is special. Within C++, you must specify `extern "C"` for */
557  /* functions which are used via function pointers, and you also */
558  /* must do that for structures which contain function pointers to */
559  /* assure C linkage -- it's not possible to have (local) anonymous */
560  /* functions which are accessed by (global) function pointers. */
561  /* */
562  /* */
563  /* FT_CALLBACK_DEF is used to _define_ a callback function, */
564  /* located in the same source code file as the structure that uses */
565  /* it. */
566  /* */
567  /* FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare */
568  /* and define a callback function, respectively, in a similar way */
569  /* as FT_BASE and FT_BASE_DEF work. */
570  /* */
571  /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
572  /* contains pointers to callback functions. */
573  /* */
574  /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
575  /* that contains pointers to callback functions. */
576  /* */
577  /* */
578  /* Some 16bit compilers have to redefine these macros to insert */
579  /* the infamous `_cdecl` or `__fastcall` declarations. */
580  /* */
581 #ifndef FT_CALLBACK_DEF
582 #ifdef __cplusplus
583 #define FT_CALLBACK_DEF( x ) extern "C" x
584 #else
585 #define FT_CALLBACK_DEF( x ) static x
586 #endif
587 #endif /* FT_CALLBACK_DEF */
588 
589 #ifndef FT_BASE_CALLBACK
590 #ifdef __cplusplus
591 #define FT_BASE_CALLBACK( x ) extern "C" x
592 #define FT_BASE_CALLBACK_DEF( x ) extern "C" x
593 #else
594 #define FT_BASE_CALLBACK( x ) extern x
595 #define FT_BASE_CALLBACK_DEF( x ) x
596 #endif
597 #endif /* FT_BASE_CALLBACK */
598 
599 #ifndef FT_CALLBACK_TABLE
600 #ifdef __cplusplus
601 #define FT_CALLBACK_TABLE extern "C"
602 #define FT_CALLBACK_TABLE_DEF extern "C"
603 #else
604 #define FT_CALLBACK_TABLE extern
605 #define FT_CALLBACK_TABLE_DEF /* nothing */
606 #endif
607 #endif /* FT_CALLBACK_TABLE */
608 
609 
610 FT_END_HEADER
611 
612 
613 #endif /* FTCONFIG_H_ */
614 
615 
616 /* END */
unsigned short FT_UInt16
Definition: ftconfig.h:211
signed short FT_Int16
Definition: ftconfig.h:200