ptypes.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Copyright (C) 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. * \file
  23. * \brief C API: Definitions of integer types of various widths
  24. */
  25. #ifndef _PTYPES_H
  26. #define _PTYPES_H
  27. /**
  28. * \def __STDC_LIMIT_MACROS
  29. * According to the Linux stdint.h, the ISO C99 standard specifies that in C++ implementations
  30. * macros like INT32_MIN and UINTPTR_MAX should only be defined if explicitly requested.
  31. * We need to define __STDC_LIMIT_MACROS before including stdint.h in C++ code
  32. * that uses such limit macros.
  33. * @internal
  34. */
  35. #ifndef __STDC_LIMIT_MACROS
  36. #define __STDC_LIMIT_MACROS
  37. #endif
  38. /* NULL, size_t, wchar_t */
  39. #include <stddef.h>
  40. /*
  41. * If all compilers provided all of the C99 headers and types,
  42. * we would just unconditionally #include <stdint.h> here
  43. * and not need any of the stuff after including platform.h.
  44. */
  45. /* Find out if we have stdint.h etc. */
  46. #include "platform.h"
  47. /*===========================================================================*/
  48. /* Generic data types */
  49. /*===========================================================================*/
  50. /* If your platform does not have the <stdint.h> header, you may
  51. need to edit the typedefs in the #else section below.
  52. Use #if...#else...#endif with predefined compiler macros if possible. */
  53. #if U_HAVE_STDINT_H
  54. /*
  55. * We mostly need <stdint.h> (which defines the standard integer types) but not <inttypes.h>.
  56. * <inttypes.h> includes <stdint.h> and adds the printf/scanf helpers PRId32, SCNx16 etc.
  57. * which we almost never use, plus stuff like imaxabs() which we never use.
  58. */
  59. #include <stdint.h>
  60. #if U_PLATFORM == U_PF_OS390
  61. /* The features header is needed to get (u)int64_t sometimes. */
  62. #include <features.h>
  63. /* z/OS has <stdint.h>, but some versions are missing uint8_t (APAR PK62248). */
  64. #if !defined(__uint8_t)
  65. #define __uint8_t 1
  66. typedef unsigned char uint8_t;
  67. #endif
  68. #endif /* U_PLATFORM == U_PF_OS390 */
  69. #elif U_HAVE_INTTYPES_H
  70. # include <inttypes.h>
  71. #else /* neither U_HAVE_STDINT_H nor U_HAVE_INTTYPES_H */
  72. #if ! U_HAVE_INT8_T
  73. typedef signed char int8_t;
  74. #endif
  75. #if ! U_HAVE_UINT8_T
  76. typedef unsigned char uint8_t;
  77. #endif
  78. #if ! U_HAVE_INT16_T
  79. typedef signed short int16_t;
  80. #endif
  81. #if ! U_HAVE_UINT16_T
  82. typedef unsigned short uint16_t;
  83. #endif
  84. #if ! U_HAVE_INT32_T
  85. typedef signed int int32_t;
  86. #endif
  87. #if ! U_HAVE_UINT32_T
  88. typedef unsigned int uint32_t;
  89. #endif
  90. #if ! U_HAVE_INT64_T
  91. #ifdef _MSC_VER
  92. typedef signed __int64 int64_t;
  93. #else
  94. typedef signed long long int64_t;
  95. #endif
  96. #endif
  97. #if ! U_HAVE_UINT64_T
  98. #ifdef _MSC_VER
  99. typedef unsigned __int64 uint64_t;
  100. #else
  101. typedef unsigned long long uint64_t;
  102. #endif
  103. #endif
  104. #endif /* U_HAVE_STDINT_H / U_HAVE_INTTYPES_H */
  105. #endif /* _PTYPES_H */