ptypes.h 3.4 KB

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