snowflake-connector-python 5.2.0__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. snowflake/connector/__init__.py +148 -0
  2. snowflake/connector/_common/__init__.py +0 -0
  3. snowflake/connector/_common/extras.py +134 -0
  4. snowflake/connector/_common/telemetry.py +221 -0
  5. snowflake/connector/_common/wif_util.py +92 -0
  6. snowflake/connector/_core/sf_core_python.cp315-win_amd64.pyd +0 -0
  7. snowflake/connector/_core/sf_core_python.pyi +79 -0
  8. snowflake/connector/_internal/__init__.py +6 -0
  9. snowflake/connector/_internal/_private_key_helper.py +31 -0
  10. snowflake/connector/_internal/api_client/__init__.py +93 -0
  11. snowflake/connector/_internal/api_client/bridge.py +41 -0
  12. snowflake/connector/_internal/api_client/client_api.py +976 -0
  13. snowflake/connector/_internal/arrow.py +47 -0
  14. snowflake/connector/_internal/arrow_context.py +240 -0
  15. snowflake/connector/_internal/arrow_stream_async.py +266 -0
  16. snowflake/connector/_internal/arrow_stream_iterator.cp311-win_amd64.pyd +0 -0
  17. snowflake/connector/_internal/arrow_stream_iterator.cp312-win_amd64.pyd +0 -0
  18. snowflake/connector/_internal/arrow_stream_iterator.cp313-win_amd64.pyd +0 -0
  19. snowflake/connector/_internal/arrow_stream_iterator.cp314-win_amd64.pyd +0 -0
  20. snowflake/connector/_internal/arrow_stream_iterator.cp314t-win_amd64.pyd +0 -0
  21. snowflake/connector/_internal/arrow_stream_iterator.cp315-win_amd64.pyd +0 -0
  22. snowflake/connector/_internal/arrow_stream_iterator.pyi +42 -0
  23. snowflake/connector/_internal/arrow_stream_utils.py +171 -0
  24. snowflake/connector/_internal/authenticator_type.py +53 -0
  25. snowflake/connector/_internal/backward_compatibility.py +245 -0
  26. snowflake/connector/_internal/binding_converters.py +741 -0
  27. snowflake/connector/_internal/config_utils.py +71 -0
  28. snowflake/connector/_internal/connection/__init__.py +39 -0
  29. snowflake/connector/_internal/connection/connection.py +616 -0
  30. snowflake/connector/_internal/connection/connection_types.py +13 -0
  31. snowflake/connector/_internal/connection/constants.py +25 -0
  32. snowflake/connector/_internal/connection/decorators.py +31 -0
  33. snowflake/connector/_internal/connection/freezable_proxy.py +104 -0
  34. snowflake/connector/_internal/connection/queries.py +10 -0
  35. snowflake/connector/_internal/connection_config_mixin.py +755 -0
  36. snowflake/connector/_internal/cursor/__init__.py +25 -0
  37. snowflake/connector/_internal/cursor/base.py +732 -0
  38. snowflake/connector/_internal/cursor/cursor_types.py +13 -0
  39. snowflake/connector/_internal/cursor/decorators.py +56 -0
  40. snowflake/connector/_internal/cursor/query_result.py +202 -0
  41. snowflake/connector/_internal/cursor/query_result_waiter.py +98 -0
  42. snowflake/connector/_internal/cursor/result_metadata.py +255 -0
  43. snowflake/connector/_internal/cursor/result_set_wrapper.py +66 -0
  44. snowflake/connector/_internal/decorators.py +539 -0
  45. snowflake/connector/_internal/error_kinds.py +111 -0
  46. snowflake/connector/_internal/errorcode.py +35 -0
  47. snowflake/connector/_internal/errorhandler.py +278 -0
  48. snowflake/connector/_internal/fips.py +28 -0
  49. snowflake/connector/_internal/logging/__init__.py +52 -0
  50. snowflake/connector/_internal/logging/config.py +134 -0
  51. snowflake/connector/_internal/logging/core_logger.py +218 -0
  52. snowflake/connector/_internal/logging/native_extension_logger.py +144 -0
  53. snowflake/connector/_internal/logout_config_mapping.py +187 -0
  54. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +57 -0
  55. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
  56. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.cpp +943 -0
  57. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.hpp +63 -0
  58. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +18 -0
  59. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
  60. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
  61. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
  62. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +118 -0
  63. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +116 -0
  64. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.cpp +323 -0
  65. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.hpp +133 -0
  66. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.cpp +275 -0
  67. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.hpp +168 -0
  68. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.cpp +439 -0
  69. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.hpp +30 -0
  70. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +48 -0
  71. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
  72. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +76 -0
  73. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
  74. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +90 -0
  75. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +63 -0
  76. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +62 -0
  77. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
  78. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +29 -0
  79. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
  80. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
  81. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
  82. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +41 -0
  83. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +65 -0
  84. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +54 -0
  85. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
  86. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +79 -0
  87. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
  88. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +52 -0
  89. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
  90. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
  91. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +117 -0
  92. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +54 -0
  93. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +34 -0
  94. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +33 -0
  95. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
  96. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +18 -0
  97. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
  98. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +39 -0
  99. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
  100. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +326 -0
  101. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +138 -0
  102. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
  103. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
  104. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
  105. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.cpp +13278 -0
  106. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.pyx +204 -0
  107. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +109 -0
  108. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +125 -0
  109. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
  110. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1914 -0
  111. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +208 -0
  112. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +128 -0
  113. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
  114. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +58 -0
  115. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +144 -0
  116. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
  117. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
  118. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
  119. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +160 -0
  120. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +98 -0
  121. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +243 -0
  122. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
  123. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +207 -0
  124. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +80 -0
  125. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +83 -0
  126. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
  127. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
  128. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +201 -0
  129. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +108 -0
  130. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
  131. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
  132. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
  133. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
  134. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
  135. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +164 -0
  136. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +926 -0
  137. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +182 -0
  138. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
  139. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
  140. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc.c +3052 -0
  141. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3019 -0
  142. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3354 -0
  143. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +344 -0
  144. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +29305 -0
  145. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +381 -0
  146. snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.cpp +108 -0
  147. snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.hpp +47 -0
  148. snowflake/connector/_internal/nanoarrow_cpp/scripts/.clang-format +8 -0
  149. snowflake/connector/_internal/nanoarrow_cpp/scripts/format.sh +8 -0
  150. snowflake/connector/_internal/protobuf_gen/__init__.py +0 -0
  151. snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.py +408 -0
  152. snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.pyi +4487 -0
  153. snowflake/connector/_internal/protobuf_gen/database_driver_v1_services.py +2088 -0
  154. snowflake/connector/_internal/protobuf_gen/proto_exception.py +17 -0
  155. snowflake/connector/_internal/result_batch.py +150 -0
  156. snowflake/connector/_internal/snowflake_restful.py +222 -0
  157. snowflake/connector/_internal/snowpark_backcompat_helpers.py +31 -0
  158. snowflake/connector/_internal/sqlstate.py +11 -0
  159. snowflake/connector/_internal/statement_utils.py +207 -0
  160. snowflake/connector/_internal/text_utils.py +112 -0
  161. snowflake/connector/_internal/type_codes.py +139 -0
  162. snowflake/connector/_internal/utils.py +65 -0
  163. snowflake/connector/_internal/write_pandas_operation.py +657 -0
  164. snowflake/connector/aio/README.md +168 -0
  165. snowflake/connector/aio/__init__.py +37 -0
  166. snowflake/connector/aio/connection/__init__.py +17 -0
  167. snowflake/connector/aio/connection/_connection.py +506 -0
  168. snowflake/connector/aio/cursor/__init__.py +35 -0
  169. snowflake/connector/aio/cursor/_base.py +1034 -0
  170. snowflake/connector/aio/cursor/_dict_cursor.py +78 -0
  171. snowflake/connector/aio/cursor/_result_set_wrapper.py +35 -0
  172. snowflake/connector/aio/cursor/_snowflake_cursor.py +72 -0
  173. snowflake/connector/aio/pandas_tools.py +279 -0
  174. snowflake/connector/aio/result_batch.py +165 -0
  175. snowflake/connector/auth/__init__.py +0 -0
  176. snowflake/connector/auth/workload_identity.py +5 -0
  177. snowflake/connector/compat.py +22 -0
  178. snowflake/connector/config_manager.py +392 -0
  179. snowflake/connector/connection/__init__.py +30 -0
  180. snowflake/connector/connection/_connection.py +641 -0
  181. snowflake/connector/connection_config.py +517 -0
  182. snowflake/connector/constants.py +52 -0
  183. snowflake/connector/cursor/__init__.py +37 -0
  184. snowflake/connector/cursor/_base.py +1169 -0
  185. snowflake/connector/cursor/_chunked_download_reader.py +75 -0
  186. snowflake/connector/cursor/_dict_cursor.py +78 -0
  187. snowflake/connector/cursor/_result_set_wrapper.py +35 -0
  188. snowflake/connector/cursor/_snowflake_cursor.py +72 -0
  189. snowflake/connector/description.py +7 -0
  190. snowflake/connector/errors.py +492 -0
  191. snowflake/connector/network.py +71 -0
  192. snowflake/connector/pandas_tools.py +191 -0
  193. snowflake/connector/py.typed +0 -0
  194. snowflake/connector/result_batch.py +216 -0
  195. snowflake/connector/telemetry.py +40 -0
  196. snowflake/connector/time_util.py +11 -0
  197. snowflake/connector/types.py +134 -0
  198. snowflake/connector/util_text.py +3 -0
  199. snowflake/connector/version.py +23 -0
  200. snowflake_connector_python-5.2.0.dist-info/DELVEWHEEL +2 -0
  201. snowflake_connector_python-5.2.0.dist-info/METADATA +190 -0
  202. snowflake_connector_python-5.2.0.dist-info/RECORD +204 -0
  203. snowflake_connector_python-5.2.0.dist-info/WHEEL +4 -0
  204. snowflake_connector_python.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
@@ -0,0 +1,926 @@
1
+ /* A portable stdint.h
2
+ ****************************************************************************
3
+ * BSD License:
4
+ ****************************************************************************
5
+ *
6
+ * Copyright (c) 2005-2016 Paul Hsieh
7
+ * All rights reserved.
8
+ *
9
+ * Redistribution and use in source and binary forms, with or without
10
+ * modification, are permitted provided that the following conditions
11
+ * are met:
12
+ *
13
+ * 1. Redistributions of source code must retain the above copyright
14
+ * notice, this list of conditions and the following disclaimer.
15
+ * 2. Redistributions in binary form must reproduce the above copyright
16
+ * notice, this list of conditions and the following disclaimer in the
17
+ * documentation and/or other materials provided with the distribution.
18
+ * 3. The name of the author may not be used to endorse or promote products
19
+ * derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ ****************************************************************************
33
+ *
34
+ * Version 0.1.15.2
35
+ *
36
+ * The ANSI C standard committee, for the C99 standard, specified the
37
+ * inclusion of a new standard include file called stdint.h. This is
38
+ * a very useful and long desired include file which contains several
39
+ * very precise definitions for integer scalar types that is
40
+ * critically important for making portable several classes of
41
+ * applications including cryptography, hashing, variable length
42
+ * integer libraries and so on. But for most developers its likely
43
+ * useful just for programming sanity.
44
+ *
45
+ * The problem is that some compiler vendors chose to ignore the C99
46
+ * standard and some older compilers have no opportunity to be updated.
47
+ * Because of this situation, simply including stdint.h in your code
48
+ * makes it unportable.
49
+ *
50
+ * So that's what this file is all about. Its an attempt to build a
51
+ * single universal include file that works on as many platforms as
52
+ * possible to deliver what stdint.h is supposed to. Even compilers
53
+ * that already come with stdint.h can use this file instead without
54
+ * any loss of functionality. A few things that should be noted about
55
+ * this file:
56
+ *
57
+ * 1) It is not guaranteed to be portable and/or present an identical
58
+ * interface on all platforms. The extreme variability of the
59
+ * ANSI C standard makes this an impossibility right from the
60
+ * very get go. Its really only meant to be useful for the vast
61
+ * majority of platforms that possess the capability of
62
+ * implementing usefully and precisely defined, standard sized
63
+ * integer scalars. Systems which are not intrinsically 2s
64
+ * complement may produce invalid constants.
65
+ *
66
+ * 2) There is an unavoidable use of non-reserved symbols.
67
+ *
68
+ * 3) Other standard include files are invoked.
69
+ *
70
+ * 4) This file may come in conflict with future platforms that do
71
+ * include stdint.h. The hope is that one or the other can be
72
+ * used with no real difference.
73
+ *
74
+ * 5) In the current verison, if your platform can't represent
75
+ * int32_t, int16_t and int8_t, it just dumps out with a compiler
76
+ * error.
77
+ *
78
+ * 6) 64 bit integers may or may not be defined. Test for their
79
+ * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
80
+ * Note that this is different from the C99 specification which
81
+ * requires the existence of 64 bit support in the compiler. If
82
+ * this is not defined for your platform, yet it is capable of
83
+ * dealing with 64 bits then it is because this file has not yet
84
+ * been extended to cover all of your system's capabilities.
85
+ *
86
+ * 7) (u)intptr_t may or may not be defined. Test for its presence
87
+ * with the test: #ifdef PTRDIFF_MAX. If this is not defined
88
+ * for your platform, then it is because this file has not yet
89
+ * been extended to cover all of your system's capabilities, not
90
+ * because its optional.
91
+ *
92
+ * 8) The following might not been defined even if your platform is
93
+ * capable of defining it:
94
+ *
95
+ * WCHAR_MIN
96
+ * WCHAR_MAX
97
+ * (u)int64_t
98
+ * PTRDIFF_MIN
99
+ * PTRDIFF_MAX
100
+ * (u)intptr_t
101
+ *
102
+ * 9) The following have not been defined:
103
+ *
104
+ * WINT_MIN
105
+ * WINT_MAX
106
+ *
107
+ * 10) The criteria for defining (u)int_least(*)_t isn't clear,
108
+ * except for systems which don't have a type that precisely
109
+ * defined 8, 16, or 32 bit types (which this include file does
110
+ * not support anyways). Default definitions have been given.
111
+ *
112
+ * 11) The criteria for defining (u)int_fast(*)_t isn't something I
113
+ * would trust to any particular compiler vendor or the ANSI C
114
+ * committee. It is well known that "compatible systems" are
115
+ * commonly created that have very different performance
116
+ * characteristics from the systems they are compatible with,
117
+ * especially those whose vendors make both the compiler and the
118
+ * system. Default definitions have been given, but its strongly
119
+ * recommended that users never use these definitions for any
120
+ * reason (they do *NOT* deliver any serious guarantee of
121
+ * improved performance -- not in this file, nor any vendor's
122
+ * stdint.h).
123
+ *
124
+ * 12) The following macros:
125
+ *
126
+ * PRINTF_INTMAX_MODIFIER
127
+ * PRINTF_INT64_MODIFIER
128
+ * PRINTF_INT32_MODIFIER
129
+ * PRINTF_INT16_MODIFIER
130
+ * PRINTF_LEAST64_MODIFIER
131
+ * PRINTF_LEAST32_MODIFIER
132
+ * PRINTF_LEAST16_MODIFIER
133
+ * PRINTF_INTPTR_MODIFIER
134
+ *
135
+ * are strings which have been defined as the modifiers required
136
+ * for the "d", "u" and "x" printf formats to correctly output
137
+ * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
138
+ * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
139
+ * PRINTF_INTPTR_MODIFIER is not defined for some systems which
140
+ * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
141
+ * defined if INT64_MAX is not defined. These are an extension
142
+ * beyond what C99 specifies must be in stdint.h.
143
+ *
144
+ * In addition, the following macros are defined:
145
+ *
146
+ * PRINTF_INTMAX_HEX_WIDTH
147
+ * PRINTF_INT64_HEX_WIDTH
148
+ * PRINTF_INT32_HEX_WIDTH
149
+ * PRINTF_INT16_HEX_WIDTH
150
+ * PRINTF_INT8_HEX_WIDTH
151
+ * PRINTF_INTMAX_DEC_WIDTH
152
+ * PRINTF_INT64_DEC_WIDTH
153
+ * PRINTF_INT32_DEC_WIDTH
154
+ * PRINTF_INT16_DEC_WIDTH
155
+ * PRINTF_UINT8_DEC_WIDTH
156
+ * PRINTF_UINTMAX_DEC_WIDTH
157
+ * PRINTF_UINT64_DEC_WIDTH
158
+ * PRINTF_UINT32_DEC_WIDTH
159
+ * PRINTF_UINT16_DEC_WIDTH
160
+ * PRINTF_UINT8_DEC_WIDTH
161
+ *
162
+ * Which specifies the maximum number of characters required to
163
+ * print the number of that type in either hexadecimal or decimal.
164
+ * These are an extension beyond what C99 specifies must be in
165
+ * stdint.h.
166
+ *
167
+ * Compilers tested (all with 0 warnings at their highest respective
168
+ * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
169
+ * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
170
+ * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
171
+ *
172
+ * This file should be considered a work in progress. Suggestions for
173
+ * improvements, especially those which increase coverage are strongly
174
+ * encouraged.
175
+ *
176
+ * Acknowledgements
177
+ *
178
+ * The following people have made significant contributions to the
179
+ * development and testing of this file:
180
+ *
181
+ * Chris Howie
182
+ * John Steele Scott
183
+ * Dave Thorup
184
+ * John Dill
185
+ * Florian Wobbe
186
+ * Christopher Sean Morrison
187
+ * Mikkel Fahnoe Jorgensen
188
+ *
189
+ */
190
+
191
+ #include <limits.h>
192
+ #include <signal.h>
193
+ #include <stddef.h>
194
+
195
+ /*
196
+ * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
197
+ * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
198
+ */
199
+
200
+ #if ((defined(_MSC_VER) && _MSC_VER >= 1600) || \
201
+ (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && \
202
+ __STDC_VERSION__ >= 199901L) || \
203
+ (defined(__WATCOMC__) && (defined(_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || \
204
+ (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || \
205
+ defined(__UINT_FAST64_TYPE__)))) && \
206
+ !defined(_PSTDINT_H_INCLUDED)
207
+ #include <stdint.h>
208
+ #define _PSTDINT_H_INCLUDED
209
+ #if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && \
210
+ !(defined(__APPLE__) && defined(__MACH__))
211
+ #ifndef PRINTF_INT64_MODIFIER
212
+ #define PRINTF_INT64_MODIFIER "l"
213
+ #endif
214
+ #ifndef PRINTF_INT32_MODIFIER
215
+ #define PRINTF_INT32_MODIFIER ""
216
+ #endif
217
+ #else
218
+ #ifndef PRINTF_INT64_MODIFIER
219
+ #define PRINTF_INT64_MODIFIER "ll"
220
+ #endif
221
+ #ifndef PRINTF_INT32_MODIFIER
222
+ #if (UINT_MAX == UINT32_MAX)
223
+ #define PRINTF_INT32_MODIFIER ""
224
+ #else
225
+ #define PRINTF_INT32_MODIFIER "l"
226
+ #endif
227
+ #endif
228
+ #endif
229
+ #ifndef PRINTF_INT16_MODIFIER
230
+ #define PRINTF_INT16_MODIFIER "h"
231
+ #endif
232
+ #ifndef PRINTF_INTMAX_MODIFIER
233
+ #define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
234
+ #endif
235
+ #ifndef PRINTF_INT64_HEX_WIDTH
236
+ #define PRINTF_INT64_HEX_WIDTH "16"
237
+ #endif
238
+ #ifndef PRINTF_UINT64_HEX_WIDTH
239
+ #define PRINTF_UINT64_HEX_WIDTH "16"
240
+ #endif
241
+ #ifndef PRINTF_INT32_HEX_WIDTH
242
+ #define PRINTF_INT32_HEX_WIDTH "8"
243
+ #endif
244
+ #ifndef PRINTF_UINT32_HEX_WIDTH
245
+ #define PRINTF_UINT32_HEX_WIDTH "8"
246
+ #endif
247
+ #ifndef PRINTF_INT16_HEX_WIDTH
248
+ #define PRINTF_INT16_HEX_WIDTH "4"
249
+ #endif
250
+ #ifndef PRINTF_UINT16_HEX_WIDTH
251
+ #define PRINTF_UINT16_HEX_WIDTH "4"
252
+ #endif
253
+ #ifndef PRINTF_INT8_HEX_WIDTH
254
+ #define PRINTF_INT8_HEX_WIDTH "2"
255
+ #endif
256
+ #ifndef PRINTF_UINT8_HEX_WIDTH
257
+ #define PRINTF_UINT8_HEX_WIDTH "2"
258
+ #endif
259
+ #ifndef PRINTF_INT64_DEC_WIDTH
260
+ #define PRINTF_INT64_DEC_WIDTH "19"
261
+ #endif
262
+ #ifndef PRINTF_UINT64_DEC_WIDTH
263
+ #define PRINTF_UINT64_DEC_WIDTH "20"
264
+ #endif
265
+ #ifndef PRINTF_INT32_DEC_WIDTH
266
+ #define PRINTF_INT32_DEC_WIDTH "10"
267
+ #endif
268
+ #ifndef PRINTF_UINT32_DEC_WIDTH
269
+ #define PRINTF_UINT32_DEC_WIDTH "10"
270
+ #endif
271
+ #ifndef PRINTF_INT16_DEC_WIDTH
272
+ #define PRINTF_INT16_DEC_WIDTH "5"
273
+ #endif
274
+ #ifndef PRINTF_UINT16_DEC_WIDTH
275
+ #define PRINTF_UINT16_DEC_WIDTH "5"
276
+ #endif
277
+ #ifndef PRINTF_INT8_DEC_WIDTH
278
+ #define PRINTF_INT8_DEC_WIDTH "3"
279
+ #endif
280
+ #ifndef PRINTF_UINT8_DEC_WIDTH
281
+ #define PRINTF_UINT8_DEC_WIDTH "3"
282
+ #endif
283
+ #ifndef PRINTF_INTMAX_HEX_WIDTH
284
+ #define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
285
+ #endif
286
+ #ifndef PRINTF_UINTMAX_HEX_WIDTH
287
+ #define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
288
+ #endif
289
+ #ifndef PRINTF_INTMAX_DEC_WIDTH
290
+ #define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
291
+ #endif
292
+ #ifndef PRINTF_UINTMAX_DEC_WIDTH
293
+ #define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
294
+ #endif
295
+
296
+ /*
297
+ * Something really weird is going on with Open Watcom. Just pull some of
298
+ * these duplicated definitions from Open Watcom's stdint.h file for now.
299
+ */
300
+
301
+ #if defined(__WATCOMC__) && __WATCOMC__ >= 1250
302
+ #if !defined(INT64_C)
303
+ #define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
304
+ #endif
305
+ #if !defined(UINT64_C)
306
+ #define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
307
+ #endif
308
+ #if !defined(INT32_C)
309
+ #define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
310
+ #endif
311
+ #if !defined(UINT32_C)
312
+ #define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
313
+ #endif
314
+ #if !defined(INT16_C)
315
+ #define INT16_C(x) (x)
316
+ #endif
317
+ #if !defined(UINT16_C)
318
+ #define UINT16_C(x) (x)
319
+ #endif
320
+ #if !defined(INT8_C)
321
+ #define INT8_C(x) (x)
322
+ #endif
323
+ #if !defined(UINT8_C)
324
+ #define UINT8_C(x) (x)
325
+ #endif
326
+ #if !defined(UINT64_MAX)
327
+ #define UINT64_MAX 18446744073709551615ULL
328
+ #endif
329
+ #if !defined(INT64_MAX)
330
+ #define INT64_MAX 9223372036854775807LL
331
+ #endif
332
+ #if !defined(UINT32_MAX)
333
+ #define UINT32_MAX 4294967295UL
334
+ #endif
335
+ #if !defined(INT32_MAX)
336
+ #define INT32_MAX 2147483647L
337
+ #endif
338
+ #if !defined(INTMAX_MAX)
339
+ #define INTMAX_MAX INT64_MAX
340
+ #endif
341
+ #if !defined(INTMAX_MIN)
342
+ #define INTMAX_MIN INT64_MIN
343
+ #endif
344
+ #endif
345
+ #endif
346
+
347
+ #ifndef _PSTDINT_H_INCLUDED
348
+ #define _PSTDINT_H_INCLUDED
349
+
350
+ #ifndef SIZE_MAX
351
+ #define SIZE_MAX (~(size_t)0)
352
+ #endif
353
+
354
+ /*
355
+ * Deduce the type assignments from limits.h under the assumption that
356
+ * integer sizes in bits are powers of 2, and follow the ANSI
357
+ * definitions.
358
+ */
359
+
360
+ #ifndef UINT8_MAX
361
+ #define UINT8_MAX 0xff
362
+ #endif
363
+ #if !defined(uint8_t) && !defined(_UINT8_T)
364
+ #if (UCHAR_MAX == UINT8_MAX) || defined(S_SPLINT_S)
365
+ typedef unsigned char uint8_t;
366
+ #define UINT8_C(v) ((uint8_t)v)
367
+ #else
368
+ #error "Platform not supported"
369
+ #endif
370
+ #endif
371
+
372
+ #ifndef INT8_MAX
373
+ #define INT8_MAX 0x7f
374
+ #endif
375
+ #ifndef INT8_MIN
376
+ #define INT8_MIN INT8_C(0x80)
377
+ #endif
378
+ #if !defined(int8_t) && !defined(_INT8_T)
379
+ #if (SCHAR_MAX == INT8_MAX) || defined(S_SPLINT_S)
380
+ typedef signed char int8_t;
381
+ #define INT8_C(v) ((int8_t)v)
382
+ #else
383
+ #error "Platform not supported"
384
+ #endif
385
+ #endif
386
+
387
+ #ifndef UINT16_MAX
388
+ #define UINT16_MAX 0xffff
389
+ #endif
390
+ #if !defined(uint16_t) && !defined(_UINT16_T)
391
+ #if (UINT_MAX == UINT16_MAX) || defined(S_SPLINT_S)
392
+ typedef unsigned int uint16_t;
393
+ #ifndef PRINTF_INT16_MODIFIER
394
+ #define PRINTF_INT16_MODIFIER ""
395
+ #endif
396
+ #define UINT16_C(v) ((uint16_t)(v))
397
+ #elif (USHRT_MAX == UINT16_MAX)
398
+ typedef unsigned short uint16_t;
399
+ #define UINT16_C(v) ((uint16_t)(v))
400
+ #ifndef PRINTF_INT16_MODIFIER
401
+ #define PRINTF_INT16_MODIFIER "h"
402
+ #endif
403
+ #else
404
+ #error "Platform not supported"
405
+ #endif
406
+ #endif
407
+
408
+ #ifndef INT16_MAX
409
+ #define INT16_MAX 0x7fff
410
+ #endif
411
+ #ifndef INT16_MIN
412
+ #define INT16_MIN INT16_C(0x8000)
413
+ #endif
414
+ #if !defined(int16_t) && !defined(_INT16_T)
415
+ #if (INT_MAX == INT16_MAX) || defined(S_SPLINT_S)
416
+ typedef signed int int16_t;
417
+ #define INT16_C(v) ((int16_t)(v))
418
+ #ifndef PRINTF_INT16_MODIFIER
419
+ #define PRINTF_INT16_MODIFIER ""
420
+ #endif
421
+ #elif (SHRT_MAX == INT16_MAX)
422
+ typedef signed short int16_t;
423
+ #define INT16_C(v) ((int16_t)(v))
424
+ #ifndef PRINTF_INT16_MODIFIER
425
+ #define PRINTF_INT16_MODIFIER "h"
426
+ #endif
427
+ #else
428
+ #error "Platform not supported"
429
+ #endif
430
+ #endif
431
+
432
+ #ifndef UINT32_MAX
433
+ #define UINT32_MAX (0xffffffffUL)
434
+ #endif
435
+ #if !defined(uint32_t) && !defined(_UINT32_T)
436
+ #if (ULONG_MAX == UINT32_MAX) || defined(S_SPLINT_S)
437
+ typedef unsigned long uint32_t;
438
+ #define UINT32_C(v) v##UL
439
+ #ifndef PRINTF_INT32_MODIFIER
440
+ #define PRINTF_INT32_MODIFIER "l"
441
+ #endif
442
+ #elif (UINT_MAX == UINT32_MAX)
443
+ typedef unsigned int uint32_t;
444
+ #ifndef PRINTF_INT32_MODIFIER
445
+ #define PRINTF_INT32_MODIFIER ""
446
+ #endif
447
+ #define UINT32_C(v) v##U
448
+ #elif (USHRT_MAX == UINT32_MAX)
449
+ typedef unsigned short uint32_t;
450
+ #define UINT32_C(v) ((unsigned short)(v))
451
+ #ifndef PRINTF_INT32_MODIFIER
452
+ #define PRINTF_INT32_MODIFIER ""
453
+ #endif
454
+ #else
455
+ #error "Platform not supported"
456
+ #endif
457
+ #endif
458
+
459
+ #ifndef INT32_MAX
460
+ #define INT32_MAX (0x7fffffffL)
461
+ #endif
462
+ #ifndef INT32_MIN
463
+ #define INT32_MIN INT32_C(0x80000000)
464
+ #endif
465
+ #if !defined(int32_t) && !defined(_INT32_T)
466
+ #if (LONG_MAX == INT32_MAX) || defined(S_SPLINT_S)
467
+ typedef signed long int32_t;
468
+ #define INT32_C(v) v##L
469
+ #ifndef PRINTF_INT32_MODIFIER
470
+ #define PRINTF_INT32_MODIFIER "l"
471
+ #endif
472
+ #elif (INT_MAX == INT32_MAX)
473
+ typedef signed int int32_t;
474
+ #define INT32_C(v) v
475
+ #ifndef PRINTF_INT32_MODIFIER
476
+ #define PRINTF_INT32_MODIFIER ""
477
+ #endif
478
+ #elif (SHRT_MAX == INT32_MAX)
479
+ typedef signed short int32_t;
480
+ #define INT32_C(v) ((short)(v))
481
+ #ifndef PRINTF_INT32_MODIFIER
482
+ #define PRINTF_INT32_MODIFIER ""
483
+ #endif
484
+ #else
485
+ #error "Platform not supported"
486
+ #endif
487
+ #endif
488
+
489
+ /*
490
+ * The macro stdint_int64_defined is temporarily used to record
491
+ * whether or not 64 integer support is available. It must be
492
+ * defined for any 64 integer extensions for new platforms that are
493
+ * added.
494
+ */
495
+
496
+ #undef stdint_int64_defined
497
+ #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined(S_SPLINT_S)
498
+ #if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined(S_SPLINT_S)
499
+ #define stdint_int64_defined
500
+ typedef long long int64_t;
501
+ typedef unsigned long long uint64_t;
502
+ #define UINT64_C(v) v##ULL
503
+ #define INT64_C(v) v##LL
504
+ #ifndef PRINTF_INT64_MODIFIER
505
+ #define PRINTF_INT64_MODIFIER "ll"
506
+ #endif
507
+ #endif
508
+ #endif
509
+
510
+ #if !defined(stdint_int64_defined)
511
+ #if defined(__GNUC__)
512
+ #define stdint_int64_defined
513
+ __extension__ typedef long long int64_t;
514
+ __extension__ typedef unsigned long long uint64_t;
515
+ #define UINT64_C(v) v##ULL
516
+ #define INT64_C(v) v##LL
517
+ #ifndef PRINTF_INT64_MODIFIER
518
+ #define PRINTF_INT64_MODIFIER "ll"
519
+ #endif
520
+ #elif defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || \
521
+ defined(__APPLE_CC__) || defined(_LONG_LONG) || defined(_CRAYC) || defined(S_SPLINT_S)
522
+ #define stdint_int64_defined
523
+ typedef long long int64_t;
524
+ typedef unsigned long long uint64_t;
525
+ #define UINT64_C(v) v##ULL
526
+ #define INT64_C(v) v##LL
527
+ #ifndef PRINTF_INT64_MODIFIER
528
+ #define PRINTF_INT64_MODIFIER "ll"
529
+ #endif
530
+ #elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || \
531
+ (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || \
532
+ (defined(__BORLANDC__) && __BORLANDC__ > 0x460) || defined(__alpha) || defined(__DECC)
533
+ #define stdint_int64_defined
534
+ typedef __int64 int64_t;
535
+ typedef unsigned __int64 uint64_t;
536
+ #define UINT64_C(v) v##UI64
537
+ #define INT64_C(v) v##I64
538
+ #ifndef PRINTF_INT64_MODIFIER
539
+ #define PRINTF_INT64_MODIFIER "I64"
540
+ #endif
541
+ #endif
542
+ #endif
543
+
544
+ #if !defined(LONG_LONG_MAX) && defined(INT64_C)
545
+ #define LONG_LONG_MAX INT64_C(9223372036854775807)
546
+ #endif
547
+ #ifndef ULONG_LONG_MAX
548
+ #define ULONG_LONG_MAX UINT64_C(18446744073709551615)
549
+ #endif
550
+
551
+ #if !defined(INT64_MAX) && defined(INT64_C)
552
+ #define INT64_MAX INT64_C(9223372036854775807)
553
+ #endif
554
+ #if !defined(INT64_MIN) && defined(INT64_C)
555
+ #define INT64_MIN INT64_C(-9223372036854775808)
556
+ #endif
557
+ #if !defined(UINT64_MAX) && defined(INT64_C)
558
+ #define UINT64_MAX UINT64_C(18446744073709551615)
559
+ #endif
560
+
561
+ /*
562
+ * Width of hexadecimal for number field.
563
+ */
564
+
565
+ #ifndef PRINTF_INT64_HEX_WIDTH
566
+ #define PRINTF_INT64_HEX_WIDTH "16"
567
+ #endif
568
+ #ifndef PRINTF_INT32_HEX_WIDTH
569
+ #define PRINTF_INT32_HEX_WIDTH "8"
570
+ #endif
571
+ #ifndef PRINTF_INT16_HEX_WIDTH
572
+ #define PRINTF_INT16_HEX_WIDTH "4"
573
+ #endif
574
+ #ifndef PRINTF_INT8_HEX_WIDTH
575
+ #define PRINTF_INT8_HEX_WIDTH "2"
576
+ #endif
577
+ #ifndef PRINTF_INT64_DEC_WIDTH
578
+ #define PRINTF_INT64_DEC_WIDTH "19"
579
+ #endif
580
+ #ifndef PRINTF_INT32_DEC_WIDTH
581
+ #define PRINTF_INT32_DEC_WIDTH "10"
582
+ #endif
583
+ #ifndef PRINTF_INT16_DEC_WIDTH
584
+ #define PRINTF_INT16_DEC_WIDTH "5"
585
+ #endif
586
+ #ifndef PRINTF_INT8_DEC_WIDTH
587
+ #define PRINTF_INT8_DEC_WIDTH "3"
588
+ #endif
589
+ #ifndef PRINTF_UINT64_DEC_WIDTH
590
+ #define PRINTF_UINT64_DEC_WIDTH "20"
591
+ #endif
592
+ #ifndef PRINTF_UINT32_DEC_WIDTH
593
+ #define PRINTF_UINT32_DEC_WIDTH "10"
594
+ #endif
595
+ #ifndef PRINTF_UINT16_DEC_WIDTH
596
+ #define PRINTF_UINT16_DEC_WIDTH "5"
597
+ #endif
598
+ #ifndef PRINTF_UINT8_DEC_WIDTH
599
+ #define PRINTF_UINT8_DEC_WIDTH "3"
600
+ #endif
601
+
602
+ /*
603
+ * Ok, lets not worry about 128 bit integers for now. Moore's law says
604
+ * we don't need to worry about that until about 2040 at which point
605
+ * we'll have bigger things to worry about.
606
+ */
607
+
608
+ #ifdef stdint_int64_defined
609
+ typedef int64_t intmax_t;
610
+ typedef uint64_t uintmax_t;
611
+ #define INTMAX_MAX INT64_MAX
612
+ #define INTMAX_MIN INT64_MIN
613
+ #define UINTMAX_MAX UINT64_MAX
614
+ #define UINTMAX_C(v) UINT64_C(v)
615
+ #define INTMAX_C(v) INT64_C(v)
616
+ #ifndef PRINTF_INTMAX_MODIFIER
617
+ #define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
618
+ #endif
619
+ #ifndef PRINTF_INTMAX_HEX_WIDTH
620
+ #define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
621
+ #endif
622
+ #ifndef PRINTF_INTMAX_DEC_WIDTH
623
+ #define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
624
+ #endif
625
+ #else
626
+ typedef int32_t intmax_t;
627
+ typedef uint32_t uintmax_t;
628
+ #define INTMAX_MAX INT32_MAX
629
+ #define UINTMAX_MAX UINT32_MAX
630
+ #define UINTMAX_C(v) UINT32_C(v)
631
+ #define INTMAX_C(v) INT32_C(v)
632
+ #ifndef PRINTF_INTMAX_MODIFIER
633
+ #define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
634
+ #endif
635
+ #ifndef PRINTF_INTMAX_HEX_WIDTH
636
+ #define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
637
+ #endif
638
+ #ifndef PRINTF_INTMAX_DEC_WIDTH
639
+ #define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
640
+ #endif
641
+ #endif
642
+
643
+ /*
644
+ * Because this file currently only supports platforms which have
645
+ * precise powers of 2 as bit sizes for the default integers, the
646
+ * least definitions are all trivial. Its possible that a future
647
+ * version of this file could have different definitions.
648
+ */
649
+
650
+ #ifndef stdint_least_defined
651
+ typedef int8_t int_least8_t;
652
+ typedef uint8_t uint_least8_t;
653
+ typedef int16_t int_least16_t;
654
+ typedef uint16_t uint_least16_t;
655
+ typedef int32_t int_least32_t;
656
+ typedef uint32_t uint_least32_t;
657
+ #define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
658
+ #define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
659
+ #define UINT_LEAST8_MAX UINT8_MAX
660
+ #define INT_LEAST8_MAX INT8_MAX
661
+ #define UINT_LEAST16_MAX UINT16_MAX
662
+ #define INT_LEAST16_MAX INT16_MAX
663
+ #define UINT_LEAST32_MAX UINT32_MAX
664
+ #define INT_LEAST32_MAX INT32_MAX
665
+ #define INT_LEAST8_MIN INT8_MIN
666
+ #define INT_LEAST16_MIN INT16_MIN
667
+ #define INT_LEAST32_MIN INT32_MIN
668
+ #ifdef stdint_int64_defined
669
+ typedef int64_t int_least64_t;
670
+ typedef uint64_t uint_least64_t;
671
+ #define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
672
+ #define UINT_LEAST64_MAX UINT64_MAX
673
+ #define INT_LEAST64_MAX INT64_MAX
674
+ #define INT_LEAST64_MIN INT64_MIN
675
+ #endif
676
+ #endif
677
+ #undef stdint_least_defined
678
+
679
+ /*
680
+ * The ANSI C committee pretending to know or specify anything about
681
+ * performance is the epitome of misguided arrogance. The mandate of
682
+ * this file is to *ONLY* ever support that absolute minimum
683
+ * definition of the fast integer types, for compatibility purposes.
684
+ * No extensions, and no attempt to suggest what may or may not be a
685
+ * faster integer type will ever be made in this file. Developers are
686
+ * warned to stay away from these types when using this or any other
687
+ * stdint.h.
688
+ */
689
+
690
+ typedef int_least8_t int_fast8_t;
691
+ typedef uint_least8_t uint_fast8_t;
692
+ typedef int_least16_t int_fast16_t;
693
+ typedef uint_least16_t uint_fast16_t;
694
+ typedef int_least32_t int_fast32_t;
695
+ typedef uint_least32_t uint_fast32_t;
696
+ #define UINT_FAST8_MAX UINT_LEAST8_MAX
697
+ #define INT_FAST8_MAX INT_LEAST8_MAX
698
+ #define UINT_FAST16_MAX UINT_LEAST16_MAX
699
+ #define INT_FAST16_MAX INT_LEAST16_MAX
700
+ #define UINT_FAST32_MAX UINT_LEAST32_MAX
701
+ #define INT_FAST32_MAX INT_LEAST32_MAX
702
+ #define INT_FAST8_MIN INT_LEAST8_MIN
703
+ #define INT_FAST16_MIN INT_LEAST16_MIN
704
+ #define INT_FAST32_MIN INT_LEAST32_MIN
705
+ #ifdef stdint_int64_defined
706
+ typedef int_least64_t int_fast64_t;
707
+ typedef uint_least64_t uint_fast64_t;
708
+ #define UINT_FAST64_MAX UINT_LEAST64_MAX
709
+ #define INT_FAST64_MAX INT_LEAST64_MAX
710
+ #define INT_FAST64_MIN INT_LEAST64_MIN
711
+ #endif
712
+
713
+ #undef stdint_int64_defined
714
+
715
+ /*
716
+ * Whatever piecemeal, per compiler thing we can do about the wchar_t
717
+ * type limits.
718
+ */
719
+
720
+ #if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__GNUC__)
721
+ #include <wchar.h>
722
+ #ifndef WCHAR_MIN
723
+ #define WCHAR_MIN 0
724
+ #endif
725
+ #ifndef WCHAR_MAX
726
+ #define WCHAR_MAX ((wchar_t) - 1)
727
+ #endif
728
+ #endif
729
+
730
+ /*
731
+ * Whatever piecemeal, per compiler/platform thing we can do about the
732
+ * (u)intptr_t types and limits.
733
+ */
734
+
735
+ #if (defined(_MSC_VER) && defined(_UINTPTR_T_DEFINED)) || defined(_UINTPTR_T)
736
+ #define STDINT_H_UINTPTR_T_DEFINED
737
+ #endif
738
+
739
+ #ifndef STDINT_H_UINTPTR_T_DEFINED
740
+ #if defined(__alpha__) || defined(__ia64__) || defined(__x86_64__) || defined(_WIN64) || \
741
+ defined(__ppc64__)
742
+ #define stdint_intptr_bits 64
743
+ #elif defined(__WATCOMC__) || defined(__TURBOC__)
744
+ #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
745
+ #define stdint_intptr_bits 16
746
+ #else
747
+ #define stdint_intptr_bits 32
748
+ #endif
749
+ #elif defined(__i386__) || defined(_WIN32) || defined(WIN32) || defined(__ppc64__)
750
+ #define stdint_intptr_bits 32
751
+ #elif defined(__INTEL_COMPILER)
752
+ /* TODO -- what did Intel do about x86-64? */
753
+ #else
754
+ /* #error "This platform might not be supported yet" */
755
+ #endif
756
+
757
+ #ifdef stdint_intptr_bits
758
+ #define stdint_intptr_glue3_i(a, b, c) a##b##c
759
+ #define stdint_intptr_glue3(a, b, c) stdint_intptr_glue3_i(a, b, c)
760
+ #ifndef PRINTF_INTPTR_MODIFIER
761
+ #define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT, stdint_intptr_bits, _MODIFIER)
762
+ #endif
763
+ #ifndef PTRDIFF_MAX
764
+ #define PTRDIFF_MAX stdint_intptr_glue3(INT, stdint_intptr_bits, _MAX)
765
+ #endif
766
+ #ifndef PTRDIFF_MIN
767
+ #define PTRDIFF_MIN stdint_intptr_glue3(INT, stdint_intptr_bits, _MIN)
768
+ #endif
769
+ #ifndef UINTPTR_MAX
770
+ #define UINTPTR_MAX stdint_intptr_glue3(UINT, stdint_intptr_bits, _MAX)
771
+ #endif
772
+ #ifndef INTPTR_MAX
773
+ #define INTPTR_MAX stdint_intptr_glue3(INT, stdint_intptr_bits, _MAX)
774
+ #endif
775
+ #ifndef INTPTR_MIN
776
+ #define INTPTR_MIN stdint_intptr_glue3(INT, stdint_intptr_bits, _MIN)
777
+ #endif
778
+ #ifndef INTPTR_C
779
+ #define INTPTR_C(x) stdint_intptr_glue3(INT, stdint_intptr_bits, _C)(x)
780
+ #endif
781
+ #ifndef UINTPTR_C
782
+ #define UINTPTR_C(x) stdint_intptr_glue3(UINT, stdint_intptr_bits, _C)(x)
783
+ #endif
784
+ typedef stdint_intptr_glue3(uint, stdint_intptr_bits, _t) uintptr_t;
785
+ typedef stdint_intptr_glue3(int, stdint_intptr_bits, _t) intptr_t;
786
+ #else
787
+ /* TODO -- This following is likely wrong for some platforms, and does
788
+ nothing for the definition of uintptr_t. */
789
+ typedef ptrdiff_t intptr_t;
790
+ #endif
791
+ #define STDINT_H_UINTPTR_T_DEFINED
792
+ #endif
793
+
794
+ /*
795
+ * Assumes sig_atomic_t is signed and we have a 2s complement machine.
796
+ */
797
+
798
+ #ifndef SIG_ATOMIC_MAX
799
+ #define SIG_ATOMIC_MAX ((((sig_atomic_t)1) << (sizeof(sig_atomic_t) * CHAR_BIT - 1)) - 1)
800
+ #endif
801
+
802
+ #endif
803
+
804
+ #if defined(__TEST_PSTDINT_FOR_CORRECTNESS)
805
+
806
+ /*
807
+ * Please compile with the maximum warning settings to make sure macros are
808
+ * not defined more than once.
809
+ */
810
+
811
+ #include <stdio.h>
812
+ #include <stdlib.h>
813
+ #include <string.h>
814
+
815
+ #define glue3_aux(x, y, z) x##y##z
816
+ #define glue3(x, y, z) glue3_aux(x, y, z)
817
+
818
+ #define DECLU(bits) glue3(uint, bits, _t) glue3(u, bits, ) = glue3(UINT, bits, _C)(0);
819
+ #define DECLI(bits) glue3(int, bits, _t) glue3(i, bits, ) = glue3(INT, bits, _C)(0);
820
+
821
+ #define DECL(us, bits) glue3(DECL, us, )(bits)
822
+
823
+ #define TESTUMAX(bits) \
824
+ glue3(u, bits, ) = ~glue3(u, bits, ); \
825
+ if (glue3(UINT, bits, _MAX) != glue3(u, bits, )) printf("Something wrong with UINT%d_MAX\n", bits)
826
+
827
+ #define REPORTERROR(msg) \
828
+ { \
829
+ err_n++; \
830
+ if (err_first <= 0) err_first = __LINE__; \
831
+ printf msg; \
832
+ }
833
+
834
+ int main() {
835
+ int err_n = 0;
836
+ int err_first = 0;
837
+ DECL(I, 8)
838
+ DECL(U, 8)
839
+ DECL(I, 16)
840
+ DECL(U, 16)
841
+ DECL(I, 32)
842
+ DECL(U, 32)
843
+ #ifdef INT64_MAX
844
+ DECL(I, 64)
845
+ DECL(U, 64)
846
+ #endif
847
+ intmax_t imax = INTMAX_C(0);
848
+ uintmax_t umax = UINTMAX_C(0);
849
+ char str0[256], str1[256];
850
+
851
+ sprintf(str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
852
+ if (0 != strcmp(str0, "2147483647"))
853
+ REPORTERROR(("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
854
+ if (atoi(PRINTF_INT32_DEC_WIDTH) != (int)strlen(str0))
855
+ REPORTERROR(("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
856
+ sprintf(str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
857
+ if (0 != strcmp(str0, "4294967295"))
858
+ REPORTERROR(("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
859
+ if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int)strlen(str0))
860
+ REPORTERROR(("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
861
+ #ifdef INT64_MAX
862
+ sprintf(str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
863
+ if (0 != strcmp(str1, "9223372036854775807"))
864
+ REPORTERROR(("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
865
+ if (atoi(PRINTF_INT64_DEC_WIDTH) != (int)strlen(str1))
866
+ REPORTERROR(("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH,
867
+ (int)strlen(str1)));
868
+ sprintf(str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
869
+ if (0 != strcmp(str1, "18446744073709550591"))
870
+ REPORTERROR(("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
871
+ if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int)strlen(str1))
872
+ REPORTERROR(("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH,
873
+ (int)strlen(str1)));
874
+ #endif
875
+
876
+ sprintf(str0, "%d %x\n", 0, ~0);
877
+
878
+ sprintf(str1, "%d %x\n", i8, ~0);
879
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with i8 : %s\n", str1));
880
+ sprintf(str1, "%u %x\n", u8, ~0);
881
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with u8 : %s\n", str1));
882
+ sprintf(str1, "%d %x\n", i16, ~0);
883
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with i16 : %s\n", str1));
884
+ sprintf(str1, "%u %x\n", u16, ~0);
885
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with u16 : %s\n", str1));
886
+ sprintf(str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
887
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with i32 : %s\n", str1));
888
+ sprintf(str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
889
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with u32 : %s\n", str1));
890
+ #ifdef INT64_MAX
891
+ sprintf(str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
892
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with i64 : %s\n", str1));
893
+ #endif
894
+ sprintf(str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
895
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with imax : %s\n", str1));
896
+ sprintf(str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
897
+ if (0 != strcmp(str0, str1)) REPORTERROR(("Something wrong with umax : %s\n", str1));
898
+
899
+ TESTUMAX(8);
900
+ TESTUMAX(16);
901
+ TESTUMAX(32);
902
+ #ifdef INT64_MAX
903
+ TESTUMAX(64);
904
+ #endif
905
+
906
+ #define STR(v) #v
907
+ #define Q(v) printf("sizeof " STR(v) " = %u\n", (unsigned)sizeof(v));
908
+ if (err_n) {
909
+ printf("pstdint.h is not correct. Please use sizes below to correct it:\n");
910
+ }
911
+
912
+ Q(int)
913
+ Q(unsigned)
914
+ Q(long int)
915
+ Q(short int)
916
+ Q(int8_t)
917
+ Q(int16_t)
918
+ Q(int32_t)
919
+ #ifdef INT64_MAX
920
+ Q(int64_t)
921
+ #endif
922
+
923
+ return EXIT_SUCCESS;
924
+ }
925
+
926
+ #endif