types.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #pragma once
  2. // DO_NOT_STYLE
  3. #include "platform.h"
  4. #include <inttypes.h>
  5. typedef int8_t i8;
  6. typedef int16_t i16;
  7. typedef uint8_t ui8;
  8. typedef uint16_t ui16;
  9. typedef int yssize_t;
  10. #define PRIYSZT "d"
  11. #if defined(_darwin_) && defined(_32_)
  12. typedef unsigned long ui32;
  13. typedef long i32;
  14. #else
  15. typedef uint32_t ui32;
  16. typedef int32_t i32;
  17. #endif
  18. #if defined(_darwin_) && defined(_64_)
  19. typedef unsigned long ui64;
  20. typedef long i64;
  21. #else
  22. typedef uint64_t ui64;
  23. typedef int64_t i64;
  24. #endif
  25. #define LL(number) INT64_C(number)
  26. #define ULL(number) UINT64_C(number)
  27. // Macro for size_t and ptrdiff_t types
  28. #if defined(_32_)
  29. #if defined(_darwin_)
  30. #define PRISZT "lu"
  31. #undef PRIi32
  32. #define PRIi32 "li"
  33. #undef SCNi32
  34. #define SCNi32 "li"
  35. #undef PRId32
  36. #define PRId32 "li"
  37. #undef SCNd32
  38. #define SCNd32 "li"
  39. #undef PRIu32
  40. #define PRIu32 "lu"
  41. #undef SCNu32
  42. #define SCNu32 "lu"
  43. #undef PRIx32
  44. #define PRIx32 "lx"
  45. #undef SCNx32
  46. #define SCNx32 "lx"
  47. #elif !defined(_cygwin_)
  48. #define PRISZT PRIu32
  49. #else
  50. #define PRISZT "u"
  51. #endif
  52. #define SCNSZT SCNu32
  53. #define PRIPDT PRIi32
  54. #define SCNPDT SCNi32
  55. #define PRITMT PRIi32
  56. #define SCNTMT SCNi32
  57. #elif defined(_64_)
  58. #if defined(_darwin_) || defined(_emscripten_)
  59. #define PRISZT "lu"
  60. #undef PRIu64
  61. #define PRIu64 PRISZT
  62. #undef PRIx64
  63. #define PRIx64 "lx"
  64. #undef PRIX64
  65. #define PRIX64 "lX"
  66. #undef PRId64
  67. #define PRId64 "ld"
  68. #undef PRIi64
  69. #define PRIi64 "li"
  70. #undef SCNi64
  71. #define SCNi64 "li"
  72. #undef SCNu64
  73. #define SCNu64 "lu"
  74. #undef SCNx64
  75. #define SCNx64 "lx"
  76. #else
  77. #define PRISZT PRIu64
  78. #endif
  79. #define SCNSZT SCNu64
  80. #define PRIPDT PRIi64
  81. #define SCNPDT SCNi64
  82. #define PRITMT PRIi64
  83. #define SCNTMT SCNi64
  84. #else
  85. #error "Unsupported platform"
  86. #endif
  87. // SUPERLONG
  88. #if !defined(DONT_USE_SUPERLONG) && !defined(SUPERLONG_MAX)
  89. #define SUPERLONG_MAX ~LL(0)
  90. typedef i64 SUPERLONG;
  91. #endif
  92. // UNICODE
  93. #ifdef __cplusplus
  94. // UCS-2, native byteorder
  95. typedef char16_t wchar16;
  96. // internal symbol type: UTF-16LE
  97. typedef wchar16 TChar;
  98. typedef char32_t wchar32;
  99. #endif
  100. #if defined(_MSC_VER)
  101. #include <basetsd.h>
  102. typedef SSIZE_T ssize_t;
  103. #define HAVE_SSIZE_T 1
  104. #include <wchar.h>
  105. #endif
  106. #include <sys/types.h>
  107. // for pb.h/cc
  108. typedef i32 arc_i32;
  109. typedef i64 arc_i64;
  110. typedef ui32 arc_ui32;
  111. typedef ui64 arc_ui64;