Home | History | Annotate | Download | only in unicode
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /*
      4 ******************************************************************************
      5 *
      6 *   Copyright (C) 1997-2012, International Business Machines
      7 *   Corporation and others.  All Rights Reserved.
      8 *
      9 ******************************************************************************
     10 *
     11 *  FILE NAME : ptypes.h
     12 *
     13 *   Date        Name        Description
     14 *   05/13/98    nos         Creation (content moved here from ptypes.h).
     15 *   03/02/99    stephen     Added AS400 support.
     16 *   03/30/99    stephen     Added Linux support.
     17 *   04/13/99    stephen     Reworked for autoconf.
     18 *   09/18/08    srl         Moved basic types back to ptypes.h from platform.h
     19 ******************************************************************************
     20 */
     21 
     22 /**
     23  * \file
     24  * \brief C API: Definitions of integer types of various widths
     25  */
     26 
     27 #ifndef _PTYPES_H
     28 #define _PTYPES_H
     29 
     30 /**
     31  * \def __STDC_LIMIT_MACROS
     32  * According to the Linux stdint.h, the ISO C99 standard specifies that in C++ implementations
     33  * macros like INT32_MIN and UINTPTR_MAX should only be defined if explicitly requested.
     34  * We need to define __STDC_LIMIT_MACROS before including stdint.h in C++ code
     35  * that uses such limit macros.
     36  * @internal
     37  */
     38 #ifndef __STDC_LIMIT_MACROS
     39 #define __STDC_LIMIT_MACROS
     40 #endif
     41 
     42 /* NULL, size_t, wchar_t */
     43 #include <stddef.h>
     44 
     45 /*
     46  * If all compilers provided all of the C99 headers and types,
     47  * we would just unconditionally #include <stdint.h> here
     48  * and not need any of the stuff after including platform.h.
     49  */
     50 
     51 /* Find out if we have stdint.h etc. */
     52 #include "unicode/platform.h"
     53 
     54 /*===========================================================================*/
     55 /* Generic data types                                                        */
     56 /*===========================================================================*/
     57 
     58 /* If your platform does not have the <stdint.h> header, you may
     59    need to edit the typedefs in the #else section below.
     60    Use #if...#else...#endif with predefined compiler macros if possible. */
     61 #if U_HAVE_STDINT_H
     62 
     63 /*
     64  * We mostly need <stdint.h> (which defines the standard integer types) but not <inttypes.h>.
     65  * <inttypes.h> includes <stdint.h> and adds the printf/scanf helpers PRId32, SCNx16 etc.
     66  * which we almost never use, plus stuff like imaxabs() which we never use.
     67  */
     68 #include <stdint.h>
     69 
     70 #if U_PLATFORM == U_PF_OS390
     71 /* The features header is needed to get (u)int64_t sometimes. */
     72 #include <features.h>
     73 /* z/OS has <stdint.h>, but some versions are missing uint8_t (APAR PK62248). */
     74 #if !defined(__uint8_t)
     75 #define __uint8_t 1
     76 typedef unsigned char uint8_t;
     77 #endif
     78 #endif /* U_PLATFORM == U_PF_OS390 */
     79 
     80 #elif U_HAVE_INTTYPES_H
     81 
     82 #   include <inttypes.h>
     83 
     84 #else /* neither U_HAVE_STDINT_H nor U_HAVE_INTTYPES_H */
     85 
     86 #if ! U_HAVE_INT8_T
     87 typedef signed char int8_t;
     88 #endif
     89 
     90 #if ! U_HAVE_UINT8_T
     91 typedef unsigned char uint8_t;
     92 #endif
     93 
     94 #if ! U_HAVE_INT16_T
     95 typedef signed short int16_t;
     96 #endif
     97 
     98 #if ! U_HAVE_UINT16_T
     99 typedef unsigned short uint16_t;
    100 #endif
    101 
    102 #if ! U_HAVE_INT32_T
    103 typedef signed int int32_t;
    104 #endif
    105 
    106 #if ! U_HAVE_UINT32_T
    107 typedef unsigned int uint32_t;
    108 #endif
    109 
    110 #if ! U_HAVE_INT64_T
    111 #ifdef _MSC_VER
    112     typedef signed __int64 int64_t;
    113 #else
    114     typedef signed long long int64_t;
    115 #endif
    116 #endif
    117 
    118 #if ! U_HAVE_UINT64_T
    119 #ifdef _MSC_VER
    120     typedef unsigned __int64 uint64_t;
    121 #else
    122     typedef unsigned long long uint64_t;
    123 #endif
    124 #endif
    125 
    126 #endif /* U_HAVE_STDINT_H / U_HAVE_INTTYPES_H */
    127 
    128 #endif /* _PTYPES_H */
    129