Home | History | Annotate | Line # | Download | only in config
      1 /****************************************************************************
      2  *
      3  * config/integer-types.h
      4  *
      5  *   FreeType integer types definitions.
      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 #ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_
     18 #define FREETYPE_CONFIG_INTEGER_TYPES_H_
     19 
     20   /* There are systems (like the Texas Instruments 'C54x) where a `char`  */
     21   /* has 16~bits.  ANSI~C says that `sizeof(char)` is always~1.  Since an */
     22   /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which  */
     23   /* is probably unexpected.                                              */
     24   /*                                                                      */
     25   /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a     */
     26   /* `char` type.                                                         */
     27 
     28 #ifndef FT_CHAR_BIT
     29 #define FT_CHAR_BIT  CHAR_BIT
     30 #endif
     31 
     32 #ifndef FT_SIZEOF_INT
     33 
     34   /* The size of an `int` type. */
     35 #if                                 FT_UINT_MAX == 0xFFFFUL
     36 #define FT_SIZEOF_INT  ( 16 / FT_CHAR_BIT )
     37 #elif                               FT_UINT_MAX == 0xFFFFFFFFUL
     38 #define FT_SIZEOF_INT  ( 32 / FT_CHAR_BIT )
     39 #elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
     40 #define FT_SIZEOF_INT  ( 64 / FT_CHAR_BIT )
     41 #else
     42 #error "Unsupported size of `int' type!"
     43 #endif
     44 
     45 #endif  /* !defined(FT_SIZEOF_INT) */
     46 
     47 #ifndef FT_SIZEOF_LONG
     48 
     49   /* The size of a `long` type.  A five-byte `long` (as used e.g. on the */
     50   /* DM642) is recognized but avoided.                                   */
     51 #if                                  FT_ULONG_MAX == 0xFFFFFFFFUL
     52 #define FT_SIZEOF_LONG  ( 32 / FT_CHAR_BIT )
     53 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
     54 #define FT_SIZEOF_LONG  ( 32 / FT_CHAR_BIT )
     55 #elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
     56 #define FT_SIZEOF_LONG  ( 64 / FT_CHAR_BIT )
     57 #else
     58 #error "Unsupported size of `long' type!"
     59 #endif
     60 
     61 #endif /* !defined(FT_SIZEOF_LONG) */
     62 
     63   /**************************************************************************
     64    *
     65    * @section:
     66    *   basic_types
     67    *
     68    */
     69 
     70 
     71   /**************************************************************************
     72    *
     73    * @type:
     74    *   FT_Int16
     75    *
     76    * @description:
     77    *   A typedef for a 16bit signed integer type.
     78    */
     79   typedef signed short  FT_Int16;
     80 
     81 
     82   /**************************************************************************
     83    *
     84    * @type:
     85    *   FT_UInt16
     86    *
     87    * @description:
     88    *   A typedef for a 16bit unsigned integer type.
     89    */
     90   typedef unsigned short  FT_UInt16;
     91 
     92   /* */
     93 
     94 
     95   /* this #if 0 ... #endif clause is for documentation purposes */
     96 #if 0
     97 
     98   /**************************************************************************
     99    *
    100    * @type:
    101    *   FT_Int32
    102    *
    103    * @description:
    104    *   A typedef for a 32bit signed integer type.  The size depends on the
    105    *   configuration.
    106    */
    107   typedef signed XXX  FT_Int32;
    108 
    109 
    110   /**************************************************************************
    111    *
    112    * @type:
    113    *   FT_UInt32
    114    *
    115    *   A typedef for a 32bit unsigned integer type.  The size depends on the
    116    *   configuration.
    117    */
    118   typedef unsigned XXX  FT_UInt32;
    119 
    120 
    121   /**************************************************************************
    122    *
    123    * @type:
    124    *   FT_Int64
    125    *
    126    *   A typedef for a 64bit signed integer type.  The size depends on the
    127    *   configuration.  Only defined if there is real 64bit support;
    128    *   otherwise, it gets emulated with a structure (if necessary).
    129    */
    130   typedef signed XXX  FT_Int64;
    131 
    132 
    133   /**************************************************************************
    134    *
    135    * @type:
    136    *   FT_UInt64
    137    *
    138    *   A typedef for a 64bit unsigned integer type.  The size depends on the
    139    *   configuration.  Only defined if there is real 64bit support;
    140    *   otherwise, it gets emulated with a structure (if necessary).
    141    */
    142   typedef unsigned XXX  FT_UInt64;
    143 
    144   /* */
    145 
    146 #endif
    147 
    148 #if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT )
    149 
    150   typedef signed int      FT_Int32;
    151   typedef unsigned int    FT_UInt32;
    152 
    153 #elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
    154 
    155   typedef signed long     FT_Int32;
    156   typedef unsigned long   FT_UInt32;
    157 
    158 #else
    159 #error "no 32bit type found -- please check your configuration files"
    160 #endif
    161 
    162 
    163   /* look up an integer type that is at least 32~bits */
    164 #if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT )
    165 
    166   typedef int            FT_Fast;
    167   typedef unsigned int   FT_UFast;
    168 
    169 #elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT )
    170 
    171   typedef long           FT_Fast;
    172   typedef unsigned long  FT_UFast;
    173 
    174 #endif
    175 
    176 
    177   /* determine whether we have a 64-bit `int` type for platforms without */
    178   /* Autoconf                                                            */
    179 #if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
    180 
    181   /* `FT_LONG64` must be defined if a 64-bit type is available */
    182 #define FT_LONG64
    183 #define FT_INT64   long
    184 #define FT_UINT64  unsigned long
    185 
    186   /**************************************************************************
    187    *
    188    * A 64-bit data type may create compilation problems if you compile in
    189    * strict ANSI mode.  To avoid them, we disable other 64-bit data types if
    190    * `__STDC__` is defined.  You can however ignore this rule by defining the
    191    * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro.
    192    */
    193 #elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
    194 
    195 #if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
    196 
    197 #define FT_LONG64
    198 #define FT_INT64   long long int
    199 #define FT_UINT64  unsigned long long int
    200 
    201 #elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
    202 
    203   /* this compiler provides the `__int64` type */
    204 #define FT_LONG64
    205 #define FT_INT64   __int64
    206 #define FT_UINT64  unsigned __int64
    207 
    208 #elif defined( __BORLANDC__ )  /* Borland C++ */
    209 
    210   /* XXXX: We should probably check the value of `__BORLANDC__` in order */
    211   /*       to test the compiler version.                                 */
    212 
    213   /* this compiler provides the `__int64` type */
    214 #define FT_LONG64
    215 #define FT_INT64   __int64
    216 #define FT_UINT64  unsigned __int64
    217 
    218 #elif defined( __WATCOMC__ )   /* Watcom C++ */
    219 
    220   /* Watcom doesn't provide 64-bit data types */
    221 
    222 #elif defined( __MWERKS__ )    /* Metrowerks CodeWarrior */
    223 
    224 #define FT_LONG64
    225 #define FT_INT64   long long int
    226 #define FT_UINT64  unsigned long long int
    227 
    228 #elif defined( __GNUC__ )
    229 
    230   /* GCC provides the `long long` type */
    231 #define FT_LONG64
    232 #define FT_INT64   long long int
    233 #define FT_UINT64  unsigned long long int
    234 
    235 #endif /* __STDC_VERSION__ >= 199901L */
    236 
    237 #endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
    238 
    239 #ifdef FT_LONG64
    240   typedef FT_INT64   FT_Int64;
    241   typedef FT_UINT64  FT_UInt64;
    242 #endif
    243 
    244 
    245 #endif  /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */
    246