snowflake-connector-python 3.16.0__cp313-cp313-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 (246) hide show
  1. snowflake/connector/__init__.py +96 -0
  2. snowflake/connector/_query_context_cache.py +276 -0
  3. snowflake/connector/_sql_util.py +48 -0
  4. snowflake/connector/_utils.py +70 -0
  5. snowflake/connector/arrow_context.py +203 -0
  6. snowflake/connector/auth/__init__.py +53 -0
  7. snowflake/connector/auth/_auth.py +586 -0
  8. snowflake/connector/auth/_http_server.py +220 -0
  9. snowflake/connector/auth/_oauth_base.py +400 -0
  10. snowflake/connector/auth/by_plugin.py +219 -0
  11. snowflake/connector/auth/default.py +36 -0
  12. snowflake/connector/auth/idtoken.py +72 -0
  13. snowflake/connector/auth/keypair.py +222 -0
  14. snowflake/connector/auth/no_auth.py +39 -0
  15. snowflake/connector/auth/oauth.py +49 -0
  16. snowflake/connector/auth/oauth_code.py +479 -0
  17. snowflake/connector/auth/oauth_credentials.py +66 -0
  18. snowflake/connector/auth/okta.py +335 -0
  19. snowflake/connector/auth/pat.py +39 -0
  20. snowflake/connector/auth/usrpwdmfa.py +69 -0
  21. snowflake/connector/auth/webbrowser.py +502 -0
  22. snowflake/connector/auth/workload_identity.py +94 -0
  23. snowflake/connector/azure_storage_client.py +276 -0
  24. snowflake/connector/backoff_policies.py +141 -0
  25. snowflake/connector/bind_upload_agent.py +89 -0
  26. snowflake/connector/cache.py +696 -0
  27. snowflake/connector/compat.py +127 -0
  28. snowflake/connector/config_manager.py +496 -0
  29. snowflake/connector/connection.py +2273 -0
  30. snowflake/connector/connection_diagnostic.py +776 -0
  31. snowflake/connector/constants.py +442 -0
  32. snowflake/connector/converter.py +785 -0
  33. snowflake/connector/converter_issue23517.py +87 -0
  34. snowflake/connector/converter_null.py +14 -0
  35. snowflake/connector/converter_snowsql.py +205 -0
  36. snowflake/connector/cursor.py +1951 -0
  37. snowflake/connector/dbapi.py +53 -0
  38. snowflake/connector/description.py +19 -0
  39. snowflake/connector/direct_file_operation_utils.py +88 -0
  40. snowflake/connector/encryption_util.py +220 -0
  41. snowflake/connector/errorcode.py +91 -0
  42. snowflake/connector/errors.py +615 -0
  43. snowflake/connector/externals_utils/__init__.py +0 -0
  44. snowflake/connector/externals_utils/externals_setup.py +27 -0
  45. snowflake/connector/feature.py +4 -0
  46. snowflake/connector/file_compression_type.py +118 -0
  47. snowflake/connector/file_lock.py +72 -0
  48. snowflake/connector/file_transfer_agent.py +1215 -0
  49. snowflake/connector/file_util.py +153 -0
  50. snowflake/connector/gcs_storage_client.py +474 -0
  51. snowflake/connector/gzip_decoder.py +85 -0
  52. snowflake/connector/local_storage_client.py +90 -0
  53. snowflake/connector/log_configuration.py +60 -0
  54. snowflake/connector/logging_utils/__init__.py +0 -0
  55. snowflake/connector/logging_utils/filters.py +72 -0
  56. snowflake/connector/nanoarrow_arrow_iterator.cp313-win_amd64.pyd +0 -0
  57. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +60 -0
  58. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
  59. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +19 -0
  60. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
  61. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
  62. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
  63. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.cpp +557 -0
  64. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.hpp +98 -0
  65. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +125 -0
  66. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +115 -0
  67. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp +1005 -0
  68. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.hpp +127 -0
  69. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +47 -0
  70. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
  71. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +83 -0
  72. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
  73. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +97 -0
  74. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +72 -0
  75. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +73 -0
  76. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
  77. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +30 -0
  78. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
  79. snowflake/connector/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
  80. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
  81. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +45 -0
  82. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +71 -0
  83. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +56 -0
  84. snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
  85. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +75 -0
  86. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
  87. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +46 -0
  88. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
  89. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
  90. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +95 -0
  91. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +57 -0
  92. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +36 -0
  93. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +34 -0
  94. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
  95. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +19 -0
  96. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
  97. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +36 -0
  98. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
  99. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +346 -0
  100. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +145 -0
  101. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
  102. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
  103. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
  104. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +101 -0
  105. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +127 -0
  106. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
  107. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1908 -0
  108. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +215 -0
  109. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +125 -0
  110. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
  111. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +55 -0
  112. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +148 -0
  113. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
  114. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
  115. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
  116. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +162 -0
  117. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +97 -0
  118. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +239 -0
  119. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
  120. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +210 -0
  121. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +84 -0
  122. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +84 -0
  123. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
  124. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
  125. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +206 -0
  126. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +118 -0
  127. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
  128. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
  129. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
  130. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
  131. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
  132. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +162 -0
  133. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +898 -0
  134. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +190 -0
  135. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
  136. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
  137. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc.c +3204 -0
  138. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3217 -0
  139. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3618 -0
  140. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +379 -0
  141. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.pyx +256 -0
  142. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.c +512 -0
  143. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.h +350 -0
  144. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +33273 -0
  145. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +397 -0
  146. snowflake/connector/nanoarrow_cpp/Logging/logging.cpp +100 -0
  147. snowflake/connector/nanoarrow_cpp/Logging/logging.hpp +49 -0
  148. snowflake/connector/network.py +1297 -0
  149. snowflake/connector/ocsp_asn1crypto.py +447 -0
  150. snowflake/connector/ocsp_snowflake.py +1883 -0
  151. snowflake/connector/options.py +131 -0
  152. snowflake/connector/pandas_tools.py +732 -0
  153. snowflake/connector/proxy.py +43 -0
  154. snowflake/connector/py.typed +0 -0
  155. snowflake/connector/result_batch.py +786 -0
  156. snowflake/connector/result_set.py +319 -0
  157. snowflake/connector/s3_storage_client.py +605 -0
  158. snowflake/connector/secret_detector.py +181 -0
  159. snowflake/connector/sf_dirs.py +64 -0
  160. snowflake/connector/sfbinaryformat.py +35 -0
  161. snowflake/connector/sfdatetime.py +345 -0
  162. snowflake/connector/snow_logging.py +144 -0
  163. snowflake/connector/sqlstate.py +9 -0
  164. snowflake/connector/ssd_internal_keys.py +30 -0
  165. snowflake/connector/ssl_wrap_socket.py +134 -0
  166. snowflake/connector/storage_client.py +478 -0
  167. snowflake/connector/telemetry.py +249 -0
  168. snowflake/connector/telemetry_oob.py +543 -0
  169. snowflake/connector/test_util.py +30 -0
  170. snowflake/connector/time_util.py +159 -0
  171. snowflake/connector/token_cache.py +402 -0
  172. snowflake/connector/tool/__init__.py +0 -0
  173. snowflake/connector/tool/dump_certs.py +57 -0
  174. snowflake/connector/tool/dump_ocsp_response.py +139 -0
  175. snowflake/connector/tool/dump_ocsp_response_cache.py +194 -0
  176. snowflake/connector/tool/probe_connection.py +69 -0
  177. snowflake/connector/url_util.py +49 -0
  178. snowflake/connector/util_text.py +301 -0
  179. snowflake/connector/vendored/__init__.py +3 -0
  180. snowflake/connector/vendored/requests/LICENSE +175 -0
  181. snowflake/connector/vendored/requests/__init__.py +169 -0
  182. snowflake/connector/vendored/requests/__version__.py +14 -0
  183. snowflake/connector/vendored/requests/_internal_utils.py +50 -0
  184. snowflake/connector/vendored/requests/adapters.py +537 -0
  185. snowflake/connector/vendored/requests/api.py +157 -0
  186. snowflake/connector/vendored/requests/auth.py +315 -0
  187. snowflake/connector/vendored/requests/certs.py +17 -0
  188. snowflake/connector/vendored/requests/compat.py +79 -0
  189. snowflake/connector/vendored/requests/cookies.py +561 -0
  190. snowflake/connector/vendored/requests/exceptions.py +140 -0
  191. snowflake/connector/vendored/requests/help.py +134 -0
  192. snowflake/connector/vendored/requests/hooks.py +33 -0
  193. snowflake/connector/vendored/requests/models.py +1033 -0
  194. snowflake/connector/vendored/requests/sessions.py +833 -0
  195. snowflake/connector/vendored/requests/status_codes.py +128 -0
  196. snowflake/connector/vendored/requests/structures.py +99 -0
  197. snowflake/connector/vendored/requests/utils.py +1093 -0
  198. snowflake/connector/vendored/urllib3/LICENSE.txt +21 -0
  199. snowflake/connector/vendored/urllib3/__init__.py +85 -0
  200. snowflake/connector/vendored/urllib3/_collections.py +355 -0
  201. snowflake/connector/vendored/urllib3/_version.py +2 -0
  202. snowflake/connector/vendored/urllib3/connection.py +572 -0
  203. snowflake/connector/vendored/urllib3/connectionpool.py +1137 -0
  204. snowflake/connector/vendored/urllib3/contrib/__init__.py +0 -0
  205. snowflake/connector/vendored/urllib3/contrib/_appengine_environ.py +36 -0
  206. snowflake/connector/vendored/urllib3/contrib/_securetransport/__init__.py +0 -0
  207. snowflake/connector/vendored/urllib3/contrib/_securetransport/bindings.py +519 -0
  208. snowflake/connector/vendored/urllib3/contrib/_securetransport/low_level.py +397 -0
  209. snowflake/connector/vendored/urllib3/contrib/appengine.py +314 -0
  210. snowflake/connector/vendored/urllib3/contrib/ntlmpool.py +130 -0
  211. snowflake/connector/vendored/urllib3/contrib/pyopenssl.py +509 -0
  212. snowflake/connector/vendored/urllib3/contrib/securetransport.py +920 -0
  213. snowflake/connector/vendored/urllib3/contrib/socks.py +216 -0
  214. snowflake/connector/vendored/urllib3/exceptions.py +323 -0
  215. snowflake/connector/vendored/urllib3/fields.py +274 -0
  216. snowflake/connector/vendored/urllib3/filepost.py +98 -0
  217. snowflake/connector/vendored/urllib3/packages/__init__.py +0 -0
  218. snowflake/connector/vendored/urllib3/packages/backports/__init__.py +0 -0
  219. snowflake/connector/vendored/urllib3/packages/backports/makefile.py +51 -0
  220. snowflake/connector/vendored/urllib3/packages/backports/weakref_finalize.py +155 -0
  221. snowflake/connector/vendored/urllib3/packages/six.py +1076 -0
  222. snowflake/connector/vendored/urllib3/poolmanager.py +540 -0
  223. snowflake/connector/vendored/urllib3/request.py +191 -0
  224. snowflake/connector/vendored/urllib3/response.py +885 -0
  225. snowflake/connector/vendored/urllib3/util/__init__.py +49 -0
  226. snowflake/connector/vendored/urllib3/util/connection.py +156 -0
  227. snowflake/connector/vendored/urllib3/util/proxy.py +57 -0
  228. snowflake/connector/vendored/urllib3/util/queue.py +22 -0
  229. snowflake/connector/vendored/urllib3/util/request.py +146 -0
  230. snowflake/connector/vendored/urllib3/util/response.py +107 -0
  231. snowflake/connector/vendored/urllib3/util/retry.py +620 -0
  232. snowflake/connector/vendored/urllib3/util/ssl_.py +495 -0
  233. snowflake/connector/vendored/urllib3/util/ssl_match_hostname.py +159 -0
  234. snowflake/connector/vendored/urllib3/util/ssltransport.py +221 -0
  235. snowflake/connector/vendored/urllib3/util/timeout.py +271 -0
  236. snowflake/connector/vendored/urllib3/util/url.py +435 -0
  237. snowflake/connector/vendored/urllib3/util/wait.py +152 -0
  238. snowflake/connector/version.py +3 -0
  239. snowflake/connector/wif_util.py +407 -0
  240. snowflake_connector_python-3.16.0.dist-info/METADATA +1475 -0
  241. snowflake_connector_python-3.16.0.dist-info/RECORD +246 -0
  242. snowflake_connector_python-3.16.0.dist-info/WHEEL +5 -0
  243. snowflake_connector_python-3.16.0.dist-info/entry_points.txt +4 -0
  244. snowflake_connector_python-3.16.0.dist-info/licenses/LICENSE.txt +202 -0
  245. snowflake_connector_python-3.16.0.dist-info/licenses/NOTICE +8 -0
  246. snowflake_connector_python-3.16.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,898 @@
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 <stddef.h>
192
+ #include <limits.h>
193
+ #include <signal.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) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
201
+ #include <stdint.h>
202
+ #define _PSTDINT_H_INCLUDED
203
+ # if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
204
+ # ifndef PRINTF_INT64_MODIFIER
205
+ # define PRINTF_INT64_MODIFIER "l"
206
+ # endif
207
+ # ifndef PRINTF_INT32_MODIFIER
208
+ # define PRINTF_INT32_MODIFIER ""
209
+ # endif
210
+ # else
211
+ # ifndef PRINTF_INT64_MODIFIER
212
+ # define PRINTF_INT64_MODIFIER "ll"
213
+ # endif
214
+ # ifndef PRINTF_INT32_MODIFIER
215
+ # if (UINT_MAX == UINT32_MAX)
216
+ # define PRINTF_INT32_MODIFIER ""
217
+ # else
218
+ # define PRINTF_INT32_MODIFIER "l"
219
+ # endif
220
+ # endif
221
+ # endif
222
+ # ifndef PRINTF_INT16_MODIFIER
223
+ # define PRINTF_INT16_MODIFIER "h"
224
+ # endif
225
+ # ifndef PRINTF_INTMAX_MODIFIER
226
+ # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
227
+ # endif
228
+ # ifndef PRINTF_INT64_HEX_WIDTH
229
+ # define PRINTF_INT64_HEX_WIDTH "16"
230
+ # endif
231
+ # ifndef PRINTF_UINT64_HEX_WIDTH
232
+ # define PRINTF_UINT64_HEX_WIDTH "16"
233
+ # endif
234
+ # ifndef PRINTF_INT32_HEX_WIDTH
235
+ # define PRINTF_INT32_HEX_WIDTH "8"
236
+ # endif
237
+ # ifndef PRINTF_UINT32_HEX_WIDTH
238
+ # define PRINTF_UINT32_HEX_WIDTH "8"
239
+ # endif
240
+ # ifndef PRINTF_INT16_HEX_WIDTH
241
+ # define PRINTF_INT16_HEX_WIDTH "4"
242
+ # endif
243
+ # ifndef PRINTF_UINT16_HEX_WIDTH
244
+ # define PRINTF_UINT16_HEX_WIDTH "4"
245
+ # endif
246
+ # ifndef PRINTF_INT8_HEX_WIDTH
247
+ # define PRINTF_INT8_HEX_WIDTH "2"
248
+ # endif
249
+ # ifndef PRINTF_UINT8_HEX_WIDTH
250
+ # define PRINTF_UINT8_HEX_WIDTH "2"
251
+ # endif
252
+ # ifndef PRINTF_INT64_DEC_WIDTH
253
+ # define PRINTF_INT64_DEC_WIDTH "19"
254
+ # endif
255
+ # ifndef PRINTF_UINT64_DEC_WIDTH
256
+ # define PRINTF_UINT64_DEC_WIDTH "20"
257
+ # endif
258
+ # ifndef PRINTF_INT32_DEC_WIDTH
259
+ # define PRINTF_INT32_DEC_WIDTH "10"
260
+ # endif
261
+ # ifndef PRINTF_UINT32_DEC_WIDTH
262
+ # define PRINTF_UINT32_DEC_WIDTH "10"
263
+ # endif
264
+ # ifndef PRINTF_INT16_DEC_WIDTH
265
+ # define PRINTF_INT16_DEC_WIDTH "5"
266
+ # endif
267
+ # ifndef PRINTF_UINT16_DEC_WIDTH
268
+ # define PRINTF_UINT16_DEC_WIDTH "5"
269
+ # endif
270
+ # ifndef PRINTF_INT8_DEC_WIDTH
271
+ # define PRINTF_INT8_DEC_WIDTH "3"
272
+ # endif
273
+ # ifndef PRINTF_UINT8_DEC_WIDTH
274
+ # define PRINTF_UINT8_DEC_WIDTH "3"
275
+ # endif
276
+ # ifndef PRINTF_INTMAX_HEX_WIDTH
277
+ # define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
278
+ # endif
279
+ # ifndef PRINTF_UINTMAX_HEX_WIDTH
280
+ # define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
281
+ # endif
282
+ # ifndef PRINTF_INTMAX_DEC_WIDTH
283
+ # define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
284
+ # endif
285
+ # ifndef PRINTF_UINTMAX_DEC_WIDTH
286
+ # define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
287
+ # endif
288
+
289
+ /*
290
+ * Something really weird is going on with Open Watcom. Just pull some of
291
+ * these duplicated definitions from Open Watcom's stdint.h file for now.
292
+ */
293
+
294
+ # if defined (__WATCOMC__) && __WATCOMC__ >= 1250
295
+ # if !defined (INT64_C)
296
+ # define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
297
+ # endif
298
+ # if !defined (UINT64_C)
299
+ # define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
300
+ # endif
301
+ # if !defined (INT32_C)
302
+ # define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
303
+ # endif
304
+ # if !defined (UINT32_C)
305
+ # define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
306
+ # endif
307
+ # if !defined (INT16_C)
308
+ # define INT16_C(x) (x)
309
+ # endif
310
+ # if !defined (UINT16_C)
311
+ # define UINT16_C(x) (x)
312
+ # endif
313
+ # if !defined (INT8_C)
314
+ # define INT8_C(x) (x)
315
+ # endif
316
+ # if !defined (UINT8_C)
317
+ # define UINT8_C(x) (x)
318
+ # endif
319
+ # if !defined (UINT64_MAX)
320
+ # define UINT64_MAX 18446744073709551615ULL
321
+ # endif
322
+ # if !defined (INT64_MAX)
323
+ # define INT64_MAX 9223372036854775807LL
324
+ # endif
325
+ # if !defined (UINT32_MAX)
326
+ # define UINT32_MAX 4294967295UL
327
+ # endif
328
+ # if !defined (INT32_MAX)
329
+ # define INT32_MAX 2147483647L
330
+ # endif
331
+ # if !defined (INTMAX_MAX)
332
+ # define INTMAX_MAX INT64_MAX
333
+ # endif
334
+ # if !defined (INTMAX_MIN)
335
+ # define INTMAX_MIN INT64_MIN
336
+ # endif
337
+ # endif
338
+ #endif
339
+
340
+ #ifndef _PSTDINT_H_INCLUDED
341
+ #define _PSTDINT_H_INCLUDED
342
+
343
+ #ifndef SIZE_MAX
344
+ # define SIZE_MAX (~(size_t)0)
345
+ #endif
346
+
347
+ /*
348
+ * Deduce the type assignments from limits.h under the assumption that
349
+ * integer sizes in bits are powers of 2, and follow the ANSI
350
+ * definitions.
351
+ */
352
+
353
+ #ifndef UINT8_MAX
354
+ # define UINT8_MAX 0xff
355
+ #endif
356
+ #if !defined(uint8_t) && !defined(_UINT8_T)
357
+ # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
358
+ typedef unsigned char uint8_t;
359
+ # define UINT8_C(v) ((uint8_t) v)
360
+ # else
361
+ # error "Platform not supported"
362
+ # endif
363
+ #endif
364
+
365
+ #ifndef INT8_MAX
366
+ # define INT8_MAX 0x7f
367
+ #endif
368
+ #ifndef INT8_MIN
369
+ # define INT8_MIN INT8_C(0x80)
370
+ #endif
371
+ #if !defined(int8_t) && !defined(_INT8_T)
372
+ # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
373
+ typedef signed char int8_t;
374
+ # define INT8_C(v) ((int8_t) v)
375
+ # else
376
+ # error "Platform not supported"
377
+ # endif
378
+ #endif
379
+
380
+ #ifndef UINT16_MAX
381
+ # define UINT16_MAX 0xffff
382
+ #endif
383
+ #if !defined(uint16_t) && !defined(_UINT16_T)
384
+ #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
385
+ typedef unsigned int uint16_t;
386
+ # ifndef PRINTF_INT16_MODIFIER
387
+ # define PRINTF_INT16_MODIFIER ""
388
+ # endif
389
+ # define UINT16_C(v) ((uint16_t) (v))
390
+ #elif (USHRT_MAX == UINT16_MAX)
391
+ typedef unsigned short uint16_t;
392
+ # define UINT16_C(v) ((uint16_t) (v))
393
+ # ifndef PRINTF_INT16_MODIFIER
394
+ # define PRINTF_INT16_MODIFIER "h"
395
+ # endif
396
+ #else
397
+ #error "Platform not supported"
398
+ #endif
399
+ #endif
400
+
401
+ #ifndef INT16_MAX
402
+ # define INT16_MAX 0x7fff
403
+ #endif
404
+ #ifndef INT16_MIN
405
+ # define INT16_MIN INT16_C(0x8000)
406
+ #endif
407
+ #if !defined(int16_t) && !defined(_INT16_T)
408
+ #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
409
+ typedef signed int int16_t;
410
+ # define INT16_C(v) ((int16_t) (v))
411
+ # ifndef PRINTF_INT16_MODIFIER
412
+ # define PRINTF_INT16_MODIFIER ""
413
+ # endif
414
+ #elif (SHRT_MAX == INT16_MAX)
415
+ typedef signed short int16_t;
416
+ # define INT16_C(v) ((int16_t) (v))
417
+ # ifndef PRINTF_INT16_MODIFIER
418
+ # define PRINTF_INT16_MODIFIER "h"
419
+ # endif
420
+ #else
421
+ #error "Platform not supported"
422
+ #endif
423
+ #endif
424
+
425
+ #ifndef UINT32_MAX
426
+ # define UINT32_MAX (0xffffffffUL)
427
+ #endif
428
+ #if !defined(uint32_t) && !defined(_UINT32_T)
429
+ #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
430
+ typedef unsigned long uint32_t;
431
+ # define UINT32_C(v) v ## UL
432
+ # ifndef PRINTF_INT32_MODIFIER
433
+ # define PRINTF_INT32_MODIFIER "l"
434
+ # endif
435
+ #elif (UINT_MAX == UINT32_MAX)
436
+ typedef unsigned int uint32_t;
437
+ # ifndef PRINTF_INT32_MODIFIER
438
+ # define PRINTF_INT32_MODIFIER ""
439
+ # endif
440
+ # define UINT32_C(v) v ## U
441
+ #elif (USHRT_MAX == UINT32_MAX)
442
+ typedef unsigned short uint32_t;
443
+ # define UINT32_C(v) ((unsigned short) (v))
444
+ # ifndef PRINTF_INT32_MODIFIER
445
+ # define PRINTF_INT32_MODIFIER ""
446
+ # endif
447
+ #else
448
+ #error "Platform not supported"
449
+ #endif
450
+ #endif
451
+
452
+ #ifndef INT32_MAX
453
+ # define INT32_MAX (0x7fffffffL)
454
+ #endif
455
+ #ifndef INT32_MIN
456
+ # define INT32_MIN INT32_C(0x80000000)
457
+ #endif
458
+ #if !defined(int32_t) && !defined(_INT32_T)
459
+ #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
460
+ typedef signed long int32_t;
461
+ # define INT32_C(v) v ## L
462
+ # ifndef PRINTF_INT32_MODIFIER
463
+ # define PRINTF_INT32_MODIFIER "l"
464
+ # endif
465
+ #elif (INT_MAX == INT32_MAX)
466
+ typedef signed int int32_t;
467
+ # define INT32_C(v) v
468
+ # ifndef PRINTF_INT32_MODIFIER
469
+ # define PRINTF_INT32_MODIFIER ""
470
+ # endif
471
+ #elif (SHRT_MAX == INT32_MAX)
472
+ typedef signed short int32_t;
473
+ # define INT32_C(v) ((short) (v))
474
+ # ifndef PRINTF_INT32_MODIFIER
475
+ # define PRINTF_INT32_MODIFIER ""
476
+ # endif
477
+ #else
478
+ #error "Platform not supported"
479
+ #endif
480
+ #endif
481
+
482
+ /*
483
+ * The macro stdint_int64_defined is temporarily used to record
484
+ * whether or not 64 integer support is available. It must be
485
+ * defined for any 64 integer extensions for new platforms that are
486
+ * added.
487
+ */
488
+
489
+ #undef stdint_int64_defined
490
+ #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
491
+ # if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
492
+ # define stdint_int64_defined
493
+ typedef long long int64_t;
494
+ typedef unsigned long long uint64_t;
495
+ # define UINT64_C(v) v ## ULL
496
+ # define INT64_C(v) v ## LL
497
+ # ifndef PRINTF_INT64_MODIFIER
498
+ # define PRINTF_INT64_MODIFIER "ll"
499
+ # endif
500
+ # endif
501
+ #endif
502
+
503
+ #if !defined (stdint_int64_defined)
504
+ # if defined(__GNUC__)
505
+ # define stdint_int64_defined
506
+ __extension__ typedef long long int64_t;
507
+ __extension__ typedef unsigned long long uint64_t;
508
+ # define UINT64_C(v) v ## ULL
509
+ # define INT64_C(v) v ## LL
510
+ # ifndef PRINTF_INT64_MODIFIER
511
+ # define PRINTF_INT64_MODIFIER "ll"
512
+ # endif
513
+ # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
514
+ # define stdint_int64_defined
515
+ typedef long long int64_t;
516
+ typedef unsigned long long uint64_t;
517
+ # define UINT64_C(v) v ## ULL
518
+ # define INT64_C(v) v ## LL
519
+ # ifndef PRINTF_INT64_MODIFIER
520
+ # define PRINTF_INT64_MODIFIER "ll"
521
+ # endif
522
+ # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
523
+ # define stdint_int64_defined
524
+ typedef __int64 int64_t;
525
+ typedef unsigned __int64 uint64_t;
526
+ # define UINT64_C(v) v ## UI64
527
+ # define INT64_C(v) v ## I64
528
+ # ifndef PRINTF_INT64_MODIFIER
529
+ # define PRINTF_INT64_MODIFIER "I64"
530
+ # endif
531
+ # endif
532
+ #endif
533
+
534
+ #if !defined (LONG_LONG_MAX) && defined (INT64_C)
535
+ # define LONG_LONG_MAX INT64_C (9223372036854775807)
536
+ #endif
537
+ #ifndef ULONG_LONG_MAX
538
+ # define ULONG_LONG_MAX UINT64_C (18446744073709551615)
539
+ #endif
540
+
541
+ #if !defined (INT64_MAX) && defined (INT64_C)
542
+ # define INT64_MAX INT64_C (9223372036854775807)
543
+ #endif
544
+ #if !defined (INT64_MIN) && defined (INT64_C)
545
+ # define INT64_MIN INT64_C (-9223372036854775808)
546
+ #endif
547
+ #if !defined (UINT64_MAX) && defined (INT64_C)
548
+ # define UINT64_MAX UINT64_C (18446744073709551615)
549
+ #endif
550
+
551
+ /*
552
+ * Width of hexadecimal for number field.
553
+ */
554
+
555
+ #ifndef PRINTF_INT64_HEX_WIDTH
556
+ # define PRINTF_INT64_HEX_WIDTH "16"
557
+ #endif
558
+ #ifndef PRINTF_INT32_HEX_WIDTH
559
+ # define PRINTF_INT32_HEX_WIDTH "8"
560
+ #endif
561
+ #ifndef PRINTF_INT16_HEX_WIDTH
562
+ # define PRINTF_INT16_HEX_WIDTH "4"
563
+ #endif
564
+ #ifndef PRINTF_INT8_HEX_WIDTH
565
+ # define PRINTF_INT8_HEX_WIDTH "2"
566
+ #endif
567
+ #ifndef PRINTF_INT64_DEC_WIDTH
568
+ # define PRINTF_INT64_DEC_WIDTH "19"
569
+ #endif
570
+ #ifndef PRINTF_INT32_DEC_WIDTH
571
+ # define PRINTF_INT32_DEC_WIDTH "10"
572
+ #endif
573
+ #ifndef PRINTF_INT16_DEC_WIDTH
574
+ # define PRINTF_INT16_DEC_WIDTH "5"
575
+ #endif
576
+ #ifndef PRINTF_INT8_DEC_WIDTH
577
+ # define PRINTF_INT8_DEC_WIDTH "3"
578
+ #endif
579
+ #ifndef PRINTF_UINT64_DEC_WIDTH
580
+ # define PRINTF_UINT64_DEC_WIDTH "20"
581
+ #endif
582
+ #ifndef PRINTF_UINT32_DEC_WIDTH
583
+ # define PRINTF_UINT32_DEC_WIDTH "10"
584
+ #endif
585
+ #ifndef PRINTF_UINT16_DEC_WIDTH
586
+ # define PRINTF_UINT16_DEC_WIDTH "5"
587
+ #endif
588
+ #ifndef PRINTF_UINT8_DEC_WIDTH
589
+ # define PRINTF_UINT8_DEC_WIDTH "3"
590
+ #endif
591
+
592
+ /*
593
+ * Ok, lets not worry about 128 bit integers for now. Moore's law says
594
+ * we don't need to worry about that until about 2040 at which point
595
+ * we'll have bigger things to worry about.
596
+ */
597
+
598
+ #ifdef stdint_int64_defined
599
+ typedef int64_t intmax_t;
600
+ typedef uint64_t uintmax_t;
601
+ # define INTMAX_MAX INT64_MAX
602
+ # define INTMAX_MIN INT64_MIN
603
+ # define UINTMAX_MAX UINT64_MAX
604
+ # define UINTMAX_C(v) UINT64_C(v)
605
+ # define INTMAX_C(v) INT64_C(v)
606
+ # ifndef PRINTF_INTMAX_MODIFIER
607
+ # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
608
+ # endif
609
+ # ifndef PRINTF_INTMAX_HEX_WIDTH
610
+ # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
611
+ # endif
612
+ # ifndef PRINTF_INTMAX_DEC_WIDTH
613
+ # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
614
+ # endif
615
+ #else
616
+ typedef int32_t intmax_t;
617
+ typedef uint32_t uintmax_t;
618
+ # define INTMAX_MAX INT32_MAX
619
+ # define UINTMAX_MAX UINT32_MAX
620
+ # define UINTMAX_C(v) UINT32_C(v)
621
+ # define INTMAX_C(v) INT32_C(v)
622
+ # ifndef PRINTF_INTMAX_MODIFIER
623
+ # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
624
+ # endif
625
+ # ifndef PRINTF_INTMAX_HEX_WIDTH
626
+ # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
627
+ # endif
628
+ # ifndef PRINTF_INTMAX_DEC_WIDTH
629
+ # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
630
+ # endif
631
+ #endif
632
+
633
+ /*
634
+ * Because this file currently only supports platforms which have
635
+ * precise powers of 2 as bit sizes for the default integers, the
636
+ * least definitions are all trivial. Its possible that a future
637
+ * version of this file could have different definitions.
638
+ */
639
+
640
+ #ifndef stdint_least_defined
641
+ typedef int8_t int_least8_t;
642
+ typedef uint8_t uint_least8_t;
643
+ typedef int16_t int_least16_t;
644
+ typedef uint16_t uint_least16_t;
645
+ typedef int32_t int_least32_t;
646
+ typedef uint32_t uint_least32_t;
647
+ # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
648
+ # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
649
+ # define UINT_LEAST8_MAX UINT8_MAX
650
+ # define INT_LEAST8_MAX INT8_MAX
651
+ # define UINT_LEAST16_MAX UINT16_MAX
652
+ # define INT_LEAST16_MAX INT16_MAX
653
+ # define UINT_LEAST32_MAX UINT32_MAX
654
+ # define INT_LEAST32_MAX INT32_MAX
655
+ # define INT_LEAST8_MIN INT8_MIN
656
+ # define INT_LEAST16_MIN INT16_MIN
657
+ # define INT_LEAST32_MIN INT32_MIN
658
+ # ifdef stdint_int64_defined
659
+ typedef int64_t int_least64_t;
660
+ typedef uint64_t uint_least64_t;
661
+ # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
662
+ # define UINT_LEAST64_MAX UINT64_MAX
663
+ # define INT_LEAST64_MAX INT64_MAX
664
+ # define INT_LEAST64_MIN INT64_MIN
665
+ # endif
666
+ #endif
667
+ #undef stdint_least_defined
668
+
669
+ /*
670
+ * The ANSI C committee pretending to know or specify anything about
671
+ * performance is the epitome of misguided arrogance. The mandate of
672
+ * this file is to *ONLY* ever support that absolute minimum
673
+ * definition of the fast integer types, for compatibility purposes.
674
+ * No extensions, and no attempt to suggest what may or may not be a
675
+ * faster integer type will ever be made in this file. Developers are
676
+ * warned to stay away from these types when using this or any other
677
+ * stdint.h.
678
+ */
679
+
680
+ typedef int_least8_t int_fast8_t;
681
+ typedef uint_least8_t uint_fast8_t;
682
+ typedef int_least16_t int_fast16_t;
683
+ typedef uint_least16_t uint_fast16_t;
684
+ typedef int_least32_t int_fast32_t;
685
+ typedef uint_least32_t uint_fast32_t;
686
+ #define UINT_FAST8_MAX UINT_LEAST8_MAX
687
+ #define INT_FAST8_MAX INT_LEAST8_MAX
688
+ #define UINT_FAST16_MAX UINT_LEAST16_MAX
689
+ #define INT_FAST16_MAX INT_LEAST16_MAX
690
+ #define UINT_FAST32_MAX UINT_LEAST32_MAX
691
+ #define INT_FAST32_MAX INT_LEAST32_MAX
692
+ #define INT_FAST8_MIN INT_LEAST8_MIN
693
+ #define INT_FAST16_MIN INT_LEAST16_MIN
694
+ #define INT_FAST32_MIN INT_LEAST32_MIN
695
+ #ifdef stdint_int64_defined
696
+ typedef int_least64_t int_fast64_t;
697
+ typedef uint_least64_t uint_fast64_t;
698
+ # define UINT_FAST64_MAX UINT_LEAST64_MAX
699
+ # define INT_FAST64_MAX INT_LEAST64_MAX
700
+ # define INT_FAST64_MIN INT_LEAST64_MIN
701
+ #endif
702
+
703
+ #undef stdint_int64_defined
704
+
705
+ /*
706
+ * Whatever piecemeal, per compiler thing we can do about the wchar_t
707
+ * type limits.
708
+ */
709
+
710
+ #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
711
+ # include <wchar.h>
712
+ # ifndef WCHAR_MIN
713
+ # define WCHAR_MIN 0
714
+ # endif
715
+ # ifndef WCHAR_MAX
716
+ # define WCHAR_MAX ((wchar_t)-1)
717
+ # endif
718
+ #endif
719
+
720
+ /*
721
+ * Whatever piecemeal, per compiler/platform thing we can do about the
722
+ * (u)intptr_t types and limits.
723
+ */
724
+
725
+ #if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
726
+ # define STDINT_H_UINTPTR_T_DEFINED
727
+ #endif
728
+
729
+ #ifndef STDINT_H_UINTPTR_T_DEFINED
730
+ # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
731
+ # define stdint_intptr_bits 64
732
+ # elif defined (__WATCOMC__) || defined (__TURBOC__)
733
+ # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
734
+ # define stdint_intptr_bits 16
735
+ # else
736
+ # define stdint_intptr_bits 32
737
+ # endif
738
+ # elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
739
+ # define stdint_intptr_bits 32
740
+ # elif defined (__INTEL_COMPILER)
741
+ /* TODO -- what did Intel do about x86-64? */
742
+ # else
743
+ /* #error "This platform might not be supported yet" */
744
+ # endif
745
+
746
+ # ifdef stdint_intptr_bits
747
+ # define stdint_intptr_glue3_i(a,b,c) a##b##c
748
+ # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
749
+ # ifndef PRINTF_INTPTR_MODIFIER
750
+ # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
751
+ # endif
752
+ # ifndef PTRDIFF_MAX
753
+ # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
754
+ # endif
755
+ # ifndef PTRDIFF_MIN
756
+ # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
757
+ # endif
758
+ # ifndef UINTPTR_MAX
759
+ # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
760
+ # endif
761
+ # ifndef INTPTR_MAX
762
+ # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
763
+ # endif
764
+ # ifndef INTPTR_MIN
765
+ # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
766
+ # endif
767
+ # ifndef INTPTR_C
768
+ # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
769
+ # endif
770
+ # ifndef UINTPTR_C
771
+ # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
772
+ # endif
773
+ typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
774
+ typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
775
+ # else
776
+ /* TODO -- This following is likely wrong for some platforms, and does
777
+ nothing for the definition of uintptr_t. */
778
+ typedef ptrdiff_t intptr_t;
779
+ # endif
780
+ # define STDINT_H_UINTPTR_T_DEFINED
781
+ #endif
782
+
783
+ /*
784
+ * Assumes sig_atomic_t is signed and we have a 2s complement machine.
785
+ */
786
+
787
+ #ifndef SIG_ATOMIC_MAX
788
+ # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
789
+ #endif
790
+
791
+ #endif
792
+
793
+ #if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
794
+
795
+ /*
796
+ * Please compile with the maximum warning settings to make sure macros are
797
+ * not defined more than once.
798
+ */
799
+
800
+ #include <stdlib.h>
801
+ #include <stdio.h>
802
+ #include <string.h>
803
+
804
+ #define glue3_aux(x,y,z) x ## y ## z
805
+ #define glue3(x,y,z) glue3_aux(x,y,z)
806
+
807
+ #define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
808
+ #define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);
809
+
810
+ #define DECL(us,bits) glue3(DECL,us,) (bits)
811
+
812
+ #define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)
813
+
814
+ #define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }
815
+
816
+ int main () {
817
+ int err_n = 0;
818
+ int err_first = 0;
819
+ DECL(I,8)
820
+ DECL(U,8)
821
+ DECL(I,16)
822
+ DECL(U,16)
823
+ DECL(I,32)
824
+ DECL(U,32)
825
+ #ifdef INT64_MAX
826
+ DECL(I,64)
827
+ DECL(U,64)
828
+ #endif
829
+ intmax_t imax = INTMAX_C(0);
830
+ uintmax_t umax = UINTMAX_C(0);
831
+ char str0[256], str1[256];
832
+
833
+ sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
834
+ if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
835
+ if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
836
+ sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
837
+ if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
838
+ if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
839
+ #ifdef INT64_MAX
840
+ sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
841
+ if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
842
+ if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
843
+ sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
844
+ if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
845
+ if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
846
+ #endif
847
+
848
+ sprintf (str0, "%d %x\n", 0, ~0);
849
+
850
+ sprintf (str1, "%d %x\n", i8, ~0);
851
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
852
+ sprintf (str1, "%u %x\n", u8, ~0);
853
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
854
+ sprintf (str1, "%d %x\n", i16, ~0);
855
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
856
+ sprintf (str1, "%u %x\n", u16, ~0);
857
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
858
+ sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
859
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
860
+ sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
861
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
862
+ #ifdef INT64_MAX
863
+ sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
864
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
865
+ #endif
866
+ sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
867
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
868
+ sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
869
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));
870
+
871
+ TESTUMAX(8);
872
+ TESTUMAX(16);
873
+ TESTUMAX(32);
874
+ #ifdef INT64_MAX
875
+ TESTUMAX(64);
876
+ #endif
877
+
878
+ #define STR(v) #v
879
+ #define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
880
+ if (err_n) {
881
+ printf ("pstdint.h is not correct. Please use sizes below to correct it:\n");
882
+ }
883
+
884
+ Q(int)
885
+ Q(unsigned)
886
+ Q(long int)
887
+ Q(short int)
888
+ Q(int8_t)
889
+ Q(int16_t)
890
+ Q(int32_t)
891
+ #ifdef INT64_MAX
892
+ Q(int64_t)
893
+ #endif
894
+
895
+ return EXIT_SUCCESS;
896
+ }
897
+
898
+ #endif