aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs
diff options
context:
space:
mode:
authorsomov <somov@yandex-team.ru>2022-02-10 16:45:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:49 +0300
commit7489e4682331202b9c7d863c0898eb83d7b12c2b (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /contrib/libs
parenta5950576e397b1909261050b8c7da16db58f10b1 (diff)
downloadydb-7489e4682331202b9c7d863c0898eb83d7b12c2b.tar.gz
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs')
-rw-r--r--contrib/libs/antlr3_cpp_runtime/ya.make10
-rw-r--r--contrib/libs/base64/avx2/ya.make2
-rw-r--r--contrib/libs/base64/ssse3/ya.make8
-rw-r--r--contrib/libs/crcutil/LICENSE404
-rw-r--r--contrib/libs/crcutil/crc32c_sse4.cc4
-rw-r--r--contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.patch.txt622
-rw-r--r--contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.txt182
-rw-r--r--contrib/libs/cxxsupp/builtins/LICENSE.txt182
-rw-r--r--contrib/libs/cxxsupp/builtins/int_types.h2
-rw-r--r--contrib/libs/cxxsupp/builtins/ya.make120
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__config24
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__locale2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__string8
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/android/locale_bionic.h6
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__tuple34
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/complex4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/cxxabi.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/span20
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/unwind.h14
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/version20
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp12
-rw-r--r--contrib/libs/cxxsupp/libcxx/ya.make60
-rw-r--r--contrib/libs/cxxsupp/libcxxrt/cxxabi.h6
-rw-r--r--contrib/libs/cxxsupp/libcxxrt/exception.cc16
-rw-r--r--contrib/libs/cxxsupp/libcxxrt/ya.make8
-rw-r--r--contrib/libs/cxxsupp/libgcc/cxxabi.cpp26
-rw-r--r--contrib/libs/cxxsupp/libgcc/cxxabi.h12
-rw-r--r--contrib/libs/cxxsupp/libgcc/stdcxx_bits.cpp24
-rw-r--r--contrib/libs/cxxsupp/libgcc/stdcxx_bits.h22
-rw-r--r--contrib/libs/cxxsupp/libgcc/ya.make30
-rw-r--r--contrib/libs/cxxsupp/libsan/generate_symbolizer.py24
-rw-r--r--contrib/libs/cxxsupp/libsan/inject.c8
-rw-r--r--contrib/libs/cxxsupp/libsan/ya.make26
-rw-r--r--contrib/libs/cxxsupp/system_stl/include/stlfwd22
-rw-r--r--contrib/libs/cxxsupp/system_stl/ya.make18
-rw-r--r--contrib/libs/cxxsupp/ya.make28
-rw-r--r--contrib/libs/farmhash/COPYING38
-rw-r--r--contrib/libs/farmhash/IMPORT2
-rw-r--r--contrib/libs/farmhash/README326
-rw-r--r--contrib/libs/farmhash/arch/sse41/ya.make24
-rw-r--r--contrib/libs/farmhash/arch/sse42/ya.make32
-rw-r--r--contrib/libs/farmhash/arch/sse42_aesni/ya.make22
-rw-r--r--contrib/libs/farmhash/common.h824
-rw-r--r--contrib/libs/farmhash/farmhash.cc23662
-rw-r--r--contrib/libs/farmhash/farmhash.h656
-rw-r--r--contrib/libs/farmhash/farmhash_iface.cc212
-rw-r--r--contrib/libs/farmhash/farmhash_iface.h56
-rw-r--r--contrib/libs/farmhash/farmhashcc.cc628
-rw-r--r--contrib/libs/farmhash/farmhashmk.cc240
-rw-r--r--contrib/libs/farmhash/farmhashna.cc346
-rw-r--r--contrib/libs/farmhash/farmhashnt.cc62
-rw-r--r--contrib/libs/farmhash/farmhashsa.cc432
-rw-r--r--contrib/libs/farmhash/farmhashsu.cc452
-rw-r--r--contrib/libs/farmhash/farmhashte.cc476
-rw-r--r--contrib/libs/farmhash/farmhashuo.cc242
-rw-r--r--contrib/libs/farmhash/farmhashxo.cc142
-rwxr-xr-xcontrib/libs/farmhash/split.py148
-rw-r--r--contrib/libs/farmhash/test.cc19574
-rw-r--r--contrib/libs/farmhash/ut/ya.make20
-rw-r--r--contrib/libs/farmhash/ya.make46
-rw-r--r--contrib/libs/fastlz/LICENSE48
-rw-r--r--contrib/libs/grpc/src/python/grpcio/ya.make4
-rw-r--r--contrib/libs/grpc/ya.make2
-rw-r--r--contrib/libs/highwayhash/IMPORT2
-rw-r--r--contrib/libs/highwayhash/LICENSE406
-rw-r--r--contrib/libs/highwayhash/README.md700
-rw-r--r--contrib/libs/highwayhash/arch/avx2/ya.make34
-rw-r--r--contrib/libs/highwayhash/arch/sse41/ya.make32
-rw-r--r--contrib/libs/highwayhash/highwayhash/arch_specific.cc236
-rw-r--r--contrib/libs/highwayhash/highwayhash/arch_specific.h306
-rw-r--r--contrib/libs/highwayhash/highwayhash/benchmark.cc626
-rw-r--r--contrib/libs/highwayhash/highwayhash/c_bindings.cc70
-rw-r--r--contrib/libs/highwayhash/highwayhash/c_bindings.h110
-rw-r--r--contrib/libs/highwayhash/highwayhash/compiler_specific.h180
-rw-r--r--contrib/libs/highwayhash/highwayhash/data_parallel.h682
-rw-r--r--contrib/libs/highwayhash/highwayhash/data_parallel_benchmark.cc302
-rw-r--r--contrib/libs/highwayhash/highwayhash/data_parallel_test.cc350
-rw-r--r--contrib/libs/highwayhash/highwayhash/endianess.h216
-rw-r--r--contrib/libs/highwayhash/highwayhash/example.cc60
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_avx2.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_avx2.h766
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_buffer.h206
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_portable.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_portable.h602
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_sse41.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_sse41.h660
-rw-r--r--contrib/libs/highwayhash/highwayhash/hh_types.h100
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash.h404
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_target.cc208
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_target.h182
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_test.cc776
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_test_avx2.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_test_portable.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_test_sse41.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_test_target.cc422
-rw-r--r--contrib/libs/highwayhash/highwayhash/highwayhash_test_target.h178
-rw-r--r--contrib/libs/highwayhash/highwayhash/iaca.h126
-rw-r--r--contrib/libs/highwayhash/highwayhash/instruction_sets.cc282
-rw-r--r--contrib/libs/highwayhash/highwayhash/instruction_sets.h176
-rw-r--r--contrib/libs/highwayhash/highwayhash/load3.h288
-rw-r--r--contrib/libs/highwayhash/highwayhash/nanobenchmark.cc874
-rw-r--r--contrib/libs/highwayhash/highwayhash/nanobenchmark.h316
-rw-r--r--contrib/libs/highwayhash/highwayhash/nanobenchmark_example.cc96
-rw-r--r--contrib/libs/highwayhash/highwayhash/os_specific.cc478
-rw-r--r--contrib/libs/highwayhash/highwayhash/os_specific.h108
-rw-r--r--contrib/libs/highwayhash/highwayhash/profiler.h1508
-rw-r--r--contrib/libs/highwayhash/highwayhash/profiler_example.cc194
-rw-r--r--contrib/libs/highwayhash/highwayhash/robust_statistics.h270
-rw-r--r--contrib/libs/highwayhash/highwayhash/scalar.h704
-rw-r--r--contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.cc366
-rw-r--r--contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.h74
-rw-r--r--contrib/libs/highwayhash/highwayhash/sip_hash.cc66
-rw-r--r--contrib/libs/highwayhash/highwayhash/sip_hash.h342
-rw-r--r--contrib/libs/highwayhash/highwayhash/sip_hash_test.cc300
-rw-r--r--contrib/libs/highwayhash/highwayhash/sip_tree_hash.cc454
-rw-r--r--contrib/libs/highwayhash/highwayhash/sip_tree_hash.h104
-rw-r--r--contrib/libs/highwayhash/highwayhash/state_helpers.h254
-rw-r--r--contrib/libs/highwayhash/highwayhash/tsc_timer.h408
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector128.h1592
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector256.h1516
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector_test.cc118
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector_test_avx2.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector_test_portable.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector_test_sse41.cc38
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector_test_target.cc440
-rw-r--r--contrib/libs/highwayhash/highwayhash/vector_test_target.h74
-rw-r--r--contrib/libs/highwayhash/ya.make80
-rw-r--r--contrib/libs/jemalloc/reg_zone.cpp46
-rw-r--r--contrib/libs/jemalloc/src/jemalloc.c4
-rw-r--r--contrib/libs/jwt-cpp/picojson.h2
-rw-r--r--contrib/libs/libaio/COPYING1030
-rw-r--r--contrib/libs/libaio/ya.make6
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/README.md182
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/aligned_alloc.c12
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/c16rtomb.c70
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/c32rtomb.c14
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/features.h10
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/getauxval.cpp20
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/glibc.cpp222
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/glibc.h40
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/mbrtoc16.c60
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/mbrtoc32.c26
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/secure_getenv.cpp24
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/timespec_get.c20
-rw-r--r--contrib/libs/libc_compat/ubuntu_14/ya.make44
-rw-r--r--contrib/libs/libidn/COPYING.LIB1008
-rw-r--r--contrib/libs/libidn/stringprep.h2
-rw-r--r--contrib/libs/libunwind/src/Unwind-EHABI.cpp2
-rw-r--r--contrib/libs/libunwind/ut/libunwind_ut.cpp52
-rw-r--r--contrib/libs/libunwind/ut/ya.make16
-rw-r--r--contrib/libs/libxml/COPYING46
-rw-r--r--contrib/libs/libxml/ya.make4
-rw-r--r--contrib/libs/llvm12/include/llvm/Demangle/ItaniumDemangle.h16
-rw-r--r--contrib/libs/llvm12/lib/Demangle/ItaniumDemangle.cpp12
-rw-r--r--contrib/libs/lzmasdk/AesOpt.c20
-rw-r--r--contrib/libs/openssl/dynamic/ya.make10
-rw-r--r--contrib/libs/openssl/include/openssl/opensslconf-linux.h40
-rw-r--r--contrib/libs/openssl/ssl/ssl_cert.c10
-rw-r--r--contrib/libs/protoc/LICENSE62
-rw-r--r--contrib/libs/re2/re2/re2.cc4
-rw-r--r--contrib/libs/re2/re2/re2.h28
-rw-r--r--contrib/libs/re2/re2/stringpiece.h8
-rw-r--r--contrib/libs/sparsehash/ya.make4
-rw-r--r--contrib/libs/sqlite3/sqlite3.c2
-rw-r--r--contrib/libs/sqlite3/ya.make6
-rw-r--r--contrib/libs/t1ha/src/t1ha0.c2
-rw-r--r--contrib/libs/ya.make42
-rw-r--r--contrib/libs/zlib/gzguts.h4
169 files changed, 37366 insertions, 37366 deletions
diff --git a/contrib/libs/antlr3_cpp_runtime/ya.make b/contrib/libs/antlr3_cpp_runtime/ya.make
index effaf1c085..5c019aa396 100644
--- a/contrib/libs/antlr3_cpp_runtime/ya.make
+++ b/contrib/libs/antlr3_cpp_runtime/ya.make
@@ -1,10 +1,10 @@
LIBRARY()
-# git repository: https://github.com/ibre5041/antlr3.git
-# XXX fork of: https://github.com/antlr/antlr3.git
-# directory: runtime/Cpp
-# revision: a4d1928e03b2b3f74579e54a6211cd1d695001b9
-
+# git repository: https://github.com/ibre5041/antlr3.git
+# XXX fork of: https://github.com/antlr/antlr3.git
+# directory: runtime/Cpp
+# revision: a4d1928e03b2b3f74579e54a6211cd1d695001b9
+
VERSION(2016-03-31-a4d1928e03b2b3f74579e54a6211cd1d695001b9)
LICENSE(
diff --git a/contrib/libs/base64/avx2/ya.make b/contrib/libs/base64/avx2/ya.make
index 173d3cef55..b0dc5ce772 100644
--- a/contrib/libs/base64/avx2/ya.make
+++ b/contrib/libs/base64/avx2/ya.make
@@ -24,7 +24,7 @@ IF (ARCH_X86_64 OR ARCH_I386)
IF (MSVC AND NOT CLANG_CL)
CONLYFLAGS(/D__AVX2__=1)
ELSEIF (CLANG_CL)
- CONLYFLAGS(-mavx2)
+ CONLYFLAGS(-mavx2)
ELSE()
CONLYFLAGS(
-mavx2
diff --git a/contrib/libs/base64/ssse3/ya.make b/contrib/libs/base64/ssse3/ya.make
index b9dde09e91..c9cf647001 100644
--- a/contrib/libs/base64/ssse3/ya.make
+++ b/contrib/libs/base64/ssse3/ya.make
@@ -21,11 +21,11 @@ SRCS(
)
IF (ARCH_X86_64 OR ARCH_I386)
- IF (MSVC AND NOT CLANG_CL)
- CONLYFLAGS(/D__SSSE3__=1)
+ IF (MSVC AND NOT CLANG_CL)
+ CONLYFLAGS(/D__SSSE3__=1)
ELSEIF (CLANG_CL)
- CONLYFLAGS(-mssse3)
- ELSE()
+ CONLYFLAGS(-mssse3)
+ ELSE()
CONLYFLAGS(
-mssse3
-std=c11
diff --git a/contrib/libs/crcutil/LICENSE b/contrib/libs/crcutil/LICENSE
index c0fd617439..d645695673 100644
--- a/contrib/libs/crcutil/LICENSE
+++ b/contrib/libs/crcutil/LICENSE
@@ -1,202 +1,202 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/contrib/libs/crcutil/crc32c_sse4.cc b/contrib/libs/crcutil/crc32c_sse4.cc
index 0ed23eb627..ed0f64410a 100644
--- a/contrib/libs/crcutil/crc32c_sse4.cc
+++ b/contrib/libs/crcutil/crc32c_sse4.cc
@@ -322,9 +322,9 @@ bool Crc32cSSE4::IsSSE42Available() {
uint32 edx;
__asm__ volatile(
#if HAVE_I386 && defined(__PIC__)
- "push %%ebx\n"
+ "push %%ebx\n"
"cpuid\n"
- "pop %%ebx\n"
+ "pop %%ebx\n"
#else
"cpuid\n"
#endif // HAVE_I386 && defined(__PIC__)
diff --git a/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.patch.txt b/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.patch.txt
index 5576656bf9..5a79a1b9d5 100644
--- a/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.patch.txt
+++ b/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.patch.txt
@@ -1,311 +1,311 @@
-==============================================================================
-The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
-==============================================================================
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
----- LLVM Exceptions to the Apache 2.0 License ----
-
-As an exception, if, as a result of your compiling your source code, portions
-of this Software are embedded into an Object form of such source code, you
-may redistribute such embedded portions in such Object form without complying
-with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
-
-In addition, if you combine or link compiled forms of this Software with
-software that is licensed under the GPLv2 ("Combined Software") and if a
-court of competent jurisdiction determines that the patent provision (Section
-3), the indemnity provision (Section 9) or other Section of the License
-conflicts with the conditions of the GPLv2, you may retroactively and
-prospectively choose to deem waived or otherwise exclude such Section(s) of
-the License, but only in their entirety and only with respect to the Combined
-Software.
-
-==============================================================================
-Software from third parties included in the LLVM Project:
-==============================================================================
-The LLVM Project contains third party software which is under different license
-terms. All such code will be identified clearly using at least one of two
-mechanisms:
-1) It will be in a separate directory tree with its own `LICENSE.txt` or
- `LICENSE` file at the top containing the specific license and restrictions
- which apply to that software, or
-2) It will contain specific license and restriction terms at the top of every
- file.
-
-==============================================================================
-Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
-==============================================================================
-
-The compiler_rt library is dual licensed under both the University of Illinois
-"BSD-Like" license and the MIT license. As a user of this code you may choose
-to use it under either license. As a contributor, you agree to allow your code
-to be used under both.
-
-Full text of the relevant licenses is included below.
-
-==============================================================================
-
-University of Illinois/NCSA
-Open Source License
-
-Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT
-
-All rights reserved.
-
-Developed by:
-
- LLVM Team
-
- University of Illinois at Urbana-Champaign
-
- http://llvm.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal with
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimers.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimers in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the names of the LLVM Team, University of Illinois at
- Urbana-Champaign, nor the names of its contributors may be used to
- endorse or promote products derived from this Software without specific
- prior written permission.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
-SOFTWARE.
-
-==============================================================================
-
-Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+ `LICENSE` file at the top containing the specific license and restrictions
+ which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+ file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
+==============================================================================
+
+The compiler_rt library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license. As a user of this code you may choose
+to use it under either license. As a contributor, you agree to allow your code
+to be used under both.
+
+Full text of the relevant licenses is included below.
+
+==============================================================================
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT
+
+All rights reserved.
+
+Developed by:
+
+ LLVM Team
+
+ University of Illinois at Urbana-Champaign
+
+ http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimers.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimers in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the names of the LLVM Team, University of Illinois at
+ Urbana-Champaign, nor the names of its contributors may be used to
+ endorse or promote products derived from this Software without specific
+ prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+
+Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.txt b/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.txt
index 8d1cc0fa53..0134694e4e 100644
--- a/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.txt
+++ b/contrib/libs/cxxsupp/builtins/LICENSE.os_version_check.c.txt
@@ -1,91 +1,91 @@
-==============================================================================
-compiler_rt License
-==============================================================================
-
-The compiler_rt library is dual licensed under both the University of Illinois
-"BSD-Like" license and the MIT license. As a user of this code you may choose
-to use it under either license. As a contributor, you agree to allow your code
-to be used under both.
-
-Full text of the relevant licenses is included below.
-
-==============================================================================
-
-University of Illinois/NCSA
-Open Source License
-
-Copyright (c) 2009-2018 by the contributors listed in CREDITS.TXT
-
-All rights reserved.
-
-Developed by:
-
- LLVM Team
-
- University of Illinois at Urbana-Champaign
-
- http://llvm.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal with
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimers.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimers in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the names of the LLVM Team, University of Illinois at
- Urbana-Champaign, nor the names of its contributors may be used to
- endorse or promote products derived from this Software without specific
- prior written permission.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
-SOFTWARE.
-
-==============================================================================
-
-Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-==============================================================================
-Copyrights and Licenses for Third Party Software Distributed with LLVM:
-==============================================================================
-The LLVM software contains code written by third parties. Such software will
-have its own individual LICENSE.TXT file in the directory in which it appears.
-This file will describe the copyrights, license, and restrictions which apply
-to that code.
-
-The disclaimer of warranty in the University of Illinois Open Source License
-applies to all code in the LLVM Distribution, and nothing in any of the
-other licenses gives permission to use the names of the LLVM Team or the
-University of Illinois to endorse or promote products derived from this
-Software.
-
+==============================================================================
+compiler_rt License
+==============================================================================
+
+The compiler_rt library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license. As a user of this code you may choose
+to use it under either license. As a contributor, you agree to allow your code
+to be used under both.
+
+Full text of the relevant licenses is included below.
+
+==============================================================================
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2009-2018 by the contributors listed in CREDITS.TXT
+
+All rights reserved.
+
+Developed by:
+
+ LLVM Team
+
+ University of Illinois at Urbana-Champaign
+
+ http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimers.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimers in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the names of the LLVM Team, University of Illinois at
+ Urbana-Champaign, nor the names of its contributors may be used to
+ endorse or promote products derived from this Software without specific
+ prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+
+Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+==============================================================================
+Copyrights and Licenses for Third Party Software Distributed with LLVM:
+==============================================================================
+The LLVM software contains code written by third parties. Such software will
+have its own individual LICENSE.TXT file in the directory in which it appears.
+This file will describe the copyrights, license, and restrictions which apply
+to that code.
+
+The disclaimer of warranty in the University of Illinois Open Source License
+applies to all code in the LLVM Distribution, and nothing in any of the
+other licenses gives permission to use the names of the LLVM Team or the
+University of Illinois to endorse or promote products derived from this
+Software.
+
diff --git a/contrib/libs/cxxsupp/builtins/LICENSE.txt b/contrib/libs/cxxsupp/builtins/LICENSE.txt
index 8f4608b1e7..aa4115e2a7 100644
--- a/contrib/libs/cxxsupp/builtins/LICENSE.txt
+++ b/contrib/libs/cxxsupp/builtins/LICENSE.txt
@@ -1,91 +1,91 @@
-==============================================================================
-compiler_rt License
-==============================================================================
-
-The compiler_rt library is dual licensed under both the University of Illinois
-"BSD-Like" license and the MIT license. As a user of this code you may choose
-to use it under either license. As a contributor, you agree to allow your code
-to be used under both.
-
-Full text of the relevant licenses is included below.
-
-==============================================================================
-
-University of Illinois/NCSA
-Open Source License
-
-Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
-
-All rights reserved.
-
-Developed by:
-
- LLVM Team
-
- University of Illinois at Urbana-Champaign
-
- http://llvm.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal with
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimers.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimers in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the names of the LLVM Team, University of Illinois at
- Urbana-Champaign, nor the names of its contributors may be used to
- endorse or promote products derived from this Software without specific
- prior written permission.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
-SOFTWARE.
-
-==============================================================================
-
-Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-==============================================================================
-Copyrights and Licenses for Third Party Software Distributed with LLVM:
-==============================================================================
-The LLVM software contains code written by third parties. Such software will
-have its own individual LICENSE.TXT file in the directory in which it appears.
-This file will describe the copyrights, license, and restrictions which apply
-to that code.
-
-The disclaimer of warranty in the University of Illinois Open Source License
-applies to all code in the LLVM Distribution, and nothing in any of the
-other licenses gives permission to use the names of the LLVM Team or the
-University of Illinois to endorse or promote products derived from this
-Software.
-
+==============================================================================
+compiler_rt License
+==============================================================================
+
+The compiler_rt library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license. As a user of this code you may choose
+to use it under either license. As a contributor, you agree to allow your code
+to be used under both.
+
+Full text of the relevant licenses is included below.
+
+==============================================================================
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
+
+All rights reserved.
+
+Developed by:
+
+ LLVM Team
+
+ University of Illinois at Urbana-Champaign
+
+ http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimers.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimers in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the names of the LLVM Team, University of Illinois at
+ Urbana-Champaign, nor the names of its contributors may be used to
+ endorse or promote products derived from this Software without specific
+ prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+
+Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+==============================================================================
+Copyrights and Licenses for Third Party Software Distributed with LLVM:
+==============================================================================
+The LLVM software contains code written by third parties. Such software will
+have its own individual LICENSE.TXT file in the directory in which it appears.
+This file will describe the copyrights, license, and restrictions which apply
+to that code.
+
+The disclaimer of warranty in the University of Illinois Open Source License
+applies to all code in the LLVM Distribution, and nothing in any of the
+other licenses gives permission to use the names of the LLVM Team or the
+University of Illinois to endorse or promote products derived from this
+Software.
+
diff --git a/contrib/libs/cxxsupp/builtins/int_types.h b/contrib/libs/cxxsupp/builtins/int_types.h
index 7e97794631..23065b89bd 100644
--- a/contrib/libs/cxxsupp/builtins/int_types.h
+++ b/contrib/libs/cxxsupp/builtins/int_types.h
@@ -61,7 +61,7 @@ typedef union
} udwords;
/* MIPS64 issue: PR 20098 */
-#if defined(__LP64__) && !(defined(__mips__) && defined(__clang__)) || (defined(_MSC_VER) && defined(__clang__))
+#if defined(__LP64__) && !(defined(__mips__) && defined(__clang__)) || (defined(_MSC_VER) && defined(__clang__))
#define CRT_HAS_128BIT
#endif
diff --git a/contrib/libs/cxxsupp/builtins/ya.make b/contrib/libs/cxxsupp/builtins/ya.make
index 5ac48cdd9f..d2c319c927 100644
--- a/contrib/libs/cxxsupp/builtins/ya.make
+++ b/contrib/libs/cxxsupp/builtins/ya.make
@@ -1,21 +1,21 @@
LIBRARY()
-# Part of compiler-rt LLVM subproject
-
-# git repository: https://github.com/llvm/llvm-project.git
-# directory: compiler-rt/lib/builtins
-# revision: 08f0372c351a57b01afee6c64066961203da28c5
-
-# os_version_check.c was taken from revision 81b89fd7bdddb7da66f2cdace97d6ede5f99d58a
-# os_version_check.c was patched from git repository https://github.com/apple/llvm-project.git revision a02454b91d2aec347b9ce03020656c445f3b2841
-
-LICENSE(
+# Part of compiler-rt LLVM subproject
+
+# git repository: https://github.com/llvm/llvm-project.git
+# directory: compiler-rt/lib/builtins
+# revision: 08f0372c351a57b01afee6c64066961203da28c5
+
+# os_version_check.c was taken from revision 81b89fd7bdddb7da66f2cdace97d6ede5f99d58a
+# os_version_check.c was patched from git repository https://github.com/apple/llvm-project.git revision a02454b91d2aec347b9ce03020656c445f3b2841
+
+LICENSE(
Apache-2.0 AND
Apache-2.0 WITH LLVM-exception AND
MIT AND
NCSA
-)
-
+)
+
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
VERSION(2016-03-03-08f0372c351a57b01afee6c64066961203da28c5)
@@ -51,64 +51,64 @@ NO_PLATFORM()
NO_COMPILER_WARNINGS()
-IF (GCC OR CLANG)
- # Clang (maybe GCC too) LTO code generator leaves the builtin calls unresolved
- # even if they are available. After the code generation pass is done
- # a linker is forced to select original object files from this library again
- # as they contain unresolved symbols. But code generation is already done,
- # object files actually are not ELFs but an LLVM bytecode and we get
- # "member at xxxxx is not an ELF object" errors from the linker.
- # Just generate native code from the beginning.
- DISABLE(USE_LTO)
-ENDIF()
-
-SRCS(
- addtf3.c
+IF (GCC OR CLANG)
+ # Clang (maybe GCC too) LTO code generator leaves the builtin calls unresolved
+ # even if they are available. After the code generation pass is done
+ # a linker is forced to select original object files from this library again
+ # as they contain unresolved symbols. But code generation is already done,
+ # object files actually are not ELFs but an LLVM bytecode and we get
+ # "member at xxxxx is not an ELF object" errors from the linker.
+ # Just generate native code from the beginning.
+ DISABLE(USE_LTO)
+ENDIF()
+
+SRCS(
+ addtf3.c
ashlti3.c
- clzti2.c
- comparetf2.c
- divdc3.c
- divsc3.c
- divtf3.c
- divti3.c
- divxc3.c
- extenddftf2.c
- extendsftf2.c
- fixdfti.c
+ clzti2.c
+ comparetf2.c
+ divdc3.c
+ divsc3.c
+ divtf3.c
+ divti3.c
+ divxc3.c
+ extenddftf2.c
+ extendsftf2.c
+ fixdfti.c
fixsfti.c
- fixtfdi.c
- fixtfsi.c
+ fixtfdi.c
+ fixtfsi.c
fixunsdfti.c
fixunssfti.c
fixunstfdi.c
- fixunstfsi.c
+ fixunstfsi.c
fixunstfti.c
fixunsxfti.c
- floatditf.c
- floatsitf.c
- floattidf.c
- floattisf.c
- floatunditf.c
- floatunsitf.c
+ floatditf.c
+ floatsitf.c
+ floattidf.c
+ floattisf.c
+ floatunditf.c
+ floatunsitf.c
floatuntidf.c
floatuntisf.c
- gcc_personality_v0.c
- int_util.c
+ gcc_personality_v0.c
+ int_util.c
lshrti3.c
- modti3.c
- muldc3.c
- muloti4.c
- mulsc3.c
- multf3.c
- mulxc3.c
- popcountdi2.c
- subtf3.c
- trunctfdf2.c
- trunctfsf2.c
- udivmodti4.c
- udivti3.c
- umodti3.c
-)
+ modti3.c
+ muldc3.c
+ muloti4.c
+ mulsc3.c
+ multf3.c
+ mulxc3.c
+ popcountdi2.c
+ subtf3.c
+ trunctfdf2.c
+ trunctfsf2.c
+ udivmodti4.c
+ udivti3.c
+ umodti3.c
+)
IF (OS_DARWIN OR OS_IOS)
SRCS(
diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config
index 64c5a00c48..bdc54b92d1 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__config
+++ b/contrib/libs/cxxsupp/libcxx/include/__config
@@ -34,16 +34,16 @@
#elif defined(_MSC_VER)
#define _LIBCPP_COMPILER_MSVC
-#if _MSVC_LANG == 201705L
-# define _LIBCPP_STD_VER 20
-#elif _MSVC_LANG == 201703L
+#if _MSVC_LANG == 201705L
+# define _LIBCPP_STD_VER 20
+#elif _MSVC_LANG == 201703L
# define _LIBCPP_STD_VER 17
#else
# define _LIBCPP_STD_VER 14
#endif
-#define _LIBCPP_UCRT_INCLUDE(x) <Y_UCRT_INCLUDE/x>
-#define _LIBCPP_MSVC_INCLUDE(x) <Y_MSVC_INCLUDE/x>
+#define _LIBCPP_UCRT_INCLUDE(x) <Y_UCRT_INCLUDE/x>
+#define _LIBCPP_MSVC_INCLUDE(x) <Y_MSVC_INCLUDE/x>
#elif defined(__IBMCPP__)
#define _LIBCPP_COMPILER_IBM
#endif
@@ -1306,8 +1306,8 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#endif
#if defined(_LIBCPP_ABI_MICROSOFT) && \
- (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) && \
- !defined(__CUDACC__)
+ (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) && \
+ !defined(__CUDACC__)
# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
#else
# define _LIBCPP_DECLSPEC_EMPTY_BASES
@@ -1336,11 +1336,11 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
#endif
-// Yandex-specific: We build our own libc++, so it has everything available
-#define _LIBCPP_DISABLE_AVAILABILITY
-// End of Yandex-specific
-
-#if defined(_LIBCPP_COMPILER_IBM) || defined(__CUDACC__)
+// Yandex-specific: We build our own libc++, so it has everything available
+#define _LIBCPP_DISABLE_AVAILABILITY
+// End of Yandex-specific
+
+#if defined(_LIBCPP_COMPILER_IBM) || defined(__CUDACC__)
#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/include/__locale b/contrib/libs/cxxsupp/libcxx/include/__locale
index 3ca06c386a..38cb7a6f39 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__locale
+++ b/contrib/libs/cxxsupp/libcxx/include/__locale
@@ -34,7 +34,7 @@
# include <__support/newlib/xlocale.h>
#elif defined(__OpenBSD__)
# include <__support/openbsd/xlocale.h>
-#elif (defined(__APPLE__) || defined(__FreeBSD__) \
+#elif (defined(__APPLE__) || defined(__FreeBSD__) \
|| defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
# include <xlocale.h>
#elif defined(__Fuchsia__)
diff --git a/contrib/libs/cxxsupp/libcxx/include/__string b/contrib/libs/cxxsupp/libcxx/include/__string
index 161f7195d0..7074a73538 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__string
+++ b/contrib/libs/cxxsupp/libcxx/include/__string
@@ -426,7 +426,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a)
{
if (__n == 0)
return nullptr;
-#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
return __builtin_char_memchr(__s, to_int_type(__a), __n);
#elif _LIBCPP_STD_VER <= 14
return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n);
@@ -509,7 +509,7 @@ char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size
{
if (__n == 0)
return 0;
-#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
return __builtin_wmemcmp(__s1, __s2, __n);
#elif _LIBCPP_STD_VER <= 14
return _VSTD::wmemcmp(__s1, __s2, __n);
@@ -529,7 +529,7 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t
char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
{
-#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
return __builtin_wcslen(__s);
#elif _LIBCPP_STD_VER <= 14
return _VSTD::wcslen(__s);
@@ -547,7 +547,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
{
if (__n == 0)
return nullptr;
-#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
+#if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__)
return __builtin_wmemchr(__s, __a, __n);
#elif _LIBCPP_STD_VER <= 14
return _VSTD::wmemchr(__s, __a, __n);
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/android/locale_bionic.h b/contrib/libs/cxxsupp/libcxx/include/__support/android/locale_bionic.h
index 650683310c..733eb83642 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/android/locale_bionic.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/android/locale_bionic.h
@@ -26,9 +26,9 @@ extern "C" {
#if defined(__ANDROID__)
#include <android/api-level.h>
-#if defined(__has_include) && __has_include(<android/ndk-version.h>)
-# include <android/ndk-version.h>
-#endif
+#if defined(__has_include) && __has_include(<android/ndk-version.h>)
+# include <android/ndk-version.h>
+#endif
#if __ANDROID_API__ < 21
#include <__support/xlocale/__posix_l_fallback.h>
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h b/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h
index cc7bdeee63..e32bcf9073 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h
@@ -64,9 +64,9 @@ static inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) {
}
static inline void __c11_atomic_thread_fence(int __order) {
- if (__order != static_cast<int>(memory_order_relaxed)) {
+ if (__order != static_cast<int>(memory_order_relaxed)) {
#if defined(_M_IX86) || defined(_M_X64)
- if (__order == static_cast<int>(memory_order_seq_cst)) {
+ if (__order == static_cast<int>(memory_order_seq_cst)) {
_MemoryBarrier;
} else {
_ReadWriteBarrier();
diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple b/contrib/libs/cxxsupp/libcxx/include/__tuple
index d52b88497a..08f4dd5efa 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__tuple
+++ b/contrib/libs/cxxsupp/libcxx/include/__tuple
@@ -91,7 +91,7 @@ struct __integer_sequence {
using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
};
-#if defined(__CUDACC__) || !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+#if defined(__CUDACC__) || !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
namespace __detail {
template<typename _Tp, size_t ..._Extra> struct __repeat;
@@ -133,7 +133,7 @@ template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<t
#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
-#if __has_builtin(__make_integer_seq) && !defined(__CUDACC__)
+#if __has_builtin(__make_integer_seq) && !defined(__CUDACC__)
template <size_t _Ep, size_t _Sp>
using __make_indices_imp =
typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
@@ -264,7 +264,7 @@ __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
} // namespace __indexer_detail
-#if !defined(__CUDACC__) || !defined(_MSC_VER)
+#if !defined(__CUDACC__) || !defined(_MSC_VER)
template <size_t _Idx, class ..._Types>
using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
__indexer_detail::__at_index<_Idx>(
@@ -274,20 +274,20 @@ using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
>{})
)::type;
-#else // !defined(__CUDACC__) || !defined(_MSC_VER)
-template <size_t _Idx, class ..._Types>
-struct __y_type_pack_element {
- using __t1 = typename __make_tuple_indices<sizeof...(_Types)>::type;
- using __t2 = __indexer_detail::__indexer<__tuple_types<_Types...>, __t1>;
- using __t3 = decltype(__indexer_detail::__at_index<_Idx>(__t2{}));
- using __t4 = typename __t3::type;
-};
-
-template <size_t _Idx, class ..._Types>
-using __type_pack_element = typename __y_type_pack_element<_Idx, _Types...>::__t4;
-
-#endif // !defined(__CUDACC__) || !defined(_MSC_VER)
-
+#else // !defined(__CUDACC__) || !defined(_MSC_VER)
+template <size_t _Idx, class ..._Types>
+struct __y_type_pack_element {
+ using __t1 = typename __make_tuple_indices<sizeof...(_Types)>::type;
+ using __t2 = __indexer_detail::__indexer<__tuple_types<_Types...>, __t1>;
+ using __t3 = decltype(__indexer_detail::__at_index<_Idx>(__t2{}));
+ using __t4 = typename __t3::type;
+};
+
+template <size_t _Idx, class ..._Types>
+using __type_pack_element = typename __y_type_pack_element<_Idx, _Types...>::__t4;
+
+#endif // !defined(__CUDACC__) || !defined(_MSC_VER)
+
#endif // __has_builtin(__type_pack_element)
template <size_t _Ip, class ..._Types>
diff --git a/contrib/libs/cxxsupp/libcxx/include/complex b/contrib/libs/cxxsupp/libcxx/include/complex
index 5c44fdbf37..e4c59193bc 100644
--- a/contrib/libs/cxxsupp/libcxx/include/complex
+++ b/contrib/libs/cxxsupp/libcxx/include/complex
@@ -1475,7 +1475,7 @@ inline namespace literals
}
-#if !defined(__CUDACC__)
+#if !defined(__CUDACC__)
constexpr complex<float> operator""if(long double __im)
{
return { 0.0f, static_cast<float>(__im) };
@@ -1485,7 +1485,7 @@ inline namespace literals
{
return { 0.0f, static_cast<float>(__im) };
}
-#endif
+#endif
}
}
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/include/cxxabi.h b/contrib/libs/cxxsupp/libcxx/include/cxxabi.h
index 155c6c846b..3b1edaf75a 100644
--- a/contrib/libs/cxxsupp/libcxx/include/cxxabi.h
+++ b/contrib/libs/cxxsupp/libcxx/include/cxxabi.h
@@ -1,9 +1,9 @@
#pragma once
-#if defined(__IOS__) || defined(__ANDROID__)
+#if defined(__IOS__) || defined(__ANDROID__)
#include_next <cxxabi.h>
#elif defined(_WIN32)
// pass
#else
#include <contrib/libs/cxxsupp/libcxxrt/cxxabi.h>
-#endif
+#endif
diff --git a/contrib/libs/cxxsupp/libcxx/include/span b/contrib/libs/cxxsupp/libcxx/include/span
index 1347fb0d64..5d57bd693c 100644
--- a/contrib/libs/cxxsupp/libcxx/include/span
+++ b/contrib/libs/cxxsupp/libcxx/include/span
@@ -591,23 +591,23 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
- inline _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept;
+ inline _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept;
- inline _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> __as_writable_bytes() const noexcept;
+ inline _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> __as_writable_bytes() const noexcept;
private:
pointer __data;
size_type __size;
};
-template<typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> span<_Tp, dynamic_extent>::__as_bytes() const noexcept
-{ return {reinterpret_cast<const byte *>(data()), size_bytes()}; }
-
-template<typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> span<_Tp, dynamic_extent>::__as_writable_bytes() const noexcept
-{ return {reinterpret_cast<byte *>(data()), size_bytes()}; }
-
+template<typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> span<_Tp, dynamic_extent>::__as_bytes() const noexcept
+{ return {reinterpret_cast<const byte *>(data()), size_bytes()}; }
+
+template<typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> span<_Tp, dynamic_extent>::__as_writable_bytes() const noexcept
+{ return {reinterpret_cast<byte *>(data()), size_bytes()}; }
+
#if !defined(_LIBCPP_HAS_NO_RANGES)
template <class _Tp, size_t _Extent>
inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;
diff --git a/contrib/libs/cxxsupp/libcxx/include/unwind.h b/contrib/libs/cxxsupp/libcxx/include/unwind.h
index 9120d3eaec..c608202230 100644
--- a/contrib/libs/cxxsupp/libcxx/include/unwind.h
+++ b/contrib/libs/cxxsupp/libcxx/include/unwind.h
@@ -1,7 +1,7 @@
-#pragma once
-
-#if defined(__IOS__)
-#include_next <unwind.h>
-#else
-#include <contrib/libs/cxxsupp/libcxxrt/unwind.h>
-#endif
+#pragma once
+
+#if defined(__IOS__)
+#include_next <unwind.h>
+#else
+#include <contrib/libs/cxxsupp/libcxxrt/unwind.h>
+#endif
diff --git a/contrib/libs/cxxsupp/libcxx/include/version b/contrib/libs/cxxsupp/libcxx/include/version
index 3190948aed..0e15cfad80 100644
--- a/contrib/libs/cxxsupp/libcxx/include/version
+++ b/contrib/libs/cxxsupp/libcxx/include/version
@@ -203,11 +203,11 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_allocator_traits_is_always_equal 201411L
# define __cpp_lib_any 201606L
# define __cpp_lib_apply 201603L
-# if defined(_MSC_VER) && _MSC_VER >= 1926
-# define __cpp_lib_array_constexpr 201803L
-# else
-# define __cpp_lib_array_constexpr 201603L
-# endif
+# if defined(_MSC_VER) && _MSC_VER >= 1926
+# define __cpp_lib_array_constexpr 201803L
+# else
+# define __cpp_lib_array_constexpr 201603L
+# endif
# define __cpp_lib_as_const 201510L
# if !defined(_LIBCPP_HAS_NO_THREADS)
# define __cpp_lib_atomic_is_always_lock_free 201603L
@@ -250,11 +250,11 @@ __cpp_lib_void_t 201411L <type_traits>
# endif
# define __cpp_lib_shared_ptr_arrays 201611L
# define __cpp_lib_shared_ptr_weak_type 201606L
-# if defined(_MSC_VER) && _MSC_VER >= 1926
-# define __cpp_lib_string_view 201803L
-# else
-# define __cpp_lib_string_view 201606L
-# endif
+# if defined(_MSC_VER) && _MSC_VER >= 1926
+# define __cpp_lib_string_view 201803L
+# else
+# define __cpp_lib_string_view 201606L
+# endif
// # define __cpp_lib_to_chars 201611L
# undef __cpp_lib_transparent_operators
# define __cpp_lib_transparent_operators 201510L
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp
index 63126a5305..300acbf759 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp
@@ -137,8 +137,8 @@ struct ExceptionPtr {
free(exception_object);
}
- // _bad_alloc_storage must be initialized before bad_alloc, so we declare and define it first.
- static std::bad_alloc _bad_alloc_storage;
+ // _bad_alloc_storage must be initialized before bad_alloc, so we declare and define it first.
+ static std::bad_alloc _bad_alloc_storage;
static ExceptionPtr bad_alloc;
//static ExceptionPtr bad_exception;
};
@@ -148,11 +148,11 @@ struct ExceptionPtr {
#pragma clang diagnostic ignored "-Waddress-of-temporary"
#endif
-std::bad_alloc ExceptionPtr::_bad_alloc_storage;
-
+std::bad_alloc ExceptionPtr::_bad_alloc_storage;
+
ExceptionPtr ExceptionPtr::bad_alloc(
- &ExceptionPtr::_bad_alloc_storage,
- reinterpret_cast<const EHThrowInfo*>(__GetExceptionInfo(ExceptionPtr::_bad_alloc_storage)));
+ &ExceptionPtr::_bad_alloc_storage,
+ reinterpret_cast<const EHThrowInfo*>(__GetExceptionInfo(ExceptionPtr::_bad_alloc_storage)));
/* ExceptionPtr
ExceptionPtr::bad_exception(&std::bad_exception(),
diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make
index e22c5f2ef7..15403fe6d5 100644
--- a/contrib/libs/cxxsupp/libcxx/ya.make
+++ b/contrib/libs/cxxsupp/libcxx/ya.make
@@ -1,12 +1,12 @@
LIBRARY()
-LICENSE(
+LICENSE(
Apache-2.0 AND
Apache-2.0 WITH LLVM-exception AND
BSD-2-Clause AND
MIT AND
NCSA
-)
+)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
@@ -25,9 +25,9 @@ ADDINCL(
CXXFLAGS(-D_LIBCPP_BUILDING_LIBRARY)
-IF (OS_ANDROID)
- DEFAULT(CXX_RT "default")
- IF (ARCH_I686 OR ARCH_ARM7)
+IF (OS_ANDROID)
+ DEFAULT(CXX_RT "default")
+ IF (ARCH_I686 OR ARCH_ARM7)
# 32-bit architectures require additional libandroid_support.so to be linked
# We add --start-group / --end-group statements due to the issue in NDK < r22.
# See: https://github.com/android/ndk/issues/1130
@@ -41,7 +41,7 @@ IF (OS_ANDROID)
)
ELSE()
LDFLAGS(-lc++abi)
- ENDIF()
+ ENDIF()
CFLAGS(
-DLIBCXX_BUILDING_LIBCXXABI
)
@@ -83,13 +83,13 @@ ELSEIF (OS_WINDOWS)
GLOBAL -D_LIBCPP_VASPRINTF_DEFINED
GLOBAL -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_
)
- IF (CLANG_CL)
+ IF (CLANG_CL)
PEERDIR(
contrib/libs/cxxsupp/builtins
)
- ENDIF()
+ ENDIF()
ELSE()
- DEFAULT(CXX_RT "glibcxx_static")
+ DEFAULT(CXX_RT "glibcxx_static")
CXXFLAGS(
-Wno-unknown-pragmas
-nostdinc++
@@ -104,20 +104,20 @@ IF (CLANG)
CFLAGS(
GLOBAL -nostdinc++
)
-ENDIF()
-
-# The CXX_RT variable controls which C++ runtime is used.
-# * libcxxrt - https://github.com/pathscale/libcxxrt library stored in Arcadia
-# * glibcxx - GNU C++ Library runtime with default (static) linkage
-# * glibcxx_static - GNU C++ Library runtime with static linkage
-# * glibcxx_dynamic - GNU C++ Library runtime with dynamic linkage
-# * glibcxx_driver - GNU C++ Library runtime provided by the compiler driver
-# * default - default C++ runtime provided by the compiler driver
-#
-# All glibcxx* runtimes are taken from system/compiler SDK
-
-DEFAULT(CXX_RT "default")
-
+ENDIF()
+
+# The CXX_RT variable controls which C++ runtime is used.
+# * libcxxrt - https://github.com/pathscale/libcxxrt library stored in Arcadia
+# * glibcxx - GNU C++ Library runtime with default (static) linkage
+# * glibcxx_static - GNU C++ Library runtime with static linkage
+# * glibcxx_dynamic - GNU C++ Library runtime with dynamic linkage
+# * glibcxx_driver - GNU C++ Library runtime provided by the compiler driver
+# * default - default C++ runtime provided by the compiler driver
+#
+# All glibcxx* runtimes are taken from system/compiler SDK
+
+DEFAULT(CXX_RT "default")
+
DISABLE(NEED_GLIBCXX_CXX17_SHIMS)
IF (CXX_RT == "libcxxrt")
@@ -143,7 +143,7 @@ ELSEIF (CXX_RT == "glibcxx" OR CXX_RT == "glibcxx_static")
-lgcc_eh
-Wl,-Bdynamic
)
- CXXFLAGS(-D__GLIBCXX__=1)
+ CXXFLAGS(-D__GLIBCXX__=1)
ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
CFLAGS(
GLOBAL -DLIBCXX_BUILDING_LIBGCC
@@ -153,19 +153,19 @@ ELSEIF (CXX_RT == "glibcxx_dynamic")
-lgcc_s
-lstdc++
)
- CXXFLAGS(-D__GLIBCXX__=1)
+ CXXFLAGS(-D__GLIBCXX__=1)
CFLAGS(
GLOBAL -DLIBCXX_BUILDING_LIBGCC
)
ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
ELSEIF (CXX_RT == "glibcxx_driver")
- CXXFLAGS(-D__GLIBCXX__=1)
+ CXXFLAGS(-D__GLIBCXX__=1)
ELSEIF (CXX_RT == "default")
- # Do nothing
-ELSE()
+ # Do nothing
+ELSE()
MESSAGE(FATAL_ERROR "Unexpected CXX_RT value: ${CXX_RT}")
-ENDIF()
-
+ENDIF()
+
IF (NEED_GLIBCXX_CXX17_SHIMS)
IF (GCC)
# Assume GCC is bundled with a modern enough version of C++ runtime
diff --git a/contrib/libs/cxxsupp/libcxxrt/cxxabi.h b/contrib/libs/cxxsupp/libcxxrt/cxxabi.h
index 6e33d33c03..7a8cb6745f 100644
--- a/contrib/libs/cxxsupp/libcxxrt/cxxabi.h
+++ b/contrib/libs/cxxsupp/libcxxrt/cxxabi.h
@@ -183,9 +183,9 @@ struct __cxa_eh_globals
*/
unsigned int uncaughtExceptions;
};
-
-#define Y_CXA_EH_GLOBALS_COMPLETE
-
+
+#define Y_CXA_EH_GLOBALS_COMPLETE
+
/**
* ABI function returning the __cxa_eh_globals structure.
*/
diff --git a/contrib/libs/cxxsupp/libcxxrt/exception.cc b/contrib/libs/cxxsupp/libcxxrt/exception.cc
index 95f05ed474..6baf428ead 100644
--- a/contrib/libs/cxxsupp/libcxxrt/exception.cc
+++ b/contrib/libs/cxxsupp/libcxxrt/exception.cc
@@ -652,14 +652,14 @@ static void free_exception(char *e)
}
}
-static constexpr size_t align_to(size_t size, size_t alignment) noexcept {
- return (size + alignment - 1) / alignment * alignment;
-}
-
-static_assert(align_to(15, 16) == 16);
-static_assert(align_to(16, 16) == 16);
-static_assert(align_to(17, 16) == 32);
-
+static constexpr size_t align_to(size_t size, size_t alignment) noexcept {
+ return (size + alignment - 1) / alignment * alignment;
+}
+
+static_assert(align_to(15, 16) == 16);
+static_assert(align_to(16, 16) == 16);
+static_assert(align_to(17, 16) == 32);
+
static constexpr size_t exception_size = align_to(sizeof(__cxa_exception), 16);
static constexpr size_t dependent_exception_size = align_to(sizeof(__cxa_dependent_exception), 16);
#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE
diff --git a/contrib/libs/cxxsupp/libcxxrt/ya.make b/contrib/libs/cxxsupp/libcxxrt/ya.make
index 735eeccaa4..12dccbd505 100644
--- a/contrib/libs/cxxsupp/libcxxrt/ya.make
+++ b/contrib/libs/cxxsupp/libcxxrt/ya.make
@@ -34,13 +34,13 @@ NO_RUNTIME()
CXXFLAGS(-nostdinc++)
IF (CXX_UNWIND == "glibcxx_dynamic" OR ARCH_PPC64LE)
- LDFLAGS(-lgcc_s)
-ELSE()
+ LDFLAGS(-lgcc_s)
+ELSE()
PEERDIR(
contrib/libs/libunwind
)
-ENDIF()
-
+ENDIF()
+
IF (SANITIZER_TYPE == undefined OR FUZZING)
NO_SANITIZE()
NO_SANITIZE_COVERAGE()
diff --git a/contrib/libs/cxxsupp/libgcc/cxxabi.cpp b/contrib/libs/cxxsupp/libgcc/cxxabi.cpp
index 025615bc4e..fdb85e15af 100644
--- a/contrib/libs/cxxsupp/libgcc/cxxabi.cpp
+++ b/contrib/libs/cxxsupp/libgcc/cxxabi.cpp
@@ -1,13 +1,13 @@
-#include "cxxabi.h"
-
-#include <new>
-
-extern "C" {
- void __cxa_throw_bad_array_length() {
- throw std::bad_alloc();
- }
-
- void __cxa_throw_bad_array_new_length() {
- throw std::bad_alloc();
- }
-}
+#include "cxxabi.h"
+
+#include <new>
+
+extern "C" {
+ void __cxa_throw_bad_array_length() {
+ throw std::bad_alloc();
+ }
+
+ void __cxa_throw_bad_array_new_length() {
+ throw std::bad_alloc();
+ }
+}
diff --git a/contrib/libs/cxxsupp/libgcc/cxxabi.h b/contrib/libs/cxxsupp/libgcc/cxxabi.h
index a67a082594..b63490423f 100644
--- a/contrib/libs/cxxsupp/libgcc/cxxabi.h
+++ b/contrib/libs/cxxsupp/libgcc/cxxabi.h
@@ -1,6 +1,6 @@
-#pragma once
-
-extern "C" {
- void __cxa_throw_bad_array_length() __attribute__((weak, noreturn));
- void __cxa_throw_bad_array_new_length() __attribute__((weak, noreturn));
-}
+#pragma once
+
+extern "C" {
+ void __cxa_throw_bad_array_length() __attribute__((weak, noreturn));
+ void __cxa_throw_bad_array_new_length() __attribute__((weak, noreturn));
+}
diff --git a/contrib/libs/cxxsupp/libgcc/stdcxx_bits.cpp b/contrib/libs/cxxsupp/libgcc/stdcxx_bits.cpp
index 01977e16d8..0a34ef50c4 100644
--- a/contrib/libs/cxxsupp/libgcc/stdcxx_bits.cpp
+++ b/contrib/libs/cxxsupp/libgcc/stdcxx_bits.cpp
@@ -1,12 +1,12 @@
-#include "stdcxx_bits.h"
-
-#include <stdexcept>
-
-namespace std {
-
-void __throw_out_of_range_fmt(const char* __fmt, ...) {
- (void)__fmt;
- throw std::out_of_range("__throw_out_of_range_fmt");
-}
-
-}
+#include "stdcxx_bits.h"
+
+#include <stdexcept>
+
+namespace std {
+
+void __throw_out_of_range_fmt(const char* __fmt, ...) {
+ (void)__fmt;
+ throw std::out_of_range("__throw_out_of_range_fmt");
+}
+
+}
diff --git a/contrib/libs/cxxsupp/libgcc/stdcxx_bits.h b/contrib/libs/cxxsupp/libgcc/stdcxx_bits.h
index c1a62b66ce..821ccb185c 100644
--- a/contrib/libs/cxxsupp/libgcc/stdcxx_bits.h
+++ b/contrib/libs/cxxsupp/libgcc/stdcxx_bits.h
@@ -1,11 +1,11 @@
-#pragma once
-
-namespace std {
-
-void __throw_out_of_range_fmt(const char*, ...)
- __attribute__((__noreturn__))
- __attribute__((__format__(__printf__, 1, 2)))
- __attribute__((__weak__))
-;
-
-}
+#pragma once
+
+namespace std {
+
+void __throw_out_of_range_fmt(const char*, ...)
+ __attribute__((__noreturn__))
+ __attribute__((__format__(__printf__, 1, 2)))
+ __attribute__((__weak__))
+;
+
+}
diff --git a/contrib/libs/cxxsupp/libgcc/ya.make b/contrib/libs/cxxsupp/libgcc/ya.make
index afe0f48ba3..d748a74846 100644
--- a/contrib/libs/cxxsupp/libgcc/ya.make
+++ b/contrib/libs/cxxsupp/libgcc/ya.make
@@ -1,24 +1,24 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(YandexOpen)
-
-# Placeholders for new GCC 4.9.2 C++ ABI which is not present on older systems
-
-OWNER(
- somov
- g:contrib
- g:cpp-contrib
-)
-
+
+# Placeholders for new GCC 4.9.2 C++ ABI which is not present on older systems
+
+OWNER(
+ somov
+ g:contrib
+ g:cpp-contrib
+)
+
IF (NOT OS_WINDOWS)
SRCS(
cxxabi.cpp
stdcxx_bits.cpp
)
ENDIF()
-
-NO_UTIL()
-
-END()
+
+NO_UTIL()
+
+END()
diff --git a/contrib/libs/cxxsupp/libsan/generate_symbolizer.py b/contrib/libs/cxxsupp/libsan/generate_symbolizer.py
index 6d410023fb..d28c64bd92 100644
--- a/contrib/libs/cxxsupp/libsan/generate_symbolizer.py
+++ b/contrib/libs/cxxsupp/libsan/generate_symbolizer.py
@@ -1,12 +1,12 @@
-import os
-import sys
-
-
-def main():
- print 'const char* ya_get_symbolizer_gen() {'
- print ' return "{}";'.format(os.path.join(os.path.dirname(sys.argv[1]), 'llvm-symbolizer'))
- print '}'
-
-
-if __name__ == '__main__':
- main()
+import os
+import sys
+
+
+def main():
+ print 'const char* ya_get_symbolizer_gen() {'
+ print ' return "{}";'.format(os.path.join(os.path.dirname(sys.argv[1]), 'llvm-symbolizer'))
+ print '}'
+
+
+if __name__ == '__main__':
+ main()
diff --git a/contrib/libs/cxxsupp/libsan/inject.c b/contrib/libs/cxxsupp/libsan/inject.c
index a2642e6ec3..7790db5f36 100644
--- a/contrib/libs/cxxsupp/libsan/inject.c
+++ b/contrib/libs/cxxsupp/libsan/inject.c
@@ -1,8 +1,8 @@
#include <unistd.h>
-extern const char* ya_get_symbolizer_gen();
-
-const char* ya_get_symbolizer() {
+extern const char* ya_get_symbolizer_gen();
+
+const char* ya_get_symbolizer() {
const char* path = ya_get_symbolizer_gen();
return access(path, X_OK) ? NULL : path;
-}
+}
diff --git a/contrib/libs/cxxsupp/libsan/ya.make b/contrib/libs/cxxsupp/libsan/ya.make
index 01e38a451f..2fb16630be 100644
--- a/contrib/libs/cxxsupp/libsan/ya.make
+++ b/contrib/libs/cxxsupp/libsan/ya.make
@@ -1,26 +1,26 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(YandexOpen)
-NO_PLATFORM()
+NO_PLATFORM()
-NO_SANITIZE()
+NO_SANITIZE()
NO_SANITIZE_COVERAGE()
-
+
OWNER(somov)
PYTHON(
generate_symbolizer.py ${CXX_COMPILER}
STDOUT symbolizer.c
)
-
-CFLAGS(-fPIC)
-
-SRCS(
- GLOBAL inject.c
-)
-
-END()
+
+CFLAGS(-fPIC)
+
+SRCS(
+ GLOBAL inject.c
+)
+
+END()
diff --git a/contrib/libs/cxxsupp/system_stl/include/stlfwd b/contrib/libs/cxxsupp/system_stl/include/stlfwd
index 07246ddca5..94e9c17f3f 100644
--- a/contrib/libs/cxxsupp/system_stl/include/stlfwd
+++ b/contrib/libs/cxxsupp/system_stl/include/stlfwd
@@ -1,14 +1,14 @@
-#pragma once
-
+#pragma once
+
// STL "forwarding" for the poor
-
-#include <cstddef>
-#include <string>
+
+#include <cstddef>
+#include <string>
#include <string_view>
-#include <utility>
-#include <vector>
-#include <list>
-#include <deque>
-#include <map>
-#include <set>
+#include <utility>
+#include <vector>
+#include <list>
+#include <deque>
+#include <map>
+#include <set>
#include <functional>
diff --git a/contrib/libs/cxxsupp/system_stl/ya.make b/contrib/libs/cxxsupp/system_stl/ya.make
index 41d48cd76d..75317898ac 100644
--- a/contrib/libs/cxxsupp/system_stl/ya.make
+++ b/contrib/libs/cxxsupp/system_stl/ya.make
@@ -1,5 +1,5 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(YandexOpen)
@@ -9,11 +9,11 @@ OWNER(
g:cpp-contrib
somov
)
-
-NO_PLATFORM()
-
-ADDINCL(GLOBAL contrib/libs/cxxsupp/system_stl/include)
-
+
+NO_PLATFORM()
+
+ADDINCL(GLOBAL contrib/libs/cxxsupp/system_stl/include)
+
IF (OS_IOS OR OS_DARWIN)
LDFLAGS(-lc++)
ELSEIF (OS_ANDROID)
@@ -35,5 +35,5 @@ ELSE()
LDFLAGS(-lstdc++)
ENDIF()
ENDIF()
-
-END()
+
+END()
diff --git a/contrib/libs/cxxsupp/ya.make b/contrib/libs/cxxsupp/ya.make
index beceda98ab..6cd299ac8a 100644
--- a/contrib/libs/cxxsupp/ya.make
+++ b/contrib/libs/cxxsupp/ya.make
@@ -1,28 +1,28 @@
LIBRARY()
-
+
WITHOUT_LICENSE_TEXTS()
# Proxy library
-LICENSE(Not-Applicable)
-
+LICENSE(Not-Applicable)
+
OWNER(
g:contrib
g:cpp-contrib
)
-NO_PLATFORM()
+NO_PLATFORM()
DISABLE(OPENSOURCE_EXPORT)
-
-IF (NOT USE_STL_SYSTEM)
- PEERDIR(
+
+IF (NOT USE_STL_SYSTEM)
+ PEERDIR(
contrib/libs/cxxsupp/libcxx
- )
-ELSE()
- PEERDIR(
- contrib/libs/cxxsupp/system_stl
- )
-ENDIF()
-
+ )
+ELSE()
+ PEERDIR(
+ contrib/libs/cxxsupp/system_stl
+ )
+ENDIF()
+
END()
RECURSE(
diff --git a/contrib/libs/farmhash/COPYING b/contrib/libs/farmhash/COPYING
index ace09804a3..8176e66198 100644
--- a/contrib/libs/farmhash/COPYING
+++ b/contrib/libs/farmhash/COPYING
@@ -1,19 +1,19 @@
-// Copyright (c) 2014 Google, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// Copyright (c) 2014 Google, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
diff --git a/contrib/libs/farmhash/IMPORT b/contrib/libs/farmhash/IMPORT
index 82f14a4b01..a923a166bf 100644
--- a/contrib/libs/farmhash/IMPORT
+++ b/contrib/libs/farmhash/IMPORT
@@ -1 +1 @@
-Imported from https://github.com/google/farmhash commit 23eecfbe7e84ebf2e229bd02248f431c36e12f1a (master branch, 2017-06-26)
+Imported from https://github.com/google/farmhash commit 23eecfbe7e84ebf2e229bd02248f431c36e12f1a (master branch, 2017-06-26)
diff --git a/contrib/libs/farmhash/README b/contrib/libs/farmhash/README
index a0b2414a2c..146936d21a 100644
--- a/contrib/libs/farmhash/README
+++ b/contrib/libs/farmhash/README
@@ -1,163 +1,163 @@
-FarmHash, a family of hash functions.
-Version 1.1
-
-Introduction
-============
-
-A general overview of hash functions and their use is available in the file
-Understanding_Hash_Functions in this directory. It may be helpful to read it
-before using FarmHash.
-
-FarmHash provides hash functions for strings and other data. The functions
-mix the input bits thoroughly but are not suitable for cryptography. See
-"Hash Quality," below, for details on how FarmHash was tested and so on.
-
-We provide reference implementations in C++, with a friendly MIT license.
-
-All members of the FarmHash family were designed with heavy reliance on
-previous work by Jyrki Alakuijala, Austin Appleby, Bob Jenkins, and others.
-
-
-Recommended Usage
-=================
-
-Our belief is that the typical hash function is mostly used for in-memory hash
-tables and similar. That use case allows hash functions that differ on
-different platforms, and that change from time to time. For this, I recommend
-using wrapper functions in a .h file with comments such as, "may change from
-time to time, may differ on different platforms, and may change depending on
-NDEBUG."
-
-Some projects may also require a forever-fixed, portable hash function. Again
-we recommend using wrapper functions in a .h, but in this case the comments on
-them would be very different.
-
-We have provided a sample of these wrapper functions in src/farmhash.h. Our
-hope is that most people will need nothing more than src/farmhash.h and
-src/farmhash.cc. Those two files are a usable and relatively portable library.
-(One portability snag: if your compiler doesn't have __builtin_expect then
-you may need to define FARMHASH_NO_BUILTIN_EXPECT.) For those that prefer
-using a configure script (perhaps because they want to "make install" later),
-FarmHash has one, but for many people it's best to ignore it.
-
-Note that the wrapper functions such as Hash() in src/farmhash.h can select
-one of several hash functions. The selection is done at compile time, based
-on your machine architecture (e.g., sizeof(size_t)) and the availability of
-vector instructions (e.g., SSE4.1).
-
-To get the best performance from FarmHash, one will need to think a bit about
-when to use compiler flags that allow vector instructions and such: -maes,
--msse4.2, -mavx, etc., or their equivalents for other compilers. Those are
-the g++ flags that make g++ emit more types of machine instructions than it
-otherwise would. For example, if you are confident that you will only be
-using FarmHash on systems with SSE4.2 and/or AES, you may communicate that to
-the compiler as explained in src/farmhash.cc. If not, use -maes, -mavx, etc.,
-when you can, and the appropriate choices will be made by via conditional
-compilation in src/farmhash.cc.
-
-It may be beneficial to try -O3 or other compiler flags as well. I also have
-found feedback-directed optimization (FDO) to improve the speed of FarmHash.
-
-The "configure" script: creating config.h
-=========================================
-
-We provide reference implementations of several FarmHash functions, written in
-C++. The build system is based on autoconf. It defaults the C++ compiler
-flags to "-g -O2", which may or may not be best.
-
-If you are planning to use the configure script, I generally recommend
-trying this first, unless you know that your system lacks AVX and/or AESNI:
-
- ./configure CXXFLAGS="-g -mavx -maes -O3"
- make all check
-
-If that fails, you can retry with -mavx and/or -maes removed, or with -mavx replaced by
--msse4.1 or -msse4.2.
-
-Please see below for thoughts on cross-platform testing, if that is a concern.
-Finally, if you want to install a library, you may use
-
- make install
-
-Some useful flags for configure include:
-
- --enable-optional-builtin-expect: This causes __builtin_expect to be optional.
- If you don't use this flag, the assumption is that FarmHash will be compiled
- with compilers that provide __builtin_expect. In practice, some FarmHash
- variants may be slightly faster if __builtin_expect is available, but it
- isn't very important and affects speed only.
-
-Further Details
-===============
-
-The above instructions will produce a single source-level library that
-includes multiple hash functions. It will use conditional compilation, and
-perhaps GCC's multiversioning, to select among the functions. In addition,
-"make all check" will create an object file using your chosen compiler, and
-test it. The object file won't necessarily contain all the code that would be
-used if you were to compile the code on other platforms. The downside of this
-is obvious: the paths not tested may not actually work if and when you try
-them. The FarmHash developers try hard to prevent such problems; please let
-us know if you find bugs.
-
-To aid your cross-platform testing, for each relevant platform you may
-compile your program that uses farmhash.cc with the preprocessor flag
-FARMHASHSELFTEST equal to 1. This causes a FarmHash self test to run
-at program startup; the self test writes output to stdout and then
-calls std::exit(). You can see this in action by running "make check":
-see src/farm-test.cc for details.
-
-There's also a trivial workaround to force particular functions to be used:
-modify the wrapper functions in hash.h. You can prevent choices being made via
-conditional compilation or multiversioning by choosing FarmHash variants with
-names like farmhashaa::Hash32, farmhashab::Hash64, etc.: those compute the same
-hash function regardless of conditional compilation, multiversioning, or
-endianness. Consult their comments and ifdefs to learn their requirements: for
-example, they are not all guaranteed to work on all platforms.
-
-Known Issues
-============
-
-1) FarmHash was developed with little-endian architectures in mind. It should
-work on big-endian too, but less work has gone into optimizing for those
-platforms. To make FarmHash work properly on big-endian platforms you may
-need to modify the wrapper .h file and/or your compiler flags to arrange for
-FARMHASH_BIG_ENDIAN to be defined, though there is logic that tries to figure
-it out automatically.
-
-2) FarmHash's implementation is fairly complex.
-
-3) The techniques described in dev/INSTRUCTIONS to let hash function
-developers regenerate src/*.cc from dev/* are hacky and not so portable.
-
-Hash Quality
-============
-
-We like to test hash functions with SMHasher, among other things.
-SMHasher isn't perfect, but it seems to find almost any significant flaw.
-SMHasher is available at http://code.google.com/p/smhasher/
-
-SMHasher is designed to pass a 32-bit seed to the hash functions it tests.
-For our functions that accept a seed, we use the given seed directly (padded
-with zeroes as needed); for our functions that don't accept a seed, we hash
-the concatenation of the given seed and the input string.
-
-Some minor flaws in 32-bit and 64-bit functions are harmless, as we
-expect the primary use of these functions will be in hash tables. We
-may have gone slightly overboard in trying to please SMHasher and other
-similar tests, but we don't want anyone to choose a different hash function
-because of some minor issue reported by a quality test.
-
-If your setup is similar enough to mine, it's easy to use SMHasher and other
-tools yourself via the "builder" in the dev directory. See dev/INSTRUCTIONS.
-(Improvements to that directory are a relatively low priority, and code
-there is never going to be as portable as the other parts of FarmHash.)
-
-For more information
-====================
-
-http://code.google.com/p/farmhash/
-
-farmhash-discuss@googlegroups.com
-
-Please feel free to send us comments, questions, bug reports, or patches.
+FarmHash, a family of hash functions.
+Version 1.1
+
+Introduction
+============
+
+A general overview of hash functions and their use is available in the file
+Understanding_Hash_Functions in this directory. It may be helpful to read it
+before using FarmHash.
+
+FarmHash provides hash functions for strings and other data. The functions
+mix the input bits thoroughly but are not suitable for cryptography. See
+"Hash Quality," below, for details on how FarmHash was tested and so on.
+
+We provide reference implementations in C++, with a friendly MIT license.
+
+All members of the FarmHash family were designed with heavy reliance on
+previous work by Jyrki Alakuijala, Austin Appleby, Bob Jenkins, and others.
+
+
+Recommended Usage
+=================
+
+Our belief is that the typical hash function is mostly used for in-memory hash
+tables and similar. That use case allows hash functions that differ on
+different platforms, and that change from time to time. For this, I recommend
+using wrapper functions in a .h file with comments such as, "may change from
+time to time, may differ on different platforms, and may change depending on
+NDEBUG."
+
+Some projects may also require a forever-fixed, portable hash function. Again
+we recommend using wrapper functions in a .h, but in this case the comments on
+them would be very different.
+
+We have provided a sample of these wrapper functions in src/farmhash.h. Our
+hope is that most people will need nothing more than src/farmhash.h and
+src/farmhash.cc. Those two files are a usable and relatively portable library.
+(One portability snag: if your compiler doesn't have __builtin_expect then
+you may need to define FARMHASH_NO_BUILTIN_EXPECT.) For those that prefer
+using a configure script (perhaps because they want to "make install" later),
+FarmHash has one, but for many people it's best to ignore it.
+
+Note that the wrapper functions such as Hash() in src/farmhash.h can select
+one of several hash functions. The selection is done at compile time, based
+on your machine architecture (e.g., sizeof(size_t)) and the availability of
+vector instructions (e.g., SSE4.1).
+
+To get the best performance from FarmHash, one will need to think a bit about
+when to use compiler flags that allow vector instructions and such: -maes,
+-msse4.2, -mavx, etc., or their equivalents for other compilers. Those are
+the g++ flags that make g++ emit more types of machine instructions than it
+otherwise would. For example, if you are confident that you will only be
+using FarmHash on systems with SSE4.2 and/or AES, you may communicate that to
+the compiler as explained in src/farmhash.cc. If not, use -maes, -mavx, etc.,
+when you can, and the appropriate choices will be made by via conditional
+compilation in src/farmhash.cc.
+
+It may be beneficial to try -O3 or other compiler flags as well. I also have
+found feedback-directed optimization (FDO) to improve the speed of FarmHash.
+
+The "configure" script: creating config.h
+=========================================
+
+We provide reference implementations of several FarmHash functions, written in
+C++. The build system is based on autoconf. It defaults the C++ compiler
+flags to "-g -O2", which may or may not be best.
+
+If you are planning to use the configure script, I generally recommend
+trying this first, unless you know that your system lacks AVX and/or AESNI:
+
+ ./configure CXXFLAGS="-g -mavx -maes -O3"
+ make all check
+
+If that fails, you can retry with -mavx and/or -maes removed, or with -mavx replaced by
+-msse4.1 or -msse4.2.
+
+Please see below for thoughts on cross-platform testing, if that is a concern.
+Finally, if you want to install a library, you may use
+
+ make install
+
+Some useful flags for configure include:
+
+ --enable-optional-builtin-expect: This causes __builtin_expect to be optional.
+ If you don't use this flag, the assumption is that FarmHash will be compiled
+ with compilers that provide __builtin_expect. In practice, some FarmHash
+ variants may be slightly faster if __builtin_expect is available, but it
+ isn't very important and affects speed only.
+
+Further Details
+===============
+
+The above instructions will produce a single source-level library that
+includes multiple hash functions. It will use conditional compilation, and
+perhaps GCC's multiversioning, to select among the functions. In addition,
+"make all check" will create an object file using your chosen compiler, and
+test it. The object file won't necessarily contain all the code that would be
+used if you were to compile the code on other platforms. The downside of this
+is obvious: the paths not tested may not actually work if and when you try
+them. The FarmHash developers try hard to prevent such problems; please let
+us know if you find bugs.
+
+To aid your cross-platform testing, for each relevant platform you may
+compile your program that uses farmhash.cc with the preprocessor flag
+FARMHASHSELFTEST equal to 1. This causes a FarmHash self test to run
+at program startup; the self test writes output to stdout and then
+calls std::exit(). You can see this in action by running "make check":
+see src/farm-test.cc for details.
+
+There's also a trivial workaround to force particular functions to be used:
+modify the wrapper functions in hash.h. You can prevent choices being made via
+conditional compilation or multiversioning by choosing FarmHash variants with
+names like farmhashaa::Hash32, farmhashab::Hash64, etc.: those compute the same
+hash function regardless of conditional compilation, multiversioning, or
+endianness. Consult their comments and ifdefs to learn their requirements: for
+example, they are not all guaranteed to work on all platforms.
+
+Known Issues
+============
+
+1) FarmHash was developed with little-endian architectures in mind. It should
+work on big-endian too, but less work has gone into optimizing for those
+platforms. To make FarmHash work properly on big-endian platforms you may
+need to modify the wrapper .h file and/or your compiler flags to arrange for
+FARMHASH_BIG_ENDIAN to be defined, though there is logic that tries to figure
+it out automatically.
+
+2) FarmHash's implementation is fairly complex.
+
+3) The techniques described in dev/INSTRUCTIONS to let hash function
+developers regenerate src/*.cc from dev/* are hacky and not so portable.
+
+Hash Quality
+============
+
+We like to test hash functions with SMHasher, among other things.
+SMHasher isn't perfect, but it seems to find almost any significant flaw.
+SMHasher is available at http://code.google.com/p/smhasher/
+
+SMHasher is designed to pass a 32-bit seed to the hash functions it tests.
+For our functions that accept a seed, we use the given seed directly (padded
+with zeroes as needed); for our functions that don't accept a seed, we hash
+the concatenation of the given seed and the input string.
+
+Some minor flaws in 32-bit and 64-bit functions are harmless, as we
+expect the primary use of these functions will be in hash tables. We
+may have gone slightly overboard in trying to please SMHasher and other
+similar tests, but we don't want anyone to choose a different hash function
+because of some minor issue reported by a quality test.
+
+If your setup is similar enough to mine, it's easy to use SMHasher and other
+tools yourself via the "builder" in the dev directory. See dev/INSTRUCTIONS.
+(Improvements to that directory are a relatively low priority, and code
+there is never going to be as portable as the other parts of FarmHash.)
+
+For more information
+====================
+
+http://code.google.com/p/farmhash/
+
+farmhash-discuss@googlegroups.com
+
+Please feel free to send us comments, questions, bug reports, or patches.
diff --git a/contrib/libs/farmhash/arch/sse41/ya.make b/contrib/libs/farmhash/arch/sse41/ya.make
index 21dde59a82..b3b2964c99 100644
--- a/contrib/libs/farmhash/arch/sse41/ya.make
+++ b/contrib/libs/farmhash/arch/sse41/ya.make
@@ -1,21 +1,21 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(MIT)
OWNER(somov)
-
-NO_COMPILER_WARNINGS()
-
+
+NO_COMPILER_WARNINGS()
+
IF (NOT MSVC OR CLANG_CL)
- CFLAGS(-msse4.1)
-ENDIF()
-
-SRCDIR(contrib/libs/farmhash)
-
+ CFLAGS(-msse4.1)
+ENDIF()
+
+SRCDIR(contrib/libs/farmhash)
+
SRCS(
farmhashnt.cc
)
-
-END()
+
+END()
diff --git a/contrib/libs/farmhash/arch/sse42/ya.make b/contrib/libs/farmhash/arch/sse42/ya.make
index fab89cdec9..6df471feb7 100644
--- a/contrib/libs/farmhash/arch/sse42/ya.make
+++ b/contrib/libs/farmhash/arch/sse42/ya.make
@@ -1,22 +1,22 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(MIT)
OWNER(somov)
-
-NO_COMPILER_WARNINGS()
-
+
+NO_COMPILER_WARNINGS()
+
IF (NOT MSVC OR CLANG_CL)
- CFLAGS(-msse4.2)
-ENDIF()
-
-SRCDIR(contrib/libs/farmhash)
-
-SRCS(
- farmhashsa.cc
- farmhashte.cc
-)
-
-END()
+ CFLAGS(-msse4.2)
+ENDIF()
+
+SRCDIR(contrib/libs/farmhash)
+
+SRCS(
+ farmhashsa.cc
+ farmhashte.cc
+)
+
+END()
diff --git a/contrib/libs/farmhash/arch/sse42_aesni/ya.make b/contrib/libs/farmhash/arch/sse42_aesni/ya.make
index d403c5b4b5..4d558bc2a2 100644
--- a/contrib/libs/farmhash/arch/sse42_aesni/ya.make
+++ b/contrib/libs/farmhash/arch/sse42_aesni/ya.make
@@ -1,24 +1,24 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(MIT)
OWNER(somov)
-
-NO_COMPILER_WARNINGS()
-
+
+NO_COMPILER_WARNINGS()
+
IF (NOT MSVC OR CLANG_CL)
CFLAGS(
-msse4.2
-maes
)
-ENDIF()
-
-SRCDIR(contrib/libs/farmhash)
-
+ENDIF()
+
+SRCDIR(contrib/libs/farmhash)
+
SRCS(
farmhashsu.cc
)
-
-END()
+
+END()
diff --git a/contrib/libs/farmhash/common.h b/contrib/libs/farmhash/common.h
index fc3a77db81..7c6acfee33 100644
--- a/contrib/libs/farmhash/common.h
+++ b/contrib/libs/farmhash/common.h
@@ -1,412 +1,412 @@
-#pragma once
-
-// Copyright (c) 2014 Google, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-// FarmHash, by Geoff Pike
-
-#include "farmhash.h"
-// FARMHASH ASSUMPTIONS: Modify as needed, or use -DFARMHASH_ASSUME_SSE42 etc.
-// Note that if you use -DFARMHASH_ASSUME_SSE42 you likely need -msse42
-// (or its equivalent for your compiler); if you use -DFARMHASH_ASSUME_AESNI
-// you likely need -maes (or its equivalent for your compiler).
-
-#ifdef FARMHASH_ASSUME_SSSE3
-#undef FARMHASH_ASSUME_SSSE3
-#define FARMHASH_ASSUME_SSSE3 1
-#endif
-
-#ifdef FARMHASH_ASSUME_SSE41
-#undef FARMHASH_ASSUME_SSE41
-#define FARMHASH_ASSUME_SSE41 1
-#endif
-
-#ifdef FARMHASH_ASSUME_SSE42
-#undef FARMHASH_ASSUME_SSE42
-#define FARMHASH_ASSUME_SSE42 1
-#endif
-
-#ifdef FARMHASH_ASSUME_AESNI
-#undef FARMHASH_ASSUME_AESNI
-#define FARMHASH_ASSUME_AESNI 1
-#endif
-
-#ifdef FARMHASH_ASSUME_AVX
-#undef FARMHASH_ASSUME_AVX
-#define FARMHASH_ASSUME_AVX 1
-#endif
-
-#if !defined(FARMHASH_CAN_USE_CXX11) && defined(LANG_CXX11)
-#define FARMHASH_CAN_USE_CXX11 1
-#else
-#undef FARMHASH_CAN_USE_CXX11
-#define FARMHASH_CAN_USE_CXX11 0
-#endif
-
-// FARMHASH PORTABILITY LAYER: Runtime error if misconfigured
-
-#ifndef FARMHASH_DIE_IF_MISCONFIGURED
-#define FARMHASH_DIE_IF_MISCONFIGURED do { *(char*)(len % 17) = 0; } while (0)
-#endif
-
-// FARMHASH PORTABILITY LAYER: "static inline" or similar
-
-#ifndef STATIC_INLINE
-#define STATIC_INLINE static inline
-#endif
-
-// FARMHASH PORTABILITY LAYER: LIKELY and UNLIKELY
-
-#if defined(_MSC_VER)
-# define FARMHASH_NO_BUILTIN_EXPECT
-#endif
-
-#if !defined(LIKELY)
-#if defined(FARMHASH_NO_BUILTIN_EXPECT) || (defined(FARMHASH_OPTIONAL_BUILTIN_EXPECT) && !defined(HAVE_BUILTIN_EXPECT))
-#define LIKELY(x) (x)
-#else
-#define LIKELY(x) (__builtin_expect(!!(x), 1))
-#endif
-#endif
-
-#undef UNLIKELY
-#define UNLIKELY(x) !LIKELY(!(x))
-
-// FARMHASH PORTABILITY LAYER: endianness and byteswapping functions
-
-#ifdef WORDS_BIGENDIAN
-#undef FARMHASH_BIG_ENDIAN
-#define FARMHASH_BIG_ENDIAN 1
-#endif
-
-#if defined(FARMHASH_LITTLE_ENDIAN) && defined(FARMHASH_BIG_ENDIAN)
-#error
-#endif
-
-#if !defined(FARMHASH_LITTLE_ENDIAN) && !defined(FARMHASH_BIG_ENDIAN)
-#define FARMHASH_UNKNOWN_ENDIAN 1
-#endif
-
-#if !defined(bswap_32) || !defined(bswap_64)
-#undef bswap_32
-#undef bswap_64
-
-#if defined(HAVE_BUILTIN_BSWAP) || defined(__clang__) || \
- (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || \
- __GNUC__ >= 5))
-// Easy case for bswap: no header file needed.
-#define bswap_32(x) __builtin_bswap32(x)
-#define bswap_64(x) __builtin_bswap64(x)
-#endif
-
-#endif
-
-#if defined(FARMHASH_UNKNOWN_ENDIAN) || !defined(bswap_64)
-
-#ifdef _MSC_VER
-
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) _byteswap_ulong(x)
-#define bswap_64(x) _byteswap_uint64(x)
-
-#elif defined(__APPLE__)
-
-// Mac OS X / Darwin features
-#include <libkern/OSByteOrder.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) OSSwapInt32(x)
-#define bswap_64(x) OSSwapInt64(x)
-
-#elif defined(__sun) || defined(sun)
-
-#include <sys/byteorder.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) BSWAP_32(x)
-#define bswap_64(x) BSWAP_64(x)
-
-#elif defined(__FreeBSD__) || defined(__DragonFly__)
-
-#include <sys/endian.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) bswap32(x)
-#define bswap_64(x) bswap64(x)
-
-#elif defined(__OpenBSD__)
-
-#include <sys/types.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) swap32(x)
-#define bswap_64(x) swap64(x)
-
-#elif defined(__NetBSD__)
-
-#include <sys/types.h>
-#include <machine/bswap.h>
-#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) bswap32(x)
-#define bswap_64(x) bswap64(x)
-#endif
-
-#else
-
-#undef bswap_32
-#undef bswap_64
-#include <byteswap.h>
-
-#endif
-
-#ifdef WORDS_BIGENDIAN
-#define FARMHASH_BIG_ENDIAN 1
-#endif
-
-#endif
-
-#ifdef FARMHASH_BIG_ENDIAN
-#define uint32_in_expected_order(x) (bswap_32(x))
-#define uint64_in_expected_order(x) (bswap_64(x))
-#else
-#define uint32_in_expected_order(x) (x)
-#define uint64_in_expected_order(x) (x)
-#endif
-
-namespace NAMESPACE_FOR_HASH_FUNCTIONS {
-
-STATIC_INLINE uint64_t Fetch64(const char *p) {
- uint64_t result;
- memcpy(&result, p, sizeof(result));
- return uint64_in_expected_order(result);
-}
-
-STATIC_INLINE uint32_t Fetch32(const char *p) {
- uint32_t result;
- memcpy(&result, p, sizeof(result));
- return uint32_in_expected_order(result);
-}
-
-STATIC_INLINE uint32_t Bswap32(uint32_t val) { return bswap_32(val); }
-STATIC_INLINE uint64_t Bswap64(uint64_t val) { return bswap_64(val); }
-
-// FARMHASH PORTABILITY LAYER: bitwise rot
-
-STATIC_INLINE uint32_t BasicRotate32(uint32_t val, int shift) {
- // Avoid shifting by 32: doing so yields an undefined result.
- return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
-}
-
-STATIC_INLINE uint64_t BasicRotate64(uint64_t val, int shift) {
- // Avoid shifting by 64: doing so yields an undefined result.
- return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
-}
-
-#if defined(_MSC_VER) && defined(FARMHASH_ROTR)
-
-STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
- return sizeof(unsigned long) == sizeof(val) ?
- _lrotr(val, shift) :
- BasicRotate32(val, shift);
-}
-
-STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
- return sizeof(unsigned long) == sizeof(val) ?
- _lrotr(val, shift) :
- BasicRotate64(val, shift);
-}
-
-#else
-
-STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
- return BasicRotate32(val, shift);
-}
-STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
- return BasicRotate64(val, shift);
-}
-
-#endif
-
-} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-
-// FARMHASH PORTABILITY LAYER: debug mode or max speed?
-// One may use -DFARMHASH_DEBUG=1 or -DFARMHASH_DEBUG=0 to force the issue.
-
-#if !defined(FARMHASH_DEBUG) && (!defined(NDEBUG) || defined(_DEBUG))
-#define FARMHASH_DEBUG 1
-#endif
-
-#undef debug_mode
-#if FARMHASH_DEBUG
-#define debug_mode 1
-#else
-#define debug_mode 0
-#endif
-
-// PLATFORM-SPECIFIC FUNCTIONS AND MACROS
-
-#undef x86_64
-#if defined (__x86_64) || defined (__x86_64__)
-#define x86_64 1
-#else
-#define x86_64 0
-#endif
-
-#undef x86
-#if defined(__i386__) || defined(__i386) || defined(__X86__)
-#define x86 1
-#else
-#define x86 x86_64
-#endif
-
-#if !defined(is_64bit)
-#define is_64bit (x86_64 || (sizeof(void*) == 8))
-#endif
-
-#undef can_use_ssse3
-#if defined(__SSSE3__) || defined(FARMHASH_ASSUME_SSSE3)
-
-#include <immintrin.h>
-#define can_use_ssse3 1
-// Now we can use _mm_hsub_epi16 and so on.
-
-#else
-#define can_use_ssse3 0
-#endif
-
-#undef can_use_sse41
-#if defined(__SSE4_1__) || defined(FARMHASH_ASSUME_SSE41)
-
-#include <immintrin.h>
-#define can_use_sse41 1
-// Now we can use _mm_insert_epi64 and so on.
-
-#else
-#define can_use_sse41 0
-#endif
-
-#undef can_use_sse42
-#if defined(__SSE4_2__) || defined(FARMHASH_ASSUME_SSE42)
-
-#include <nmmintrin.h>
-#define can_use_sse42 1
-// Now we can use _mm_crc32_u{32,16,8}. And on 64-bit platforms, _mm_crc32_u64.
-
-#else
-#define can_use_sse42 0
-#endif
-
-#undef can_use_aesni
-#if defined(__AES__) || defined(FARMHASH_ASSUME_AESNI)
-
-#include <wmmintrin.h>
-#define can_use_aesni 1
-// Now we can use _mm_aesimc_si128 and so on.
-
-#else
-#define can_use_aesni 0
-#endif
-
-#undef can_use_avx
-#if defined(__AVX__) || defined(FARMHASH_ASSUME_AVX)
-
-#include <immintrin.h>
-#define can_use_avx 1
-
-#else
-#define can_use_avx 0
-#endif
-
-#if can_use_ssse3 || can_use_sse41 || can_use_sse42 || can_use_aesni || can_use_avx
-STATIC_INLINE __m128i Fetch128(const char* s) {
- return _mm_loadu_si128(reinterpret_cast<const __m128i*>(s));
-}
-#endif
-// Building blocks for hash functions
-
-// std::swap() was in <algorithm> but is in <utility> from C++11 on.
-#if !FARMHASH_CAN_USE_CXX11
-#include <algorithm>
-#endif
-
-#undef PERMUTE3
-#define PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0)
-
-namespace NAMESPACE_FOR_HASH_FUNCTIONS {
-
-// Some primes between 2^63 and 2^64 for various uses.
-static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
-static const uint64_t k1 = 0xb492b66fbe98f273ULL;
-static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
-
-// Magic numbers for 32-bit hashing. Copied from Murmur3.
-static const uint32_t c1 = 0xcc9e2d51;
-static const uint32_t c2 = 0x1b873593;
-
-// A 32-bit to 32-bit integer hash copied from Murmur3.
-STATIC_INLINE uint32_t fmix(uint32_t h)
-{
- h ^= h >> 16;
- h *= 0x85ebca6b;
- h ^= h >> 13;
- h *= 0xc2b2ae35;
- h ^= h >> 16;
- return h;
-}
-
-STATIC_INLINE uint32_t Mur(uint32_t a, uint32_t h) {
- // Helper from Murmur3 for combining two 32-bit values.
- a *= c1;
- a = Rotate32(a, 17);
- a *= c2;
- h ^= a;
- h = Rotate32(h, 19);
- return h * 5 + 0xe6546b64;
-}
-
-template <typename T> STATIC_INLINE T DebugTweak(T x) {
- if (debug_mode) {
- if (sizeof(x) == 4) {
- x = ~Bswap32(x * c1);
- } else {
- x = ~Bswap64(x * k1);
- }
- }
- return x;
-}
-
-template <> uint128_t DebugTweak(uint128_t x) {
- if (debug_mode) {
- uint64_t y = DebugTweak(Uint128Low64(x));
- uint64_t z = DebugTweak(Uint128High64(x));
- y += z;
- z += y;
- x = Uint128(y, z * k1);
- }
- return x;
-}
-
-} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-
-using namespace std;
-using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
+#pragma once
+
+// Copyright (c) 2014 Google, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+// FarmHash, by Geoff Pike
+
+#include "farmhash.h"
+// FARMHASH ASSUMPTIONS: Modify as needed, or use -DFARMHASH_ASSUME_SSE42 etc.
+// Note that if you use -DFARMHASH_ASSUME_SSE42 you likely need -msse42
+// (or its equivalent for your compiler); if you use -DFARMHASH_ASSUME_AESNI
+// you likely need -maes (or its equivalent for your compiler).
+
+#ifdef FARMHASH_ASSUME_SSSE3
+#undef FARMHASH_ASSUME_SSSE3
+#define FARMHASH_ASSUME_SSSE3 1
+#endif
+
+#ifdef FARMHASH_ASSUME_SSE41
+#undef FARMHASH_ASSUME_SSE41
+#define FARMHASH_ASSUME_SSE41 1
+#endif
+
+#ifdef FARMHASH_ASSUME_SSE42
+#undef FARMHASH_ASSUME_SSE42
+#define FARMHASH_ASSUME_SSE42 1
+#endif
+
+#ifdef FARMHASH_ASSUME_AESNI
+#undef FARMHASH_ASSUME_AESNI
+#define FARMHASH_ASSUME_AESNI 1
+#endif
+
+#ifdef FARMHASH_ASSUME_AVX
+#undef FARMHASH_ASSUME_AVX
+#define FARMHASH_ASSUME_AVX 1
+#endif
+
+#if !defined(FARMHASH_CAN_USE_CXX11) && defined(LANG_CXX11)
+#define FARMHASH_CAN_USE_CXX11 1
+#else
+#undef FARMHASH_CAN_USE_CXX11
+#define FARMHASH_CAN_USE_CXX11 0
+#endif
+
+// FARMHASH PORTABILITY LAYER: Runtime error if misconfigured
+
+#ifndef FARMHASH_DIE_IF_MISCONFIGURED
+#define FARMHASH_DIE_IF_MISCONFIGURED do { *(char*)(len % 17) = 0; } while (0)
+#endif
+
+// FARMHASH PORTABILITY LAYER: "static inline" or similar
+
+#ifndef STATIC_INLINE
+#define STATIC_INLINE static inline
+#endif
+
+// FARMHASH PORTABILITY LAYER: LIKELY and UNLIKELY
+
+#if defined(_MSC_VER)
+# define FARMHASH_NO_BUILTIN_EXPECT
+#endif
+
+#if !defined(LIKELY)
+#if defined(FARMHASH_NO_BUILTIN_EXPECT) || (defined(FARMHASH_OPTIONAL_BUILTIN_EXPECT) && !defined(HAVE_BUILTIN_EXPECT))
+#define LIKELY(x) (x)
+#else
+#define LIKELY(x) (__builtin_expect(!!(x), 1))
+#endif
+#endif
+
+#undef UNLIKELY
+#define UNLIKELY(x) !LIKELY(!(x))
+
+// FARMHASH PORTABILITY LAYER: endianness and byteswapping functions
+
+#ifdef WORDS_BIGENDIAN
+#undef FARMHASH_BIG_ENDIAN
+#define FARMHASH_BIG_ENDIAN 1
+#endif
+
+#if defined(FARMHASH_LITTLE_ENDIAN) && defined(FARMHASH_BIG_ENDIAN)
+#error
+#endif
+
+#if !defined(FARMHASH_LITTLE_ENDIAN) && !defined(FARMHASH_BIG_ENDIAN)
+#define FARMHASH_UNKNOWN_ENDIAN 1
+#endif
+
+#if !defined(bswap_32) || !defined(bswap_64)
+#undef bswap_32
+#undef bswap_64
+
+#if defined(HAVE_BUILTIN_BSWAP) || defined(__clang__) || \
+ (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || \
+ __GNUC__ >= 5))
+// Easy case for bswap: no header file needed.
+#define bswap_32(x) __builtin_bswap32(x)
+#define bswap_64(x) __builtin_bswap64(x)
+#endif
+
+#endif
+
+#if defined(FARMHASH_UNKNOWN_ENDIAN) || !defined(bswap_64)
+
+#ifdef _MSC_VER
+
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) _byteswap_ulong(x)
+#define bswap_64(x) _byteswap_uint64(x)
+
+#elif defined(__APPLE__)
+
+// Mac OS X / Darwin features
+#include <libkern/OSByteOrder.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) OSSwapInt32(x)
+#define bswap_64(x) OSSwapInt64(x)
+
+#elif defined(__sun) || defined(sun)
+
+#include <sys/byteorder.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) BSWAP_32(x)
+#define bswap_64(x) BSWAP_64(x)
+
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+
+#include <sys/endian.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
+
+#elif defined(__OpenBSD__)
+
+#include <sys/types.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) swap32(x)
+#define bswap_64(x) swap64(x)
+
+#elif defined(__NetBSD__)
+
+#include <sys/types.h>
+#include <machine/bswap.h>
+#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
+#endif
+
+#else
+
+#undef bswap_32
+#undef bswap_64
+#include <byteswap.h>
+
+#endif
+
+#ifdef WORDS_BIGENDIAN
+#define FARMHASH_BIG_ENDIAN 1
+#endif
+
+#endif
+
+#ifdef FARMHASH_BIG_ENDIAN
+#define uint32_in_expected_order(x) (bswap_32(x))
+#define uint64_in_expected_order(x) (bswap_64(x))
+#else
+#define uint32_in_expected_order(x) (x)
+#define uint64_in_expected_order(x) (x)
+#endif
+
+namespace NAMESPACE_FOR_HASH_FUNCTIONS {
+
+STATIC_INLINE uint64_t Fetch64(const char *p) {
+ uint64_t result;
+ memcpy(&result, p, sizeof(result));
+ return uint64_in_expected_order(result);
+}
+
+STATIC_INLINE uint32_t Fetch32(const char *p) {
+ uint32_t result;
+ memcpy(&result, p, sizeof(result));
+ return uint32_in_expected_order(result);
+}
+
+STATIC_INLINE uint32_t Bswap32(uint32_t val) { return bswap_32(val); }
+STATIC_INLINE uint64_t Bswap64(uint64_t val) { return bswap_64(val); }
+
+// FARMHASH PORTABILITY LAYER: bitwise rot
+
+STATIC_INLINE uint32_t BasicRotate32(uint32_t val, int shift) {
+ // Avoid shifting by 32: doing so yields an undefined result.
+ return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
+}
+
+STATIC_INLINE uint64_t BasicRotate64(uint64_t val, int shift) {
+ // Avoid shifting by 64: doing so yields an undefined result.
+ return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
+}
+
+#if defined(_MSC_VER) && defined(FARMHASH_ROTR)
+
+STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
+ return sizeof(unsigned long) == sizeof(val) ?
+ _lrotr(val, shift) :
+ BasicRotate32(val, shift);
+}
+
+STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
+ return sizeof(unsigned long) == sizeof(val) ?
+ _lrotr(val, shift) :
+ BasicRotate64(val, shift);
+}
+
+#else
+
+STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
+ return BasicRotate32(val, shift);
+}
+STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
+ return BasicRotate64(val, shift);
+}
+
+#endif
+
+} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
+
+// FARMHASH PORTABILITY LAYER: debug mode or max speed?
+// One may use -DFARMHASH_DEBUG=1 or -DFARMHASH_DEBUG=0 to force the issue.
+
+#if !defined(FARMHASH_DEBUG) && (!defined(NDEBUG) || defined(_DEBUG))
+#define FARMHASH_DEBUG 1
+#endif
+
+#undef debug_mode
+#if FARMHASH_DEBUG
+#define debug_mode 1
+#else
+#define debug_mode 0
+#endif
+
+// PLATFORM-SPECIFIC FUNCTIONS AND MACROS
+
+#undef x86_64
+#if defined (__x86_64) || defined (__x86_64__)
+#define x86_64 1
+#else
+#define x86_64 0
+#endif
+
+#undef x86
+#if defined(__i386__) || defined(__i386) || defined(__X86__)
+#define x86 1
+#else
+#define x86 x86_64
+#endif
+
+#if !defined(is_64bit)
+#define is_64bit (x86_64 || (sizeof(void*) == 8))
+#endif
+
+#undef can_use_ssse3
+#if defined(__SSSE3__) || defined(FARMHASH_ASSUME_SSSE3)
+
+#include <immintrin.h>
+#define can_use_ssse3 1
+// Now we can use _mm_hsub_epi16 and so on.
+
+#else
+#define can_use_ssse3 0
+#endif
+
+#undef can_use_sse41
+#if defined(__SSE4_1__) || defined(FARMHASH_ASSUME_SSE41)
+
+#include <immintrin.h>
+#define can_use_sse41 1
+// Now we can use _mm_insert_epi64 and so on.
+
+#else
+#define can_use_sse41 0
+#endif
+
+#undef can_use_sse42
+#if defined(__SSE4_2__) || defined(FARMHASH_ASSUME_SSE42)
+
+#include <nmmintrin.h>
+#define can_use_sse42 1
+// Now we can use _mm_crc32_u{32,16,8}. And on 64-bit platforms, _mm_crc32_u64.
+
+#else
+#define can_use_sse42 0
+#endif
+
+#undef can_use_aesni
+#if defined(__AES__) || defined(FARMHASH_ASSUME_AESNI)
+
+#include <wmmintrin.h>
+#define can_use_aesni 1
+// Now we can use _mm_aesimc_si128 and so on.
+
+#else
+#define can_use_aesni 0
+#endif
+
+#undef can_use_avx
+#if defined(__AVX__) || defined(FARMHASH_ASSUME_AVX)
+
+#include <immintrin.h>
+#define can_use_avx 1
+
+#else
+#define can_use_avx 0
+#endif
+
+#if can_use_ssse3 || can_use_sse41 || can_use_sse42 || can_use_aesni || can_use_avx
+STATIC_INLINE __m128i Fetch128(const char* s) {
+ return _mm_loadu_si128(reinterpret_cast<const __m128i*>(s));
+}
+#endif
+// Building blocks for hash functions
+
+// std::swap() was in <algorithm> but is in <utility> from C++11 on.
+#if !FARMHASH_CAN_USE_CXX11
+#include <algorithm>
+#endif
+
+#undef PERMUTE3
+#define PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0)
+
+namespace NAMESPACE_FOR_HASH_FUNCTIONS {
+
+// Some primes between 2^63 and 2^64 for various uses.
+static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
+static const uint64_t k1 = 0xb492b66fbe98f273ULL;
+static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
+
+// Magic numbers for 32-bit hashing. Copied from Murmur3.
+static const uint32_t c1 = 0xcc9e2d51;
+static const uint32_t c2 = 0x1b873593;
+
+// A 32-bit to 32-bit integer hash copied from Murmur3.
+STATIC_INLINE uint32_t fmix(uint32_t h)
+{
+ h ^= h >> 16;
+ h *= 0x85ebca6b;
+ h ^= h >> 13;
+ h *= 0xc2b2ae35;
+ h ^= h >> 16;
+ return h;
+}
+
+STATIC_INLINE uint32_t Mur(uint32_t a, uint32_t h) {
+ // Helper from Murmur3 for combining two 32-bit values.
+ a *= c1;
+ a = Rotate32(a, 17);
+ a *= c2;
+ h ^= a;
+ h = Rotate32(h, 19);
+ return h * 5 + 0xe6546b64;
+}
+
+template <typename T> STATIC_INLINE T DebugTweak(T x) {
+ if (debug_mode) {
+ if (sizeof(x) == 4) {
+ x = ~Bswap32(x * c1);
+ } else {
+ x = ~Bswap64(x * k1);
+ }
+ }
+ return x;
+}
+
+template <> uint128_t DebugTweak(uint128_t x) {
+ if (debug_mode) {
+ uint64_t y = DebugTweak(Uint128Low64(x));
+ uint64_t z = DebugTweak(Uint128High64(x));
+ y += z;
+ z += y;
+ x = Uint128(y, z * k1);
+ }
+ return x;
+}
+
+} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
+
+using namespace std;
+using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
diff --git a/contrib/libs/farmhash/farmhash.cc b/contrib/libs/farmhash/farmhash.cc
index 7e3d393034..27b344fc65 100644
--- a/contrib/libs/farmhash/farmhash.cc
+++ b/contrib/libs/farmhash/farmhash.cc
@@ -1,11835 +1,11835 @@
-// Copyright (c) 2014 Google, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-// FarmHash, by Geoff Pike
-
+// Copyright (c) 2014 Google, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+// FarmHash, by Geoff Pike
+
#include <util/system/compiler.h>
-#include "farmhash.h"
-// FARMHASH ASSUMPTIONS: Modify as needed, or use -DFARMHASH_ASSUME_SSE42 etc.
-// Note that if you use -DFARMHASH_ASSUME_SSE42 you likely need -msse42
-// (or its equivalent for your compiler); if you use -DFARMHASH_ASSUME_AESNI
-// you likely need -maes (or its equivalent for your compiler).
-
-#ifdef FARMHASH_ASSUME_SSSE3
-#undef FARMHASH_ASSUME_SSSE3
-#define FARMHASH_ASSUME_SSSE3 1
-#endif
-
-#ifdef FARMHASH_ASSUME_SSE41
-#undef FARMHASH_ASSUME_SSE41
-#define FARMHASH_ASSUME_SSE41 1
-#endif
-
-#ifdef FARMHASH_ASSUME_SSE42
-#undef FARMHASH_ASSUME_SSE42
-#define FARMHASH_ASSUME_SSE42 1
-#endif
-
-#ifdef FARMHASH_ASSUME_AESNI
-#undef FARMHASH_ASSUME_AESNI
-#define FARMHASH_ASSUME_AESNI 1
-#endif
-
-#ifdef FARMHASH_ASSUME_AVX
-#undef FARMHASH_ASSUME_AVX
-#define FARMHASH_ASSUME_AVX 1
-#endif
-
-#if !defined(FARMHASH_CAN_USE_CXX11) && defined(LANG_CXX11)
-#define FARMHASH_CAN_USE_CXX11 1
-#else
-#undef FARMHASH_CAN_USE_CXX11
-#define FARMHASH_CAN_USE_CXX11 0
-#endif
-
-// FARMHASH PORTABILITY LAYER: Runtime error if misconfigured
-
-#ifndef FARMHASH_DIE_IF_MISCONFIGURED
-#define FARMHASH_DIE_IF_MISCONFIGURED do { *(char*)(len % 17) = 0; } while (0)
-#endif
-
-// FARMHASH PORTABILITY LAYER: "static inline" or similar
-
-#ifndef STATIC_INLINE
-#define STATIC_INLINE static inline
-#endif
-
-// FARMHASH PORTABILITY LAYER: LIKELY and UNLIKELY
-
-#if !defined(LIKELY)
-#if defined(FARMHASH_NO_BUILTIN_EXPECT) || (defined(FARMHASH_OPTIONAL_BUILTIN_EXPECT) && !defined(HAVE_BUILTIN_EXPECT))
-#define LIKELY(x) (x)
-#else
-#define LIKELY(x) (__builtin_expect(!!(x), 1))
-#endif
-#endif
-
-#undef UNLIKELY
-#define UNLIKELY(x) !LIKELY(!(x))
-
-// FARMHASH PORTABILITY LAYER: endianness and byteswapping functions
-
-#ifdef WORDS_BIGENDIAN
-#undef FARMHASH_BIG_ENDIAN
-#define FARMHASH_BIG_ENDIAN 1
-#endif
-
-#if defined(FARMHASH_LITTLE_ENDIAN) && defined(FARMHASH_BIG_ENDIAN)
-#error
-#endif
-
-#if !defined(FARMHASH_LITTLE_ENDIAN) && !defined(FARMHASH_BIG_ENDIAN)
-#define FARMHASH_UNKNOWN_ENDIAN 1
-#endif
-
-#if !defined(bswap_32) || !defined(bswap_64)
-#undef bswap_32
-#undef bswap_64
-
-#if defined(HAVE_BUILTIN_BSWAP) || defined(__clang__) || \
- (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || \
- __GNUC__ >= 5))
-// Easy case for bswap: no header file needed.
-#define bswap_32(x) __builtin_bswap32(x)
-#define bswap_64(x) __builtin_bswap64(x)
-#endif
-
-#endif
-
-#if defined(FARMHASH_UNKNOWN_ENDIAN) || !defined(bswap_64)
-
-#ifdef _MSC_VER
-
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) _byteswap_ulong(x)
-#define bswap_64(x) _byteswap_uint64(x)
-
-#elif defined(__APPLE__)
-
-// Mac OS X / Darwin features
-#include <libkern/OSByteOrder.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) OSSwapInt32(x)
-#define bswap_64(x) OSSwapInt64(x)
-
-#elif defined(__sun) || defined(sun)
-
-#include <sys/byteorder.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) BSWAP_32(x)
-#define bswap_64(x) BSWAP_64(x)
-
-#elif defined(__FreeBSD__) || defined(__DragonFly__)
-
-#include <sys/endian.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) bswap32(x)
-#define bswap_64(x) bswap64(x)
-
-#elif defined(__OpenBSD__)
-
-#include <sys/types.h>
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) swap32(x)
-#define bswap_64(x) swap64(x)
-
-#elif defined(__NetBSD__)
-
-#include <sys/types.h>
-#include <machine/bswap.h>
-#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
-#undef bswap_32
-#undef bswap_64
-#define bswap_32(x) bswap32(x)
-#define bswap_64(x) bswap64(x)
-#endif
-
-#else
-
-#undef bswap_32
-#undef bswap_64
-#include <byteswap.h>
-
-#endif
-
-#ifdef WORDS_BIGENDIAN
-#define FARMHASH_BIG_ENDIAN 1
-#endif
-
-#endif
-
-#ifdef FARMHASH_BIG_ENDIAN
-#define uint32_in_expected_order(x) (bswap_32(x))
-#define uint64_in_expected_order(x) (bswap_64(x))
-#else
-#define uint32_in_expected_order(x) (x)
-#define uint64_in_expected_order(x) (x)
-#endif
-
-namespace NAMESPACE_FOR_HASH_FUNCTIONS {
-
-STATIC_INLINE uint64_t Fetch64(const char *p) {
- uint64_t result;
- memcpy(&result, p, sizeof(result));
- return uint64_in_expected_order(result);
-}
-
-STATIC_INLINE uint32_t Fetch32(const char *p) {
- uint32_t result;
- memcpy(&result, p, sizeof(result));
- return uint32_in_expected_order(result);
-}
-
-STATIC_INLINE uint32_t Bswap32(uint32_t val) { return bswap_32(val); }
-STATIC_INLINE uint64_t Bswap64(uint64_t val) { return bswap_64(val); }
-
-// FARMHASH PORTABILITY LAYER: bitwise rot
-
-STATIC_INLINE uint32_t BasicRotate32(uint32_t val, int shift) {
- // Avoid shifting by 32: doing so yields an undefined result.
- return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
-}
-
-STATIC_INLINE uint64_t BasicRotate64(uint64_t val, int shift) {
- // Avoid shifting by 64: doing so yields an undefined result.
- return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
-}
-
-#if defined(_MSC_VER) && defined(FARMHASH_ROTR)
-
-STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
- return sizeof(unsigned long) == sizeof(val) ?
- _lrotr(val, shift) :
- BasicRotate32(val, shift);
-}
-
-STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
- return sizeof(unsigned long) == sizeof(val) ?
- _lrotr(val, shift) :
- BasicRotate64(val, shift);
-}
-
-#else
-
-STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
- return BasicRotate32(val, shift);
-}
-STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
- return BasicRotate64(val, shift);
-}
-
-#endif
-
-} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-
-// FARMHASH PORTABILITY LAYER: debug mode or max speed?
-// One may use -DFARMHASH_DEBUG=1 or -DFARMHASH_DEBUG=0 to force the issue.
-
-#if !defined(FARMHASH_DEBUG) && (!defined(NDEBUG) || defined(_DEBUG))
-#define FARMHASH_DEBUG 1
-#endif
-
-#undef debug_mode
-#if FARMHASH_DEBUG
-#define debug_mode 1
-#else
-#define debug_mode 0
-#endif
-
-// PLATFORM-SPECIFIC FUNCTIONS AND MACROS
-
-#undef x86_64
-#if defined (__x86_64) || defined (__x86_64__)
-#define x86_64 1
-#else
-#define x86_64 0
-#endif
-
-#undef x86
-#if defined(__i386__) || defined(__i386) || defined(__X86__)
-#define x86 1
-#else
-#define x86 x86_64
-#endif
-
-#if !defined(is_64bit)
-#define is_64bit (x86_64 || (sizeof(void*) == 8))
-#endif
-
-#undef can_use_ssse3
-#if defined(__SSSE3__) || defined(FARMHASH_ASSUME_SSSE3)
-
-#include <immintrin.h>
-#define can_use_ssse3 1
-// Now we can use _mm_hsub_epi16 and so on.
-
-#else
-#define can_use_ssse3 0
-#endif
-
-#undef can_use_sse41
-#if defined(__SSE4_1__) || defined(FARMHASH_ASSUME_SSE41)
-
-#include <immintrin.h>
-#define can_use_sse41 1
-// Now we can use _mm_insert_epi64 and so on.
-
-#else
-#define can_use_sse41 0
-#endif
-
-#undef can_use_sse42
-#if defined(__SSE4_2__) || defined(FARMHASH_ASSUME_SSE42)
-
-#include <nmmintrin.h>
-#define can_use_sse42 1
-// Now we can use _mm_crc32_u{32,16,8}. And on 64-bit platforms, _mm_crc32_u64.
-
-#else
-#define can_use_sse42 0
-#endif
-
-#undef can_use_aesni
-#if defined(__AES__) || defined(FARMHASH_ASSUME_AESNI)
-
-#include <wmmintrin.h>
-#define can_use_aesni 1
-// Now we can use _mm_aesimc_si128 and so on.
-
-#else
-#define can_use_aesni 0
-#endif
-
-#undef can_use_avx
-#if defined(__AVX__) || defined(FARMHASH_ASSUME_AVX)
-
-#include <immintrin.h>
-#define can_use_avx 1
-
-#else
-#define can_use_avx 0
-#endif
-
-#if can_use_ssse3 || can_use_sse41 || can_use_sse42 || can_use_aesni || can_use_avx
-STATIC_INLINE __m128i Fetch128(const char* s) {
- return _mm_loadu_si128(reinterpret_cast<const __m128i*>(s));
-}
-#endif
-// Building blocks for hash functions
-
-// std::swap() was in <algorithm> but is in <utility> from C++11 on.
-#if !FARMHASH_CAN_USE_CXX11
-#include <algorithm>
-#endif
-
-#undef PERMUTE3
-#define PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0)
-
-namespace NAMESPACE_FOR_HASH_FUNCTIONS {
-
-// Some primes between 2^63 and 2^64 for various uses.
-static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
-static const uint64_t k1 = 0xb492b66fbe98f273ULL;
-static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
-
-// Magic numbers for 32-bit hashing. Copied from Murmur3.
-static const uint32_t c1 = 0xcc9e2d51;
-static const uint32_t c2 = 0x1b873593;
-
-// A 32-bit to 32-bit integer hash copied from Murmur3.
-STATIC_INLINE uint32_t fmix(uint32_t h)
-{
- h ^= h >> 16;
- h *= 0x85ebca6b;
- h ^= h >> 13;
- h *= 0xc2b2ae35;
- h ^= h >> 16;
- return h;
-}
-
-STATIC_INLINE uint32_t Mur(uint32_t a, uint32_t h) {
- // Helper from Murmur3 for combining two 32-bit values.
- a *= c1;
- a = Rotate32(a, 17);
- a *= c2;
- h ^= a;
- h = Rotate32(h, 19);
- return h * 5 + 0xe6546b64;
-}
-
-template <typename T> STATIC_INLINE T DebugTweak(T x) {
- if (debug_mode) {
- if (sizeof(x) == 4) {
- x = ~Bswap32(x * c1);
- } else {
- x = ~Bswap64(x * k1);
- }
- }
- return x;
-}
-
-template <> uint128_t DebugTweak(uint128_t x) {
- if (debug_mode) {
- uint64_t y = DebugTweak(Uint128Low64(x));
- uint64_t z = DebugTweak(Uint128High64(x));
- y += z;
- z += y;
- x = Uint128(y, z * k1);
- }
- return x;
-}
-
-} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-
-using namespace std;
-using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
-namespace farmhashna {
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-#undef Bswap
-#define Bswap Bswap64
-
-STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
- return val ^ (val >> 47);
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
- return Hash128to64(Uint128(u, v));
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
- // Murmur-inspired hashing.
- uint64_t a = (u ^ v) * mul;
- a ^= (a >> 47);
- uint64_t b = (v ^ a) * mul;
- b ^= (b >> 47);
- b *= mul;
- return b;
-}
-
-STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
- if (len >= 8) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) + k2;
- uint64_t b = Fetch(s + len - 8);
- uint64_t c = Rotate(b, 37) * mul + a;
- uint64_t d = (Rotate(a, 25) + b) * mul;
- return HashLen16(c, d, mul);
- }
- if (len >= 4) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch32(s);
- return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
- }
- if (len > 0) {
- uint8_t a = s[0];
- uint8_t b = s[len >> 1];
- uint8_t c = s[len - 1];
- uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
- uint32_t z = len + (static_cast<uint32_t>(c) << 2);
- return ShiftMix(y * k2 ^ z * k0) * k2;
- }
- return k2;
-}
-
-// This probably works well for 16-byte strings as well, but it may be overkill
-// in that case.
-STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) * k1;
- uint64_t b = Fetch(s + 8);
- uint64_t c = Fetch(s + len - 8) * mul;
- uint64_t d = Fetch(s + len - 16) * k2;
- return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
- a + Rotate(b + k2, 18) + c, mul);
-}
-
-// Return a 16-byte hash for 48 bytes. Quick and dirty.
-// Callers do best to use "random-looking" values for a and b.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
- a += w;
- b = Rotate(b + a + z, 21);
- uint64_t c = a;
- a += x;
- a += y;
- b += Rotate(a, 44);
- return make_pair(a + z, b + c);
-}
-
-// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- const char* s, uint64_t a, uint64_t b) {
- return WeakHashLen32WithSeeds(Fetch(s),
- Fetch(s + 8),
- Fetch(s + 16),
- Fetch(s + 24),
- a,
- b);
-}
-
-// Return an 8-byte hash for 33 to 64 bytes.
-STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) * k2;
- uint64_t b = Fetch(s + 8);
- uint64_t c = Fetch(s + len - 8) * mul;
- uint64_t d = Fetch(s + len - 16) * k2;
- uint64_t y = Rotate(a + b, 43) + Rotate(c, 30) + d;
- uint64_t z = HashLen16(y, a + Rotate(b + k2, 18) + c, mul);
- uint64_t e = Fetch(s + 16) * mul;
- uint64_t f = Fetch(s + 24);
- uint64_t g = (y + Fetch(s + len - 32)) * mul;
- uint64_t h = (z + Fetch(s + len - 24)) * mul;
- return HashLen16(Rotate(e + f, 43) + Rotate(g, 30) + h,
- e + Rotate(f + a, 18) + g, mul);
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- const uint64_t seed = 81;
- if (len <= 32) {
- if (len <= 16) {
- return HashLen0to16(s, len);
- } else {
- return HashLen17to32(s, len);
- }
- } else if (len <= 64) {
- return HashLen33to64(s, len);
- }
-
- // For strings over 64 bytes we loop. Internal state consists of
- // 56 bytes: v, w, x, y, and z.
- uint64_t x = seed;
- uint64_t y = seed * k1 + 113;
- uint64_t z = ShiftMix(y * k2 + 113) * k2;
- pair<uint64_t, uint64_t> v = make_pair(0, 0);
- pair<uint64_t, uint64_t> w = make_pair(0, 0);
- x = x * k2 + Fetch(s);
-
- // Set end so that after the loop we have 1 to 64 bytes left to process.
- const char* end = s + ((len - 1) / 64) * 64;
- const char* last64 = end + ((len - 1) & 63) - 63;
- assert(s + len - 64 == last64);
- do {
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- s += 64;
- } while (s != end);
- uint64_t mul = k1 + ((z & 0xff) << 1);
- // Make s point to the last 64 bytes of input.
- s = last64;
- w.first += ((len - 1) & 63);
- v.first += w.first;
- w.first += v.first;
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * mul;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * mul;
- x ^= w.second * 9;
- y += v.first * 9 + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * mul;
- v = WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- return HashLen16(HashLen16(v.first, w.first, mul) + ShiftMix(y) * k0 + z,
- HashLen16(v.second, w.second, mul) + x,
- mul);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1);
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return Hash64WithSeeds(s, len, k2, seed);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
- return HashLen16(Hash64(s, len) - seed0, seed1);
-}
-} // namespace farmhashna
-namespace farmhashuo {
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r) {
- uint64_t a = (x ^ y) * mul;
- a ^= (a >> 47);
- uint64_t b = (y ^ a) * mul;
- return Rotate(b, r) * mul;
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len,
- uint64_t seed0, uint64_t seed1) {
- if (len <= 64) {
- return farmhashna::Hash64WithSeeds(s, len, seed0, seed1);
- }
-
- // For strings over 64 bytes we loop. Internal state consists of
- // 64 bytes: u, v, w, x, y, and z.
- uint64_t x = seed0;
- uint64_t y = seed1 * k2 + 113;
- uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
- pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
- pair<uint64_t, uint64_t> w = make_pair(0, 0);
- uint64_t u = x - z;
- x *= k2;
- uint64_t mul = k2 + (u & 0x82);
-
- // Set end so that after the loop we have 1 to 64 bytes left to process.
- const char* end = s + ((len - 1) / 64) * 64;
- const char* last64 = end + ((len - 1) & 63) - 63;
- assert(s + len - 64 == last64);
- do {
- uint64_t a0 = Fetch(s);
- uint64_t a1 = Fetch(s + 8);
- uint64_t a2 = Fetch(s + 16);
- uint64_t a3 = Fetch(s + 24);
- uint64_t a4 = Fetch(s + 32);
- uint64_t a5 = Fetch(s + 40);
- uint64_t a6 = Fetch(s + 48);
- uint64_t a7 = Fetch(s + 56);
- x += a0 + a1;
- y += a2;
- z += a3;
- v.first += a4;
- v.second += a5 + a1;
- w.first += a6;
- w.second += a7;
-
- x = Rotate(x, 26);
- x *= 9;
- y = Rotate(y, 29);
- z *= mul;
- v.first = Rotate(v.first, 33);
- v.second = Rotate(v.second, 30);
- w.first ^= x;
- w.first *= 9;
- z = Rotate(z, 32);
- z += w.second;
- w.second += z;
- z *= 9;
- std::swap(u, y);
-
- z += a0 + a6;
- v.first += a2;
- v.second += a3;
- w.first += a4;
- w.second += a5 + a6;
- x += a1;
- y += a7;
-
- y += v.first;
- v.first += x - y;
- v.second += w.first;
- w.first += v.second;
- w.second += x - y;
- x += w.second;
- w.second = Rotate(w.second, 34);
- std::swap(u, z);
- s += 64;
- } while (s != end);
- // Make s point to the last 64 bytes of input.
- s = last64;
- u *= 9;
- v.second = Rotate(v.second, 28);
- v.first = Rotate(v.first, 20);
- w.first += ((len - 1) & 63);
- u += y;
- y += u;
- x = Rotate(y - x + v.first + Fetch(s + 8), 37) * mul;
- y = Rotate(y ^ v.second ^ Fetch(s + 48), 42) * mul;
- x ^= w.second * 9;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * mul;
- v = farmhashna::WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
- w = farmhashna::WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- return H(farmhashna::HashLen16(v.first + x, w.first ^ y, mul) + z - u,
- H(v.second + y, w.second + z, k2, 30) ^ x,
- k2,
- 31);
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return len <= 64 ? farmhashna::Hash64WithSeed(s, len, seed) :
- Hash64WithSeeds(s, len, 0, seed);
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- return len <= 64 ? farmhashna::Hash64(s, len) :
- Hash64WithSeeds(s, len, 81, 0);
-}
-} // namespace farmhashuo
-namespace farmhashxo {
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-STATIC_INLINE uint64_t H32(const char *s, size_t len, uint64_t mul,
- uint64_t seed0 = 0, uint64_t seed1 = 0) {
- uint64_t a = Fetch(s) * k1;
- uint64_t b = Fetch(s + 8);
- uint64_t c = Fetch(s + len - 8) * mul;
- uint64_t d = Fetch(s + len - 16) * k2;
- uint64_t u = Rotate(a + b, 43) + Rotate(c, 30) + d + seed0;
- uint64_t v = a + Rotate(b + k2, 18) + c + seed1;
- a = farmhashna::ShiftMix((u ^ v) * mul);
- b = farmhashna::ShiftMix((v ^ a) * mul);
- return b;
-}
-
-// Return an 8-byte hash for 33 to 64 bytes.
-STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
- uint64_t mul0 = k2 - 30;
- uint64_t mul1 = k2 - 30 + 2 * len;
- uint64_t h0 = H32(s, 32, mul0);
- uint64_t h1 = H32(s + len - 32, 32, mul1);
- return ((h1 * mul1) + h0) * mul1;
-}
-
-// Return an 8-byte hash for 65 to 96 bytes.
-STATIC_INLINE uint64_t HashLen65to96(const char *s, size_t len) {
- uint64_t mul0 = k2 - 114;
- uint64_t mul1 = k2 - 114 + 2 * len;
- uint64_t h0 = H32(s, 32, mul0);
- uint64_t h1 = H32(s + 32, 32, mul1);
- uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1);
- return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1;
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- if (len <= 32) {
- if (len <= 16) {
- return farmhashna::HashLen0to16(s, len);
- } else {
- return farmhashna::HashLen17to32(s, len);
- }
- } else if (len <= 64) {
- return HashLen33to64(s, len);
- } else if (len <= 96) {
- return HashLen65to96(s, len);
- } else if (len <= 256) {
- return farmhashna::Hash64(s, len);
- } else {
- return farmhashuo::Hash64(s, len);
- }
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
- return farmhashuo::Hash64WithSeeds(s, len, seed0, seed1);
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return farmhashuo::Hash64WithSeed(s, len, seed);
-}
-} // namespace farmhashxo
-namespace farmhashte {
-#if !can_use_sse41 || !x86_64
-
-uint64_t Hash64(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash64(s, len);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len,
- uint64_t seed0, uint64_t seed1) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed0 + seed1 + Hash64(s, len);
-}
-
-#else
-
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-#undef Bswap
-#define Bswap Bswap64
-
-// Helpers for data-parallel operations (1x 128 bits or 2x 64 or 4x 32).
-STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi64(x, y); }
-STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
-STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
-STATIC_INLINE __m128i Shuf(__m128i x, __m128i y) { return _mm_shuffle_epi8(y, x); }
-
-// Requires n >= 256. Requires SSE4.1. Should be slightly faster if the
-// compiler uses AVX instructions (e.g., use the -mavx flag with GCC).
-STATIC_INLINE uint64_t Hash64Long(const char* s, size_t n,
- uint64_t seed0, uint64_t seed1) {
- const __m128i kShuf =
- _mm_set_epi8(4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1);
- const __m128i kMult =
- _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03,
- 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51);
- uint64_t seed2 = (seed0 + 113) * (seed1 + 9);
- uint64_t seed3 = (Rotate(seed0, 23) + 27) * (Rotate(seed1, 30) + 111);
- __m128i d0 = _mm_cvtsi64_si128(seed0);
- __m128i d1 = _mm_cvtsi64_si128(seed1);
- __m128i d2 = Shuf(kShuf, d0);
- __m128i d3 = Shuf(kShuf, d1);
- __m128i d4 = Xor(d0, d1);
- __m128i d5 = Xor(d1, d2);
- __m128i d6 = Xor(d2, d4);
- __m128i d7 = _mm_set1_epi32(seed2 >> 32);
- __m128i d8 = Mul(kMult, d2);
- __m128i d9 = _mm_set1_epi32(seed3 >> 32);
- __m128i d10 = _mm_set1_epi32(seed3);
- __m128i d11 = Add(d2, _mm_set1_epi32(seed2));
- const char* end = s + (n & ~static_cast<size_t>(255));
- do {
- __m128i z;
- z = Fetch128(s);
- d0 = Add(d0, z);
- d1 = Shuf(kShuf, d1);
- d2 = Xor(d2, d0);
- d4 = Xor(d4, z);
- d4 = Xor(d4, d1);
- std::swap(d0, d6);
- z = Fetch128(s + 16);
- d5 = Add(d5, z);
- d6 = Shuf(kShuf, d6);
- d8 = Shuf(kShuf, d8);
- d7 = Xor(d7, d5);
- d0 = Xor(d0, z);
- d0 = Xor(d0, d6);
- std::swap(d5, d11);
- z = Fetch128(s + 32);
- d1 = Add(d1, z);
- d2 = Shuf(kShuf, d2);
- d4 = Shuf(kShuf, d4);
- d5 = Xor(d5, z);
- d5 = Xor(d5, d2);
- std::swap(d10, d4);
- z = Fetch128(s + 48);
- d6 = Add(d6, z);
- d7 = Shuf(kShuf, d7);
- d0 = Shuf(kShuf, d0);
- d8 = Xor(d8, d6);
- d1 = Xor(d1, z);
- d1 = Add(d1, d7);
- z = Fetch128(s + 64);
- d2 = Add(d2, z);
- d5 = Shuf(kShuf, d5);
- d4 = Add(d4, d2);
- d6 = Xor(d6, z);
- d6 = Xor(d6, d11);
- std::swap(d8, d2);
- z = Fetch128(s + 80);
- d7 = Xor(d7, z);
- d8 = Shuf(kShuf, d8);
- d1 = Shuf(kShuf, d1);
- d0 = Add(d0, d7);
- d2 = Add(d2, z);
- d2 = Add(d2, d8);
- std::swap(d1, d7);
- z = Fetch128(s + 96);
- d4 = Shuf(kShuf, d4);
- d6 = Shuf(kShuf, d6);
- d8 = Mul(kMult, d8);
- d5 = Xor(d5, d11);
- d7 = Xor(d7, z);
- d7 = Add(d7, d4);
- std::swap(d6, d0);
- z = Fetch128(s + 112);
- d8 = Add(d8, z);
- d0 = Shuf(kShuf, d0);
- d2 = Shuf(kShuf, d2);
- d1 = Xor(d1, d8);
- d10 = Xor(d10, z);
- d10 = Xor(d10, d0);
- std::swap(d11, d5);
- z = Fetch128(s + 128);
- d4 = Add(d4, z);
- d5 = Shuf(kShuf, d5);
- d7 = Shuf(kShuf, d7);
- d6 = Add(d6, d4);
- d8 = Xor(d8, z);
- d8 = Xor(d8, d5);
- std::swap(d4, d10);
- z = Fetch128(s + 144);
- d0 = Add(d0, z);
- d1 = Shuf(kShuf, d1);
- d2 = Add(d2, d0);
- d4 = Xor(d4, z);
- d4 = Xor(d4, d1);
- z = Fetch128(s + 160);
- d5 = Add(d5, z);
- d6 = Shuf(kShuf, d6);
- d8 = Shuf(kShuf, d8);
- d7 = Xor(d7, d5);
- d0 = Xor(d0, z);
- d0 = Xor(d0, d6);
- std::swap(d2, d8);
- z = Fetch128(s + 176);
- d1 = Add(d1, z);
- d2 = Shuf(kShuf, d2);
- d4 = Shuf(kShuf, d4);
- d5 = Mul(kMult, d5);
- d5 = Xor(d5, z);
- d5 = Xor(d5, d2);
- std::swap(d7, d1);
- z = Fetch128(s + 192);
- d6 = Add(d6, z);
- d7 = Shuf(kShuf, d7);
- d0 = Shuf(kShuf, d0);
- d8 = Add(d8, d6);
- d1 = Xor(d1, z);
- d1 = Xor(d1, d7);
- std::swap(d0, d6);
- z = Fetch128(s + 208);
- d2 = Add(d2, z);
- d5 = Shuf(kShuf, d5);
- d4 = Xor(d4, d2);
- d6 = Xor(d6, z);
- d6 = Xor(d6, d9);
- std::swap(d5, d11);
- z = Fetch128(s + 224);
- d7 = Add(d7, z);
- d8 = Shuf(kShuf, d8);
- d1 = Shuf(kShuf, d1);
- d0 = Xor(d0, d7);
- d2 = Xor(d2, z);
- d2 = Xor(d2, d8);
- std::swap(d10, d4);
- z = Fetch128(s + 240);
- d3 = Add(d3, z);
- d4 = Shuf(kShuf, d4);
- d6 = Shuf(kShuf, d6);
- d7 = Mul(kMult, d7);
- d5 = Add(d5, d3);
- d7 = Xor(d7, z);
- d7 = Xor(d7, d4);
- std::swap(d3, d9);
- s += 256;
- } while (s != end);
- d6 = Add(Mul(kMult, d6), _mm_cvtsi64_si128(n));
- if (n % 256 != 0) {
- d7 = Add(_mm_shuffle_epi32(d8, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0)), d7);
- d8 = Add(Mul(kMult, d8), _mm_cvtsi64_si128(farmhashxo::Hash64(s, n % 256)));
- }
- __m128i t[8];
- d0 = Mul(kMult, Shuf(kShuf, Mul(kMult, d0)));
- d3 = Mul(kMult, Shuf(kShuf, Mul(kMult, d3)));
- d9 = Mul(kMult, Shuf(kShuf, Mul(kMult, d9)));
- d1 = Mul(kMult, Shuf(kShuf, Mul(kMult, d1)));
- d0 = Add(d11, d0);
- d3 = Xor(d7, d3);
- d9 = Add(d8, d9);
- d1 = Add(d10, d1);
- d4 = Add(d3, d4);
- d5 = Add(d9, d5);
- d6 = Xor(d1, d6);
- d2 = Add(d0, d2);
- t[0] = d0;
- t[1] = d3;
- t[2] = d9;
- t[3] = d1;
- t[4] = d4;
- t[5] = d5;
- t[6] = d6;
- t[7] = d2;
- return farmhashxo::Hash64(reinterpret_cast<const char*>(t), sizeof(t));
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- // Empirically, farmhashxo seems faster until length 512.
- return len >= 512 ? Hash64Long(s, len, k2, k1) : farmhashxo::Hash64(s, len);
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return len >= 512 ? Hash64Long(s, len, k1, seed) :
- farmhashxo::Hash64WithSeed(s, len, seed);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
- return len >= 512 ? Hash64Long(s, len, seed0, seed1) :
- farmhashxo::Hash64WithSeeds(s, len, seed0, seed1);
-}
-
-#endif
-} // namespace farmhashte
-namespace farmhashnt {
-#if !can_use_sse41 || !x86_64
-
-uint32_t Hash32(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash32(s, len);
-}
-
-#else
-
-uint32_t Hash32(const char *s, size_t len) {
- return static_cast<uint32_t>(farmhashte::Hash64(s, len));
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- return static_cast<uint32_t>(farmhashte::Hash64WithSeed(s, len, seed));
-}
-
-#endif
-} // namespace farmhashnt
-namespace farmhashmk {
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len, uint32_t seed = 0) {
- uint32_t a = Fetch(s - 4 + (len >> 1));
- uint32_t b = Fetch(s + 4);
- uint32_t c = Fetch(s + len - 8);
- uint32_t d = Fetch(s + (len >> 1));
- uint32_t e = Fetch(s);
- uint32_t f = Fetch(s + len - 4);
- uint32_t h = d * c1 + len + seed;
- a = Rotate(a, 12) + f;
- h = Mur(c, h) + a;
- a = Rotate(a, 3) + c;
- h = Mur(e, h) + a;
- a = Rotate(a + f, 12) + d;
- h = Mur(b ^ seed, h) + a;
- return fmix(h);
-}
-
-STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len, uint32_t seed = 0) {
- uint32_t b = seed;
- uint32_t c = 9;
- for (size_t i = 0; i < len; i++) {
- signed char v = s[i];
- b = b * c1 + v;
- c ^= b;
- }
- return fmix(Mur(b, Mur(len, c)));
-}
-
-STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len, uint32_t seed = 0) {
- uint32_t a = len, b = len * 5, c = 9, d = b + seed;
- a += Fetch(s);
- b += Fetch(s + len - 4);
- c += Fetch(s + ((len >> 1) & 4));
- return fmix(seed ^ Mur(c, Mur(b, Mur(a, d))));
-}
-
-uint32_t Hash32(const char *s, size_t len) {
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
- Hash32Len13to24(s, len);
- }
-
- // len > 24
- uint32_t h = len, g = c1 * len, f = g;
- uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
- uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
- uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
- uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
- uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
- h ^= a0;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- h ^= a2;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- g ^= a1;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- g ^= a3;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- f += a4;
- f = Rotate(f, 19) + 113;
- size_t iters = (len - 1) / 20;
- do {
- uint32_t a = Fetch(s);
- uint32_t b = Fetch(s + 4);
- uint32_t c = Fetch(s + 8);
- uint32_t d = Fetch(s + 12);
- uint32_t e = Fetch(s + 16);
- h += a;
- g += b;
- f += c;
- h = Mur(d, h) + e;
- g = Mur(c, g) + a;
- f = Mur(b + e * c1, f) + d;
- f += g;
- g += f;
- s += 20;
- } while (--iters != 0);
- g = Rotate(g, 11) * c1;
- g = Rotate(g, 17) * c1;
- f = Rotate(f, 11) * c1;
- f = Rotate(f, 17) * c1;
- h = Rotate(h + g, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- h = Rotate(h + f, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- return h;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return Hash32Len5to12(s, len, seed);
- else return Hash32Len0to4(s, len, seed);
- }
- uint32_t h = Hash32Len13to24(s, 24, seed ^ len);
- return Mur(Hash32(s + 24, len - 24) + seed, h);
-}
-} // namespace farmhashmk
-namespace farmhashsu {
-#if !can_use_sse42 || !can_use_aesni
-
-uint32_t Hash32(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash32(s, len);
-}
-
-#else
-
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-// Helpers for data-parallel operations (4x 32-bits).
-STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
-STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
-STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
-STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
-STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
-STATIC_INLINE __m128i RotateLeft(__m128i x, int c) {
- return Or(_mm_slli_epi32(x, c),
- _mm_srli_epi32(x, 32 - c));
-}
-STATIC_INLINE __m128i Rol17(__m128i x) { return RotateLeft(x, 17); }
-STATIC_INLINE __m128i Rol19(__m128i x) { return RotateLeft(x, 19); }
-STATIC_INLINE __m128i Shuffle0321(__m128i x) {
- return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
-}
-
-uint32_t Hash32(const char *s, size_t len) {
- const uint32_t seed = 81;
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ?
- farmhashmk::Hash32Len0to4(s, len) :
- farmhashmk::Hash32Len5to12(s, len)) :
- farmhashmk::Hash32Len13to24(s, len);
- }
-
- if (len < 40) {
- uint32_t a = len, b = seed * c2, c = a + b;
- a += Fetch(s + len - 4);
- b += Fetch(s + len - 20);
- c += Fetch(s + len - 16);
- uint32_t d = a;
- a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
- a = Mur(a, Mur(b, _mm_crc32_u32(c, d)));
- a += Fetch(s + len - 12);
- b += Fetch(s + len - 8);
- d += a;
- a += d;
- b = Mur(b, d) * c2;
- a = _mm_crc32_u32(a, b + c);
- return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
- }
-
-#undef Mulc1
-#define Mulc1(x) Mul((x), cc1)
-
-#undef Mulc2
-#define Mulc2(x) Mul((x), cc2)
-
-#undef Murk
-#define Murk(a, h) \
- Add(k, \
- Mul5( \
- Rol19( \
- Xor( \
- Mulc2( \
- Rol17( \
- Mulc1(a))), \
- (h)))))
-
- const __m128i cc1 = _mm_set1_epi32(c1);
- const __m128i cc2 = _mm_set1_epi32(c2);
- __m128i h = _mm_set1_epi32(seed);
- __m128i g = _mm_set1_epi32(c1 * seed);
- __m128i f = g;
- __m128i k = _mm_set1_epi32(0xe6546b64);
- __m128i q;
- if (len < 80) {
- __m128i a = Fetch128(s);
- __m128i b = Fetch128(s + 16);
- __m128i c = Fetch128(s + (len - 15) / 2);
- __m128i d = Fetch128(s + len - 32);
- __m128i e = Fetch128(s + len - 16);
- h = Add(h, a);
- g = Add(g, b);
- q = g;
- g = Shuffle0321(g);
- f = Add(f, c);
- __m128i be = Add(b, Mulc1(e));
- h = Add(h, f);
- f = Add(f, h);
- h = Add(Murk(d, h), e);
- k = Xor(k, _mm_shuffle_epi8(g, f));
- g = Add(Xor(c, g), a);
- f = Add(Xor(be, f), d);
- k = Add(k, be);
- k = Add(k, _mm_shuffle_epi8(f, h));
- f = Add(f, g);
- g = Add(g, f);
- g = Add(_mm_set1_epi32(len), Mulc1(g));
- } else {
- // len >= 80
- // The following is loosely modelled after farmhashmk::Hash32.
- size_t iters = (len - 1) / 80;
- len -= iters * 80;
-
-#undef Chunk
-#define Chunk() do { \
- __m128i a = Fetch128(s); \
- __m128i b = Fetch128(s + 16); \
- __m128i c = Fetch128(s + 32); \
- __m128i d = Fetch128(s + 48); \
- __m128i e = Fetch128(s + 64); \
- h = Add(h, a); \
- g = Add(g, b); \
- g = Shuffle0321(g); \
- f = Add(f, c); \
- __m128i be = Add(b, Mulc1(e)); \
- h = Add(h, f); \
- f = Add(f, h); \
- h = Add(h, d); \
- q = Add(q, e); \
- h = Rol17(h); \
- h = Mulc1(h); \
- k = Xor(k, _mm_shuffle_epi8(g, f)); \
- g = Add(Xor(c, g), a); \
- f = Add(Xor(be, f), d); \
- std::swap(f, q); \
- q = _mm_aesimc_si128(q); \
- k = Add(k, be); \
- k = Add(k, _mm_shuffle_epi8(f, h)); \
- f = Add(f, g); \
- g = Add(g, f); \
- f = Mulc1(f); \
-} while (0)
-
- q = g;
- while (iters-- != 0) {
- Chunk();
- s += 80;
- }
-
- if (len != 0) {
- h = Add(h, _mm_set1_epi32(len));
- s = s + len - 80;
- Chunk();
- }
- }
-
- g = Shuffle0321(g);
- k = Xor(k, g);
- k = Xor(k, q);
- h = Xor(h, q);
- f = Mulc1(f);
- k = Mulc2(k);
- g = Mulc1(g);
- h = Mulc2(h);
- k = Add(k, _mm_shuffle_epi8(g, f));
- h = Add(h, f);
- f = Add(f, h);
- g = Add(g, k);
- k = Add(k, g);
- k = Xor(k, _mm_shuffle_epi8(f, h));
- __m128i buf[4];
- buf[0] = f;
- buf[1] = g;
- buf[2] = k;
- buf[3] = h;
- s = reinterpret_cast<char*>(buf);
- uint32_t x = Fetch(s);
- uint32_t y = Fetch(s+4);
- uint32_t z = Fetch(s+8);
- x = _mm_crc32_u32(x, Fetch(s+12));
- y = _mm_crc32_u32(y, Fetch(s+16));
- z = _mm_crc32_u32(z * c1, Fetch(s+20));
- x = _mm_crc32_u32(x, Fetch(s+24));
- y = _mm_crc32_u32(y * c1, Fetch(s+28));
- uint32_t o = y;
- z = _mm_crc32_u32(z, Fetch(s+32));
- x = _mm_crc32_u32(x * c1, Fetch(s+36));
- y = _mm_crc32_u32(y, Fetch(s+40));
- z = _mm_crc32_u32(z * c1, Fetch(s+44));
- x = _mm_crc32_u32(x, Fetch(s+48));
- y = _mm_crc32_u32(y * c1, Fetch(s+52));
- z = _mm_crc32_u32(z, Fetch(s+56));
- x = _mm_crc32_u32(x, Fetch(s+60));
- return (o - x + y - z) * c1;
-}
-
-#undef Chunk
-#undef Murk
-#undef Mulc2
-#undef Mulc1
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
- else return farmhashmk::Hash32Len0to4(s, len, seed);
- }
- uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
- return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
-}
-
-#endif
-} // namespace farmhashsu
-namespace farmhashsa {
-#if !can_use_sse42
-
-uint32_t Hash32(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash32(s, len);
-}
-
-#else
-
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-// Helpers for data-parallel operations (4x 32-bits).
-STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
-STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
-STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
-STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
-STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
-STATIC_INLINE __m128i Rotate(__m128i x, int c) {
- return Or(_mm_slli_epi32(x, c),
- _mm_srli_epi32(x, 32 - c));
-}
-STATIC_INLINE __m128i Rot17(__m128i x) { return Rotate(x, 17); }
-STATIC_INLINE __m128i Rot19(__m128i x) { return Rotate(x, 19); }
-STATIC_INLINE __m128i Shuffle0321(__m128i x) {
- return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
-}
-
-uint32_t Hash32(const char *s, size_t len) {
- const uint32_t seed = 81;
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ?
- farmhashmk::Hash32Len0to4(s, len) :
- farmhashmk::Hash32Len5to12(s, len)) :
- farmhashmk::Hash32Len13to24(s, len);
- }
-
- if (len < 40) {
- uint32_t a = len, b = seed * c2, c = a + b;
- a += Fetch(s + len - 4);
- b += Fetch(s + len - 20);
- c += Fetch(s + len - 16);
- uint32_t d = a;
- a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
- a = Mur(a, Mur(b, Mur(c, d)));
- a += Fetch(s + len - 12);
- b += Fetch(s + len - 8);
- d += a;
- a += d;
- b = Mur(b, d) * c2;
- a = _mm_crc32_u32(a, b + c);
- return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
- }
-
-#undef Mulc1
-#define Mulc1(x) Mul((x), cc1)
-
-#undef Mulc2
-#define Mulc2(x) Mul((x), cc2)
-
-#undef Murk
-#define Murk(a, h) \
- Add(k, \
- Mul5( \
- Rot19( \
- Xor( \
- Mulc2( \
- Rot17( \
- Mulc1(a))), \
- (h)))))
-
- const __m128i cc1 = _mm_set1_epi32(c1);
- const __m128i cc2 = _mm_set1_epi32(c2);
- __m128i h = _mm_set1_epi32(seed);
- __m128i g = _mm_set1_epi32(c1 * seed);
- __m128i f = g;
- __m128i k = _mm_set1_epi32(0xe6546b64);
- if (len < 80) {
- __m128i a = Fetch128(s);
- __m128i b = Fetch128(s + 16);
- __m128i c = Fetch128(s + (len - 15) / 2);
- __m128i d = Fetch128(s + len - 32);
- __m128i e = Fetch128(s + len - 16);
- h = Add(h, a);
- g = Add(g, b);
- g = Shuffle0321(g);
- f = Add(f, c);
- __m128i be = Add(b, Mulc1(e));
- h = Add(h, f);
- f = Add(f, h);
- h = Add(Murk(d, h), e);
- k = Xor(k, _mm_shuffle_epi8(g, f));
- g = Add(Xor(c, g), a);
- f = Add(Xor(be, f), d);
- k = Add(k, be);
- k = Add(k, _mm_shuffle_epi8(f, h));
- f = Add(f, g);
- g = Add(g, f);
- g = Add(_mm_set1_epi32(len), Mulc1(g));
- } else {
- // len >= 80
- // The following is loosely modelled after farmhashmk::Hash32.
- size_t iters = (len - 1) / 80;
- len -= iters * 80;
-
-#undef Chunk
-#define Chunk() do { \
- __m128i a = Fetch128(s); \
- __m128i b = Fetch128(s + 16); \
- __m128i c = Fetch128(s + 32); \
- __m128i d = Fetch128(s + 48); \
- __m128i e = Fetch128(s + 64); \
- h = Add(h, a); \
- g = Add(g, b); \
- g = Shuffle0321(g); \
- f = Add(f, c); \
- __m128i be = Add(b, Mulc1(e)); \
- h = Add(h, f); \
- f = Add(f, h); \
- h = Add(Murk(d, h), e); \
- k = Xor(k, _mm_shuffle_epi8(g, f)); \
- g = Add(Xor(c, g), a); \
- f = Add(Xor(be, f), d); \
- k = Add(k, be); \
- k = Add(k, _mm_shuffle_epi8(f, h)); \
- f = Add(f, g); \
- g = Add(g, f); \
- f = Mulc1(f); \
-} while (0)
-
- while (iters-- != 0) {
- Chunk();
- s += 80;
- }
-
- if (len != 0) {
- h = Add(h, _mm_set1_epi32(len));
- s = s + len - 80;
- Chunk();
- }
- }
-
- g = Shuffle0321(g);
- k = Xor(k, g);
- f = Mulc1(f);
- k = Mulc2(k);
- g = Mulc1(g);
- h = Mulc2(h);
- k = Add(k, _mm_shuffle_epi8(g, f));
- h = Add(h, f);
- f = Add(f, h);
- g = Add(g, k);
- k = Add(k, g);
- k = Xor(k, _mm_shuffle_epi8(f, h));
- __m128i buf[4];
- buf[0] = f;
- buf[1] = g;
- buf[2] = k;
- buf[3] = h;
- s = reinterpret_cast<char*>(buf);
- uint32_t x = Fetch(s);
- uint32_t y = Fetch(s+4);
- uint32_t z = Fetch(s+8);
- x = _mm_crc32_u32(x, Fetch(s+12));
- y = _mm_crc32_u32(y, Fetch(s+16));
- z = _mm_crc32_u32(z * c1, Fetch(s+20));
- x = _mm_crc32_u32(x, Fetch(s+24));
- y = _mm_crc32_u32(y * c1, Fetch(s+28));
- uint32_t o = y;
- z = _mm_crc32_u32(z, Fetch(s+32));
- x = _mm_crc32_u32(x * c1, Fetch(s+36));
- y = _mm_crc32_u32(y, Fetch(s+40));
- z = _mm_crc32_u32(z * c1, Fetch(s+44));
- x = _mm_crc32_u32(x, Fetch(s+48));
- y = _mm_crc32_u32(y * c1, Fetch(s+52));
- z = _mm_crc32_u32(z, Fetch(s+56));
- x = _mm_crc32_u32(x, Fetch(s+60));
- return (o - x + y - z) * c1;
-}
-
-#undef Chunk
-#undef Murk
-#undef Mulc2
-#undef Mulc1
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
- else return farmhashmk::Hash32Len0to4(s, len, seed);
- }
- uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
- return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
-}
-
-#endif
-} // namespace farmhashsa
-namespace farmhashcc {
-// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
-// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
-// a seeded 32-bit hash function similar to CityHash32.
-
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len) {
- uint32_t a = Fetch(s - 4 + (len >> 1));
- uint32_t b = Fetch(s + 4);
- uint32_t c = Fetch(s + len - 8);
- uint32_t d = Fetch(s + (len >> 1));
- uint32_t e = Fetch(s);
- uint32_t f = Fetch(s + len - 4);
- uint32_t h = len;
-
- return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
-}
-
-STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len) {
- uint32_t b = 0;
- uint32_t c = 9;
- for (size_t i = 0; i < len; i++) {
- signed char v = s[i];
- b = b * c1 + v;
- c ^= b;
- }
- return fmix(Mur(b, Mur(len, c)));
-}
-
-STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len) {
- uint32_t a = len, b = len * 5, c = 9, d = b;
- a += Fetch(s);
- b += Fetch(s + len - 4);
- c += Fetch(s + ((len >> 1) & 4));
- return fmix(Mur(c, Mur(b, Mur(a, d))));
-}
-
+#include "farmhash.h"
+// FARMHASH ASSUMPTIONS: Modify as needed, or use -DFARMHASH_ASSUME_SSE42 etc.
+// Note that if you use -DFARMHASH_ASSUME_SSE42 you likely need -msse42
+// (or its equivalent for your compiler); if you use -DFARMHASH_ASSUME_AESNI
+// you likely need -maes (or its equivalent for your compiler).
+
+#ifdef FARMHASH_ASSUME_SSSE3
+#undef FARMHASH_ASSUME_SSSE3
+#define FARMHASH_ASSUME_SSSE3 1
+#endif
+
+#ifdef FARMHASH_ASSUME_SSE41
+#undef FARMHASH_ASSUME_SSE41
+#define FARMHASH_ASSUME_SSE41 1
+#endif
+
+#ifdef FARMHASH_ASSUME_SSE42
+#undef FARMHASH_ASSUME_SSE42
+#define FARMHASH_ASSUME_SSE42 1
+#endif
+
+#ifdef FARMHASH_ASSUME_AESNI
+#undef FARMHASH_ASSUME_AESNI
+#define FARMHASH_ASSUME_AESNI 1
+#endif
+
+#ifdef FARMHASH_ASSUME_AVX
+#undef FARMHASH_ASSUME_AVX
+#define FARMHASH_ASSUME_AVX 1
+#endif
+
+#if !defined(FARMHASH_CAN_USE_CXX11) && defined(LANG_CXX11)
+#define FARMHASH_CAN_USE_CXX11 1
+#else
+#undef FARMHASH_CAN_USE_CXX11
+#define FARMHASH_CAN_USE_CXX11 0
+#endif
+
+// FARMHASH PORTABILITY LAYER: Runtime error if misconfigured
+
+#ifndef FARMHASH_DIE_IF_MISCONFIGURED
+#define FARMHASH_DIE_IF_MISCONFIGURED do { *(char*)(len % 17) = 0; } while (0)
+#endif
+
+// FARMHASH PORTABILITY LAYER: "static inline" or similar
+
+#ifndef STATIC_INLINE
+#define STATIC_INLINE static inline
+#endif
+
+// FARMHASH PORTABILITY LAYER: LIKELY and UNLIKELY
+
+#if !defined(LIKELY)
+#if defined(FARMHASH_NO_BUILTIN_EXPECT) || (defined(FARMHASH_OPTIONAL_BUILTIN_EXPECT) && !defined(HAVE_BUILTIN_EXPECT))
+#define LIKELY(x) (x)
+#else
+#define LIKELY(x) (__builtin_expect(!!(x), 1))
+#endif
+#endif
+
+#undef UNLIKELY
+#define UNLIKELY(x) !LIKELY(!(x))
+
+// FARMHASH PORTABILITY LAYER: endianness and byteswapping functions
+
+#ifdef WORDS_BIGENDIAN
+#undef FARMHASH_BIG_ENDIAN
+#define FARMHASH_BIG_ENDIAN 1
+#endif
+
+#if defined(FARMHASH_LITTLE_ENDIAN) && defined(FARMHASH_BIG_ENDIAN)
+#error
+#endif
+
+#if !defined(FARMHASH_LITTLE_ENDIAN) && !defined(FARMHASH_BIG_ENDIAN)
+#define FARMHASH_UNKNOWN_ENDIAN 1
+#endif
+
+#if !defined(bswap_32) || !defined(bswap_64)
+#undef bswap_32
+#undef bswap_64
+
+#if defined(HAVE_BUILTIN_BSWAP) || defined(__clang__) || \
+ (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || \
+ __GNUC__ >= 5))
+// Easy case for bswap: no header file needed.
+#define bswap_32(x) __builtin_bswap32(x)
+#define bswap_64(x) __builtin_bswap64(x)
+#endif
+
+#endif
+
+#if defined(FARMHASH_UNKNOWN_ENDIAN) || !defined(bswap_64)
+
+#ifdef _MSC_VER
+
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) _byteswap_ulong(x)
+#define bswap_64(x) _byteswap_uint64(x)
+
+#elif defined(__APPLE__)
+
+// Mac OS X / Darwin features
+#include <libkern/OSByteOrder.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) OSSwapInt32(x)
+#define bswap_64(x) OSSwapInt64(x)
+
+#elif defined(__sun) || defined(sun)
+
+#include <sys/byteorder.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) BSWAP_32(x)
+#define bswap_64(x) BSWAP_64(x)
+
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+
+#include <sys/endian.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
+
+#elif defined(__OpenBSD__)
+
+#include <sys/types.h>
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) swap32(x)
+#define bswap_64(x) swap64(x)
+
+#elif defined(__NetBSD__)
+
+#include <sys/types.h>
+#include <machine/bswap.h>
+#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
+#undef bswap_32
+#undef bswap_64
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
+#endif
+
+#else
+
+#undef bswap_32
+#undef bswap_64
+#include <byteswap.h>
+
+#endif
+
+#ifdef WORDS_BIGENDIAN
+#define FARMHASH_BIG_ENDIAN 1
+#endif
+
+#endif
+
+#ifdef FARMHASH_BIG_ENDIAN
+#define uint32_in_expected_order(x) (bswap_32(x))
+#define uint64_in_expected_order(x) (bswap_64(x))
+#else
+#define uint32_in_expected_order(x) (x)
+#define uint64_in_expected_order(x) (x)
+#endif
+
+namespace NAMESPACE_FOR_HASH_FUNCTIONS {
+
+STATIC_INLINE uint64_t Fetch64(const char *p) {
+ uint64_t result;
+ memcpy(&result, p, sizeof(result));
+ return uint64_in_expected_order(result);
+}
+
+STATIC_INLINE uint32_t Fetch32(const char *p) {
+ uint32_t result;
+ memcpy(&result, p, sizeof(result));
+ return uint32_in_expected_order(result);
+}
+
+STATIC_INLINE uint32_t Bswap32(uint32_t val) { return bswap_32(val); }
+STATIC_INLINE uint64_t Bswap64(uint64_t val) { return bswap_64(val); }
+
+// FARMHASH PORTABILITY LAYER: bitwise rot
+
+STATIC_INLINE uint32_t BasicRotate32(uint32_t val, int shift) {
+ // Avoid shifting by 32: doing so yields an undefined result.
+ return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
+}
+
+STATIC_INLINE uint64_t BasicRotate64(uint64_t val, int shift) {
+ // Avoid shifting by 64: doing so yields an undefined result.
+ return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
+}
+
+#if defined(_MSC_VER) && defined(FARMHASH_ROTR)
+
+STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
+ return sizeof(unsigned long) == sizeof(val) ?
+ _lrotr(val, shift) :
+ BasicRotate32(val, shift);
+}
+
+STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
+ return sizeof(unsigned long) == sizeof(val) ?
+ _lrotr(val, shift) :
+ BasicRotate64(val, shift);
+}
+
+#else
+
+STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
+ return BasicRotate32(val, shift);
+}
+STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
+ return BasicRotate64(val, shift);
+}
+
+#endif
+
+} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
+
+// FARMHASH PORTABILITY LAYER: debug mode or max speed?
+// One may use -DFARMHASH_DEBUG=1 or -DFARMHASH_DEBUG=0 to force the issue.
+
+#if !defined(FARMHASH_DEBUG) && (!defined(NDEBUG) || defined(_DEBUG))
+#define FARMHASH_DEBUG 1
+#endif
+
+#undef debug_mode
+#if FARMHASH_DEBUG
+#define debug_mode 1
+#else
+#define debug_mode 0
+#endif
+
+// PLATFORM-SPECIFIC FUNCTIONS AND MACROS
+
+#undef x86_64
+#if defined (__x86_64) || defined (__x86_64__)
+#define x86_64 1
+#else
+#define x86_64 0
+#endif
+
+#undef x86
+#if defined(__i386__) || defined(__i386) || defined(__X86__)
+#define x86 1
+#else
+#define x86 x86_64
+#endif
+
+#if !defined(is_64bit)
+#define is_64bit (x86_64 || (sizeof(void*) == 8))
+#endif
+
+#undef can_use_ssse3
+#if defined(__SSSE3__) || defined(FARMHASH_ASSUME_SSSE3)
+
+#include <immintrin.h>
+#define can_use_ssse3 1
+// Now we can use _mm_hsub_epi16 and so on.
+
+#else
+#define can_use_ssse3 0
+#endif
+
+#undef can_use_sse41
+#if defined(__SSE4_1__) || defined(FARMHASH_ASSUME_SSE41)
+
+#include <immintrin.h>
+#define can_use_sse41 1
+// Now we can use _mm_insert_epi64 and so on.
+
+#else
+#define can_use_sse41 0
+#endif
+
+#undef can_use_sse42
+#if defined(__SSE4_2__) || defined(FARMHASH_ASSUME_SSE42)
+
+#include <nmmintrin.h>
+#define can_use_sse42 1
+// Now we can use _mm_crc32_u{32,16,8}. And on 64-bit platforms, _mm_crc32_u64.
+
+#else
+#define can_use_sse42 0
+#endif
+
+#undef can_use_aesni
+#if defined(__AES__) || defined(FARMHASH_ASSUME_AESNI)
+
+#include <wmmintrin.h>
+#define can_use_aesni 1
+// Now we can use _mm_aesimc_si128 and so on.
+
+#else
+#define can_use_aesni 0
+#endif
+
+#undef can_use_avx
+#if defined(__AVX__) || defined(FARMHASH_ASSUME_AVX)
+
+#include <immintrin.h>
+#define can_use_avx 1
+
+#else
+#define can_use_avx 0
+#endif
+
+#if can_use_ssse3 || can_use_sse41 || can_use_sse42 || can_use_aesni || can_use_avx
+STATIC_INLINE __m128i Fetch128(const char* s) {
+ return _mm_loadu_si128(reinterpret_cast<const __m128i*>(s));
+}
+#endif
+// Building blocks for hash functions
+
+// std::swap() was in <algorithm> but is in <utility> from C++11 on.
+#if !FARMHASH_CAN_USE_CXX11
+#include <algorithm>
+#endif
+
+#undef PERMUTE3
+#define PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0)
+
+namespace NAMESPACE_FOR_HASH_FUNCTIONS {
+
+// Some primes between 2^63 and 2^64 for various uses.
+static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
+static const uint64_t k1 = 0xb492b66fbe98f273ULL;
+static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
+
+// Magic numbers for 32-bit hashing. Copied from Murmur3.
+static const uint32_t c1 = 0xcc9e2d51;
+static const uint32_t c2 = 0x1b873593;
+
+// A 32-bit to 32-bit integer hash copied from Murmur3.
+STATIC_INLINE uint32_t fmix(uint32_t h)
+{
+ h ^= h >> 16;
+ h *= 0x85ebca6b;
+ h ^= h >> 13;
+ h *= 0xc2b2ae35;
+ h ^= h >> 16;
+ return h;
+}
+
+STATIC_INLINE uint32_t Mur(uint32_t a, uint32_t h) {
+ // Helper from Murmur3 for combining two 32-bit values.
+ a *= c1;
+ a = Rotate32(a, 17);
+ a *= c2;
+ h ^= a;
+ h = Rotate32(h, 19);
+ return h * 5 + 0xe6546b64;
+}
+
+template <typename T> STATIC_INLINE T DebugTweak(T x) {
+ if (debug_mode) {
+ if (sizeof(x) == 4) {
+ x = ~Bswap32(x * c1);
+ } else {
+ x = ~Bswap64(x * k1);
+ }
+ }
+ return x;
+}
+
+template <> uint128_t DebugTweak(uint128_t x) {
+ if (debug_mode) {
+ uint64_t y = DebugTweak(Uint128Low64(x));
+ uint64_t z = DebugTweak(Uint128High64(x));
+ y += z;
+ z += y;
+ x = Uint128(y, z * k1);
+ }
+ return x;
+}
+
+} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
+
+using namespace std;
+using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
+namespace farmhashna {
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+#undef Bswap
+#define Bswap Bswap64
+
+STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
+ return val ^ (val >> 47);
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
+ return Hash128to64(Uint128(u, v));
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
+ // Murmur-inspired hashing.
+ uint64_t a = (u ^ v) * mul;
+ a ^= (a >> 47);
+ uint64_t b = (v ^ a) * mul;
+ b ^= (b >> 47);
+ b *= mul;
+ return b;
+}
+
+STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
+ if (len >= 8) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) + k2;
+ uint64_t b = Fetch(s + len - 8);
+ uint64_t c = Rotate(b, 37) * mul + a;
+ uint64_t d = (Rotate(a, 25) + b) * mul;
+ return HashLen16(c, d, mul);
+ }
+ if (len >= 4) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch32(s);
+ return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
+ }
+ if (len > 0) {
+ uint8_t a = s[0];
+ uint8_t b = s[len >> 1];
+ uint8_t c = s[len - 1];
+ uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
+ uint32_t z = len + (static_cast<uint32_t>(c) << 2);
+ return ShiftMix(y * k2 ^ z * k0) * k2;
+ }
+ return k2;
+}
+
+// This probably works well for 16-byte strings as well, but it may be overkill
+// in that case.
+STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) * k1;
+ uint64_t b = Fetch(s + 8);
+ uint64_t c = Fetch(s + len - 8) * mul;
+ uint64_t d = Fetch(s + len - 16) * k2;
+ return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
+ a + Rotate(b + k2, 18) + c, mul);
+}
+
+// Return a 16-byte hash for 48 bytes. Quick and dirty.
+// Callers do best to use "random-looking" values for a and b.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
+ a += w;
+ b = Rotate(b + a + z, 21);
+ uint64_t c = a;
+ a += x;
+ a += y;
+ b += Rotate(a, 44);
+ return make_pair(a + z, b + c);
+}
+
+// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ const char* s, uint64_t a, uint64_t b) {
+ return WeakHashLen32WithSeeds(Fetch(s),
+ Fetch(s + 8),
+ Fetch(s + 16),
+ Fetch(s + 24),
+ a,
+ b);
+}
+
+// Return an 8-byte hash for 33 to 64 bytes.
+STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) * k2;
+ uint64_t b = Fetch(s + 8);
+ uint64_t c = Fetch(s + len - 8) * mul;
+ uint64_t d = Fetch(s + len - 16) * k2;
+ uint64_t y = Rotate(a + b, 43) + Rotate(c, 30) + d;
+ uint64_t z = HashLen16(y, a + Rotate(b + k2, 18) + c, mul);
+ uint64_t e = Fetch(s + 16) * mul;
+ uint64_t f = Fetch(s + 24);
+ uint64_t g = (y + Fetch(s + len - 32)) * mul;
+ uint64_t h = (z + Fetch(s + len - 24)) * mul;
+ return HashLen16(Rotate(e + f, 43) + Rotate(g, 30) + h,
+ e + Rotate(f + a, 18) + g, mul);
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ const uint64_t seed = 81;
+ if (len <= 32) {
+ if (len <= 16) {
+ return HashLen0to16(s, len);
+ } else {
+ return HashLen17to32(s, len);
+ }
+ } else if (len <= 64) {
+ return HashLen33to64(s, len);
+ }
+
+ // For strings over 64 bytes we loop. Internal state consists of
+ // 56 bytes: v, w, x, y, and z.
+ uint64_t x = seed;
+ uint64_t y = seed * k1 + 113;
+ uint64_t z = ShiftMix(y * k2 + 113) * k2;
+ pair<uint64_t, uint64_t> v = make_pair(0, 0);
+ pair<uint64_t, uint64_t> w = make_pair(0, 0);
+ x = x * k2 + Fetch(s);
+
+ // Set end so that after the loop we have 1 to 64 bytes left to process.
+ const char* end = s + ((len - 1) / 64) * 64;
+ const char* last64 = end + ((len - 1) & 63) - 63;
+ assert(s + len - 64 == last64);
+ do {
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ s += 64;
+ } while (s != end);
+ uint64_t mul = k1 + ((z & 0xff) << 1);
+ // Make s point to the last 64 bytes of input.
+ s = last64;
+ w.first += ((len - 1) & 63);
+ v.first += w.first;
+ w.first += v.first;
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * mul;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * mul;
+ x ^= w.second * 9;
+ y += v.first * 9 + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * mul;
+ v = WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ return HashLen16(HashLen16(v.first, w.first, mul) + ShiftMix(y) * k0 + z,
+ HashLen16(v.second, w.second, mul) + x,
+ mul);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1);
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return Hash64WithSeeds(s, len, k2, seed);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return HashLen16(Hash64(s, len) - seed0, seed1);
+}
+} // namespace farmhashna
+namespace farmhashuo {
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r) {
+ uint64_t a = (x ^ y) * mul;
+ a ^= (a >> 47);
+ uint64_t b = (y ^ a) * mul;
+ return Rotate(b, r) * mul;
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len,
+ uint64_t seed0, uint64_t seed1) {
+ if (len <= 64) {
+ return farmhashna::Hash64WithSeeds(s, len, seed0, seed1);
+ }
+
+ // For strings over 64 bytes we loop. Internal state consists of
+ // 64 bytes: u, v, w, x, y, and z.
+ uint64_t x = seed0;
+ uint64_t y = seed1 * k2 + 113;
+ uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
+ pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
+ pair<uint64_t, uint64_t> w = make_pair(0, 0);
+ uint64_t u = x - z;
+ x *= k2;
+ uint64_t mul = k2 + (u & 0x82);
+
+ // Set end so that after the loop we have 1 to 64 bytes left to process.
+ const char* end = s + ((len - 1) / 64) * 64;
+ const char* last64 = end + ((len - 1) & 63) - 63;
+ assert(s + len - 64 == last64);
+ do {
+ uint64_t a0 = Fetch(s);
+ uint64_t a1 = Fetch(s + 8);
+ uint64_t a2 = Fetch(s + 16);
+ uint64_t a3 = Fetch(s + 24);
+ uint64_t a4 = Fetch(s + 32);
+ uint64_t a5 = Fetch(s + 40);
+ uint64_t a6 = Fetch(s + 48);
+ uint64_t a7 = Fetch(s + 56);
+ x += a0 + a1;
+ y += a2;
+ z += a3;
+ v.first += a4;
+ v.second += a5 + a1;
+ w.first += a6;
+ w.second += a7;
+
+ x = Rotate(x, 26);
+ x *= 9;
+ y = Rotate(y, 29);
+ z *= mul;
+ v.first = Rotate(v.first, 33);
+ v.second = Rotate(v.second, 30);
+ w.first ^= x;
+ w.first *= 9;
+ z = Rotate(z, 32);
+ z += w.second;
+ w.second += z;
+ z *= 9;
+ std::swap(u, y);
+
+ z += a0 + a6;
+ v.first += a2;
+ v.second += a3;
+ w.first += a4;
+ w.second += a5 + a6;
+ x += a1;
+ y += a7;
+
+ y += v.first;
+ v.first += x - y;
+ v.second += w.first;
+ w.first += v.second;
+ w.second += x - y;
+ x += w.second;
+ w.second = Rotate(w.second, 34);
+ std::swap(u, z);
+ s += 64;
+ } while (s != end);
+ // Make s point to the last 64 bytes of input.
+ s = last64;
+ u *= 9;
+ v.second = Rotate(v.second, 28);
+ v.first = Rotate(v.first, 20);
+ w.first += ((len - 1) & 63);
+ u += y;
+ y += u;
+ x = Rotate(y - x + v.first + Fetch(s + 8), 37) * mul;
+ y = Rotate(y ^ v.second ^ Fetch(s + 48), 42) * mul;
+ x ^= w.second * 9;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * mul;
+ v = farmhashna::WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
+ w = farmhashna::WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ return H(farmhashna::HashLen16(v.first + x, w.first ^ y, mul) + z - u,
+ H(v.second + y, w.second + z, k2, 30) ^ x,
+ k2,
+ 31);
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return len <= 64 ? farmhashna::Hash64WithSeed(s, len, seed) :
+ Hash64WithSeeds(s, len, 0, seed);
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ return len <= 64 ? farmhashna::Hash64(s, len) :
+ Hash64WithSeeds(s, len, 81, 0);
+}
+} // namespace farmhashuo
+namespace farmhashxo {
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+STATIC_INLINE uint64_t H32(const char *s, size_t len, uint64_t mul,
+ uint64_t seed0 = 0, uint64_t seed1 = 0) {
+ uint64_t a = Fetch(s) * k1;
+ uint64_t b = Fetch(s + 8);
+ uint64_t c = Fetch(s + len - 8) * mul;
+ uint64_t d = Fetch(s + len - 16) * k2;
+ uint64_t u = Rotate(a + b, 43) + Rotate(c, 30) + d + seed0;
+ uint64_t v = a + Rotate(b + k2, 18) + c + seed1;
+ a = farmhashna::ShiftMix((u ^ v) * mul);
+ b = farmhashna::ShiftMix((v ^ a) * mul);
+ return b;
+}
+
+// Return an 8-byte hash for 33 to 64 bytes.
+STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
+ uint64_t mul0 = k2 - 30;
+ uint64_t mul1 = k2 - 30 + 2 * len;
+ uint64_t h0 = H32(s, 32, mul0);
+ uint64_t h1 = H32(s + len - 32, 32, mul1);
+ return ((h1 * mul1) + h0) * mul1;
+}
+
+// Return an 8-byte hash for 65 to 96 bytes.
+STATIC_INLINE uint64_t HashLen65to96(const char *s, size_t len) {
+ uint64_t mul0 = k2 - 114;
+ uint64_t mul1 = k2 - 114 + 2 * len;
+ uint64_t h0 = H32(s, 32, mul0);
+ uint64_t h1 = H32(s + 32, 32, mul1);
+ uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1);
+ return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1;
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ if (len <= 32) {
+ if (len <= 16) {
+ return farmhashna::HashLen0to16(s, len);
+ } else {
+ return farmhashna::HashLen17to32(s, len);
+ }
+ } else if (len <= 64) {
+ return HashLen33to64(s, len);
+ } else if (len <= 96) {
+ return HashLen65to96(s, len);
+ } else if (len <= 256) {
+ return farmhashna::Hash64(s, len);
+ } else {
+ return farmhashuo::Hash64(s, len);
+ }
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return farmhashuo::Hash64WithSeeds(s, len, seed0, seed1);
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return farmhashuo::Hash64WithSeed(s, len, seed);
+}
+} // namespace farmhashxo
+namespace farmhashte {
+#if !can_use_sse41 || !x86_64
+
+uint64_t Hash64(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash64(s, len);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len,
+ uint64_t seed0, uint64_t seed1) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed0 + seed1 + Hash64(s, len);
+}
+
+#else
+
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+#undef Bswap
+#define Bswap Bswap64
+
+// Helpers for data-parallel operations (1x 128 bits or 2x 64 or 4x 32).
+STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi64(x, y); }
+STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
+STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
+STATIC_INLINE __m128i Shuf(__m128i x, __m128i y) { return _mm_shuffle_epi8(y, x); }
+
+// Requires n >= 256. Requires SSE4.1. Should be slightly faster if the
+// compiler uses AVX instructions (e.g., use the -mavx flag with GCC).
+STATIC_INLINE uint64_t Hash64Long(const char* s, size_t n,
+ uint64_t seed0, uint64_t seed1) {
+ const __m128i kShuf =
+ _mm_set_epi8(4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1);
+ const __m128i kMult =
+ _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03,
+ 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51);
+ uint64_t seed2 = (seed0 + 113) * (seed1 + 9);
+ uint64_t seed3 = (Rotate(seed0, 23) + 27) * (Rotate(seed1, 30) + 111);
+ __m128i d0 = _mm_cvtsi64_si128(seed0);
+ __m128i d1 = _mm_cvtsi64_si128(seed1);
+ __m128i d2 = Shuf(kShuf, d0);
+ __m128i d3 = Shuf(kShuf, d1);
+ __m128i d4 = Xor(d0, d1);
+ __m128i d5 = Xor(d1, d2);
+ __m128i d6 = Xor(d2, d4);
+ __m128i d7 = _mm_set1_epi32(seed2 >> 32);
+ __m128i d8 = Mul(kMult, d2);
+ __m128i d9 = _mm_set1_epi32(seed3 >> 32);
+ __m128i d10 = _mm_set1_epi32(seed3);
+ __m128i d11 = Add(d2, _mm_set1_epi32(seed2));
+ const char* end = s + (n & ~static_cast<size_t>(255));
+ do {
+ __m128i z;
+ z = Fetch128(s);
+ d0 = Add(d0, z);
+ d1 = Shuf(kShuf, d1);
+ d2 = Xor(d2, d0);
+ d4 = Xor(d4, z);
+ d4 = Xor(d4, d1);
+ std::swap(d0, d6);
+ z = Fetch128(s + 16);
+ d5 = Add(d5, z);
+ d6 = Shuf(kShuf, d6);
+ d8 = Shuf(kShuf, d8);
+ d7 = Xor(d7, d5);
+ d0 = Xor(d0, z);
+ d0 = Xor(d0, d6);
+ std::swap(d5, d11);
+ z = Fetch128(s + 32);
+ d1 = Add(d1, z);
+ d2 = Shuf(kShuf, d2);
+ d4 = Shuf(kShuf, d4);
+ d5 = Xor(d5, z);
+ d5 = Xor(d5, d2);
+ std::swap(d10, d4);
+ z = Fetch128(s + 48);
+ d6 = Add(d6, z);
+ d7 = Shuf(kShuf, d7);
+ d0 = Shuf(kShuf, d0);
+ d8 = Xor(d8, d6);
+ d1 = Xor(d1, z);
+ d1 = Add(d1, d7);
+ z = Fetch128(s + 64);
+ d2 = Add(d2, z);
+ d5 = Shuf(kShuf, d5);
+ d4 = Add(d4, d2);
+ d6 = Xor(d6, z);
+ d6 = Xor(d6, d11);
+ std::swap(d8, d2);
+ z = Fetch128(s + 80);
+ d7 = Xor(d7, z);
+ d8 = Shuf(kShuf, d8);
+ d1 = Shuf(kShuf, d1);
+ d0 = Add(d0, d7);
+ d2 = Add(d2, z);
+ d2 = Add(d2, d8);
+ std::swap(d1, d7);
+ z = Fetch128(s + 96);
+ d4 = Shuf(kShuf, d4);
+ d6 = Shuf(kShuf, d6);
+ d8 = Mul(kMult, d8);
+ d5 = Xor(d5, d11);
+ d7 = Xor(d7, z);
+ d7 = Add(d7, d4);
+ std::swap(d6, d0);
+ z = Fetch128(s + 112);
+ d8 = Add(d8, z);
+ d0 = Shuf(kShuf, d0);
+ d2 = Shuf(kShuf, d2);
+ d1 = Xor(d1, d8);
+ d10 = Xor(d10, z);
+ d10 = Xor(d10, d0);
+ std::swap(d11, d5);
+ z = Fetch128(s + 128);
+ d4 = Add(d4, z);
+ d5 = Shuf(kShuf, d5);
+ d7 = Shuf(kShuf, d7);
+ d6 = Add(d6, d4);
+ d8 = Xor(d8, z);
+ d8 = Xor(d8, d5);
+ std::swap(d4, d10);
+ z = Fetch128(s + 144);
+ d0 = Add(d0, z);
+ d1 = Shuf(kShuf, d1);
+ d2 = Add(d2, d0);
+ d4 = Xor(d4, z);
+ d4 = Xor(d4, d1);
+ z = Fetch128(s + 160);
+ d5 = Add(d5, z);
+ d6 = Shuf(kShuf, d6);
+ d8 = Shuf(kShuf, d8);
+ d7 = Xor(d7, d5);
+ d0 = Xor(d0, z);
+ d0 = Xor(d0, d6);
+ std::swap(d2, d8);
+ z = Fetch128(s + 176);
+ d1 = Add(d1, z);
+ d2 = Shuf(kShuf, d2);
+ d4 = Shuf(kShuf, d4);
+ d5 = Mul(kMult, d5);
+ d5 = Xor(d5, z);
+ d5 = Xor(d5, d2);
+ std::swap(d7, d1);
+ z = Fetch128(s + 192);
+ d6 = Add(d6, z);
+ d7 = Shuf(kShuf, d7);
+ d0 = Shuf(kShuf, d0);
+ d8 = Add(d8, d6);
+ d1 = Xor(d1, z);
+ d1 = Xor(d1, d7);
+ std::swap(d0, d6);
+ z = Fetch128(s + 208);
+ d2 = Add(d2, z);
+ d5 = Shuf(kShuf, d5);
+ d4 = Xor(d4, d2);
+ d6 = Xor(d6, z);
+ d6 = Xor(d6, d9);
+ std::swap(d5, d11);
+ z = Fetch128(s + 224);
+ d7 = Add(d7, z);
+ d8 = Shuf(kShuf, d8);
+ d1 = Shuf(kShuf, d1);
+ d0 = Xor(d0, d7);
+ d2 = Xor(d2, z);
+ d2 = Xor(d2, d8);
+ std::swap(d10, d4);
+ z = Fetch128(s + 240);
+ d3 = Add(d3, z);
+ d4 = Shuf(kShuf, d4);
+ d6 = Shuf(kShuf, d6);
+ d7 = Mul(kMult, d7);
+ d5 = Add(d5, d3);
+ d7 = Xor(d7, z);
+ d7 = Xor(d7, d4);
+ std::swap(d3, d9);
+ s += 256;
+ } while (s != end);
+ d6 = Add(Mul(kMult, d6), _mm_cvtsi64_si128(n));
+ if (n % 256 != 0) {
+ d7 = Add(_mm_shuffle_epi32(d8, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0)), d7);
+ d8 = Add(Mul(kMult, d8), _mm_cvtsi64_si128(farmhashxo::Hash64(s, n % 256)));
+ }
+ __m128i t[8];
+ d0 = Mul(kMult, Shuf(kShuf, Mul(kMult, d0)));
+ d3 = Mul(kMult, Shuf(kShuf, Mul(kMult, d3)));
+ d9 = Mul(kMult, Shuf(kShuf, Mul(kMult, d9)));
+ d1 = Mul(kMult, Shuf(kShuf, Mul(kMult, d1)));
+ d0 = Add(d11, d0);
+ d3 = Xor(d7, d3);
+ d9 = Add(d8, d9);
+ d1 = Add(d10, d1);
+ d4 = Add(d3, d4);
+ d5 = Add(d9, d5);
+ d6 = Xor(d1, d6);
+ d2 = Add(d0, d2);
+ t[0] = d0;
+ t[1] = d3;
+ t[2] = d9;
+ t[3] = d1;
+ t[4] = d4;
+ t[5] = d5;
+ t[6] = d6;
+ t[7] = d2;
+ return farmhashxo::Hash64(reinterpret_cast<const char*>(t), sizeof(t));
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ // Empirically, farmhashxo seems faster until length 512.
+ return len >= 512 ? Hash64Long(s, len, k2, k1) : farmhashxo::Hash64(s, len);
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return len >= 512 ? Hash64Long(s, len, k1, seed) :
+ farmhashxo::Hash64WithSeed(s, len, seed);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return len >= 512 ? Hash64Long(s, len, seed0, seed1) :
+ farmhashxo::Hash64WithSeeds(s, len, seed0, seed1);
+}
+
+#endif
+} // namespace farmhashte
+namespace farmhashnt {
+#if !can_use_sse41 || !x86_64
+
+uint32_t Hash32(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash32(s, len);
+}
+
+#else
+
+uint32_t Hash32(const char *s, size_t len) {
+ return static_cast<uint32_t>(farmhashte::Hash64(s, len));
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ return static_cast<uint32_t>(farmhashte::Hash64WithSeed(s, len, seed));
+}
+
+#endif
+} // namespace farmhashnt
+namespace farmhashmk {
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len, uint32_t seed = 0) {
+ uint32_t a = Fetch(s - 4 + (len >> 1));
+ uint32_t b = Fetch(s + 4);
+ uint32_t c = Fetch(s + len - 8);
+ uint32_t d = Fetch(s + (len >> 1));
+ uint32_t e = Fetch(s);
+ uint32_t f = Fetch(s + len - 4);
+ uint32_t h = d * c1 + len + seed;
+ a = Rotate(a, 12) + f;
+ h = Mur(c, h) + a;
+ a = Rotate(a, 3) + c;
+ h = Mur(e, h) + a;
+ a = Rotate(a + f, 12) + d;
+ h = Mur(b ^ seed, h) + a;
+ return fmix(h);
+}
+
+STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len, uint32_t seed = 0) {
+ uint32_t b = seed;
+ uint32_t c = 9;
+ for (size_t i = 0; i < len; i++) {
+ signed char v = s[i];
+ b = b * c1 + v;
+ c ^= b;
+ }
+ return fmix(Mur(b, Mur(len, c)));
+}
+
+STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len, uint32_t seed = 0) {
+ uint32_t a = len, b = len * 5, c = 9, d = b + seed;
+ a += Fetch(s);
+ b += Fetch(s + len - 4);
+ c += Fetch(s + ((len >> 1) & 4));
+ return fmix(seed ^ Mur(c, Mur(b, Mur(a, d))));
+}
+
+uint32_t Hash32(const char *s, size_t len) {
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
+ Hash32Len13to24(s, len);
+ }
+
+ // len > 24
+ uint32_t h = len, g = c1 * len, f = g;
+ uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
+ uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
+ uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
+ uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
+ uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
+ h ^= a0;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ h ^= a2;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ g ^= a1;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ g ^= a3;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ f += a4;
+ f = Rotate(f, 19) + 113;
+ size_t iters = (len - 1) / 20;
+ do {
+ uint32_t a = Fetch(s);
+ uint32_t b = Fetch(s + 4);
+ uint32_t c = Fetch(s + 8);
+ uint32_t d = Fetch(s + 12);
+ uint32_t e = Fetch(s + 16);
+ h += a;
+ g += b;
+ f += c;
+ h = Mur(d, h) + e;
+ g = Mur(c, g) + a;
+ f = Mur(b + e * c1, f) + d;
+ f += g;
+ g += f;
+ s += 20;
+ } while (--iters != 0);
+ g = Rotate(g, 11) * c1;
+ g = Rotate(g, 17) * c1;
+ f = Rotate(f, 11) * c1;
+ f = Rotate(f, 17) * c1;
+ h = Rotate(h + g, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ h = Rotate(h + f, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ return h;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return Hash32Len5to12(s, len, seed);
+ else return Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = Hash32Len13to24(s, 24, seed ^ len);
+ return Mur(Hash32(s + 24, len - 24) + seed, h);
+}
+} // namespace farmhashmk
+namespace farmhashsu {
+#if !can_use_sse42 || !can_use_aesni
+
+uint32_t Hash32(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash32(s, len);
+}
+
+#else
+
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+// Helpers for data-parallel operations (4x 32-bits).
+STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
+STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
+STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
+STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
+STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
+STATIC_INLINE __m128i RotateLeft(__m128i x, int c) {
+ return Or(_mm_slli_epi32(x, c),
+ _mm_srli_epi32(x, 32 - c));
+}
+STATIC_INLINE __m128i Rol17(__m128i x) { return RotateLeft(x, 17); }
+STATIC_INLINE __m128i Rol19(__m128i x) { return RotateLeft(x, 19); }
+STATIC_INLINE __m128i Shuffle0321(__m128i x) {
+ return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
+}
+
+uint32_t Hash32(const char *s, size_t len) {
+ const uint32_t seed = 81;
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ?
+ farmhashmk::Hash32Len0to4(s, len) :
+ farmhashmk::Hash32Len5to12(s, len)) :
+ farmhashmk::Hash32Len13to24(s, len);
+ }
+
+ if (len < 40) {
+ uint32_t a = len, b = seed * c2, c = a + b;
+ a += Fetch(s + len - 4);
+ b += Fetch(s + len - 20);
+ c += Fetch(s + len - 16);
+ uint32_t d = a;
+ a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
+ a = Mur(a, Mur(b, _mm_crc32_u32(c, d)));
+ a += Fetch(s + len - 12);
+ b += Fetch(s + len - 8);
+ d += a;
+ a += d;
+ b = Mur(b, d) * c2;
+ a = _mm_crc32_u32(a, b + c);
+ return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
+ }
+
+#undef Mulc1
+#define Mulc1(x) Mul((x), cc1)
+
+#undef Mulc2
+#define Mulc2(x) Mul((x), cc2)
+
+#undef Murk
+#define Murk(a, h) \
+ Add(k, \
+ Mul5( \
+ Rol19( \
+ Xor( \
+ Mulc2( \
+ Rol17( \
+ Mulc1(a))), \
+ (h)))))
+
+ const __m128i cc1 = _mm_set1_epi32(c1);
+ const __m128i cc2 = _mm_set1_epi32(c2);
+ __m128i h = _mm_set1_epi32(seed);
+ __m128i g = _mm_set1_epi32(c1 * seed);
+ __m128i f = g;
+ __m128i k = _mm_set1_epi32(0xe6546b64);
+ __m128i q;
+ if (len < 80) {
+ __m128i a = Fetch128(s);
+ __m128i b = Fetch128(s + 16);
+ __m128i c = Fetch128(s + (len - 15) / 2);
+ __m128i d = Fetch128(s + len - 32);
+ __m128i e = Fetch128(s + len - 16);
+ h = Add(h, a);
+ g = Add(g, b);
+ q = g;
+ g = Shuffle0321(g);
+ f = Add(f, c);
+ __m128i be = Add(b, Mulc1(e));
+ h = Add(h, f);
+ f = Add(f, h);
+ h = Add(Murk(d, h), e);
+ k = Xor(k, _mm_shuffle_epi8(g, f));
+ g = Add(Xor(c, g), a);
+ f = Add(Xor(be, f), d);
+ k = Add(k, be);
+ k = Add(k, _mm_shuffle_epi8(f, h));
+ f = Add(f, g);
+ g = Add(g, f);
+ g = Add(_mm_set1_epi32(len), Mulc1(g));
+ } else {
+ // len >= 80
+ // The following is loosely modelled after farmhashmk::Hash32.
+ size_t iters = (len - 1) / 80;
+ len -= iters * 80;
+
+#undef Chunk
+#define Chunk() do { \
+ __m128i a = Fetch128(s); \
+ __m128i b = Fetch128(s + 16); \
+ __m128i c = Fetch128(s + 32); \
+ __m128i d = Fetch128(s + 48); \
+ __m128i e = Fetch128(s + 64); \
+ h = Add(h, a); \
+ g = Add(g, b); \
+ g = Shuffle0321(g); \
+ f = Add(f, c); \
+ __m128i be = Add(b, Mulc1(e)); \
+ h = Add(h, f); \
+ f = Add(f, h); \
+ h = Add(h, d); \
+ q = Add(q, e); \
+ h = Rol17(h); \
+ h = Mulc1(h); \
+ k = Xor(k, _mm_shuffle_epi8(g, f)); \
+ g = Add(Xor(c, g), a); \
+ f = Add(Xor(be, f), d); \
+ std::swap(f, q); \
+ q = _mm_aesimc_si128(q); \
+ k = Add(k, be); \
+ k = Add(k, _mm_shuffle_epi8(f, h)); \
+ f = Add(f, g); \
+ g = Add(g, f); \
+ f = Mulc1(f); \
+} while (0)
+
+ q = g;
+ while (iters-- != 0) {
+ Chunk();
+ s += 80;
+ }
+
+ if (len != 0) {
+ h = Add(h, _mm_set1_epi32(len));
+ s = s + len - 80;
+ Chunk();
+ }
+ }
+
+ g = Shuffle0321(g);
+ k = Xor(k, g);
+ k = Xor(k, q);
+ h = Xor(h, q);
+ f = Mulc1(f);
+ k = Mulc2(k);
+ g = Mulc1(g);
+ h = Mulc2(h);
+ k = Add(k, _mm_shuffle_epi8(g, f));
+ h = Add(h, f);
+ f = Add(f, h);
+ g = Add(g, k);
+ k = Add(k, g);
+ k = Xor(k, _mm_shuffle_epi8(f, h));
+ __m128i buf[4];
+ buf[0] = f;
+ buf[1] = g;
+ buf[2] = k;
+ buf[3] = h;
+ s = reinterpret_cast<char*>(buf);
+ uint32_t x = Fetch(s);
+ uint32_t y = Fetch(s+4);
+ uint32_t z = Fetch(s+8);
+ x = _mm_crc32_u32(x, Fetch(s+12));
+ y = _mm_crc32_u32(y, Fetch(s+16));
+ z = _mm_crc32_u32(z * c1, Fetch(s+20));
+ x = _mm_crc32_u32(x, Fetch(s+24));
+ y = _mm_crc32_u32(y * c1, Fetch(s+28));
+ uint32_t o = y;
+ z = _mm_crc32_u32(z, Fetch(s+32));
+ x = _mm_crc32_u32(x * c1, Fetch(s+36));
+ y = _mm_crc32_u32(y, Fetch(s+40));
+ z = _mm_crc32_u32(z * c1, Fetch(s+44));
+ x = _mm_crc32_u32(x, Fetch(s+48));
+ y = _mm_crc32_u32(y * c1, Fetch(s+52));
+ z = _mm_crc32_u32(z, Fetch(s+56));
+ x = _mm_crc32_u32(x, Fetch(s+60));
+ return (o - x + y - z) * c1;
+}
+
+#undef Chunk
+#undef Murk
+#undef Mulc2
+#undef Mulc1
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
+ else return farmhashmk::Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
+ return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
+}
+
+#endif
+} // namespace farmhashsu
+namespace farmhashsa {
+#if !can_use_sse42
+
+uint32_t Hash32(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash32(s, len);
+}
+
+#else
+
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+// Helpers for data-parallel operations (4x 32-bits).
+STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
+STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
+STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
+STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
+STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
+STATIC_INLINE __m128i Rotate(__m128i x, int c) {
+ return Or(_mm_slli_epi32(x, c),
+ _mm_srli_epi32(x, 32 - c));
+}
+STATIC_INLINE __m128i Rot17(__m128i x) { return Rotate(x, 17); }
+STATIC_INLINE __m128i Rot19(__m128i x) { return Rotate(x, 19); }
+STATIC_INLINE __m128i Shuffle0321(__m128i x) {
+ return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
+}
+
+uint32_t Hash32(const char *s, size_t len) {
+ const uint32_t seed = 81;
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ?
+ farmhashmk::Hash32Len0to4(s, len) :
+ farmhashmk::Hash32Len5to12(s, len)) :
+ farmhashmk::Hash32Len13to24(s, len);
+ }
+
+ if (len < 40) {
+ uint32_t a = len, b = seed * c2, c = a + b;
+ a += Fetch(s + len - 4);
+ b += Fetch(s + len - 20);
+ c += Fetch(s + len - 16);
+ uint32_t d = a;
+ a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
+ a = Mur(a, Mur(b, Mur(c, d)));
+ a += Fetch(s + len - 12);
+ b += Fetch(s + len - 8);
+ d += a;
+ a += d;
+ b = Mur(b, d) * c2;
+ a = _mm_crc32_u32(a, b + c);
+ return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
+ }
+
+#undef Mulc1
+#define Mulc1(x) Mul((x), cc1)
+
+#undef Mulc2
+#define Mulc2(x) Mul((x), cc2)
+
+#undef Murk
+#define Murk(a, h) \
+ Add(k, \
+ Mul5( \
+ Rot19( \
+ Xor( \
+ Mulc2( \
+ Rot17( \
+ Mulc1(a))), \
+ (h)))))
+
+ const __m128i cc1 = _mm_set1_epi32(c1);
+ const __m128i cc2 = _mm_set1_epi32(c2);
+ __m128i h = _mm_set1_epi32(seed);
+ __m128i g = _mm_set1_epi32(c1 * seed);
+ __m128i f = g;
+ __m128i k = _mm_set1_epi32(0xe6546b64);
+ if (len < 80) {
+ __m128i a = Fetch128(s);
+ __m128i b = Fetch128(s + 16);
+ __m128i c = Fetch128(s + (len - 15) / 2);
+ __m128i d = Fetch128(s + len - 32);
+ __m128i e = Fetch128(s + len - 16);
+ h = Add(h, a);
+ g = Add(g, b);
+ g = Shuffle0321(g);
+ f = Add(f, c);
+ __m128i be = Add(b, Mulc1(e));
+ h = Add(h, f);
+ f = Add(f, h);
+ h = Add(Murk(d, h), e);
+ k = Xor(k, _mm_shuffle_epi8(g, f));
+ g = Add(Xor(c, g), a);
+ f = Add(Xor(be, f), d);
+ k = Add(k, be);
+ k = Add(k, _mm_shuffle_epi8(f, h));
+ f = Add(f, g);
+ g = Add(g, f);
+ g = Add(_mm_set1_epi32(len), Mulc1(g));
+ } else {
+ // len >= 80
+ // The following is loosely modelled after farmhashmk::Hash32.
+ size_t iters = (len - 1) / 80;
+ len -= iters * 80;
+
+#undef Chunk
+#define Chunk() do { \
+ __m128i a = Fetch128(s); \
+ __m128i b = Fetch128(s + 16); \
+ __m128i c = Fetch128(s + 32); \
+ __m128i d = Fetch128(s + 48); \
+ __m128i e = Fetch128(s + 64); \
+ h = Add(h, a); \
+ g = Add(g, b); \
+ g = Shuffle0321(g); \
+ f = Add(f, c); \
+ __m128i be = Add(b, Mulc1(e)); \
+ h = Add(h, f); \
+ f = Add(f, h); \
+ h = Add(Murk(d, h), e); \
+ k = Xor(k, _mm_shuffle_epi8(g, f)); \
+ g = Add(Xor(c, g), a); \
+ f = Add(Xor(be, f), d); \
+ k = Add(k, be); \
+ k = Add(k, _mm_shuffle_epi8(f, h)); \
+ f = Add(f, g); \
+ g = Add(g, f); \
+ f = Mulc1(f); \
+} while (0)
+
+ while (iters-- != 0) {
+ Chunk();
+ s += 80;
+ }
+
+ if (len != 0) {
+ h = Add(h, _mm_set1_epi32(len));
+ s = s + len - 80;
+ Chunk();
+ }
+ }
+
+ g = Shuffle0321(g);
+ k = Xor(k, g);
+ f = Mulc1(f);
+ k = Mulc2(k);
+ g = Mulc1(g);
+ h = Mulc2(h);
+ k = Add(k, _mm_shuffle_epi8(g, f));
+ h = Add(h, f);
+ f = Add(f, h);
+ g = Add(g, k);
+ k = Add(k, g);
+ k = Xor(k, _mm_shuffle_epi8(f, h));
+ __m128i buf[4];
+ buf[0] = f;
+ buf[1] = g;
+ buf[2] = k;
+ buf[3] = h;
+ s = reinterpret_cast<char*>(buf);
+ uint32_t x = Fetch(s);
+ uint32_t y = Fetch(s+4);
+ uint32_t z = Fetch(s+8);
+ x = _mm_crc32_u32(x, Fetch(s+12));
+ y = _mm_crc32_u32(y, Fetch(s+16));
+ z = _mm_crc32_u32(z * c1, Fetch(s+20));
+ x = _mm_crc32_u32(x, Fetch(s+24));
+ y = _mm_crc32_u32(y * c1, Fetch(s+28));
+ uint32_t o = y;
+ z = _mm_crc32_u32(z, Fetch(s+32));
+ x = _mm_crc32_u32(x * c1, Fetch(s+36));
+ y = _mm_crc32_u32(y, Fetch(s+40));
+ z = _mm_crc32_u32(z * c1, Fetch(s+44));
+ x = _mm_crc32_u32(x, Fetch(s+48));
+ y = _mm_crc32_u32(y * c1, Fetch(s+52));
+ z = _mm_crc32_u32(z, Fetch(s+56));
+ x = _mm_crc32_u32(x, Fetch(s+60));
+ return (o - x + y - z) * c1;
+}
+
+#undef Chunk
+#undef Murk
+#undef Mulc2
+#undef Mulc1
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
+ else return farmhashmk::Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
+ return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
+}
+
+#endif
+} // namespace farmhashsa
+namespace farmhashcc {
+// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
+// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
+// a seeded 32-bit hash function similar to CityHash32.
+
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len) {
+ uint32_t a = Fetch(s - 4 + (len >> 1));
+ uint32_t b = Fetch(s + 4);
+ uint32_t c = Fetch(s + len - 8);
+ uint32_t d = Fetch(s + (len >> 1));
+ uint32_t e = Fetch(s);
+ uint32_t f = Fetch(s + len - 4);
+ uint32_t h = len;
+
+ return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
+}
+
+STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len) {
+ uint32_t b = 0;
+ uint32_t c = 9;
+ for (size_t i = 0; i < len; i++) {
+ signed char v = s[i];
+ b = b * c1 + v;
+ c ^= b;
+ }
+ return fmix(Mur(b, Mur(len, c)));
+}
+
+STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len) {
+ uint32_t a = len, b = len * 5, c = 9, d = b;
+ a += Fetch(s);
+ b += Fetch(s + len - 4);
+ c += Fetch(s + ((len >> 1) & 4));
+ return fmix(Mur(c, Mur(b, Mur(a, d))));
+}
+
Y_PRAGMA_DIAGNOSTIC_PUSH
Y_PRAGMA_NO_WSHADOW
-uint32_t Hash32(const char *s, size_t len) {
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
- Hash32Len13to24(s, len);
- }
-
- // len > 24
- uint32_t h = len, g = c1 * len, f = g;
- uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
- uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
- uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
- uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
- uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
- h ^= a0;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- h ^= a2;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- g ^= a1;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- g ^= a3;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- f += a4;
- f = Rotate(f, 19);
- f = f * 5 + 0xe6546b64;
- size_t iters = (len - 1) / 20;
- do {
- uint32_t a0 = Rotate(Fetch(s) * c1, 17) * c2;
- uint32_t a1 = Fetch(s + 4);
- uint32_t a2 = Rotate(Fetch(s + 8) * c1, 17) * c2;
- uint32_t a3 = Rotate(Fetch(s + 12) * c1, 17) * c2;
- uint32_t a4 = Fetch(s + 16);
- h ^= a0;
- h = Rotate(h, 18);
- h = h * 5 + 0xe6546b64;
- f += a1;
- f = Rotate(f, 19);
- f = f * c1;
- g += a2;
- g = Rotate(g, 18);
- g = g * 5 + 0xe6546b64;
- h ^= a3 + a1;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- g ^= a4;
- g = Bswap(g) * 5;
- h += a4 * 5;
- h = Bswap(h);
- f += a0;
- PERMUTE3(f, h, g);
- s += 20;
- } while (--iters != 0);
- g = Rotate(g, 11) * c1;
- g = Rotate(g, 17) * c1;
- f = Rotate(f, 11) * c1;
- f = Rotate(f, 17) * c1;
- h = Rotate(h + g, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- h = Rotate(h + f, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- return h;
-}
+uint32_t Hash32(const char *s, size_t len) {
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
+ Hash32Len13to24(s, len);
+ }
+
+ // len > 24
+ uint32_t h = len, g = c1 * len, f = g;
+ uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
+ uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
+ uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
+ uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
+ uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
+ h ^= a0;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ h ^= a2;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ g ^= a1;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ g ^= a3;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ f += a4;
+ f = Rotate(f, 19);
+ f = f * 5 + 0xe6546b64;
+ size_t iters = (len - 1) / 20;
+ do {
+ uint32_t a0 = Rotate(Fetch(s) * c1, 17) * c2;
+ uint32_t a1 = Fetch(s + 4);
+ uint32_t a2 = Rotate(Fetch(s + 8) * c1, 17) * c2;
+ uint32_t a3 = Rotate(Fetch(s + 12) * c1, 17) * c2;
+ uint32_t a4 = Fetch(s + 16);
+ h ^= a0;
+ h = Rotate(h, 18);
+ h = h * 5 + 0xe6546b64;
+ f += a1;
+ f = Rotate(f, 19);
+ f = f * c1;
+ g += a2;
+ g = Rotate(g, 18);
+ g = g * 5 + 0xe6546b64;
+ h ^= a3 + a1;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ g ^= a4;
+ g = Bswap(g) * 5;
+ h += a4 * 5;
+ h = Bswap(h);
+ f += a0;
+ PERMUTE3(f, h, g);
+ s += 20;
+ } while (--iters != 0);
+ g = Rotate(g, 11) * c1;
+ g = Rotate(g, 17) * c1;
+ f = Rotate(f, 11) * c1;
+ f = Rotate(f, 17) * c1;
+ h = Rotate(h + g, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ h = Rotate(h + f, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ return h;
+}
Y_PRAGMA_DIAGNOSTIC_POP
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
- else return farmhashmk::Hash32Len0to4(s, len, seed);
- }
- uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
- return Mur(Hash32(s + 24, len - 24) + seed, h);
-}
-
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-#undef Bswap
-#define Bswap Bswap64
-
-STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
- return val ^ (val >> 47);
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
- return Hash128to64(Uint128(u, v));
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
- // Murmur-inspired hashing.
- uint64_t a = (u ^ v) * mul;
- a ^= (a >> 47);
- uint64_t b = (v ^ a) * mul;
- b ^= (b >> 47);
- b *= mul;
- return b;
-}
-
-STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
- if (len >= 8) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) + k2;
- uint64_t b = Fetch(s + len - 8);
- uint64_t c = Rotate(b, 37) * mul + a;
- uint64_t d = (Rotate(a, 25) + b) * mul;
- return HashLen16(c, d, mul);
- }
- if (len >= 4) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch32(s);
- return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
- }
- if (len > 0) {
- uint8_t a = s[0];
- uint8_t b = s[len >> 1];
- uint8_t c = s[len - 1];
- uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
- uint32_t z = len + (static_cast<uint32_t>(c) << 2);
- return ShiftMix(y * k2 ^ z * k0) * k2;
- }
- return k2;
-}
-
-// Return a 16-byte hash for 48 bytes. Quick and dirty.
-// Callers do best to use "random-looking" values for a and b.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
- a += w;
- b = Rotate(b + a + z, 21);
- uint64_t c = a;
- a += x;
- a += y;
- b += Rotate(a, 44);
- return make_pair(a + z, b + c);
-}
-
-// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- const char* s, uint64_t a, uint64_t b) {
- return WeakHashLen32WithSeeds(Fetch(s),
- Fetch(s + 8),
- Fetch(s + 16),
- Fetch(s + 24),
- a,
- b);
-}
-
-
-
-// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
-// of any length representable in signed long. Based on City and Murmur.
-STATIC_INLINE uint128_t CityMurmur(const char *s, size_t len, uint128_t seed) {
- uint64_t a = Uint128Low64(seed);
- uint64_t b = Uint128High64(seed);
- uint64_t c = 0;
- uint64_t d = 0;
- signed long l = len - 16;
- if (l <= 0) { // len <= 16
- a = ShiftMix(a * k1) * k1;
- c = b * k1 + HashLen0to16(s, len);
- d = ShiftMix(a + (len >= 8 ? Fetch(s) : c));
- } else { // len > 16
- c = HashLen16(Fetch(s + len - 8) + k1, a);
- d = HashLen16(b + len, c + Fetch(s + len - 16));
- a += d;
- do {
- a ^= ShiftMix(Fetch(s) * k1) * k1;
- a *= k1;
- b ^= a;
- c ^= ShiftMix(Fetch(s + 8) * k1) * k1;
- c *= k1;
- d ^= c;
- s += 16;
- l -= 16;
- } while (l > 0);
- }
- a = HashLen16(a, c);
- b = HashLen16(d, b);
- return Uint128(a ^ b, HashLen16(b, a));
-}
-
-uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) {
- if (len < 128) {
- return CityMurmur(s, len, seed);
- }
-
- // We expect len >= 128 to be the common case. Keep 56 bytes of state:
- // v, w, x, y, and z.
- pair<uint64_t, uint64_t> v, w;
- uint64_t x = Uint128Low64(seed);
- uint64_t y = Uint128High64(seed);
- uint64_t z = len * k1;
- v.first = Rotate(y ^ k1, 49) * k1 + Fetch(s);
- v.second = Rotate(v.first, 42) * k1 + Fetch(s + 8);
- w.first = Rotate(y + z, 35) * k1 + x;
- w.second = Rotate(x + Fetch(s + 88), 53) * k1;
-
- // This is the same inner loop as CityHash64(), manually unrolled.
- do {
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- s += 64;
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- s += 64;
- len -= 128;
- } while (LIKELY(len >= 128));
- x += Rotate(v.first + z, 49) * k0;
- y = y * k0 + Rotate(w.second, 37);
- z = z * k0 + Rotate(w.first, 27);
- w.first *= 9;
- v.first *= k0;
- // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
- for (size_t tail_done = 0; tail_done < len; ) {
- tail_done += 32;
- y = Rotate(x + y, 42) * k0 + v.second;
- w.first += Fetch(s + len - tail_done + 16);
- x = x * k0 + w.first;
- z += w.second + Fetch(s + len - tail_done);
- w.second += v.first;
- v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
- v.first *= k0;
- }
- // At this point our 56 bytes of state should contain more than
- // enough information for a strong 128-bit hash. We use two
- // different 56-byte-to-8-byte hashes to get a 16-byte final result.
- x = HashLen16(x, v.first);
- y = HashLen16(y + z, w.first);
- return Uint128(HashLen16(x + v.second, w.second) + y,
- HashLen16(x + w.second, y + v.second));
-}
-
-STATIC_INLINE uint128_t CityHash128(const char *s, size_t len) {
- return len >= 16 ?
- CityHash128WithSeed(s + 16, len - 16,
- Uint128(Fetch(s), Fetch(s + 8) + k0)) :
- CityHash128WithSeed(s, len, Uint128(k0, k1));
-}
-
-uint128_t Fingerprint128(const char* s, size_t len) {
- return CityHash128(s, len);
-}
-} // namespace farmhashcc
-namespace NAMESPACE_FOR_HASH_FUNCTIONS {
-
-// BASIC STRING HASHING
-
-// Hash function for a byte array. See also Hash(), below.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint32_t Hash32(const char* s, size_t len) {
- return DebugTweak(
- (can_use_sse41 & x86_64) ? farmhashnt::Hash32(s, len) :
- (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32(s, len) :
- can_use_sse42 ? farmhashsa::Hash32(s, len) :
- farmhashmk::Hash32(s, len));
-}
-
-// Hash function for a byte array. For convenience, a 32-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
- return DebugTweak(
- (can_use_sse41 & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
- (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32WithSeed(s, len, seed) :
- can_use_sse42 ? farmhashsa::Hash32WithSeed(s, len, seed) :
- farmhashmk::Hash32WithSeed(s, len, seed));
-}
-
-// Hash function for a byte array. For convenience, a 64-bit seed is also
-// hashed into the result. See also Hash(), below.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64(const char* s, size_t len) {
- return DebugTweak(
- (can_use_sse42 & x86_64) ?
- farmhashte::Hash64(s, len) :
- farmhashxo::Hash64(s, len));
-}
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-size_t Hash(const char* s, size_t len) {
- return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
-}
-
-// Hash function for a byte array. For convenience, a 64-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
- return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
-}
-
-// Hash function for a byte array. For convenience, two seeds are also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
- return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
-}
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint128_t Hash128(const char* s, size_t len) {
- return DebugTweak(farmhashcc::Fingerprint128(s, len));
-}
-
-// Hash function for a byte array. For convenience, a 128-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) {
- return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
-}
-
-// BASIC NON-STRING HASHING
-
-// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
-
-// Fingerprint function for a byte array. Most useful in 32-bit binaries.
-uint32_t Fingerprint32(const char* s, size_t len) {
- return farmhashmk::Hash32(s, len);
-}
-
-// Fingerprint function for a byte array.
-uint64_t Fingerprint64(const char* s, size_t len) {
- return farmhashna::Hash64(s, len);
-}
-
-// Fingerprint function for a byte array.
-uint128_t Fingerprint128(const char* s, size_t len) {
- return farmhashcc::Fingerprint128(s, len);
-}
-
-// Older and still available but perhaps not as fast as the above:
-// farmhashns::Hash32{,WithSeed}()
-
-} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-
-#if FARMHASHSELFTEST
-
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashccTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-1039179260u, 1690343979u, 1018511555u, 2464489001u,
-20368522u, 2663783964u, 175201532u, 1619210592u,
-4081014168u,
-2576519988u,
-3285042206u, 502478099u, 739479538u, 1500332790u,
-13754768u, 3789353455u, 3473868058u, 1909255088u,
-2212771159u,
-1112731063u,
-826915357u, 2893489933u, 118369799u, 1848668220u,
-1308219822u, 249416982u, 64306364u, 4221800195u,
-1020067935u,
-3955445564u,
-563346294u, 550236731u, 2339016688u, 1826259714u,
-3872358639u, 2295981050u, 1870005390u, 4015628802u,
-1451961420u,
-653440099u,
-1292493871u, 164377749u, 1717712483u, 463414587u,
-3924343675u, 1050492084u, 3566618804u, 2046983362u,
-31917516u,
-2957164615u,
-230718965u, 999595115u, 3534822176u, 2175709186u,
-965707431u, 441796222u, 2481718051u, 1827777486u,
-2590087362u,
-3879448744u,
-3515079898u, 1601433082u, 982764532u, 254808716u,
-1293372530u, 4205605817u, 947001462u, 1138890052u,
-176305566u,
-2447367541u,
-2973802542u, 4123621138u, 3083865840u, 1706367795u,
-792114347u, 2880110657u, 440613768u, 195054868u,
-1359016305u,
-3363804638u,
-649488537u, 1624045597u, 1441938215u, 3147758996u,
-3199173578u, 2597283203u, 2191333609u, 3763129144u,
-1117290165u,
-1062549743u,
-2565615889u, 1046361554u, 1581968261u, 1058773671u,
-1123053168u, 3807622275u, 1486749916u, 3900816089u,
-2437877004u,
-1894455839u,
-1912520953u, 1914997013u, 561048608u, 1643267444u,
-3671572006u, 194811086u, 1468911468u, 2179206286u,
-673206794u,
-3486923651u,
-3741426466u, 3292160512u, 697001377u, 1900763774u,
-3726097344u, 629282039u, 3578723715u, 2868028489u,
-3269862919u,
-2303349487u,
-3643953525u, 2307255916u, 849996280u, 732080434u,
-909961480u, 3542445214u, 2628347095u, 4236856917u,
-1380660650u,
-2631821908u,
-2007289004u, 3509705198u, 3788541675u, 789457322u,
-3090670546u, 638977894u, 3503881773u, 947102987u,
-1525325287u,
-1816697045u,
-2706647405u, 288763142u, 3505438495u, 481308609u,
-2882636782u, 3745162621u, 3503467033u, 428247823u,
-176408838u,
-333551502u,
-1001068721u, 1681483651u, 75380831u, 4191469679u,
-3627361839u, 2736617386u, 3120737438u, 1297502456u,
-864896482u,
-85674920u,
-2886047255u, 4119881331u, 2496990525u, 3442502055u,
-1806582817u, 3186345024u, 4099591287u, 2560171465u,
-3489229104u,
-3065015872u,
-2755089808u, 3098442882u, 378524719u, 2664097023u,
-1771960725u, 2901182183u, 55258521u, 1266621443u,
-581644891u,
-37790450u,
-1800731704u, 3601350920u, 53428754u, 2759476837u,
-3391093099u, 1496510311u, 2511119507u, 2636877410u,
-631613207u,
-1573846064u,
-260484875u, 1088212603u, 2369525206u, 322522428u,
-3191396600u, 2076543340u, 1552496658u, 2739811558u,
-3867875546u,
-2051584261u,
-2126250818u, 901517871u, 3651631165u, 1323139145u,
-1521111765u, 477802997u, 3508559783u, 383954241u,
-3804516756u,
-4250206331u,
-2655954340u, 2484996477u, 1417544845u, 1520282298u,
-2745204366u, 2869345147u, 1872738335u, 2592877343u,
-1619744564u,
-1804962124u,
-3458679890u, 423948620u, 273645618u, 4187865426u,
-376057175u, 2943431463u, 3581950599u, 1035398331u,
-1088213445u,
-861988903u,
-1323370244u, 777069428u, 506235917u, 369720851u,
-2789995854u, 230915180u, 1505086948u, 940361236u,
-3727873235u,
-1159167499u,
-1860302871u, 3456858862u, 3923555152u, 2131072714u,
-2910461068u, 3671950363u, 2010742682u, 4088068851u,
-3616470388u,
-2087714788u,
-221675509u, 1230154072u, 3450704646u, 1463226695u,
-1998357699u, 266026801u, 619568740u, 3560427266u,
-4148162586u,
-3150417316u,
-1356375822u, 2056097622u, 627905802u, 3881675638u,
-2309738053u, 971916703u, 3447805361u, 1673575328u,
-673084328u,
-3317849401u,
-2836362782u, 2377208890u, 3275350588u, 158350552u,
-2553241779u, 2497264995u, 3262882649u, 3897937187u,
-1598963653u,
-3068514414u,
-601541505u, 374517071u, 3380795976u, 235752573u,
-284670003u, 2990192160u, 904937105u, 2306579150u,
-2117362589u,
-1635274830u,
-3355572906u, 170799903u, 1226685528u, 664567688u,
-413219134u, 878324258u, 4026159448u, 3620649295u,
-1823625377u,
-3175888439u,
-1759344347u, 2640637095u, 3549558u, 2192984935u,
-978623493u, 804017880u, 3877562323u, 3843116489u,
-1641748342u,
-1853539444u,
-3001178468u, 3443560727u, 2685426077u, 1653064722u,
-349231508u, 2726789654u, 3136215581u, 768402830u,
-269384321u,
-531936536u,
-2592883487u, 1343156334u, 3628619802u, 1477143570u,
-4269458419u, 3285611028u, 959104925u, 2712290710u,
-3480237248u,
-835796333u,
-2020636251u, 1191914589u, 126521603u, 4288023938u,
-3731699932u, 2136758855u, 985780142u, 193807575u,
-1850544433u,
-653947619u,
-3929316796u, 381871169u, 950486363u, 1787262279u,
-360480382u, 1800636585u, 1039258631u, 3682073259u,
-1262819303u,
-1786000319u,
-1570627191u, 893065837u, 301304916u, 1478469809u,
-623018819u, 2742232545u, 2058913014u, 1706060059u,
-2421125401u,
-1315829592u,
-3208766775u, 1805586156u, 575853086u, 3085025513u,
-4010908260u, 2344058256u, 3814407434u, 1458485673u,
-2474514786u,
-3581895658u,
-2710719679u, 190812706u, 2135454262u, 2620080728u,
-3400757986u, 1669914857u, 1559978393u, 1629811331u,
-3096616493u,
-1391424435u,
-4158376003u, 1015657076u, 794783832u, 479952178u,
-1150290207u, 2497437906u, 231815090u, 755078067u,
-3832053281u,
-63649475u,
-2415822606u, 4105027719u, 1706992318u, 1106598740u,
-3941945667u, 1271300761u, 505882259u, 760186809u,
-2657183368u,
-1925422058u,
-1039773764u, 880219458u, 4275949176u, 1556833823u,
-925882132u, 4216310340u, 757497522u, 461833914u,
-3884002070u,
-2790957660u,
-2100050089u, 651959176u, 1380301291u, 1289124125u,
-452314403u, 226156280u, 3306924715u, 1750807758u,
-2290180542u,
-1953760569u,
-2253069096u, 3960924806u, 1786291620u, 60736185u,
-2569018293u, 3870479674u, 2247005661u, 2239850953u,
-4261808536u,
-3282975782u,
-780945879u, 3349849383u, 1579362556u, 2265045884u,
-905088740u, 725212379u, 3156479246u, 2501620391u,
-3062836263u,
-4070422690u,
-996797869u, 4082582315u, 976105756u, 303983602u,
-1862104804u, 3864508254u, 3383979677u, 2835500286u,
-2798364010u,
-519359476u,
-3447342725u, 194373889u, 3313466630u, 232399983u,
-2841787856u, 1672751454u, 3345183154u, 1805381384u,
-2226129336u,
-2847829057u,
-2350774567u, 2838540121u, 2757948482u, 1017002062u,
-2329150951u, 2171488196u, 3668619047u, 3874977844u,
-3287966998u,
-262346753u,
-2493054715u, 2298644430u, 2926101182u, 1528457638u,
-598656233u, 2615845874u, 989110727u, 820441411u,
-253617372u,
-2201077208u,
-2047569338u, 3114356329u, 3335563734u, 2967673540u,
-768438341u, 1417708203u, 3873718246u, 1538441843u,
-1279167650u,
-3917966776u,
-2218481734u, 1015935150u, 1957845042u, 1318150213u,
-3146423971u, 4218994877u, 1162470863u, 1519718292u,
-2594658906u,
-665870414u,
-3430347817u, 3933868731u, 1597041394u, 3138684682u,
-3398212027u, 1064647658u, 1576321132u, 14792918u,
-224938029u,
-3706456050u,
-847274786u, 2645698692u, 1743374687u, 2343133224u,
-3066596790u, 2857270120u, 200596308u, 452055528u,
-2319312082u,
-3488655402u,
-4146865894u, 608206438u, 2699777051u, 3687240713u,
-327957508u, 3664730153u, 568134564u, 2993484554u,
-4159860363u,
-4274533921u,
-1079994063u, 2360220210u, 3609597760u, 3639708902u,
-2836180437u, 1069910270u, 1892427666u, 1874729790u,
-1267712826u,
-121886940u,
-3572289214u, 2475945610u, 783779452u, 588827737u,
-1531395014u, 2085084212u, 2219189792u, 3981444548u,
-2218885336u,
-1691622694u,
-2053232885u, 1386558530u, 2182946189u, 2365247285u,
-1871081313u, 2935751853u, 38413723u, 543465863u,
-900691890u,
-2899905665u,
-575120562u, 93133904u, 457154948u, 2983705792u,
-4232229200u, 2038565963u, 614693984u, 3405328302u,
-4083090010u,
-2088004171u,
-244031209u, 1861889294u, 2417109253u, 3299562328u,
-4158642443u, 4199064449u, 3161611046u, 885015950u,
-3677904099u,
-2969861785u,
-772348805u, 1712263832u, 3219357614u, 484271305u,
-3645706114u, 2059620251u, 409557488u, 2278896731u,
-224475749u,
-3523022952u,
-2057140088u, 449131785u, 1149879244u, 4255363996u,
-3602720135u, 1690010854u, 2503998822u, 2750828466u,
-3340671802u,
-1447583863u,
-2649684943u, 2764747249u, 3046070595u, 3441726138u,
-3840332559u, 3156747501u, 1288666680u, 1472744459u,
-3452391933u,
-1617542784u,
-217869690u, 3718469527u, 348639731u, 590532355u,
-43789787u, 22606314u, 1621559290u, 2231743261u,
-2234620879u,
-544748955u,
-3169387920u, 203343594u, 3272552527u, 1078282365u,
-809576321u, 854207584u, 3625491053u, 1193737267u,
-1628966807u,
-2661421060u,
-2433442061u, 3886639039u, 2149304418u, 303000565u,
-1432830882u, 137378235u, 1135974068u, 318705754u,
-2491227157u,
-2627534472u,
-3520352233u, 2488397682u, 3969194920u, 3843962181u,
-2135981459u, 2611933220u, 799460731u, 2300968851u,
-3412851628u,
-3070914013u,
-3555224260u, 4125937572u, 240359903u, 722496673u,
-2061023600u, 3843919221u, 2759960043u, 1191155322u,
-1504041490u,
-3735253656u,
-1773124736u, 101110011u, 1627699578u, 2645634551u,
-263603947u, 1388368439u, 677146538u, 1644201982u,
-2625699644u,
-2403862553u,
-2426069017u, 3613511705u, 915141802u, 2981654265u,
-3474818167u, 2611101773u, 627891434u, 762754924u,
-2143021902u,
-51067670u,
-4017746573u, 2269879853u, 3037857950u, 2388899692u,
-582729171u, 1886116725u, 2281219772u, 264704948u,
-3509984037u,
-4078683368u,
-2172959411u, 1807195632u, 3357092302u, 2253764928u,
-2320369390u, 3076335959u, 2623583210u, 168378015u,
-1435562650u,
-1100977467u,
-3160490319u, 2550328495u, 2396855930u, 1347823908u,
-1617990918u, 3849653099u, 3224111576u, 1681539821u,
-4171542880u,
-552200045u,
-3562947778u, 1676237880u, 3747732307u, 2453332913u,
-865530667u, 3566636849u, 3485502777u, 336779723u,
-2535942410u,
-1685000184u,
-820545711u, 1893670486u, 1273910461u, 1193758569u,
-970365241u, 381205962u, 3612810852u, 1160577445u,
-541488143u,
-4005031080u,
-2333965236u, 2419855455u, 3484533538u, 3073937876u,
-908466956u, 661391539u, 2342122412u, 1467049112u,
-1785800827u,
-135343033u,
-139643209u, 2438375667u, 974654058u, 3216478230u,
-3807620420u, 779043363u, 2812846449u, 333254784u,
-1025244024u,
-2242303095u,
-2476683742u, 350018683u, 174652916u, 933097576u,
-826905896u, 559603581u, 2777181260u, 164915169u,
-4070353203u,
-1459055748u,
-297303985u, 3103837241u, 3812514233u, 232265137u,
-2032819099u, 1523091376u, 3531238208u, 1403510182u,
-2886832080u,
-2599705941u,
-2789695716u, 68437968u, 3823813791u, 1040994569u,
-3024194990u, 2461740520u, 3735391266u, 2042207153u,
-2461678616u,
-3519231840u,
-1344224923u, 411442756u, 1179779351u, 7661528u,
-778352196u, 3288808867u, 589356197u, 2627504511u,
-3374744599u,
-3312172905u,
-357423007u, 3539567796u, 4044452215u, 1445118403u,
-2937983820u, 184089910u, 346201845u, 2427295202u,
-1345448010u,
-2884434843u,
-3085001879u, 2640105409u, 315310640u, 3530289798u,
-3362974764u, 963602652u, 75228477u, 3509381180u,
-4012777756u,
-2380345941u,
-1073137836u, 2083960378u, 1220315185u, 3628720934u,
-3508867818u, 67148343u, 3558085158u, 1753943368u,
-863309561u,
-2844713625u,
-441921850u, 854732254u, 816793316u, 2555428747u,
-3440623414u, 1707304366u, 3189874375u, 1623229221u,
-1220335976u,
-806745430u,
-3909262947u, 1680369031u, 2926179486u, 3410391660u,
-3991630434u, 2876458763u, 1179167079u, 536360759u,
-1592117159u,
-1514343977u,
-1032622306u, 2057494855u, 784938958u, 178402996u,
-1152907972u, 2326185495u, 2939973666u, 4181120253u,
-552831733u,
-664251856u,
-1297139539u, 1969357631u, 1474065957u, 3055419017u,
-3395829380u, 3316562752u, 2168409017u, 614624786u,
-3585854336u,
-668291094u,
-1162889217u, 3773171307u, 2263271126u, 355089668u,
-3195850578u, 3396793277u, 3519870267u, 527857605u,
-3972392320u,
-2224315010u,
-4047225561u, 3271434798u, 3192704713u, 2798505213u,
-3932215896u, 3792924012u, 3796843756u, 453872975u,
-4050552799u,
-1056432676u,
-928166947u, 121311642u, 930989547u, 2087070683u,
-1288978057u, 1556325239u, 1812435626u, 1682385724u,
-1214364933u,
-904760776u,
-3957045528u, 3949822847u, 2411065880u, 3716420732u,
-3424837835u, 3833550693u, 1799375326u, 2012368921u,
-2768764136u,
-1786111037u,
-4055479315u, 3751639533u, 2808224623u, 3492656387u,
-1306824780u, 2624000170u, 3134795218u, 1778409297u,
-3900821801u,
-593336325u,
-2772069220u, 2980873673u, 3574497158u, 3994780459u,
-4246519854u, 3482758570u, 4228015183u, 33101083u,
-1769887734u,
-4158035314u,
-3690638998u, 1119035482u, 4134969651u, 2483207353u,
-3932823321u, 285829887u, 3485140138u, 1304815138u,
-995608264u,
-3133997465u,
-1195477617u, 2147693728u, 3506673112u, 4234467492u,
-1183174337u, 1395340482u, 769199343u, 193262308u,
-2798920256u,
-3827889422u,
-3399695609u, 3036045724u, 2999477386u, 3567001759u,
-2682864314u, 1414023907u, 3699872975u, 3369870701u,
-2662284872u,
-2179640019u,
-2485080099u, 3234415609u, 3755915606u, 1339453220u,
-1567403399u, 2076272391u, 293946298u, 3861962750u,
-1291949822u,
-2916864995u,
-132642326u, 2215117062u, 2205863575u, 2488805750u,
-405632860u, 3248129390u, 2952606864u, 896734759u,
-2047417173u,
-3865951392u,
-657296855u, 1328547532u, 3966511825u, 3959682388u,
-4171801020u, 2981416957u, 1868896247u, 790081075u,
-3143666398u,
-2950766549u,
-2065854887u, 2737081890u, 995061774u, 1510712611u,
-2865954809u, 565044286u, 1565631102u, 1500654931u,
-494822108u,
-2803515503u,
-1058154996u, 3506280187u, 856885925u, 4204610546u,
-800905649u, 1130711562u, 558146282u, 2053400666u,
-449794061u,
-2643520245u,
-2101248725u, 3123292429u, 3583524041u, 983372394u,
-1587743780u, 672870813u, 444833475u, 100741452u,
-366232251u,
-1717951248u,
-524144122u, 1362432726u, 1304947719u, 674306020u,
-405665887u, 4081931036u, 1580408204u, 2343242778u,
-3901654006u,
-2627173567u,
-3015148205u, 814686701u, 1327920712u, 1346494176u,
-2468632605u, 2259795544u, 2519278184u, 2129281928u,
-2860266380u,
-4001619412u,
-1154910973u, 2841022216u, 1199925485u, 1372200293u,
-2713179055u, 3609776550u, 2896463880u, 1056406892u,
-177413841u,
-40180172u,
-3274788406u, 660921784u, 1686225028u, 4003382965u,
-2532691887u, 4256809101u, 1186018983u, 667359096u,
-2375266493u,
-2760222015u,
-745187078u, 312264012u, 396822261u, 2588536966u,
-2026998998u, 1766454365u, 3218807676u, 3915487497u,
-2630550356u,
-4130063378u,
-4231937074u, 752212123u, 3085144349u, 3267186363u,
-4103872100u, 4193207863u, 1306401710u, 3014853131u,
-1067760598u,
-2306188342u,
-2437881506u, 4258185052u, 2506507580u, 130876929u,
-1076894205u, 4106981702u, 2799540844u, 945747327u,
-1436722291u,
-2499772225u,
-2571537041u, 2038830635u, 2066826058u, 2892892912u,
-524875858u, 3392572161u, 2869992096u, 1308273341u,
-923668994u,
-1980407857u,
-2275009652u, 240598096u, 2658376530u, 3505603048u,
-1022603789u, 582423424u, 846379327u, 4092636095u,
-4177298326u,
-1004173023u,
-2154027018u, 2993634669u, 1098364089u, 3035642175u,
-1335688126u, 1376393415u, 1252369770u, 3815033328u,
-1999309358u,
-1234054757u,
-1388595255u, 2859334775u, 366532860u, 3453410395u,
-4226967708u, 1321729870u, 2078463405u, 156766592u,
-3157683394u,
-3549293384u,
-3348214547u, 2879648344u, 1144813399u, 2758966254u,
-647753581u, 813615926u, 2035441590u, 1961053117u,
-600168686u,
-2192833387u,
-3156481401u, 3627320321u, 383550248u, 81209584u,
-2339331745u, 1284116690u, 1980144976u, 2955724163u,
-789301728u,
-3842040415u,
-1115881490u, 965249078u, 4098663322u, 1870257033u,
-2923150701u, 4217108433u, 183816559u, 2104089285u,
-2640095343u,
-3173757052u,
-927847464u, 2383114981u, 4287174363u, 1886129652u,
-70635161u, 1182924521u, 1121440038u, 4246220730u,
-3890583049u,
-975913757u,
-2436253031u, 1074894869u, 1301280627u, 992471939u,
-735658128u, 244441856u, 1541612456u, 3457776165u,
-3503534059u,
-1931651133u,
-349142786u, 3669028584u, 1828812038u, 99128389u,
-1364272849u, 1963678455u, 3971963311u, 2316950886u,
-1308901796u,
-2789591580u,
-1460494965u, 2380227479u, 1577190651u, 1755822080u,
-2911014607u, 859387544u, 13023113u, 2319243370u,
-2522582211u,
-2299110490u,
-3342378874u, 2589323490u, 1884430765u, 3739058655u,
-2419330954u, 355389916u, 273950915u, 3670136553u,
-410946824u,
-3174041420u,
-2609010298u, 3059091350u, 2300275014u, 725729828u,
-2548380995u, 1738849964u, 1257081412u, 79430455u,
-810321297u,
-3246190593u,
-1007937684u, 912115394u, 40880059u, 3450073327u,
-4289832174u, 2253485111u, 1065639151u, 2953189309u,
-124779113u,
-654299738u,
-115760833u, 1250932069u, 884995826u, 3998908281u,
-1382882981u, 1134187162u, 3202324501u, 487502928u,
-3032756345u,
-4057517628u,
-933197381u, 2319223127u, 2044528655u, 2554572663u,
-4049450620u, 1620812836u, 2832905391u, 2273005481u,
-1913090121u,
-1055456023u,
-510593296u, 3285343192u, 2912822536u, 1645225063u,
-638418430u, 452701300u, 1025483165u, 1639370512u,
-167948643u,
-2809842730u,
-2983135664u, 407521332u, 1543756616u, 3949773145u,
-4283462892u, 659962275u, 3878013463u, 1000748756u,
-4053212051u,
-4099239406u,
-3467581965u, 354635541u, 21301844u, 3831212473u,
-3189450571u, 2264401966u, 4096484849u, 1736448515u,
-3976926096u,
-3727194724u,
-2243487039u, 585209095u, 3143046007u, 969558123u,
-3037113502u, 3594170243u, 2835860223u, 3775493975u,
-2787220812u,
-2274252217u,
-2915380701u, 3077533278u, 1252871826u, 1519790952u,
-205297661u, 2950557658u, 3956882191u, 2724439401u,
-3694608025u,
-124028038u,
-216019153u, 1533010676u, 2259986336u, 2014061617u,
-2068617849u, 3078123052u, 2692046098u, 1582812948u,
-396916232u,
-1470894001u,
-1694309312u, 300268215u, 1553892743u, 671176040u,
-1544988994u, 2793402821u, 4194972569u, 2296476154u,
-748354332u,
-3491325898u,
-4261053291u, 1104998242u, 797816835u, 243564059u,
-2197717393u, 299029458u, 1675252188u, 3139770041u,
-583018574u,
-2532106100u,
-2099391658u, 3760526730u, 3422719327u, 3556917689u,
-2374009285u, 2130865894u, 3710563151u, 1437538307u,
-3938030842u,
-2006930694u,
-2151243336u, 1939741287u, 1957068175u, 2135147479u,
-649553342u, 1713643042u, 4188696599u, 1698739939u,
-3549427584u,
-1016382174u,
-322644378u, 2476164549u, 2037263020u, 88036019u,
-2548960923u, 539867919u, 2871157727u, 4031659929u,
-754087252u,
-972656559u,
-4246379429u, 3877308578u, 2059459630u, 3614934323u,
-1410565271u, 2102980459u, 215395636u, 1083393481u,
-3775523015u,
-2062750105u,
-2475645882u, 3041186774u, 3534315423u, 758607219u,
-1686100614u, 180500983u, 1155581185u, 1476664671u,
-2918661695u,
-3812731350u,
-4003853737u, 4148884881u, 1468469436u, 3278880418u,
-1045838071u, 1049161262u, 360450415u, 3158065524u,
-814443735u,
-3391401707u,
-729968410u, 738771593u, 3662738792u, 1672830580u,
-4199496163u, 188487238u, 219098233u, 2141731267u,
-3890250614u,
-2988780375u,
-4026279523u, 3489429375u, 2468433807u, 1178270701u,
-2685094218u, 2716621497u, 3718335529u, 2273344755u,
-701110882u,
-1925717409u,
-1515176562u, 2325460593u, 3954798930u, 784566105u,
-3769422266u, 1641530321u, 2703876862u, 2907480267u,
-1828076455u,
-1805635221u,
-3883381245u, 1476756210u, 2072514392u, 3658557081u,
-2003610746u, 2556845550u, 729594004u, 3303898266u,
-1968227254u,
-423204951u,
-231828688u, 4223697811u, 698619045u, 3636824418u,
-2738779239u, 2333529003u, 2833158642u, 580285428u,
-3038148234u,
-1012378004u,
-1113647298u, 1424593483u, 4053247723u, 1167152941u,
-2677383578u, 3419485379u, 2135673840u, 440478166u,
-1682229112u,
-3226724137u,
-1217439806u, 3828726923u, 3636576271u, 3467643156u,
-2005614908u, 2655346461u, 2345488441u, 1027557096u,
-3594084220u,
-1372306343u,
-2342583762u, 4291342905u, 4094931814u, 3254771759u,
-821978248u, 2404930117u, 1143937655u, 3156949255u,
-3460606610u,
-449701786u,
-3474906110u, 1932585294u, 2283357584u, 1808481478u,
-3522851029u, 3040164731u, 1530172182u, 2950426149u,
-1402416557u,
-756419859u,
-4132576145u, 724994790u, 2852015871u, 2177908339u,
-899914731u, 139675671u, 1423281870u, 3198458070u,
-807581308u,
-2021611521u,
-1801452575u, 1425984297u, 2833835949u, 1536827865u,
-3902351840u, 164546042u, 1872840974u, 3986194780u,
-792156290u,
-3378681896u,
-941547959u, 3931328334u, 3661060482u, 2386420777u,
-3920146272u, 3458621279u, 3348500844u, 2269586542u,
-797371473u,
-3188953649u,
-80514771u, 2913333490u, 1246325623u, 3253846094u,
-1723906239u, 1606413555u, 587500718u, 1412413859u,
-2310046829u,
-2113313263u,
-3855635608u, 47271944u, 1112281934u, 3440228404u,
-2633519166u, 425094457u, 307659635u, 67338587u,
-2412987939u,
-2363930989u,
-2853008596u, 2844637339u, 922568813u, 130379293u,
-2825204405u, 2904442145u, 1176875333u, 1511685505u,
-599177514u,
-1872681372u,
-682394826u, 1888849790u, 3635304282u, 1761257265u,
-1571292431u, 355247075u, 1177210823u, 1691529530u,
-3629531121u,
-3760474006u,
-1129340625u, 868116266u, 3908237785u, 1942124366u,
-1266630014u, 3214841995u, 334023850u, 1110037019u,
-369650727u,
-1288666741u,
-70535706u, 20230114u, 4284225520u, 727856157u,
-293696779u, 1244943770u, 3976592462u, 560421917u,
-4171688499u,
-2438786950u,
-1218144639u, 3809125983u, 1302395746u, 534542359u,
-2121993015u, 2899519374u, 3192177626u, 1761707794u,
-3101683464u,
-1555403906u,
-3225675390u, 1875263768u, 4278894569u, 651707603u,
-2111591484u, 3802716028u, 2900262228u, 1181469202u,
-3254743797u,
-1822684466u,
-860641829u, 3046128268u, 1284833012u, 1125261608u,
-461384524u, 2331344566u, 1274400010u, 990498321u,
-3462536298u,
-3796842585u,
-2346607194u, 279495949u, 3951194590u, 3522664971u,
-3169688303u, 726831706u, 1123875117u, 1816166599u,
-3759808754u,
-2918558151u,
-3713203220u, 3369939267u, 466047109u, 384042536u,
-587271104u, 2191634696u, 2449929095u, 1157932232u,
-2084466674u,
-841370485u,
-3241372562u, 4277738486u, 2150836793u, 1173569449u,
-778768930u, 2594706485u, 3065269405u, 3019263663u,
-2660146610u,
-2789946230u,
-77056913u, 728174395u, 3647185904u, 804562358u,
-2697276483u, 881311175u, 1178696435u, 2059173891u,
-2308303791u,
-221481230u,
-50241451u, 3689414100u, 1969074761u, 2732071529u,
-1900890356u, 840789500u, 2100609300u, 985565597u,
-1220850414u,
-2456636259u,
-223607678u, 1016310244u, 1937434395u, 85717256u,
-275058190u, 3712011133u, 171916016u, 2389569096u,
-3679765802u,
-3575358777u,
-3481108261u, 3178286380u, 2489642395u, 2931039055u,
-3086601621u, 3079518902u, 3027718495u, 2506894644u,
-2976869602u,
-2134336365u,
-2420172217u, 918054427u, 661522682u, 1403791357u,
-3587174388u, 2623673551u, 1355661457u, 4159477684u,
-1109013587u,
-3112183488u,
-2217849279u, 3500291996u, 2419603731u, 2929886201u,
-3854470013u, 1358382103u, 1357666555u, 21053566u,
-2716621233u,
-3094836862u,
-3309729704u, 57086558u, 839187419u, 2757944838u,
-3651040558u, 3607536716u, 3691257732u, 2312878285u,
-1202511724u,
-183479927u,
-2509829803u, 109313218u, 478173887u, 2072044014u,
-190631406u, 2495604975u, 1010416260u, 3679857586u,
-726566957u,
-258500881u,
-1805873908u, 3081447051u, 2352101327u, 534922207u,
-1584552873u, 813470716u, 255914637u, 249169434u,
-3193498057u,
-1038802706u,
-2590158653u, 3147907290u, 663060128u, 1156177857u,
-634616100u, 312879189u, 1545020368u, 2054634247u,
-3271451914u,
-3438291534u,
-2181454946u, 3864535432u, 2398586877u, 896491075u,
-2810631478u, 2770357487u, 3372930052u, 898070638u,
-2051007323u,
-392959778u,
-36645539u, 3743556044u, 4134529680u, 4124451188u,
-566806297u, 2936523982u, 1304761965u, 537399498u,
-1940818842u,
-40862381u,
-36288410u, 3063605629u, 2826611650u, 3961972098u,
-1871578006u, 2392095486u, 1136931591u, 513864488u,
-173276451u,
-3039055682u,
-3543322032u, 1943592006u, 657217094u, 1751698246u,
-2969618445u, 456616022u, 900309519u, 113892716u,
-1126392103u,
-1235651045u,
-1882073852u, 2136610853u, 2353639710u, 2819956700u,
-3980083530u, 828773559u, 224069850u, 902434120u,
-2802008036u,
-94358995u,
-2777723394u, 2812641403u, 2525832595u, 4157388110u,
-4235563782u, 937800324u, 141690749u, 568062536u,
-550123849u,
-1330316521u,
-1949488696u, 2296431366u, 1958465262u, 3564751729u,
-3748252207u, 120455129u, 1607318832u, 2525729790u,
-2640987481u,
-2332096657u,
-1775969159u, 1555085077u, 2913525137u, 1347085183u,
-2376253113u, 3194050574u, 1806090610u, 678641356u,
-1499146713u,
-383849715u,
-3299835823u, 2284860330u, 2614269636u, 3913628844u,
-2761334210u, 1959484587u, 529797021u, 239966995u,
-3102194829u,
-3602307804u,
-1122192627u, 3577510006u, 164486066u, 1680137310u,
-1473396395u, 1467801424u, 903493660u, 1185943071u,
-2798556505u,
-2306744492u,
-3167201310u, 3577947177u, 3067592134u, 2905506289u,
-1210366329u, 204484056u, 2347778932u, 3862374472u,
-3277439508u,
-4187414621u,
-1646699310u, 621385800u, 3934869089u, 3975491588u,
-3580085916u, 1925674500u, 2436305348u, 3983301539u,
-2739439523u,
-3291507446u,
-3395637920u, 3753389171u, 2955202032u, 2654255623u,
-3771089254u, 2140443405u, 2779834738u, 3261942805u,
-3526889244u,
-1842009139u,
-4048484340u, 2106218403u, 2161244271u, 772152700u,
-1158647659u, 3776791619u, 3882186721u, 699525237u,
-2954670460u,
-1007105869u,
-3359152025u, 1146388699u, 1401550303u, 2326582541u,
-4181783540u, 1085644043u, 1942143795u, 1038368308u,
-1526153809u,
-4042547244u,
-1891441000u, 2573991874u, 1281441253u, 3635098284u,
-1980545715u, 825985487u, 3934748116u, 4228386979u,
-1480870944u,
-1042194545u,
-2397771642u, 2248490001u, 3817869868u, 878654626u,
-3785629484u, 1672470870u, 3229367873u, 1894538933u,
-1010692731u,
-1733824268u,
-656620328u, 3048283803u, 3353340056u, 2324965120u,
-4192585951u, 2284524675u, 3483884368u, 1510168293u,
-1554942691u,
-1309709396u,
-1241133168u, 3162179280u, 4046378054u, 3171681593u,
-1165297136u, 3496703563u, 150437903u, 1948622072u,
-1076332463u,
-2292479143u,
-1464229958u, 3479738093u, 2328067598u, 2334503110u,
-833324834u, 3981605747u, 3002629155u, 2854644186u,
-2832201336u,
-95796957u,
-3269249397u, 2358313329u, 3411860910u, 4283292480u,
-2802208697u, 1305947955u, 2156803420u, 1991340283u,
-189678024u,
-447602599u,
-1055411517u, 1531748363u, 1555852656u, 412402681u,
-3774988152u, 20597551u, 2925024131u, 1423989620u,
-3749428061u,
-1541439448u,
-112270416u, 1936224776u, 132162941u, 3772011507u,
-3814102518u, 1908807815u, 444154079u, 823765347u,
-3362275567u,
-3419047430u,
-2108287005u, 2315102125u, 658593738u, 3195094029u,
-3721937534u, 3176229204u, 3398835373u, 1271898712u,
-1142546577u,
-3185986817u,
-3562705803u, 2046119567u, 912990621u, 1829977672u,
-3459576979u, 1118045834u, 1369529376u, 3320601076u,
-3954988953u,
-4002467635u,
-3359456351u, 1314849568u, 1766750942u, 2998874853u,
-1181800239u, 707328036u, 3314954697u, 2066721120u,
-598194215u,
-1124451278u,
-3156679616u, 3742684743u, 2960199690u, 2683497915u,
-2566077529u, 937014607u, 102095219u, 4262922475u,
-3132264275u,
-1262099830u,
-862722905u, 2717653494u, 3245583534u, 3427209989u,
-3220278124u, 85457091u, 2222333500u, 3513997967u,
-3522324951u,
-2830855552u,
-2215004781u, 3482411840u, 4227160614u, 2030964411u,
-1741393851u, 2643723748u, 942813508u, 403442675u,
-3112048748u,
-530556423u,
-3817755244u, 3543286628u, 2247276090u, 1532920842u,
-4101962711u, 1446540991u, 3297821473u, 1861255389u,
-1984398u,
-2366525138u,
-377589481u, 3549193828u, 1427765914u, 506831657u,
-277278988u, 1447652775u, 3214362239u, 3142198690u,
-2843087541u,
-468915015u,
-807895062u, 2198723907u, 4031145069u, 2417156212u,
-4027298697u, 637175947u, 1229254212u, 1773257887u,
-1659444818u,
-451148891u,
-2099741368u, 735351990u, 2534775713u, 3261804619u,
-712519954u, 3527962772u, 3758642738u, 4245823575u,
-1281314264u,
-1167866160u,
-1489546151u, 1197354389u, 1043278102u, 2563326586u,
-371937794u, 2320164817u, 3189512691u, 573685198u,
-4108603513u,
-3758899588u,
-3507030163u, 2947201212u, 2529492585u, 578234375u,
-3362349842u, 3318878925u, 3611203517u, 3059253190u,
-4270755916u,
-4291274625u,
-4237586791u, 4137422245u, 2927218651u, 2444687041u,
-797128811u, 2043057612u, 396533859u, 2665256178u,
-3346510674u,
-1779586176u,
-3076562062u, 1882746214u, 921095362u, 2026988397u,
-514514911u, 3886379478u, 4218272420u, 1480386793u,
-3900160816u,
-2292273451u,
-1276138356u, 1125461821u, 1912885715u, 3365266013u,
-1333211627u, 4085009861u, 1390530102u, 3347984752u,
-2721771301u,
-1419492325u,
-4066766256u, 3250852311u, 820111852u, 1382201318u,
-2366036798u, 938032241u, 3100979439u, 487048687u,
-2292851045u,
-3241399180u,
-3912670510u, 2416437067u, 2973194517u, 3507707986u,
-1935099406u, 2533441488u, 104616731u, 2892622820u,
-3801190339u,
-4239188808u,
-807238241u, 3300121546u, 2249406147u, 4032114017u,
-3713738189u, 3324425575u, 4275607376u, 3663120298u,
-4173658372u,
-3984289690u,
-1827636846u, 3264588778u, 3297165529u, 558623533u,
-2728945672u, 1566297318u, 3447249966u, 481719551u,
-1596842050u,
-1838185946u,
-265271620u, 1050246315u, 4046655705u, 1844193138u,
-3807563245u, 1075384804u, 1292554949u, 1506525927u,
-2921816148u,
-2051885269u,
-1930534041u, 3872721086u, 1564489377u, 2272482181u,
-2849358683u, 589618304u, 2262072443u, 290363051u,
-299168363u,
-3867603931u,
-2868688756u, 2545263115u, 1092098533u, 3885725603u,
-2352430409u, 1981595469u, 2047946646u, 1332642839u,
-793806516u,
-214858837u,
-1061484659u, 3192394476u, 1115054785u, 3690637234u,
-996792368u, 2023479706u, 3046498231u, 4205835102u,
-3870714754u,
-257472875u,
-3549864599u, 2040276129u, 2414778670u, 812235477u,
-2674248196u, 1864096101u, 2257492689u, 1332556794u,
-1079540713u,
-465530720u,
-2304763972u, 830724724u, 3354588920u, 2510713652u,
-3103749409u, 468835585u, 1707620787u, 3038024846u,
-1000303198u,
-3462270146u,
-2748698899u, 2100348093u, 511537258u, 1237187486u,
-102049383u, 2268226698u, 3162251739u, 4219404629u,
-838822407u,
-1481440623u,
-2989224077u, 2676681975u, 3246551821u, 3812079906u,
-370572963u, 2283154352u, 3084789986u, 1961085583u,
-1955640586u,
-2409348147u,
-2284780581u, 1634818716u, 4018221729u, 2320761377u,
-3566831899u, 1799560520u, 91431959u, 1754113747u,
-1459430477u,
-3613658517u,
-924489906u, 3406317699u, 866289774u, 3924821603u,
-1265394945u, 1870668109u, 151949856u, 2747006534u,
-3111906201u,
-64039467u,
-2314447545u, 2600195638u, 4095795204u, 4162096026u,
-1026756826u, 2460047982u, 52686887u, 823198739u,
-1518045160u,
-2867527376u,
-566410761u, 2200433819u, 2114146405u, 2893790965u,
-881504901u, 974783212u, 490815659u, 937300283u,
-1523735309u,
-2511976468u,
-2634644947u, 355119367u, 1373773092u, 309232995u,
-3088671051u, 787126032u, 3442836843u, 4289194567u,
-2177850062u,
-1174136430u,
-3248982914u, 3129039732u, 1166851580u, 2196451882u,
-469595580u, 2130837700u, 3783349021u, 3745262548u,
-1236930515u,
-3032131496u,
-1525591437u, 1823628217u, 1939019255u, 1950270463u,
-3659899927u, 3688643445u, 3004399289u, 1155199552u,
-357547234u,
-2213110526u,
-3122658210u, 2667800490u, 2718690333u, 3512372076u,
-1098611683u, 2657518392u, 4248458835u, 3109874532u,
-1592908438u,
-2864927516u,
-3635248840u, 1251777186u, 3797340158u, 3508496870u,
-303354834u, 1482394062u, 2087100120u, 1595931912u,
-608574156u,
-723367884u,
-907938402u, 3357047807u, 1619629851u, 3092082995u,
-89030300u, 916336992u, 1861180168u, 3436334155u,
-1375000544u,
-3472936241u,
-1321217853u, 791356402u, 2872410224u, 2326250297u,
-2657644088u, 1748314108u, 4146771421u, 2913114440u,
-2924821844u,
-2101101496u,
-3268017251u, 2109603066u, 690665520u, 1830067573u,
-951427661u, 2982533150u, 3884512506u, 2358657479u,
-2833210784u,
-3419798214u,
-3785893994u, 2103940206u, 86759766u, 4031230616u,
-3745237192u, 2739453927u, 497038072u, 3303159408u,
-1251537249u,
-1993408196u,
-3185905715u, 2885948408u, 3154277110u, 2444150313u,
-2505582079u, 2120610195u, 3266465773u, 1814611964u,
-3080050407u,
-1079915522u,
-1819346505u, 2529946763u, 892097374u, 3740257161u,
-3618100441u, 1079900094u, 3607172225u, 737863389u,
-360704560u,
-3341993089u,
-1139047381u, 3132219631u, 1248981859u, 1109338159u,
-2004908615u, 4022302594u, 4166640860u, 2959140950u,
-3949235962u,
-2832278473u,
-2200524012u, 2634933043u, 2495844522u, 2613799818u,
-4034096813u, 683271795u, 1673546817u, 1363163726u,
-1805395136u,
-511749501u,
-1231032599u, 2305979751u, 345737783u, 3339868854u,
-2931857933u, 2323251738u, 1332068477u, 51846558u,
-3927238177u,
-1387182179u,
-1701238601u, 1419275173u, 2580882268u, 3357874599u,
-1726558907u, 1292901039u, 1371322339u, 1311713044u,
-3526735232u,
-4017884184u,
-3366093428u, 77140994u, 2128996229u, 1357915765u,
-4019691901u, 483989024u, 2390311750u, 2766065288u,
-3938587520u,
-3064810344u,
-1054589198u, 1274997019u, 4040589616u, 1277751144u,
-2274907047u, 4170399945u, 2886368209u, 4168922115u,
-3901237033u,
-3252972311u,
-2205185840u, 3403097556u, 3385493699u, 2809751370u,
-555319628u, 399539034u, 2998971454u, 1521596214u,
-178870216u,
-1471733541u,
-519629198u, 514159209u, 1500582242u, 1928616587u,
-2686427928u, 4133138798u, 1225914083u, 1432713584u,
-3559310915u,
-3925489366u,
-1055613123u, 4126676029u, 2723867653u, 3290604111u,
-1377022957u, 2373608155u, 3615237379u, 594338683u,
-2645257602u,
-2408427260u,
-917033274u, 750455097u, 625657657u, 121713200u,
-2191273413u, 4043949724u, 3293146785u, 3809297972u,
-3947296919u,
-115456894u,
-1529576616u, 1459278275u, 2157117997u, 1747859293u,
-4106665903u, 996939232u, 2007976332u, 4274649009u,
-1017725787u,
-4244666096u,
-1219631331u, 3072426253u, 3547691720u, 1620822012u,
-1397717508u, 2031597325u, 3345983430u, 2459068000u,
-3645130467u,
-2308642742u,
-359955852u, 1348467968u, 1133123059u, 2435919062u,
-2800365907u, 4213217210u, 4056565603u, 2811666556u,
-2318007236u,
-3823652401u,
-3654086429u, 1273260424u, 1591610446u, 943349350u,
-3441227678u, 3779964757u, 233818224u, 3469971032u,
-3764095096u,
-4009204587u,
-678472092u, 1990559652u, 2583121088u, 2978143652u,
-2496370864u, 2139539656u, 4287972050u, 295832576u,
-3536742861u,
-2257466133u,
-2738052161u, 1988611898u, 2466189642u, 3294419573u,
-2311186273u, 474374532u, 3081964174u, 2515138278u,
-835731677u,
-1178182694u,
-3352119543u, 2884763225u, 3462399574u, 2900817210u,
-1993698511u, 2868445043u, 2746444849u, 1205258179u,
-2353442946u,
-4079040070u,
-3624133102u, 2907136076u, 2902521697u, 426813211u,
-1418185512u, 3711189488u, 1351506552u, 1934749519u,
-46595543u,
-401688809u,
-3514602124u, 1396852607u, 1951477943u, 2502249173u,
-3199695820u, 2890250638u, 4205072507u, 1715623846u,
-3266686789u,
-3218688128u,
-1697759742u, 851227671u, 2358709645u, 4174233268u,
-500583683u, 3805940955u, 736234120u, 2710563712u,
-1949664540u,
-3139414003u,
-4293073253u, 1284406972u, 1785182449u, 1051548274u,
-2994248357u, 2499882522u, 717208669u, 2039517285u,
-518424929u,
-143136433u,
-2303774671u, 1272930860u, 2286410920u, 788459311u,
-273225293u, 2439291703u, 2254505236u, 3446287701u,
-3655156558u,
-1546628787u,
-340081500u, 3285722006u, 1324810435u, 1053980860u,
-1779472859u, 2700355724u, 686005017u, 3762376315u,
-3963193100u,
-1370881135u,
-661300087u, 1152753704u, 2349891598u, 3910051187u,
-2109444785u, 1311123870u, 2639837565u, 1896770931u,
-1081414128u,
-869877586u,
-4284220400u, 63045374u, 235968615u, 184451062u,
-1271099822u, 1319179857u, 3274963209u, 4172272710u,
-3388797445u,
-2965973320u,
-3793110097u, 3327241723u, 2991804005u, 1199544355u,
-771553759u, 2031749842u, 2596517372u, 1199888213u,
-858347951u,
-3340178832u,
-2903875412u, 763490382u, 76949161u, 2056544406u,
-1145227689u, 998233136u, 2354530024u, 427713587u,
-3537837347u,
-604661755u,
-923986833u, 1023730418u, 798294227u, 432557449u,
-801802449u, 1861313429u, 3899128441u, 4068407979u,
-2352677083u,
-3783539925u,
-10731973u, 3390767975u, 3949540249u, 1920121661u,
-3248580201u, 641956426u, 2104847395u, 604835744u,
-1491663404u,
-4255204651u,
-1520970746u, 2845653368u, 3247412938u, 3730629005u,
-855569514u, 3073294700u, 2429691698u, 3818342476u,
-3938869985u,
-2731201328u,
-2335202643u, 778117742u, 13298408u, 228780590u,
-2871715314u, 3253688653u, 4150999702u, 3846220408u,
-930808u,
-1397128726u,
-1964216488u, 2781092828u, 116285375u, 2271239476u,
-3724347554u, 2931203895u, 3893169206u, 1883912528u,
-2093892660u,
-3658787024u,
-3095016046u, 1094059199u, 3640239610u, 558564267u,
-2102812456u, 464734873u, 925262247u, 1609838036u,
-588364741u,
-1731409233u,
-1576165139u, 3933979268u, 375316394u, 4247099643u,
-3670508019u, 4080496835u, 2371248533u, 183762693u,
-2078935389u,
-2699810414u,
-1491815683u, 2999180789u, 1831158425u, 1603373553u,
-2006136905u, 3210230591u, 416748595u, 1536971415u,
-3271869367u,
-1266062739u,
-2138414557u, 3337114778u, 1634586826u, 36472629u,
-4482244u, 568009609u, 2721216780u, 4037289545u,
-2235138807u,
-1789351460u,
-4067539527u, 1323062829u, 3864620647u, 4192026301u,
-4278901241u, 1399025382u, 2826652805u, 1363860382u,
-1801770651u,
-1613381526u,
-1165249276u, 4046576622u, 2535596946u, 3260388176u,
-1078898578u, 2259750862u, 643387587u, 237144235u,
-4199571427u,
-3440917581u,
-3067939258u, 2018625455u, 1460528353u, 3138629939u,
-1666223528u, 3841139376u, 2528281125u, 885565193u,
-2609492686u,
-2517257479u,
-560864620u, 2261471820u, 3491559165u, 1329620416u,
-622383582u, 1759597655u, 2877873893u, 584692817u,
-1901728399u,
-2599000260u,
-3169771644u, 296332336u, 774719455u, 4175920823u,
-2287316070u, 4115615023u, 1073335619u, 4240292725u,
-1359158837u,
-1960974237u,
-3173724597u, 1619084286u, 2876340752u, 4065675347u,
-480741335u, 1237329941u, 701055566u, 3729009837u,
-1314736422u,
-4003180069u,
-3118519317u, 3035354420u, 3380357671u, 4020909015u,
-253958714u, 3545798863u, 3008185002u, 2624719888u,
-3219955575u,
-3060719376u,
-573101682u, 1580316843u, 2610493412u, 3490983536u,
-3601975611u, 851470366u, 635384901u, 3427048824u,
-1470002757u,
-3592460087u,
-2265226856u, 4124282457u, 2106385486u, 3334305617u,
-4208282753u, 3798749815u, 225396466u, 118791182u,
-2523395972u,
-194595464u,
-2563824631u, 2521301383u, 4224409406u, 468670274u,
-1761966400u, 1300908277u, 2570709228u, 1847901526u,
-1470099163u,
-2690466752u,
-1472536718u, 2399279735u, 4150607803u, 1775080054u,
-2082537685u, 4080034578u, 1256001880u, 392967725u,
-2055838940u,
-3349115816u,
-1745947263u, 2213925887u, 1836572741u, 2417722792u,
-636223705u, 2423329294u, 3960951311u, 1543591052u,
-1547914361u,
-2760945653u,
-3519014111u, 313543871u, 4119598884u, 1071003714u,
-2192556597u, 1526995535u, 3929839778u, 536388591u,
-3040873792u,
-3752682932u,
-1640614237u, 2432794021u, 385337403u, 2794410617u,
-2386128075u, 1055206708u, 1422747714u, 3759330929u,
-2533597496u,
-30440955u,
-1482899460u, 3350385050u, 616259409u, 3980103795u,
-1211364140u, 1040071544u, 594746920u, 1645973936u,
-2547331531u,
-1097726368u,
-700666526u, 2976247482u, 1144906608u, 996506677u,
-1997130756u, 800321417u, 1392942823u, 1601662248u,
-2079778663u,
-529512908u,
-2925120134u, 4106433085u, 630221833u, 2423086156u,
-1119859778u, 1726827981u, 1870859181u, 2559832707u,
-1792284257u,
-2059356387u,
-3572353364u, 3229407475u, 575621095u, 3221893291u,
-2372428048u, 2020123035u, 961449593u, 2243824063u,
-3803906611u,
-3735348189u,
-2981620804u, 4180681078u, 1555330629u, 230736535u,
-2075526640u, 749652975u, 713664372u, 2152096659u,
-2142067223u,
-3322302242u,
-1421646830u, 2092832615u, 1213735101u, 3192136753u,
-1106723940u, 3455398230u, 2541685524u, 2529956739u,
-3789430647u,
-1950084508u,
-2157395621u, 850457360u, 2758902426u, 2848030169u,
-6506379u, 1162213157u, 2981459221u, 272690871u,
-3059420255u,
-4242691285u,
-588065598u, 1206949936u, 3968214184u, 566348532u,
-126142880u, 1480567086u, 2959621988u, 2050218418u,
-2242731195u,
-3833514449u,
-1898070331u, 3687399477u, 3891859374u, 868185955u,
-2335308774u, 3676335246u, 3871121805u, 2189032743u,
-3275728647u,
-860492892u,
-1590764344u, 4130384758u, 262871548u, 3004764525u,
-2685542071u, 991231482u, 435122019u, 3031116998u,
-2898921700u,
-2917932604u,
-4238665148u, 2459072654u, 3444612545u, 4207731740u,
-1808564313u, 2798532269u, 3944553556u, 3926395409u,
-1633200670u,
-4138335224u,
-2524878605u, 4184292650u, 3563398268u, 4288943552u,
-3802121210u, 957502058u, 2410820887u, 4227117506u,
-4018625153u,
-4284329158u,
-530216712u, 2978986531u, 863452221u, 1910162118u,
-4088211378u, 4091971261u, 3150811451u, 4200871487u,
-3794038652u,
-3041564310u,
-2045287082u, 887805614u, 2889167251u, 4120352181u,
-1699912580u, 3478922097u, 3211994687u, 3136177842u,
-1500806861u,
-3211881347u,
-2147976385u, 3342722260u, 3359650541u, 4197378460u,
-781354073u, 1533623029u, 2204677828u, 3228172832u,
-3248592437u,
-3355841359u,
-560815159u, 1144951236u, 4027015711u, 2882625391u,
-339363613u, 2354572719u, 1769831876u, 4238589331u,
-1519732871u,
-2185834614u,
-1601096831u, 129709881u, 39655633u, 367604993u,
-1737681770u, 3259114599u, 2767070452u, 872365177u,
-1574125529u,
-3405020189u,
-4181346685u, 1134030380u, 403769171u, 2193351164u,
-1426232618u, 2885309450u, 3033612627u, 924948363u,
-935514094u,
-3202053329u,
-912294839u, 1618472324u, 4159158431u, 3744999487u,
-777064358u, 3974213124u, 1990246048u, 309725290u,
-2449849392u,
-1943692420u,
-2288635750u, 2433793635u, 2168904061u, 683315308u,
-3081493019u, 3477759434u, 3815496269u, 2823504699u,
-586945121u,
-3088963200u,
-3492287335u, 636875049u, 1111206944u, 2037346120u,
-1282050044u, 1409681512u, 1786128584u, 755810950u,
-2332676758u,
-2178142310u,
-957827166u, 1014983590u, 1888800725u, 3608595803u,
-3200072714u, 2534008478u, 659336139u, 1281728287u,
-4060560529u,
-2915575125u,
-3521503774u, 2926487340u, 1096297674u, 653489861u,
-2352326980u, 2561136777u, 1224141198u, 1250479629u,
-1297625391u,
-2409997371u,
-1942483722u, 2481835750u, 1394715707u, 1673070941u,
-2456039704u, 3980558014u, 3547934764u, 1882038812u,
-1078160498u,
-2488279087u,
-1848235245u, 1211914722u, 2264928765u, 2807773070u,
-270145554u, 583747883u, 3826009010u, 2996618216u,
-425727157u,
-992726957u,
-3384462280u, 726650661u, 1955043265u, 1923879512u,
-1854693773u, 2987614542u, 2660044993u, 2457260810u,
-426299370u,
-2671892900u,
-1827308087u, 3083953443u, 1791749638u, 3265087416u,
-2119752201u, 2547122538u, 3990783236u, 1912713468u,
-3688865211u,
-1815780016u,
-303699291u, 2416763742u, 2690891610u, 1535193548u,
-1107803989u, 1504143133u, 2235270371u, 2545884083u,
-2276278682u,
-411724404u,
-3416925704u, 2565792091u, 3383911757u, 546058824u,
-3374654444u, 2364630415u, 2693473470u, 2622125691u,
-261864817u,
-55682470u,
-857617568u, 141304067u, 1885488541u, 155368182u,
-1281949051u, 3384522408u, 3254816901u, 1959816782u,
-1452224057u,
-2830267691u,
-3709231247u, 58988202u, 4218130458u, 2984061349u,
-1888707848u, 4223605071u, 4241442486u, 375269213u,
-3208327038u,
-2199916493u,
-550337252u, 2855061437u, 276088636u, 114362204u,
-2321163647u, 2127813633u, 3289403024u, 2686973202u,
-2717376797u,
-3593428039u,
-3648831666u, 890925902u, 3289404818u, 3289516821u,
-4248913260u, 1858916580u, 3303932308u, 1752797086u,
-1628149686u,
-3245893605u,
-1568537311u, 2844194502u, 1593855770u, 2408174109u,
-124797514u, 2085649512u, 3188565660u, 2264996276u,
-1926696513u,
-3053957740u,
-2238806881u, 2189050973u, 203685243u, 379855590u,
-3920271562u, 1058600179u, 3698061923u, 4255106849u,
-608401664u,
-1598041932u,
-3318266418u, 2535016555u, 852760884u, 1918098822u,
-2200437599u, 1532285043u, 3425662132u, 3561293706u,
-2231633206u,
-4108785088u,
-3359152801u, 173534780u, 208383607u, 2862988169u,
-2406642243u, 426814583u, 2777335795u, 3322703596u,
-954190623u,
-615093090u,
-4179102978u, 2452847930u, 100239619u, 42471741u,
-818352432u, 2190624654u, 504379960u, 3631619975u,
-633412456u,
-1018421783u,
-842645419u, 711808707u, 3424580813u, 2132457941u,
-1158335882u, 3567952480u, 2302183699u, 1145788151u,
-3474264138u,
-3105085243u,
-3115506027u, 2783713015u, 3871785309u, 539583269u,
-1400252405u, 3857849984u, 4231186588u, 1278653799u,
-1760227022u,
-761044088u,
-3838185417u, 2439542532u, 585283357u, 2055995220u,
-937117124u, 3831944855u, 1823586038u, 3287917855u,
-485082427u,
-3209172809u,
-1984570176u, 2818337297u, 2691869057u, 3790476953u,
-839035557u, 3203129010u, 669981176u, 4121157385u,
-3519870450u,
-3792633352u,
-3017650322u, 1603459507u, 4225677666u, 376555451u,
-473780127u, 2018786277u, 3299822439u, 1010254499u,
-2383887565u,
-3155009499u,
-3108110655u, 2641738274u, 3684908622u, 1606463047u,
-3311068174u, 52708046u, 754181455u, 1018079176u,
-3915670272u,
-3366999425u,
-1012880204u, 1339439715u, 466437962u, 1402662350u,
-2504046911u, 736323938u, 2037800124u, 1725908589u,
-716341840u,
-1750123474u,
-3366342464u, 1743666195u, 2975303189u, 3821364027u,
-3253707772u, 3635548377u, 3840413796u, 1955642085u,
-1018315169u,
-1258092848u,
-2095540656u, 1076256607u, 117289557u, 1311658655u,
-2118301000u, 68721550u, 2886814107u, 2712432819u,
-4201862886u,
-753807148u,
-1940229047u, 731347296u, 1068901393u, 3873155894u,
-2852787666u, 1973464853u, 79735652u, 3966380587u,
-3245740712u,
-2525773438u,
-734938109u, 3045656416u, 3335746354u, 4099732691u,
-1911896517u, 1697006473u, 1145487066u, 1605663299u,
-3053606724u,
-2386289465u,
-3821211369u, 1006215345u, 1256304829u, 1053001668u,
-1289194958u, 118761054u, 1853688730u, 2803418011u,
-188650809u,
-3763686458u,
-1006829556u, 2961984133u, 3390525025u, 2061199893u,
-141792681u, 2439893463u, 2652982650u, 1804942682u,
-1546510005u,
-1246961405u,
-2407577046u, 565772575u, 3751844810u, 2943166103u,
-3750052451u, 3022527280u, 25162928u, 397381043u,
-1818337632u,
-3447363730u,
-3936437150u, 2569420703u, 2215592390u, 2171555672u,
-3665571006u, 4021712412u, 2939158353u, 4057813172u,
-1823237318u,
-103999245u,
-3251978010u, 3591914940u, 3582495283u, 2519035265u,
-3905726135u, 3180393349u, 2743117123u, 55247368u,
-3325286701u,
-705195946u,
-1857526853u, 1480518550u, 3809990433u, 1398189338u,
-3126362926u, 3959531492u, 1503658285u, 1977847740u,
-3043964489u,
-2613086143u,
-1518119282u, 4238434900u, 3905746486u, 3064949667u,
-1028122931u, 3309119457u, 4071194920u, 3096098907u,
-4137180520u,
-494467959u,
-1231408687u, 1691606157u, 1793452569u, 2722196118u,
-3478603952u, 1059665738u, 2282032278u, 3990268388u,
-1719514651u,
-4248311578u,
-3799146721u, 898026304u, 3367808954u, 4162472815u,
-170495870u, 1308116609u, 3428285344u, 1714716475u,
-395576794u,
-4153638621u,
-2999745812u, 3483315953u, 304980828u, 595337120u,
-3486516729u, 2331563143u, 2583609459u, 1885928417u,
-3834283777u,
-979337825u,
-932057378u, 3124081189u, 1930356777u, 3865887996u,
-4178282217u, 4214219408u, 3669465884u, 1472413856u,
-3356866587u,
-1012769806u,
-3043639963u, 996996396u, 207308216u, 982967331u,
-2991319933u, 318066902u, 721489670u, 1249967713u,
-749240921u,
-591392325u,
-2379365192u, 2250868849u, 2163259329u, 143191325u,
-3778285606u, 982149096u, 3536906200u, 2244353244u,
-1443862317u,
-3161549210u,
-2183127464u, 2015409516u, 547003700u, 2032484282u,
-523677821u, 4275663308u, 3827205526u, 3903778273u,
-2444530525u,
-2543645801u,
-1173958423u, 784740616u, 2878693675u, 3127696736u,
-3832037316u, 3161002398u, 4084166400u, 4213346853u,
-223390424u,
-4273380883u,
-2130315482u, 3429606032u, 3367732613u, 1912357694u,
-422632590u, 1266957023u, 3437535648u, 736404240u,
-2281709372u,
-415859912u,
-212948797u, 351612650u, 3920561440u, 112963586u,
-2230727543u, 2851076612u, 1990662634u, 2264296857u,
-3131463650u,
-2704034623u,
-3541637839u, 2954232792u, 533986918u, 4158757533u,
-65174248u, 4232639593u, 865906667u, 1948225652u,
-779656112u,
-3873989249u,
-2372984749u, 2346988193u, 1104345713u, 1165654138u,
-4045762610u, 3588205178u, 461363991u, 1111215752u,
-1389675192u,
-2404325151u,
-2152228101u, 3808973622u, 1901235912u, 3458690696u,
-314513238u, 2539459143u, 2847998873u, 952026138u,
-2325705328u,
-407844712u,
-3727960715u, 2996448351u, 2374336760u, 3138756390u,
-2600015243u, 539980418u, 1876285352u, 1670330799u,
-1709360377u,
-2868531654u,
-494777964u, 2773053597u, 599486162u, 3962209577u,
-1871328846u, 2171933018u, 110279472u, 384074780u,
-4147021936u,
-2333589647u,
-4251778066u, 40493468u, 3099342316u, 4108779767u,
-2812424588u, 954542332u, 2040682331u, 2251152306u,
-45915516u,
-259525626u,
-1045384743u, 4134656562u, 749389261u, 874399445u,
-616549904u, 2200447504u, 436024539u, 78972290u,
-3210485762u,
-1907985531u,
-3013721395u, 4214533685u, 4198804243u, 534879265u,
-1517190881u, 3756787754u, 1152563554u, 1718750948u,
-777737463u,
-1402478860u,
-1824562784u, 1879401449u, 3515818786u, 513165201u,
-1423491227u, 2103067918u, 2291777410u, 1097943000u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; IsAlive(farmhashcc::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashcc::Hash32(data, len++)); { uint128_t u = farmhashcc::Fingerprint128(data, len++); uint64_t h = Uint128Low64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); h = Uint128High64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
-Check(farmhashcc::Hash32WithSeed(data + offset, len, SEED));
-Check(farmhashcc::Hash32(data + offset, len));
-{ uint128_t u = farmhashcc::Fingerprint128(data + offset, len); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint128_t u = farmhashcc::CityHash128WithSeed(data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashccTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-cout << farmhashcc::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
-cout << farmhashcc::Hash32(data + offset, len) << "u," << endl;
-{ uint128_t u = farmhashcc::Fingerprint128(data + offset, len); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint128_t u = farmhashcc::CityHash128WithSeed(data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashccTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashccTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashccTest::Dump(0, i);
- }
- farmhashccTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashmkTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-4081014168u,
-2576519988u,
-2212771159u,
-1112731063u,
-1020067935u,
-3955445564u,
-1451961420u,
-653440099u,
-31917516u,
-2957164615u,
-2590087362u,
-3879448744u,
-176305566u,
-2447367541u,
-1359016305u,
-3363804638u,
-1117290165u,
-1062549743u,
-2437877004u,
-1894455839u,
-673206794u,
-3486923651u,
-3269862919u,
-2303349487u,
-1380660650u,
-595525107u,
-1525325287u,
-2025609358u,
-176408838u,
-1592885012u,
-864896482u,
-2101378090u,
-3489229104u,
-2118965695u,
-581644891u,
-2718789079u,
-631613207u,
-4228658372u,
-3867875546u,
-3531368319u,
-3804516756u,
-3317755099u,
-1619744564u,
-2884717286u,
-1088213445u,
-2667691076u,
-3727873235u,
-2330406762u,
-3616470388u,
-967660719u,
-4148162586u,
-315219121u,
-673084328u,
-3047602355u,
-1598963653u,
-1267826661u,
-2117362589u,
-2861192253u,
-1823625377u,
-1380350078u,
-1641748342u,
-1176094482u,
-269384321u,
-2178982315u,
-3480237248u,
-2660755208u,
-1850544433u,
-3429699438u,
-1262819303u,
-640556464u,
-2421125401u,
-2188368608u,
-2612932825u,
-1474432581u,
-173790449u,
-2124882189u,
-831272654u,
-622960146u,
-4238751051u,
-3250317967u,
-2120810248u,
-1948231495u,
-1389029321u,
-2200398357u,
-2134232963u,
-2948072329u,
-617717625u,
-681164587u,
-114859387u,
-430545646u,
-57239089u,
-3163338012u,
-3482496399u,
-557662576u,
-1102441413u,
-2670159360u,
-991116729u,
-846014240u,
-4233741566u,
-1802317242u,
-3129528802u,
-1459456375u,
-1305643039u,
-3258671612u,
-1578285833u,
-868590079u,
-1631034517u,
-1695432937u,
-561078856u,
-1004115553u,
-3086090507u,
-3818348650u,
-731596645u,
-780926790u,
-2544205955u,
-158479164u,
-3983514188u,
-2004735250u,
-3436218400u,
-673684751u,
-1463431419u,
-2880490219u,
-3223748024u,
-2218318859u,
-1474466194u,
-2636437533u,
-2206794961u,
-140995728u,
-1186394086u,
-1805716888u,
-1640037724u,
-3942729099u,
-1944727013u,
-918951560u,
-498666871u,
-3486974657u,
-2967205462u,
-1167253804u,
-1884281041u,
-2866015002u,
-4158319270u,
-2627220079u,
-3733319624u,
-3317092271u,
-438323662u,
-3195868065u,
-3426606709u,
-360708338u,
-1905491012u,
-650004803u,
-1351266252u,
-3133279000u,
-3722811115u,
-2722412434u,
-918432408u,
-3678271248u,
-269599647u,
-621514057u,
-3117077855u,
-1545425390u,
-2597567410u,
-1221437820u,
-3493254589u,
-102787342u,
-918861168u,
-348795089u,
-3439883229u,
-2353641807u,
-2209585469u,
-4035884492u,
-2686995435u,
-1649888022u,
-3852893848u,
-3042700028u,
-314103172u,
-726977769u,
-2489830276u,
-2872753660u,
-1316214989u,
-1488801501u,
-1811420390u,
-639581627u,
-2362837215u,
-3634581834u,
-3648576802u,
-1257314182u,
-762118371u,
-4268447045u,
-730167096u,
-755561509u,
-882614845u,
-3696972894u,
-228263661u,
-1478636142u,
-2767751651u,
-1532617116u,
-3838657661u,
-1944359935u,
-1401102137u,
-3772933173u,
-1050098254u,
-1658079354u,
-1846025728u,
-2204244794u,
-2017217424u,
-1275162853u,
-1429816745u,
-2175565479u,
-1716109139u,
-1187506761u,
-2434641075u,
-2725597783u,
-1795687662u,
-1393312782u,
-3511565397u,
-627885430u,
-4145733164u,
-2519005353u,
-231414775u,
-1242015635u,
-2760723497u,
-2185540568u,
-727314436u,
-2358790354u,
-1186393454u,
-4234795645u,
-350567813u,
-866773875u,
-3145590392u,
-1158374055u,
-3903123687u,
-1862119793u,
-2204587556u,
-4266276976u,
-4151548555u,
-915250402u,
-2874695320u,
-2360311410u,
-1099212769u,
-1271542714u,
-3473148363u,
-1637325418u,
-1807795989u,
-2493819794u,
-3800917924u,
-4001205856u,
-2582153621u,
-3365872040u,
-2890146216u,
-2626363824u,
-3133351295u,
-4046827296u,
-3053118771u,
-4113026751u,
-884356716u,
-3828347401u,
-10608262u,
-830987972u,
-1841080500u,
-3202717763u,
-3561778749u,
-1906000052u,
-3058284660u,
-1432904514u,
-2567431677u,
-2550162530u,
-665557986u,
-936887821u,
-2101205308u,
-4253535847u,
-1662043545u,
-1253611611u,
-2091370094u,
-2635077370u,
-2602176041u,
-3624115809u,
-748442714u,
-2709749154u,
-1023493343u,
-860291012u,
-3924715584u,
-1536436740u,
-2551145800u,
-2391782865u,
-1467705048u,
-2583909796u,
-3616666170u,
-1162857372u,
-4228631071u,
-1510132376u,
-2739165009u,
-2656606142u,
-3454996358u,
-3155038853u,
-1022087316u,
-100044110u,
-494208296u,
-2746186477u,
-4216782431u,
-225448834u,
-3728320521u,
-335282866u,
-3148194874u,
-953503703u,
-1293353960u,
-202372387u,
-1326119870u,
-4045123735u,
-3819994846u,
-1629004186u,
-1081099186u,
-3591584153u,
-1670825804u,
-3404257979u,
-3262192301u,
-2572846095u,
-3714992543u,
-4264142572u,
-529616678u,
-2882154574u,
-3006354178u,
-3865969421u,
-2007174907u,
-308283107u,
-2629833703u,
-3159124075u,
-1146492131u,
-494104332u,
-493149727u,
-1342910585u,
-521642387u,
-2201695937u,
-2517980959u,
-2426821287u,
-777374655u,
-2228189792u,
-4027055486u,
-228976000u,
-3842083468u,
-1723920223u,
-1192126094u,
-787744493u,
-2740368380u,
-2284153001u,
-2773829458u,
-442000614u,
-387830783u,
-2169780670u,
-2253144627u,
-3532502484u,
-1969684059u,
-1165351416u,
-3055056536u,
-3582324253u,
-231419363u,
-770979865u,
-3213983597u,
-3690452836u,
-935794639u,
-3230602762u,
-2841762457u,
-407598927u,
-1164479891u,
-3721799696u,
-354738136u,
-1801566618u,
-3206038542u,
-2621379981u,
-1943487262u,
-3534745636u,
-1074424589u,
-1304517521u,
-4133400969u,
-2339317978u,
-2135116860u,
-4180643791u,
-2415309340u,
-1855926417u,
-3418648630u,
-1968113037u,
-597304222u,
-3668824865u,
-3810008716u,
-3014702569u,
-3151212026u,
-156057449u,
-373134533u,
-2068234004u,
-191580563u,
-3832754488u,
-2924104199u,
-2026044494u,
-4065780435u,
-122565840u,
-4194985167u,
-2744823717u,
-2494098735u,
-3753793370u,
-1885739217u,
-2488161225u,
-3643797615u,
-2653367310u,
-2494061477u,
-189968132u,
-899646597u,
-392100396u,
-4012318310u,
-3855777086u,
-3566860954u,
-2698574996u,
-2414249905u,
-1330623339u,
-1263222732u,
-1277741760u,
-2194959402u,
-1629656136u,
-120494320u,
-1072368005u,
-1084245077u,
-4011372748u,
-1366613353u,
-3108643228u,
-3332219532u,
-2114746095u,
-3964007334u,
-371687128u,
-1084813876u,
-126459896u,
-4292782331u,
-321283184u,
-398168499u,
-3604983506u,
-560701543u,
-2073961354u,
-4240841868u,
-4151211362u,
-1338986875u,
-4093476832u,
-2269279497u,
-3500846299u,
-2510225147u,
-598000444u,
-1330391422u,
-1432533385u,
-4171226231u,
-426821154u,
-2932270996u,
-3378981077u,
-2217871549u,
-1619647984u,
-4051608043u,
-3180237819u,
-12919578u,
-1375401767u,
-371320427u,
-2986640571u,
-2336669859u,
-3796464715u,
-1892383284u,
-306814912u,
-2125823211u,
-1863678891u,
-3249703818u,
-3840225752u,
-281579900u,
-264680257u,
-4266359110u,
-4182229890u,
-2239659703u,
-3627947372u,
-2373929191u,
-224082765u,
-4053639058u,
-1862360303u,
-3187739624u,
-3392706679u,
-948039509u,
-817505760u,
-1215842393u,
-3462222651u,
-536021853u,
-182346832u,
-2731944883u,
-2346674384u,
-2640961678u,
-3446695687u,
-2271722179u,
-1301069656u,
-2803881468u,
-2832614405u,
-1691544398u,
-698756814u,
-3980620906u,
-3565421410u,
-754769376u,
-4115923404u,
-3909962218u,
-2747614077u,
-2888289845u,
-1016920862u,
-2790946178u,
-3067070960u,
-3173251481u,
-1572132982u,
-255048203u,
-2996538818u,
-3405398987u,
-136106013u,
-3581605228u,
-4277437977u,
-2147300534u,
-3728426265u,
-3483629996u,
-1478452694u,
-20756076u,
-2774992067u,
-432987927u,
-1516771026u,
-3511588664u,
-2130994978u,
-509385406u,
-873090347u,
-2163904107u,
-4192239086u,
-2532489989u,
-1090772651u,
-3910797408u,
-3710882132u,
-155010959u,
-1369823531u,
-1599664937u,
-4035593587u,
-1212746925u,
-795822552u,
-116689518u,
-3674240941u,
-1135576664u,
-756750261u,
-1027431362u,
-390555140u,
-2228460216u,
-1506940482u,
-3733857700u,
-3048762971u,
-2511703196u,
-548609887u,
-1607354252u,
-659053982u,
-259884450u,
-1793130460u,
-4083364495u,
-3148555881u,
-1764350138u,
-2436485683u,
-4031563025u,
-3261860724u,
-2475833430u,
-2101726086u,
-3191176464u,
-2646658847u,
-2127042126u,
-771316100u,
-2115922959u,
-3208515045u,
-2355437783u,
-3621147793u,
-1580163615u,
-3211555675u,
-3299188490u,
-191613920u,
-466733956u,
-2939029038u,
-1509152039u,
-130591314u,
-1892874677u,
-1646908044u,
-3452406523u,
-3998376606u,
-1199243832u,
-2187108812u,
-3189230066u,
-4161151481u,
-3371454980u,
-3681788646u,
-180842187u,
-3685022399u,
-3058749895u,
-3250165163u,
-2895367943u,
-2627101723u,
-771755098u,
-1332921024u,
-3638871848u,
-514215135u,
-3591227378u,
-2300310870u,
-3689533503u,
-851607114u,
-114330368u,
-2709027386u,
-1743034877u,
-1013693860u,
-288169008u,
-3545190686u,
-1052165084u,
-3995862307u,
-96902755u,
-1097819851u,
-2645431442u,
-2184148618u,
-2151206566u,
-350979797u,
-3467920900u,
-421116779u,
-1246252u,
-4057835428u,
-329324407u,
-4104482417u,
-844624570u,
-3306265806u,
-3787625025u,
-4263241191u,
-3251413927u,
-2921204431u,
-2931915325u,
-992134330u,
-3986338354u,
-1327895216u,
-1458363596u,
-1480608532u,
-728594368u,
-3804366693u,
-794404223u,
-1643240863u,
-793417255u,
-4167916443u,
-2683488959u,
-3124925324u,
-4184843652u,
-3750971752u,
-308509829u,
-1054550805u,
-2797511972u,
-4043123412u,
-1587158240u,
-4050518606u,
-3030062190u,
-2589912753u,
-603440067u,
-937013191u,
-1071662315u,
-2100661456u,
-2602005741u,
-435516078u,
-2260470147u,
-1256268350u,
-3612035u,
-3368856141u,
-151516099u,
-3081868591u,
-3363755681u,
-2049963149u,
-2885320434u,
-84682005u,
-2411758308u,
-2695174275u,
-3099904644u,
-1787308684u,
-1132379308u,
-564634346u,
-510236510u,
-2804443681u,
-3931864252u,
-2064427949u,
-1893979229u,
-2916544974u,
-1885887717u,
-2978018250u,
-494192125u,
-2642662373u,
-901112508u,
-636035003u,
-1658643797u,
-172746975u,
-517504890u,
-3440019372u,
-4144498044u,
-1854755456u,
-3672653905u,
-4176892856u,
-382159097u,
-282871690u,
-3629300472u,
-2500754041u,
-1677659759u,
-1067175061u,
-161654075u,
-1672575536u,
-346120493u,
-2730229631u,
-203466442u,
-1244549529u,
-199761971u,
-2744895408u,
-3195315331u,
-2124618519u,
-3261045496u,
-985339699u,
-3385585455u,
-1545740710u,
-3636652160u,
-2167020081u,
-1207897204u,
-28752417u,
-2895834146u,
-3640845375u,
-3750293073u,
-548997850u,
-4207814196u,
-4183030708u,
-2462810989u,
-3929965401u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; IsAlive(farmhashmk::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashmk::Hash32(data, len++)); IsAlive(farmhashmk::Hash32(data, len++)); len -= 3; return alive > 0; }
-Check(farmhashmk::Hash32WithSeed(data + offset, len, SEED));
-Check(farmhashmk::Hash32(data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashmkTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-cout << farmhashmk::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
-cout << farmhashmk::Hash32(data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashmkTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashmkTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashmkTest::Dump(0, i);
- }
- farmhashmkTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashnaTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-1140953930u, 861465670u,
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-890626835u, 800175912u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-3283896453u, 1867689945u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-1110588164u, 4186314283u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-283198166u, 2741341286u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-452473466u, 1706958772u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-236935126u, 2976578695u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-2305012065u, 2169731866u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-3058973506u, 2379411653u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-147814787u, 720739346u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-3425469811u, 3690733394u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-1635026870u, 192883107u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-3969463346u, 1436364519u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-2859809759u, 3808705738u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-4023053163u, 2650381482u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-3476440786u, 3829307897u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-2902102606u, 3600725550u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1448662590u, 397635823u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-180854224u, 2604346966u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-1669465176u, 1341975128u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-1043692997u, 1454396064u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-703505868u, 678706990u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-1933894405u, 3043213226u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-3828089804u, 3632594520u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-3729087873u, 1303930448u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3103338579u, 3064290191u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2295806711u, 1781190011u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-1968445277u, 315203929u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-440398219u, 1891630171u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-4204318635u, 441430649u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-3010839769u, 2837339569u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-4139181436u, 2993479124u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-667183474u, 2084369203u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-1016656857u, 3022024459u,
-3254014218u, 429095991u,
-165589978u, 1578546616u,
-985653208u, 1718653828u,
-623071693u, 366414107u,
-249776086u, 1207522198u,
-3047342438u, 2991127487u,
-3120876698u, 1684583131u,
-46987739u, 1157614300u,
-863214540u, 1087193030u,
-199124911u, 520792961u,
-3614377032u, 586863115u,
-3331828431u, 1013201099u,
-1716848157u, 4033596884u,
-1164298657u, 4140791139u,
-1146169032u, 1434258493u,
-3824360466u, 3242407770u,
-3725511003u, 232064808u,
-872586426u, 762243036u,
-2736953692u, 816692935u,
-512845449u, 3748861010u,
-2266795890u, 3781899767u,
-4290630595u, 517646945u,
-22638523u, 648000590u,
-959214578u, 558910384u,
-1283799121u, 3047062993u,
-1024246061u, 4027776454u,
-3544509313u, 622325861u,
-834785312u, 382936554u,
-411505255u, 1973395102u,
-1825135056u, 2725923798u,
-580988377u, 2826990641u,
-3474970689u, 1029055034u,
-812546227u, 2506885666u,
-2584372201u, 1758123094u,
-589567754u, 325737734u,
-345313518u, 2022370576u,
-3886113119u, 3338548567u,
-257578986u, 3698087965u,
-1776047957u, 1771384107u,
-3604937815u, 3198590202u,
-2305332220u, 191910725u,
-4232136669u, 427759438u,
-4244322689u, 542201663u,
-3315355162u, 2135941665u,
-556609672u, 45845311u,
-1175961330u, 3948351189u,
-23075771u, 3252374102u,
-1634635545u, 4151937410u,
-713127376u, 1467786451u,
-663013031u, 3444053918u,
-2638154051u, 810082938u,
-3077742128u, 1062268187u,
-2115441882u, 4081398201u,
-3735739145u, 2794294783u,
-2335576331u, 2560479831u,
-1379288194u, 4225182569u,
-2442302747u, 3948961926u,
-3958366652u, 3067277639u,
-3667516477u, 1709989541u,
-1516711748u, 2339636583u,
-4188504038u, 59581167u,
-2725013602u, 3639843023u,
-2658147000u, 2643979752u,
-3758739543u, 4189944477u,
-2470483982u, 877580602u,
-2995362413u, 118817200u,
-3252925478u, 2062343506u,
-3981838403u, 3762572073u,
-1231633714u, 4168280671u,
-2931588131u, 3284356565u,
-1129162571u, 732225574u,
-4173605289u, 1407328702u,
-1677744031u, 3532596884u,
-3232041815u, 1652884780u,
-2256541290u, 3459463480u,
-3740979556u, 259034107u,
-2227121257u, 1426140634u,
-3606709555u, 3424793077u,
-315836068u, 3200749877u,
-1386256573u, 24035717u,
-2982018998u, 1811050648u,
-234531934u, 1115203611u,
-1598686658u, 3146815575u,
-1603559457u, 323296368u,
-2632963283u, 1778459926u,
-739944537u, 579625482u,
-3486330348u, 492621815u,
-1231665285u, 2457048126u,
-3903349120u, 389846205u,
-3355404249u, 3275550588u,
-1052645068u, 862072556u,
-2834153464u, 1481069623u,
-2657392572u, 4279236653u,
-1688445808u, 701920051u,
-3740748788u, 3388062747u,
-1873358321u, 2152785640u,
-883382081u, 1005815394u,
-1020177209u, 734239551u,
-2371453141u, 100326520u,
-3488500412u, 1279682138u,
-2610427744u, 49703572u,
-3026361211u, 605900428u,
-302392721u, 2509302188u,
-1416453607u, 2815915291u,
-1862819968u, 519710058u,
-2450888314u, 4017598378u,
-937074653u, 3035635454u,
-1590230729u, 3268013438u,
-2710029305u, 12886044u,
-3711259084u, 2627383582u,
-3895772404u, 648534979u,
-260307902u, 855990313u,
-3669691805u, 263366740u,
-2938543471u, 414331688u,
-3080542944u, 3405007814u,
-3565059103u, 1190977418u,
-390836981u, 1606450012u,
-2649808239u, 2514169310u,
-2747519432u, 4129538640u,
-1721522849u, 492099164u,
-792990594u, 3625507637u,
-2271095827u, 2993032712u,
-2302363854u, 4013112951u,
-1111617969u, 2183845740u,
-795918276u, 1116991810u,
-3110898804u, 3963062126u,
-2737064702u, 462795667u,
-937372240u, 1343017609u,
-1091041189u, 2790555455u,
-277024217u, 25485284u,
-1166522068u, 1623631848u,
-241727183u, 2836158787u,
-3112996740u, 573836428u,
-2721658101u, 1937681565u,
-4175169209u, 3190765433u,
-1970000788u, 1668258120u,
-114616703u, 954762543u,
-199237753u, 4094644498u,
-2522281978u, 732086117u,
-1756889687u, 2936126607u,
-2437031370u, 4103143808u,
-3883389541u, 3171090854u,
-2483004780u, 1927385370u,
-2360538162u, 2740855009u,
-4241185118u, 1492209542u,
-1672737098u, 2148675559u,
-1789864670u, 2434313103u,
-2319172611u, 2760941207u,
-2636210123u, 1338083267u,
-1128080590u, 822806371u,
-1199583556u, 314727461u,
-1335160250u, 2084630531u,
-1156261526u, 316766066u,
-112090465u, 3129033323u,
-2746885618u, 636616055u,
-2582210744u, 1721064910u,
-3468394263u, 470463518u,
-2076016059u, 408721884u,
-2121041886u, 378460278u,
-1915948002u, 357324860u,
-2301682622u, 2691859523u,
-1869756364u, 2429314418u,
-2193146527u, 1185564327u,
-2614088922u, 1975527044u,
-919067651u, 2855948894u,
-3662539576u, 1943802836u,
-3529473373u, 1490330107u,
-366036094u, 3384241033u,
-4276268604u, 448403661u,
-4271796078u, 1910401882u,
-3077107698u, 299427366u,
-2035665349u, 3201262636u,
-3738454258u, 2554452696u,
-3588997135u, 3363895827u,
-1267505995u, 1852004679u,
-2237827073u, 2803250686u,
-3468044908u, 2143572850u,
-1728158656u, 1022551180u,
-1996680960u, 839529273u,
-2400647871u, 2201096054u,
-3606433628u, 2597259793u,
-3544595875u, 3909443124u,
-819278607u, 3447346709u,
-806136613u, 2711436388u,
-3656063205u, 837475154u,
-694525336u, 4070212073u,
-4011303412u, 1068395209u,
-438095290u, 484603494u,
-2673730227u, 737767009u,
-642310823u, 3914002299u,
-308425103u, 268427550u,
-1334387085u, 4069797497u,
-4280783219u, 2914011058u,
-4243643405u, 2849988118u,
-2504230175u, 1817156623u,
-2804200483u, 3406991497u,
-2948254999u, 2102063419u,
-1071272117u, 514889942u,
-571972433u, 1246595599u,
-1735616066u, 1539151988u,
-1230831543u, 277987182u,
-4269526481u, 991511607u,
-95237878u, 2005032160u,
-1291113144u, 626619670u,
-3560835907u, 164940926u,
-1433635018u, 116647396u,
-3039097112u, 2868163232u,
-1141645918u, 1764165478u,
-881378302u, 2159170082u,
-2953647681u, 1011320066u,
-184856151u, 1723308975u,
-336034862u, 2017579106u,
-1476681709u, 147523618u,
-3896252223u, 2264728166u,
-944743644u, 1694443528u,
-2690700128u, 1947321519u,
-735478508u, 4058183171u,
-260177668u, 505662155u,
-2391691262u, 1920739747u,
-3216960415u, 1898176786u,
-3722741628u, 1511077569u,
-449636564u, 983350414u,
-2580237367u, 2055059789u,
-1103819072u, 2089123665u,
-3873755579u, 2718467458u,
-3124338704u, 3204250304u,
-2475035432u, 1120017626u,
-3873758287u, 1982999824u,
-2950794582u, 780634378u,
-2842141483u, 4029205195u,
-1656892865u, 3330993377u,
-80890710u, 1953796601u,
-3873078673u, 136118734u,
-2317676604u, 4199091610u,
-1864448181u, 3063437608u,
-1699452298u, 1403506686u,
-1513069466u, 2348491299u,
-4273657745u, 4055855649u,
-1805475756u, 2562064338u,
-973124563u, 4197091358u,
-172861513u, 2858726767u,
-4271866024u, 3071338162u,
-3590386266u, 2328277259u,
-1096050703u, 1189614342u,
-459509140u, 771592405u,
-817999971u, 3740825152u,
-520400189u, 1941874618u,
-185232757u, 4032960199u,
-3928245258u, 3527721294u,
-1301118856u, 752188080u,
-3512945009u, 308584855u,
-2105373972u, 752872278u,
-3823368815u, 3760952096u,
-4250142168u, 2565680167u,
-3646354146u, 1259957455u,
-1085857127u, 3471066607u,
-38924274u, 3770488806u,
-1083869477u, 3312508103u,
-71956383u, 3738784936u,
-3099963860u, 1255084262u,
-4286969992u, 3621849251u,
-1190908967u, 1831557743u,
-2363435042u, 54945052u,
-4059585566u, 4023974274u,
-1788578453u, 3442180039u,
-2534883189u, 2432427547u,
-3909757989u, 731996369u,
-4168347425u, 1356028512u,
-2741583197u, 1280920000u,
-312887059u, 3259015297u,
-3946278527u, 4135481831u,
-1281043691u, 1121403845u,
-3312292477u, 1819941269u,
-1741932545u, 3293015483u,
-2127558730u, 713121337u,
-2635469238u, 486003418u,
-4015067527u, 2976737859u,
-2108187161u, 927011680u,
-1970188338u, 4177613234u,
-1799789551u, 2118505126u,
-4134691985u, 1958963937u,
-1929210029u, 2555835851u,
-2768832862u, 910892050u,
-2567532373u, 4075249328u,
-86689814u, 3726640307u,
-1392137718u, 1240000030u,
-4104757832u, 3026358429u,
-313797689u, 1435798509u,
-3101500919u, 1241665335u,
-3573008472u, 3615577014u,
-3767659003u, 3134294021u,
-4063565523u, 2296824134u,
-1541946015u, 3087190425u,
-2693152531u, 2199672572u,
-2123763822u, 1034244398u,
-857839960u, 2515339233u,
-2228007483u, 1628096047u,
-2116502287u, 2502657424u,
-2809830736u, 460237542u,
-450205998u, 3646921704u,
-3818199357u, 1808504491u,
-1950698961u, 2069753399u,
-3657033172u, 3734547671u,
-4067859590u, 3292597295u,
-1106466069u, 356742959u,
-2469567432u, 3495418823u,
-183440071u, 3248055817u,
-3662626864u, 1750561299u,
-3926138664u, 4088592524u,
-567122118u, 3810297651u,
-992181339u, 3384018814u,
-3272124369u, 3177596743u,
-320086295u, 2316548367u,
-100741310u, 451656820u,
-4086604273u, 3759628395u,
-2553391092u, 1745659881u,
-3650357479u, 2390172694u,
-330172533u, 767377322u,
-526742034u, 4102497288u,
-2088767754u, 164402616u,
-2482632320u, 2352347393u,
-1873658044u, 3861555476u,
-2751052984u, 1767810825u,
-20037241u, 545143220u,
-2594532522u, 472304191u,
-3441135892u, 3323383489u,
-258785117u, 2977745165u,
-2781737565u, 2963590112u,
-2756998822u, 207428029u,
-2581558559u, 3824717027u,
-1258619503u, 3472047571u,
-2648427775u, 2360400900u,
-2393763818u, 2332399088u,
-3932701729u, 884421165u,
-1396468647u, 1377764574u,
-4061795938u, 1559119087u,
-3343596838u, 3604258095u,
-1435134775u, 1099809675u,
-908163739u, 1418405656u,
-368446627u, 3741651161u,
-3374512975u, 3542220540u,
-3244772570u, 200009340u,
-3198975081u, 2521038253u,
-4081637863u, 337070226u,
-3235259030u, 3897262827u,
-736956644u, 641040550u,
-644850146u, 1306761320u,
-4219448634u, 193750500u,
-3293278106u, 1383997679u,
-1242645122u, 4109252858u,
-450747727u, 3716617561u,
-362725793u, 2252520167u,
-3377483696u, 1788337208u,
-8130777u, 3226734120u,
-759239140u, 1012411364u,
-1658628529u, 2911512007u,
-1002580201u, 1681898320u,
-3039016929u, 4294520281u,
-367022558u, 3071359622u,
-3205848570u, 152989999u,
-3839042136u, 2357687350u,
-4273132307u, 3898950547u,
-1176841812u, 1314157485u,
-75443951u, 1027027239u,
-1858986613u, 2040551642u,
-36574105u, 2603059541u,
-3456147251u, 2137668425u,
-4077477194u, 3565689036u,
-491832241u, 363703593u,
-2579177168u, 3589545214u,
-265993036u, 1864569342u,
-4149035573u, 3189253455u,
-1072259310u, 3153745937u,
-923017956u, 490608221u,
-855846773u, 845706553u,
-1018226240u, 1604548872u,
-3833372385u, 3287246572u,
-2757959551u, 2452872151u,
-1553870564u, 1713154780u,
-2649450292u, 500120236u,
-84251717u, 661869670u,
-1444911517u, 2489716881u,
-2810524030u, 1561519055u,
-3884088359u, 2509890699u,
-4247155916u, 1005636939u,
-3224066062u, 2774151984u,
-2035978240u, 2514910366u,
-1478837908u, 3144450144u,
-2107011431u, 96459446u,
-3587732908u, 2389230590u,
-3287635953u, 250533792u,
-1235983679u, 4237425634u,
-3704645833u, 3882376657u,
-2976369049u, 1187061987u,
-276949224u, 4100839753u,
-1698347543u, 1629662314u,
-1556151829u, 3784939568u,
-427484362u, 4246879223u,
-3155311770u, 4285163791u,
-1693376813u, 124492786u,
-1858777639u, 3476334357u,
-1941442701u, 1121980173u,
-3485932087u, 820852908u,
-358032121u, 2511026735u,
-1873607283u, 2556067450u,
-2248275536u, 1528632094u,
-1535473864u, 556796152u,
-1499201704u, 1472623890u,
-1526518503u, 3692729434u,
-1476438092u, 2913077464u,
-335109599u, 2167614601u,
-4121131078u, 3158127917u,
-3051522276u, 4046477658u,
-2857717851u, 1863977403u,
-1341023343u, 692059110u,
-1802040304u, 990407433u,
-3285847572u, 319814144u,
-561105582u, 1540183799u,
-4052924496u, 2926590471u,
-2244539806u, 439121871u,
-3317903224u, 3178387550u,
-4265214507u, 82077489u,
-1978918971u, 4279668976u,
-128732476u, 2853224222u,
-464407878u, 4190838199u,
-997819001u, 3250520802u,
-2330081301u, 4095846095u,
-733509243u, 1583801700u,
-722314527u, 3552883023u,
-1403784280u, 432327540u,
-1877837196u, 3912423882u,
-505219998u, 696031431u,
-908238873u, 4189387259u,
-8759461u, 2540185277u,
-3385159748u, 381355877u,
-2519951681u, 1679786240u,
-2019419351u, 4051584612u,
-1933923923u, 3768201861u,
-1670133081u, 3454981037u,
-700836153u, 1675560450u,
-371560700u, 338262316u,
-847351840u, 2222395828u,
-3130433948u, 405251683u,
-3037574880u, 184098830u,
-453340528u, 1385561439u,
-2224044848u, 4071581802u,
-1431235296u, 5570097u,
-570114376u, 2287305551u,
-2272418128u, 803575837u,
-3943113491u, 414959787u,
-708083137u, 2452657767u,
-4019147902u, 3841480082u,
-3791794715u, 2965956183u,
-2763690963u, 2350937598u,
-3424361375u, 779434428u,
-1274947212u, 686105485u,
-3426668051u, 3692865672u,
-3057021940u, 2285701422u,
-349809124u, 1379278508u,
-3623750518u, 215970497u,
-1783152480u, 823305654u,
-216118434u, 1787189830u,
-3692048450u, 2272612521u,
-3032187389u, 4159715581u,
-1388133148u, 1611772864u,
-2544383526u, 552925303u,
-3420960112u, 3198900547u,
-3503230228u, 2603352423u,
-2318375898u, 4064071435u,
-3006227299u, 4194096960u,
-1283392422u, 1510460996u,
-174272138u, 3671038966u,
-1775955687u, 1719108984u,
-1763892006u, 1385029063u,
-4083790740u, 406757708u,
-684087286u, 531310503u,
-3329923157u, 3492083607u,
-1059031410u, 3037314475u,
-3105682208u, 3382290593u,
-2292208503u, 426380557u,
-97373678u, 3842309471u,
-777173623u, 3241407531u,
-303065016u, 1477104583u,
-4234905200u, 2512514774u,
-2649684057u, 1397502982u,
-1802596032u, 3973022223u,
-2543566442u, 3139578968u,
-3193669211u, 811750340u,
-4013496209u, 567361887u,
-4169410406u, 3622282782u,
-3403136990u, 2540585554u,
-895210040u, 3862229802u,
-1145435213u, 4146963980u,
-784952939u, 943914610u,
-573034522u, 464420660u,
-2356867109u, 3054347639u,
-3985088434u, 1911188923u,
-583391304u, 176468511u,
-2990150068u, 2338031599u,
-519948041u, 3181425568u,
-496106033u, 4110294665u,
-2736756930u, 1196757691u,
-1089679033u, 240953857u,
-3399092928u, 4040779538u,
-2843673626u, 240495962u,
-3017658263u, 3828377737u,
-4243717901u, 2448373688u,
-2759616657u, 2246245780u,
-308018483u, 4262383425u,
-2731780771u, 328023017u,
-2884443148u, 841480070u,
-3188015819u, 4051263539u,
-2298178908u, 2944209234u,
-1372958390u, 4164532914u,
-4074952232u, 1683612329u,
-2155036654u, 1872815858u,
-2041174279u, 2368092311u,
-206775997u, 2283918569u,
-645945606u, 115406202u,
-4206471368u, 3923500892u,
-2217060665u, 350160869u,
-706531239u, 2824302286u,
-509981657u, 1469342315u,
-140980u, 1891558063u,
-164887091u, 3094962711u,
-3437115622u, 13327420u,
-422986366u, 330624974u,
-3630863408u, 2425505046u,
-824008515u, 3543885677u,
-918718096u, 376390582u,
-3224043675u, 3724791476u,
-1837192976u, 2968738516u,
-3424344721u, 3187805406u,
-1550978788u, 1743089918u,
-4251270061u, 645016762u,
-3855037968u, 1928519266u,
-1373803416u, 2289007286u,
-1889218686u, 1610271373u,
-3059200728u, 2108753646u,
-582042641u, 812347242u,
-3188172418u, 191994904u,
-1343511943u, 2247006571u,
-463291708u, 2697254095u,
-1534175504u, 1106275740u,
-622521957u, 917121602u,
-4095777215u, 3955972648u,
-3852234638u, 2845309942u,
-3299763344u, 2864033668u,
-2554947496u, 799569078u,
-2551629074u, 1102873346u,
-2661022773u, 2006922227u,
-2900438444u, 1448194126u,
-1321567432u, 1983773590u,
-1237256330u, 3449066284u,
-1691553115u, 3274671549u,
-4271625619u, 2741371614u,
-3285899651u, 786322314u,
-1586632825u, 564385522u,
-2530557509u, 2974240289u,
-1244759631u, 3263135197u,
-3592389776u, 3570296884u,
-2749873561u, 521432811u,
-987586766u, 3206261120u,
-1327840078u, 4078716491u,
-1753812954u, 976892272u,
-1827135136u, 1781944746u,
-1328622957u, 1015377974u,
-3439601008u, 2209584557u,
-2482286699u, 1109175923u,
-874877499u, 2036083451u,
-483570344u, 1091877599u,
-4190721328u, 1129462471u,
-640035849u, 1867372700u,
-920761165u, 3273688770u,
-1623777358u, 3389003793u,
-3241132743u, 2734783008u,
-696674661u, 2502161880u,
-1646071378u, 1164309901u,
-350411888u, 1978005963u,
-2253937037u, 7371540u,
-989577914u, 3626554867u,
-3214796883u, 531343826u,
-398899695u, 1145247203u,
-1516846461u, 3656006011u,
-529303412u, 3318455811u,
-3062828129u, 1696355359u,
-3698796465u, 3155218919u,
-1457595996u, 3191404246u,
-1395609912u, 2917345728u,
-1237411891u, 1854985978u,
-1091884675u, 3504488111u,
-3109924189u, 1628881950u,
-3939149151u, 878608872u,
-778235395u, 1052990614u,
-903730231u, 2069566979u,
-2437686324u, 3163786257u,
-2257884264u, 2123173186u,
-939764916u, 2933010098u,
-1235300371u, 1256485167u,
-1950274665u, 2180372319u,
-2648400302u, 122035049u,
-1883344352u, 2083771672u,
-3712110541u, 321199441u,
-1896357377u, 508560958u,
-3066325351u, 2770847216u,
-3177982504u, 296902736u,
-1486926688u, 456842861u,
-601221482u, 3992583643u,
-2794121515u, 1533934172u,
-1706465470u, 4281971893u,
-2557027816u, 900741486u,
-227175484u, 550595824u,
-690918144u, 2825943628u,
-90375300u, 300318232u,
-1985329734u, 1440763373u,
-3670603707u, 2533900859u,
-3253901179u, 542270815u,
-3677388841u, 307706478u,
-2570910669u, 3320103693u,
-1273768482u, 1216399252u,
-1652924805u, 1043647584u,
-1120323676u, 639941430u,
-325675502u, 3652676161u,
-4241680335u, 1545838362u,
-1991398008u, 4100211814u,
-1097584090u, 3262252593u,
-2254324292u, 1765019121u,
-4060211241u, 2315856188u,
-3704419305u, 411263051u,
-238929055u, 3540688404u,
-3094544537u, 3250435765u,
-3460621305u, 1967599860u,
-2016157366u, 847389916u,
-1659615591u, 4020453639u,
-901109753u, 2682611693u,
-1661364280u, 177155177u,
-3210561911u, 3802058181u,
-797089608u, 3286110054u,
-2110358240u, 1353279028u,
-2479975820u, 471725410u,
-2219863904u, 3623364733u,
-3167128228u, 1052188336u,
-3656587111u, 721788662u,
-3061255808u, 1615375832u,
-924941453u, 2547780700u,
-3328169224u, 1310964134u,
-2701956286u, 4145497671u,
-1421461094u, 1221397398u,
-1589183618u, 1492533854u,
-449740816u, 2686506989u,
-3035198924u, 1682886232u,
-2529760244u, 3342031659u,
-1235084019u, 2151665147u,
-2315686577u, 3282027660u,
-1140138691u, 2754346599u,
-2091754612u, 1178454681u,
-4226896579u, 2942520471u,
-2122168506u, 3751680858u,
-3213794286u, 2601416506u,
-4142747914u, 3951404257u,
-4243249649u, 748595836u,
-4004834921u, 238887261u,
-1927321047u, 2217148444u,
-205977665u, 1885975275u,
-186020771u, 2367569534u,
-2941662631u, 2608559272u,
-3342096731u, 741809437u,
-1962659444u, 3539886328u,
-3036596491u, 2282550094u,
-2366462727u, 2748286642u,
-2144472852u, 1390394371u,
-1257385924u, 2205425874u,
-2119055686u, 46865323u,
-3597555910u, 3188438773u,
-2372320753u, 3641116924u,
-3116286108u, 2680722658u,
-3371014971u, 2058751609u,
-2966943726u, 2345078707u,
-2330535244u, 4013841927u,
-1169588594u, 857915866u,
-1875260989u, 3175831309u,
-3193475664u, 1955181430u,
-923161569u, 4068653043u,
-776445899u, 954196929u,
-61509556u, 4248237857u,
-3808667664u, 581227317u,
-2893240187u, 4159497403u,
-4212264930u, 3973886195u,
-2077539039u, 851579036u,
-2957587591u, 772351886u,
-1173659554u, 946748363u,
-2794103714u, 2094375930u,
-4234750213u, 3671645488u,
-2614250782u, 2620465358u,
-3122317317u, 2365436865u,
-3393973390u, 523513960u,
-3645735309u, 2766686992u,
-2023960931u, 2312244996u,
-1875932218u, 3253711056u,
-3622416881u, 3274929205u,
-612094988u, 1555465129u,
-2114270406u, 3553762793u,
-1832633644u, 1087551556u,
-3306195841u, 1702313921u,
-3675066046u, 1735998785u,
-1690923980u, 1482649756u,
-1171351291u, 2043136409u,
-1962596992u, 461214626u,
-3278253346u, 1392428048u,
-3744621107u, 1028502697u,
-3991171462u, 1014064003u,
-3642345425u, 3186995039u,
-6114625u, 3359104346u,
-414856965u, 2814387514u,
-3583605071u, 2497896367u,
-1024572712u, 1927582962u,
-2892797583u, 845302635u,
-328548052u, 1523379748u,
-3392622118u, 1347167673u,
-1012316581u, 37767602u,
-2647726017u, 1070326065u,
-2075035198u, 4202817168u,
-2502924707u, 2612406822u,
-2187115553u, 1180137213u,
-701024148u, 1481965992u,
-3223787553u, 2083541843u,
-203230202u, 3876887380u,
-1334816273u, 2870251538u,
-2186205850u, 3985213979u,
-333533378u, 806507642u,
-1010064531u, 713520765u,
-3084131515u, 2637421459u,
-1703168933u, 1517562266u,
-4089081247u, 3231042924u,
-3079916123u, 3154574447u,
-2253948262u, 1725190035u,
-2452539325u, 1343734533u,
-213706059u, 2519409656u,
-108055211u, 2916327746u,
-587001593u, 1917607088u,
-4202913084u, 926304016u,
-469255411u, 4042080256u,
-3498936874u, 246692543u,
-495780578u, 438717281u,
-2259272650u, 4011324645u,
-2836854664u, 2317249321u,
-946828752u, 1280403658u,
-1905648354u, 2034241661u,
-774652981u, 1285694082u,
-2200307766u, 2158671727u,
-1135162148u, 232040752u,
-397012087u, 1717527689u,
-1720414106u, 918797022u,
-2580119304u, 3568069742u,
-2904461070u, 3893453420u,
-973817938u, 667499332u,
-3785870412u, 2088861715u,
-1565179401u, 600903026u,
-591806775u, 3512242245u,
-997964515u, 2339605347u,
-1134342772u, 3234226304u,
-4084179455u, 302315791u,
-2445626811u, 2590372496u,
-345572299u, 2274770442u,
-3600587867u, 3706939009u,
-1430507980u, 2656330434u,
-1079209397u, 2122849632u,
-1423705223u, 3826321888u,
-3683385276u, 1057038163u,
-1242840526u, 3987000643u,
-2398253089u, 1538190921u,
-1295898647u, 3570196893u,
-3065138774u, 3111336863u,
-2524949549u, 4203895425u,
-3025864372u, 968800353u,
-1023721001u, 3763083325u,
-526350786u, 635552097u,
-2308118370u, 2166472723u,
-2196937373u, 2643841788u,
-3040011470u, 4010301879u,
-2782379560u, 3474682856u,
-4201389782u, 4223278891u,
-1457302296u, 2251842132u,
-1090062008u, 3188219189u,
-292733931u, 1424229089u,
-1590782640u, 1365212370u,
-3975957073u, 3982969588u,
-2927147928u, 1048291071u,
-2766680094u, 884908196u,
-35237839u, 2221180633u,
-2490333812u, 4098360768u,
-4029081103u, 3490831871u,
-2392516272u, 3455379186u,
-3948800722u, 335456628u,
-2105117968u, 4181629008u,
-1044201772u, 3335754111u,
-540133451u, 3313113759u,
-3786107905u, 2627207327u,
-3540337875u, 3473113388u,
-3430536378u, 2514123129u,
-2124531276u, 3872633376u,
-3272957388u, 3501994650u,
-2418881542u, 487365389u,
-3877672368u, 1512866656u,
-3486531087u, 2102955203u,
-1136054817u, 3004241477u,
-1549075351u, 1302002008u,
-3936430045u, 2258587644u,
-4109233936u, 3679809321u,
-3467083076u, 2484463221u,
-1594979755u, 529218470u,
-3527024461u, 1147434678u,
-106799023u, 1823161970u,
-1704656738u, 1675883700u,
-3308746763u, 1875093248u,
-1352868568u, 1898561846u,
-2508994984u, 3177750780u,
-4217929592u, 400784472u,
-80090315u, 3564414786u,
-3841585648u, 3379293868u,
-160353261u, 2413172925u,
-2378499279u, 673436726u,
-1505702418u, 1330977363u,
-1853298225u, 3201741245u,
-2135714208u, 4069554166u,
-3715612384u, 3692488887u,
-3680311316u, 4274382900u,
-914186796u, 2264886523u,
-3869634032u, 1254199592u,
-1131020455u, 194781179u,
-429923922u, 2763792336u,
-2052895198u, 3997373194u,
-3440090658u, 2165746386u,
-1575500242u, 3463310191u,
-2064974716u, 3779513671u,
-3106421434u, 880320527u,
-3281914119u, 286569042u,
-3909096631u, 122359727u,
-1429837716u, 252230074u,
-4111461225u, 762273136u,
-93658514u, 2766407143u,
-3623657004u, 3869801679u,
-3925695921u, 2390397316u,
-2499025338u, 2741806539u,
-2507199021u, 1659221866u,
-361292116u, 4048761557u,
-3797133396u, 1517903247u,
-3121647246u, 3884308578u,
-1697201500u, 1558800262u,
-4150812360u, 3161302278u,
-2610217849u, 641564641u,
-183814518u, 2075245419u,
-611996508u, 2223461433u,
-329123979u, 121860586u,
-860985829u, 1137889144u,
-4018949439u, 2904348960u,
-947795261u, 1992594155u,
-4255427501u, 2281583851u,
-2892637604u, 1478186924u,
-3050771207u, 2767035539u,
-373510582u, 1963520320u,
-3763848370u, 3756817798u,
-627269409u, 1806905031u,
-1814444610u, 3646665053u,
-1822693920u, 278515794u,
-584050483u, 4142579188u,
-2149745808u, 3193071606u,
-1179706341u, 2693495182u,
-3259749808u, 644172091u,
-880509048u, 3340630542u,
-3365160815u, 2384445068u,
-3053081915u, 2840648309u,
-1986990122u, 1084703471u,
-2370410550u, 1627743573u,
-2244943480u, 4057483496u,
-2611595995u, 2470013639u,
-4024732359u, 3987190386u,
-873421687u, 2447660175u,
-3226583022u, 767655877u,
-2528024413u, 1962070688u,
-1233635843u, 2163464207u,
-659054446u, 854207134u,
-258410943u, 4197831420u,
-2515400215u, 3100476924u,
-1961549594u, 2219491151u,
-3997658851u, 163850514u,
-470325051u, 2598261204u,
-3052145580u, 59836528u,
-1376188597u, 966733415u,
-850667549u, 3622479237u,
-1083731990u, 1525777459u,
-4005126532u, 1428155540u,
-2781907007u, 943739431u,
-1493961005u, 2839096988u,
-2000057832u, 1941829603u,
-1901484772u, 939810041u,
-3377407371u, 3090115837u,
-3310840540u, 2068409688u,
-3261383939u, 2212130277u,
-2594774045u, 2912652418u,
-4179816101u, 3534504531u,
-3349254805u, 2796552902u,
-1385421283u, 4259908631u,
-3714780837u, 3070073945u,
-3372846298u, 3835884044u,
-3047965714u, 3009018735u,
-744091167u, 1861124263u,
-2764936304u, 1338171648u,
-4222019554u, 1395200692u,
-1371426007u, 3338031581u,
-2525665319u, 4196233786u,
-2332743921u, 1474702008u,
-2274266301u, 4255175517u,
-2290169528u, 1793910997u,
-2188254024u, 354202001u,
-3864458796u, 4280290498u,
-1554419340u, 1733094688u,
-2010552302u, 1561807039u,
-664313606u, 2548990879u,
-1084699349u, 3233936866u,
-973895284u, 2386881969u,
-1831995860u, 2961465052u,
-1428704144u, 3269904970u,
-231648253u, 2602483763u,
-4125013173u, 3319187387u,
-3347011944u, 1892898231u,
-4019114049u, 868879116u,
-4085937045u, 2378411019u,
-1072588531u, 3547435717u,
-2208070766u, 1069899078u,
-3142980597u, 2337088907u,
-1593338562u, 919414554u,
-688077849u, 3625708135u,
-1472447348u, 1947711896u,
-3953006207u, 877438080u,
-845995820u, 3150361443u,
-3053496713u, 2484577841u,
-224271045u, 2914958001u,
-2682612949u, 806655563u,
-2436224507u, 1907729235u,
-2920583824u, 1251814062u,
-2070814520u, 4034325578u,
-497847539u, 2714317144u,
-385182008u, 640855184u,
-1327075087u, 1062468773u,
-1757405994u, 1374270191u,
-4263183176u, 3041193150u,
-1037871524u, 3633173991u,
-4231821821u, 2830131945u,
-3505072908u, 2830570613u,
-4195208715u, 575398021u,
-3992840257u, 3691788221u,
-1949847968u, 2999344380u,
-3183782163u, 3723754342u,
-759716128u, 3284107364u,
-1714496583u, 15918244u,
-820509475u, 2553936299u,
-2201876606u, 4237151697u,
-2605688266u, 3253705097u,
-1008333207u, 712158730u,
-1722280252u, 1933868287u,
-4152736859u, 2097020806u,
-584426382u, 2836501956u,
-2522777566u, 1996172430u,
-2122199776u, 1069285218u,
-1474209360u, 690831894u,
-107482532u, 3695525410u,
-670591796u, 768977505u,
-2412057331u, 3647886687u,
-3110327607u, 1072658422u,
-379861934u, 1557579480u,
-4124127129u, 2271365865u,
-3880613089u, 739218494u,
-547346027u, 388559045u,
-3147335977u, 176230425u,
-3094853730u, 2554321205u,
-1495176194u, 4093461535u,
-3521297827u, 4108148413u,
-1913727929u, 1177947623u,
-1911655402u, 1053371241u,
-3265708874u, 1266515850u,
-1045540427u, 3194420196u,
-3717104621u, 1144474110u,
-1464392345u, 52070157u,
-4144237690u, 3350490823u,
-4166253320u, 2747410691u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; { uint64_t h = farmhashna::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
-{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint64_t h = farmhashna::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashnaTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint64_t h = farmhashna::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashnaTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashnaTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashnaTest::Dump(0, i);
- }
- farmhashnaTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashntTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-2681724312u,
-797982799u,
-921001710u,
-2134990486u,
-2244477846u,
-2992121793u,
-3943596029u,
-452431531u,
-2557197665u,
-2532580744u,
-3099673830u,
-3696623795u,
-3281581178u,
-1882212500u,
-275903667u,
-3033004529u,
-1402319660u,
-2699376854u,
-4222949502u,
-1712034059u,
-1330324210u,
-2921867846u,
-1728752234u,
-326029180u,
-3349570000u,
-1612122221u,
-1646032583u,
-1432476832u,
-3552092450u,
-1499109081u,
-1554038301u,
-3190844552u,
-540224401u,
-489963606u,
-1562872448u,
-2128624475u,
-1262831810u,
-1672724608u,
-2077310004u,
-1911523866u,
-294527927u,
-1389770549u,
-2026137563u,
-629449419u,
-2489287368u,
-645684964u,
-230403464u,
-3272648435u,
-165370827u,
-1230085527u,
-3628174014u,
-851743255u,
-1554380634u,
-3667013118u,
-2290487377u,
-1909203251u,
-1498556724u,
-4165088768u,
-197618179u,
-914413116u,
-1913303225u,
-3117299654u,
-1357272220u,
-507436733u,
-1413396341u,
-146044391u,
-429095991u,
-3056862311u,
-366414107u,
-2293458109u,
-1684583131u,
-1170404994u,
-520792961u,
-1577421232u,
-4033596884u,
-4229339322u,
-3242407770u,
-2649785113u,
-816692935u,
-3555213933u,
-517646945u,
-2180594090u,
-3047062993u,
-2391606125u,
-382936554u,
-788479970u,
-2826990641u,
-3167748333u,
-1758123094u,
-389974094u,
-3338548567u,
-2583576230u,
-3198590202u,
-4155628142u,
-542201663u,
-2856634168u,
-3948351189u,
-4194218315u,
-1467786451u,
-2743592929u,
-1062268187u,
-3810665822u,
-2560479831u,
-997658837u,
-3067277639u,
-1211737169u,
-59581167u,
-1389679610u,
-4189944477u,
-100876854u,
-2062343506u,
-3088828656u,
-3284356565u,
-3130054947u,
-3532596884u,
-3887208531u,
-259034107u,
-3233195759u,
-3200749877u,
-760633989u,
-1115203611u,
-1516407838u,
-1778459926u,
-2146672889u,
-2457048126u,
-2217471853u,
-862072556u,
-3745267835u,
-701920051u,
-581695350u,
-1410111809u,
-3326135446u,
-2187968410u,
-4267859263u,
-479241367u,
-2868987960u,
-704325635u,
-1418509533u,
-735688735u,
-3283299459u,
-813690332u,
-1439630796u,
-3195309868u,
-1616408198u,
-3254795114u,
-2799925823u,
-3929484338u,
-1798536177u,
-4205965408u,
-1499475160u,
-4247675634u,
-3779953975u,
-785893184u,
-2778575413u,
-1160134629u,
-823113169u,
-4116162021u,
-4167766971u,
-2487440590u,
-4004655503u,
-4044418876u,
-1462554406u,
-2011102035u,
-4265993528u,
-576405853u,
-4038839101u,
-2425317635u,
-1401013391u,
-3062418115u,
-3167030094u,
-2602636307u,
-4264167741u,
-4017058800u,
-1029665228u,
-4036354071u,
-2670703363u,
-688472265u,
-1054670286u,
-338058159u,
-1539305024u,
-146827036u,
-4060134777u,
-2502815838u,
-1603444633u,
-2448966429u,
-3891353218u,
-1082330589u,
-201837927u,
-2848283092u,
-883849006u,
-1982110346u,
-541496720u,
-133643215u,
-3847827123u,
-4015671361u,
-2849988118u,
-3452457457u,
-2102063419u,
-3281002516u,
-1539151988u,
-1147951686u,
-2005032160u,
-2415262714u,
-116647396u,
-1029284767u,
-2159170082u,
-1919171906u,
-2017579106u,
-2473524405u,
-1694443528u,
-3671562289u,
-505662155u,
-1019936943u,
-1511077569u,
-773792826u,
-2089123665u,
-484732447u,
-1120017626u,
-2809286837u,
-4029205195u,
-1097806406u,
-136118734u,
-4017075736u,
-1403506686u,
-1516736273u,
-2562064338u,
-2984955003u,
-3071338162u,
-1923531348u,
-771592405u,
-2586632018u,
-4032960199u,
-2687561076u,
-308584855u,
-1692079268u,
-2565680167u,
-3674576684u,
-3770488806u,
-69201295u,
-1255084262u,
-3593730713u,
-54945052u,
-1939595371u,
-2432427547u,
-2295501078u,
-1280920000u,
-82177963u,
-1121403845u,
-2889101923u,
-713121337u,
-1747052377u,
-927011680u,
-4142246789u,
-1958963937u,
-1636932722u,
-4075249328u,
-2025886508u,
-3026358429u,
-1845587644u,
-3615577014u,
-1363253259u,
-3087190425u,
-341851980u,
-2515339233u,
-1276595523u,
-460237542u,
-4198897105u,
-2069753399u,
-4278599955u,
-356742959u,
-3735275001u,
-1750561299u,
-668829411u,
-3384018814u,
-4233785523u,
-451656820u,
-107312677u,
-2390172694u,
-1216645846u,
-164402616u,
-1689811113u,
-1767810825u,
-1397772514u,
-3323383489u,
-2986430557u,
-207428029u,
-2260498180u,
-2360400900u,
-1263709570u,
-1377764574u,
-4252610345u,
-1099809675u,
-2776960536u,
-3542220540u,
-3752806924u,
-337070226u,
-3267551635u,
-1306761320u,
-2220373824u,
-4109252858u,
-896322512u,
-1788337208u,
-1336556841u,
-2911512007u,
-3712582785u,
-3071359622u,
-2561488770u,
-3898950547u,
-536047554u,
-2040551642u,
-3528794619u,
-3565689036u,
-1197100813u,
-1864569342u,
-3329594980u,
-490608221u,
-1174785921u,
-3287246572u,
-2163330264u,
-500120236u,
-2520062970u,
-1561519055u,
-4042710240u,
-2774151984u,
-3160666939u,
-96459446u,
-1878067032u,
-4237425634u,
-2952135524u,
-4100839753u,
-1265237690u,
-4246879223u,
-834830418u,
-3476334357u,
-4277111759u,
-2511026735u,
-3065234219u,
-556796152u,
-198182691u,
-2913077464u,
-1535115487u,
-4046477658u,
-140762681u,
-990407433u,
-2198985327u,
-2926590471u,
-559702706u,
-82077489u,
-1096697687u,
-4190838199u,
-3046872820u,
-1583801700u,
-2185339100u,
-3912423882u,
-3703603898u,
-2540185277u,
-1446869792u,
-4051584612u,
-2719373510u,
-1675560450u,
-1996164093u,
-405251683u,
-2864244470u,
-4071581802u,
-2028708916u,
-803575837u,
-557660441u,
-3841480082u,
-255451671u,
-779434428u,
-3452203069u,
-2285701422u,
-1568745354u,
-823305654u,
-3184047862u,
-4159715581u,
-3160134214u,
-3198900547u,
-1566527339u,
-4194096960u,
-1496132623u,
-1719108984u,
-2584236470u,
-531310503u,
-3456882941u,
-3382290593u,
-467441309u,
-3241407531u,
-2540270567u,
-1397502982u,
-3348545480u,
-811750340u,
-1017047954u,
-2540585554u,
-3531646869u,
-943914610u,
-1903578924u,
-1911188923u,
-241574049u,
-3181425568u,
-3529565564u,
-240953857u,
-2964595704u,
-3828377737u,
-4260564140u,
-4262383425u,
-383233885u,
-4051263539u,
-919677938u,
-1683612329u,
-4204155962u,
-2283918569u,
-4153726847u,
-350160869u,
-1387233546u,
-1891558063u,
-740563169u,
-330624974u,
-2948665536u,
-376390582u,
-3799363969u,
-3187805406u,
-2263421398u,
-1928519266u,
-2746577402u,
-2108753646u,
-768287270u,
-2247006571u,
-212490675u,
-917121602u,
-2549835613u,
-2864033668u,
-3738062408u,
-2006922227u,
-2616619070u,
-3449066284u,
-431292293u,
-786322314u,
-1415970351u,
-3263135197u,
-2954777083u,
-3206261120u,
-2287507921u,
-1781944746u,
-4081586725u,
-1109175923u,
-1813855658u,
-1129462471u,
-1037031473u,
-3389003793u,
-3122687303u,
-1164309901u,
-3193251135u,
-3626554867u,
-3071568023u,
-3656006011u,
-1167681812u,
-3155218919u,
-2704165015u,
-1854985978u,
-1712976649u,
-878608872u,
-4155949943u,
-3163786257u,
-1626463554u,
-1256485167u,
-582664250u,
-2083771672u,
-804336148u,
-2770847216u,
-1674051445u,
-3992583643u,
-2966108111u,
-900741486u,
-4014551783u,
-300318232u,
-3517585534u,
-542270815u,
-760762191u,
-1216399252u,
-643179562u,
-3652676161u,
-2990167340u,
-3262252593u,
-2134299399u,
-411263051u,
-1342880802u,
-1967599860u,
-853593042u,
-2682611693u,
-850464484u,
-3286110054u,
-3842907484u,
-3623364733u,
-3693536939u,
-1615375832u,
-2318423400u,
-4145497671u,
-1728968857u,
-2686506989u,
-1502282913u,
-2151665147u,
-3651607391u,
-1178454681u,
-4146839064u,
-2601416506u,
-1448097974u,
-238887261u,
-4093725287u,
-2367569534u,
-679517009u,
-3539886328u,
-3086277222u,
-1390394371u,
-119173722u,
-1766260771u,
-751439914u,
-215917713u,
-2656990891u,
-1570750352u,
-3533987737u,
-3576119563u,
-963183826u,
-3796810515u,
-136547246u,
-2592925324u,
-427154472u,
-1228758574u,
-1464255968u,
-2984611177u,
-2001585786u,
-1525438381u,
-1348536411u,
-2861338018u,
-764077711u,
-3785343245u,
-457568934u,
-4104954272u,
-2381948487u,
-3148473363u,
-2180270337u,
-1387729170u,
-951677556u,
-2721005055u,
-66786703u,
-1149351924u,
-1895026827u,
-3711056516u,
-3638638708u,
-2263003308u,
-3448840877u,
-225333538u,
-3797521928u,
-3262952567u,
-2078619498u,
-1178073973u,
-3288261538u,
-1496966875u,
-2481012988u,
-114945840u,
-1632780103u,
-2087949619u,
-3787017905u,
-2575395164u,
-2971726178u,
-3642087909u,
-3894199764u,
-203853421u,
-425935223u,
-3565833278u,
-1748785729u,
-580966986u,
-2124704694u,
-1107045577u,
-1067532701u,
-1406028344u,
-18613994u,
-3476683808u,
-3762914298u,
-1844996900u,
-904215228u,
-1118521573u,
-3657647605u,
-3136157065u,
-2287683323u,
-126005630u,
-3555092974u,
-49515858u,
-1010661841u,
-1902040126u,
-1400735275u,
-2771676666u,
-2225229957u,
-3454177594u,
-2883475137u,
-4144472319u,
-1051332394u,
-542648229u,
-1669710469u,
-553041029u,
-584127807u,
-2993670925u,
-3587959456u,
-1745399498u,
-1404723176u,
-1334333531u,
-3239516985u,
-1275954779u,
-367320647u,
-3684418197u,
-4030809053u,
-484559105u,
-4255931645u,
-4271715616u,
-3171911678u,
-928543347u,
-2159512867u,
-313902234u,
-647086234u,
-577214736u,
-1130129573u,
-995791646u,
-1645086060u,
-4122335794u,
-1064648931u,
-2752145076u,
-3312498873u,
-4238535494u,
-1471227427u,
-633688562u,
-1959779970u,
-766642813u,
-1380896111u,
-3647601207u,
-1733961041u,
-521947915u,
-189164145u,
-486382294u,
-3770038872u,
-3235740744u,
-1912506671u,
-2276864677u,
-1588060152u,
-2504457929u,
-1471020554u,
-3623212998u,
-3026631806u,
-2342164722u,
-1674890530u,
-3011542850u,
-3549160092u,
-4290680005u,
-3943068002u,
-2273781461u,
-2127663659u,
-1646681121u,
-447810651u,
-2366308558u,
-970504950u,
-2008155560u,
-2695940969u,
-3444688454u,
-1739318893u,
-2683090634u,
-2774816580u,
-437560100u,
-512012738u,
-3305170944u,
-665292744u,
-3580039116u,
-1579404983u,
-3397891494u,
-710590371u,
-2514565805u,
-3624609754u,
-3516075816u,
-1314000850u,
-1935166880u,
-3257747610u,
-3776931214u,
-3183054185u,
-675129307u,
-3333261712u,
-1154611403u,
-2759854023u,
-1963228038u,
-505138315u,
-1803966773u,
-4032705384u,
-798395739u,
-3473799845u,
-476400898u,
-602972493u,
-3289878097u,
-2520311409u,
-3214794876u,
-748160407u,
-1326769504u,
-902775872u,
-1372805534u,
-1213925114u,
-3009384989u,
-3781981134u,
-2835608783u,
-2716786748u,
-1669490957u,
-1089334066u,
-250756920u,
-4041016629u,
-2495807367u,
-2008251381u,
-106212622u,
-1927268995u,
-2251978818u,
-3788056262u,
-3678660147u,
-2656772270u,
-1997584981u,
-2668998785u,
-2954162084u,
-845687881u,
-776018378u,
-2066910012u,
-918315064u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; IsAlive(farmhashnt::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashnt::Hash32(data, len++)); IsAlive(farmhashnt::Hash32(data, len++)); len -= 3; return alive > 0; }
-Check(farmhashnt::Hash32WithSeed(data + offset, len, SEED));
-Check(farmhashnt::Hash32(data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashntTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-cout << farmhashnt::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
-cout << farmhashnt::Hash32(data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashntTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashntTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashntTest::Dump(0, i);
- }
- farmhashntTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashsaTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-4081014168u,
-2576519988u,
-2212771159u,
-1112731063u,
-1020067935u,
-3955445564u,
-1451961420u,
-653440099u,
-31917516u,
-2957164615u,
-2590087362u,
-3879448744u,
-176305566u,
-2447367541u,
-1359016305u,
-3363804638u,
-1117290165u,
-1062549743u,
-2437877004u,
-1894455839u,
-673206794u,
-3486923651u,
-3269862919u,
-2303349487u,
-1380660650u,
-595525107u,
-1525325287u,
-2025609358u,
-176408838u,
-1592885012u,
-864896482u,
-2101378090u,
-3489229104u,
-2118965695u,
-581644891u,
-2718789079u,
-631613207u,
-4228658372u,
-3867875546u,
-3531368319u,
-3804516756u,
-3317755099u,
-1619744564u,
-2884717286u,
-1088213445u,
-2667691076u,
-3727873235u,
-2330406762u,
-858590707u,
-123802208u,
-4150036245u,
-182283099u,
-1478882570u,
-3282617403u,
-819171187u,
-1172627392u,
-4254302102u,
-2957028020u,
-437030323u,
-2452147680u,
-2868246750u,
-3530169402u,
-3154852132u,
-215019192u,
-357580983u,
-1354454461u,
-1108813287u,
-2324008118u,
-2315997713u,
-4181601562u,
-1360882441u,
-92423273u,
-3048866755u,
-3369188505u,
-3664371439u,
-2920710428u,
-1027891570u,
-2653166430u,
-3461888315u,
-1475780447u,
-292769636u,
-1737473313u,
-4064110516u,
-4170160075u,
-762850927u,
-3630603695u,
-2803307356u,
-844987665u,
-460980967u,
-3005635467u,
-2802568977u,
-588668033u,
-2148940781u,
-3239099984u,
-1266953698u,
-3197808789u,
-3519942533u,
-2511995334u,
-2553810188u,
-871667697u,
-1358675720u,
-1499319171u,
-2044931270u,
-1210355103u,
-807152540u,
-3262320756u,
-2810214575u,
-1813386141u,
-4089465863u,
-903928165u,
-1388899322u,
-3209183659u,
-834536144u,
-2733354550u,
-2742289921u,
-3689042563u,
-2655593281u,
-4169686303u,
-415985561u,
-138892376u,
-516115393u,
-65683883u,
-4162865100u,
-889944635u,
-313566528u,
-3346420907u,
-1504303591u,
-2256809275u,
-742243229u,
-779775302u,
-3140940172u,
-2312556111u,
-2304095772u,
-1151741606u,
-2194712422u,
-1714084652u,
-3272736835u,
-1311540658u,
-191179665u,
-3996605106u,
-1657345233u,
-4205442903u,
-1553339212u,
-2351843044u,
-1647502006u,
-2525516233u,
-292202846u,
-1498646290u,
-1429323381u,
-974274898u,
-3759331561u,
-2881238887u,
-826787221u,
-1069622448u,
-221991032u,
-1462969082u,
-2799661508u,
-364022781u,
-2594244377u,
-797773898u,
-4097839290u,
-1529150125u,
-2456805570u,
-541503425u,
-3936326142u,
-3112719954u,
-775223581u,
-3074018423u,
-3198488875u,
-1772191849u,
-2456535211u,
-3154686028u,
-1520862019u,
-4005829426u,
-1306433767u,
-1943028506u,
-2246000782u,
-1057766454u,
-3761996982u,
-3441075333u,
-898641979u,
-3450209088u,
-3941329307u,
-3289922449u,
-3085075827u,
-1814193220u,
-690422997u,
-2627846676u,
-2653520704u,
-3739145533u,
-3996776010u,
-2287072592u,
-1346671698u,
-3082629900u,
-2298811274u,
-3639722036u,
-1729419228u,
-1836765953u,
-3708118742u,
-213436u,
-950223749u,
-3734247682u,
-2924575678u,
-1382024841u,
-2431637732u,
-3448846682u,
-1341301397u,
-4206956590u,
-1730650902u,
-2581075456u,
-1542359141u,
-707222542u,
-2925350541u,
-3846303536u,
-3579103295u,
-3932175763u,
-1339615732u,
-848825750u,
-1070170828u,
-1964973818u,
-577060344u,
-607721296u,
-4031023048u,
-406883794u,
-3991905552u,
-1198544082u,
-872468460u,
-1044847096u,
-3159976313u,
-3020028266u,
-2108700400u,
-3373767922u,
-264431841u,
-2817097007u,
-3700061048u,
-1733731531u,
-3459415893u,
-80378591u,
-1479875104u,
-19735612u,
-1382658977u,
-3416562245u,
-1959852842u,
-2384002344u,
-124683828u,
-3725782174u,
-2300301222u,
-393852269u,
-1302492002u,
-3623776492u,
-3787086417u,
-1730024749u,
-1710531361u,
-443700716u,
-1461987482u,
-671998131u,
-3018380746u,
-2592292305u,
-3390799372u,
-3945101155u,
-3743494852u,
-3716045582u,
-996005166u,
-320698449u,
-3420221765u,
-1518157951u,
-2555810666u,
-3381929684u,
-2019638523u,
-3088262796u,
-2072178906u,
-3433649364u,
-203906916u,
-34663784u,
-290301305u,
-1188021504u,
-3754681145u,
-3920313139u,
-2840496520u,
-1656802962u,
-2288475489u,
-3399185138u,
-1296000826u,
-2362384746u,
-309633360u,
-2719851778u,
-776035930u,
-3200733043u,
-365690832u,
-3326378243u,
-1500331457u,
-1625708592u,
-4230903462u,
-715344888u,
-3363777768u,
-2243620288u,
-2890765789u,
-553154234u,
-4044100108u,
-4056887320u,
-1185656496u,
-3671476744u,
-1064586897u,
-1154949698u,
-3493481974u,
-1294573722u,
-1869224012u,
-2530084956u,
-995321553u,
-833419249u,
-563815282u,
-250258043u,
-2970801822u,
-441007535u,
-42246961u,
-2820426655u,
-2878882436u,
-2363245780u,
-2138489282u,
-2972360481u,
-2312619393u,
-3598664848u,
-3071556076u,
-776990325u,
-3220427357u,
-2257939577u,
-3817305903u,
-1502979698u,
-3159755934u,
-3955997276u,
-2423850008u,
-1959927572u,
-1219782288u,
-4119776679u,
-1124253854u,
-3678052422u,
-2620644947u,
-1262408666u,
-3480072280u,
-2627137665u,
-807538749u,
-3276646337u,
-518510128u,
-1137828655u,
-1498449110u,
-3031692317u,
-1125635969u,
-1130096111u,
-780007336u,
-3111856399u,
-1014917264u,
-780877352u,
-2909458336u,
-4235949214u,
-2423879289u,
-275888892u,
-3891926795u,
-3538163953u,
-54815161u,
-162228302u,
-258154068u,
-3554455591u,
-1801469029u,
-2801563220u,
-726560058u,
-2450221940u,
-3677582978u,
-440993800u,
-424762443u,
-2624525253u,
-2587715329u,
-2292264424u,
-1074856749u,
-3294752007u,
-3164112672u,
-2399146799u,
-1920182465u,
-3858835361u,
-193755240u,
-3333610311u,
-1757504059u,
-2576027039u,
-2775253365u,
-2939191561u,
-1046147275u,
-235149906u,
-4262218222u,
-2900542726u,
-2260154702u,
-1019551635u,
-1194720570u,
-3519118691u,
-3039483153u,
-84918216u,
-3053381097u,
-2572396843u,
-3849763371u,
-2782686780u,
-3710049554u,
-3403430713u,
-2346080784u,
-2496307442u,
-1597281872u,
-696018239u,
-704625714u,
-623026921u,
-3182413559u,
-3794540330u,
-305497722u,
-1592680199u,
-2377854072u,
-3060601746u,
-3953057908u,
-3941551588u,
-1033716182u,
-2765716854u,
-1309699058u,
-3519400181u,
-3073370877u,
-115583008u,
-4032909296u,
-2944563574u,
-3762753718u,
-192842727u,
-1711348701u,
-3086147235u,
-1658229443u,
-1479783872u,
-3839977157u,
-225619117u,
-1349684817u,
-1964813173u,
-565753187u,
-2530252046u,
-840014353u,
-1645183704u,
-3668429078u,
-3438418557u,
-639704059u,
-360837811u,
-2531807958u,
-1572353913u,
-2116037299u,
-1948437512u,
-744553393u,
-2380697034u,
-3775234105u,
-3816065157u,
-301868653u,
-2960939561u,
-3306528247u,
-2389296549u,
-805918610u,
-1759358265u,
-1760876328u,
-2827601706u,
-2944594708u,
-3313666458u,
-2022601495u,
-730938791u,
-193539397u,
-2026103244u,
-802928398u,
-2630934308u,
-782805818u,
-3499326016u,
-293509489u,
-3646131514u,
-3182478647u,
-854800333u,
-2284531628u,
-438528022u,
-2339298129u,
-1692289216u,
-2427728723u,
-46501288u,
-350652353u,
-1355971222u,
-889682372u,
-944799254u,
-2763906061u,
-2807550612u,
-2683762637u,
-100870317u,
-2449357318u,
-2638348436u,
-4206088869u,
-1788948473u,
-3537588549u,
-2782490204u,
-134406470u,
-2409190528u,
-2362439849u,
-1861661528u,
-2101513194u,
-1424834765u,
-3581765745u,
-3185999525u,
-2057487100u,
-2303941176u,
-3639628788u,
-1180265315u,
-230437935u,
-2108319366u,
-1131685143u,
-1055685292u,
-1509007009u,
-1258485140u,
-560525005u,
-3598799040u,
-3835680585u,
-1851859628u,
-332858996u,
-641769248u,
-4252450037u,
-865386707u,
-720719117u,
-3133612164u,
-3833045874u,
-3492515435u,
-2465970289u,
-4234420011u,
-573859916u,
-252532886u,
-870392318u,
-4051320920u,
-894929092u,
-3748361688u,
-699355960u,
-1885212350u,
-1609756949u,
-461896870u,
-1337065461u,
-1775211059u,
-1786193749u,
-2815154643u,
-2128729882u,
-969639529u,
-3960427545u,
-859416958u,
-2739758802u,
-2698032197u,
-2813292418u,
-1985467524u,
-396604317u,
-4122172759u,
-1201259789u,
-4282051702u,
-3270018895u,
-961215209u,
-961075860u,
-4211926998u,
-4088374597u,
-577510509u,
-3058349487u,
-4025377754u,
-2815478438u,
-471023164u,
-3947959608u,
-4161486934u,
-2299888461u,
-1103571511u,
-2450153872u,
-1839939275u,
-108299608u,
-858086440u,
-1030152945u,
-3895328530u,
-3009080718u,
-3690840454u,
-3847025277u,
-152331362u,
-161365689u,
-831319961u,
-2166017294u,
-3945322722u,
-4059970216u,
-1420824131u,
-2770648308u,
-1567250186u,
-2181067149u,
-1939743488u,
-3080158120u,
-3435218248u,
-2495237495u,
-3814085102u,
-3180983013u,
-3199054292u,
-2204745908u,
-1140337267u,
-2213569784u,
-1941879842u,
-2105562605u,
-3618835614u,
-2247103645u,
-2492473487u,
-856414299u,
-166022030u,
-4080104712u,
-3218935344u,
-3284220561u,
-4261581452u,
-1206944836u,
-3496705432u,
-2215996876u,
-3154627465u,
-3384005496u,
-742170556u,
-1333047620u,
-802680366u,
-156833431u,
-2682100354u,
-2493654830u,
-584848366u,
-1691693131u,
-2169934170u,
-779968026u,
-2099545800u,
-1423039695u,
-4292110968u,
-4266576788u,
-149142597u,
-748501873u,
-3865014822u,
-1913588198u,
-130285614u,
-3500768879u,
-915458923u,
-3071792750u,
-1339986633u,
-4143929149u,
-4048379479u,
-725193827u,
-1375113643u,
-2425277412u,
-4144659274u,
-465714768u,
-226991589u,
-2212127704u,
-3936145258u,
-2891024846u,
-3816000225u,
-979331165u,
-1749907536u,
-53847318u,
-1462525833u,
-2961425455u,
-368859113u,
-3572721452u,
-453048644u,
-1628629918u,
-3497673923u,
-3619079585u,
-139870565u,
-1518176798u,
-3933074281u,
-1878623729u,
-2074035641u,
-3016759257u,
-1313053591u,
-2557706970u,
-2348296582u,
-962370022u,
-2337285014u,
-1618936717u,
-1915877085u,
-2743743122u,
-3250783882u,
-1346652536u,
-143311109u,
-2443788461u,
-1048248964u,
-2806619339u,
-3263266976u,
-1668146349u,
-3397428868u,
-3276188862u,
-1774196343u,
-1993847813u,
-2771079610u,
-476672419u,
-2119050359u,
-2918326659u,
-2245402721u,
-2692910474u,
-2374383269u,
-342400227u,
-2961437795u,
-3899230368u,
-337787132u,
-3664444935u,
-1269451153u,
-2971526729u,
-1486511182u,
-791070133u,
-2570319890u,
-3482497490u,
-2134230518u,
-4273391202u,
-1825511330u,
-3947753714u,
-1389755724u,
-3995075516u,
-2081052615u,
-3626343470u,
-4213603435u,
-2137917278u,
-2898987303u,
-3059215715u,
-3383237881u,
-3003674434u,
-409174425u,
-1911915604u,
-2087728055u,
-2942005882u,
-3386522440u,
-714936074u,
-261924004u,
-3268784033u,
-1141188757u,
-2413217552u,
-1515163433u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; IsAlive(farmhashsa::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashsa::Hash32(data, len++)); IsAlive(farmhashsa::Hash32(data, len++)); len -= 3; return alive > 0; }
-Check(farmhashsa::Hash32WithSeed(data + offset, len, SEED));
-Check(farmhashsa::Hash32(data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashsaTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-cout << farmhashsa::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
-cout << farmhashsa::Hash32(data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashsaTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashsaTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashsaTest::Dump(0, i);
- }
- farmhashsaTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashsuTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-4081014168u,
-2576519988u,
-2212771159u,
-1112731063u,
-1020067935u,
-3955445564u,
-1451961420u,
-653440099u,
-31917516u,
-2957164615u,
-2590087362u,
-3879448744u,
-176305566u,
-2447367541u,
-1359016305u,
-3363804638u,
-1117290165u,
-1062549743u,
-2437877004u,
-1894455839u,
-673206794u,
-3486923651u,
-3269862919u,
-2303349487u,
-1380660650u,
-595525107u,
-1525325287u,
-2025609358u,
-176408838u,
-1592885012u,
-864896482u,
-2101378090u,
-3489229104u,
-2118965695u,
-581644891u,
-2718789079u,
-631613207u,
-4228658372u,
-3867875546u,
-3531368319u,
-3804516756u,
-3317755099u,
-1619744564u,
-2884717286u,
-1088213445u,
-2667691076u,
-3727873235u,
-2330406762u,
-858590707u,
-457744844u,
-4150036245u,
-2000404290u,
-1478882570u,
-901678172u,
-819171187u,
-195942998u,
-4254302102u,
-3967266927u,
-437030323u,
-4018009204u,
-2868246750u,
-3540087514u,
-3154852132u,
-3319116625u,
-357580983u,
-3177665294u,
-1108813287u,
-1253366798u,
-2315997713u,
-510718750u,
-1360882441u,
-2770216279u,
-3048866755u,
-3406961221u,
-3664371439u,
-1151145514u,
-1027891570u,
-2699067992u,
-3461888315u,
-198061905u,
-292769636u,
-1106771795u,
-4064110516u,
-3258279756u,
-762850927u,
-1818699721u,
-2803307356u,
-3919169404u,
-460980967u,
-3125535078u,
-2802568977u,
-3582546426u,
-2148940781u,
-3963274378u,
-1266953698u,
-204185123u,
-1100034381u,
-3009193601u,
-4200651967u,
-274889605u,
-2700589508u,
-952511689u,
-3765324859u,
-3465498478u,
-4014967037u,
-2070988082u,
-2972423530u,
-3068638223u,
-4156773651u,
-489509804u,
-1323863238u,
-3731914806u,
-2846098469u,
-2728930632u,
-346814072u,
-848146907u,
-551160669u,
-4165126521u,
-2039095001u,
-4179859388u,
-2434936359u,
-2764414551u,
-238491210u,
-732483969u,
-3366512764u,
-478307468u,
-4124179572u,
-4142733597u,
-1953448206u,
-4199329278u,
-865077060u,
-2627662116u,
-2802499360u,
-3141206831u,
-1959218197u,
-911371451u,
-125987200u,
-2821366175u,
-2530992747u,
-2409206225u,
-117991880u,
-2133402461u,
-895510531u,
-428719601u,
-3036014536u,
-1223783733u,
-733793540u,
-970650405u,
-547701766u,
-570764615u,
-3224485368u,
-3192714940u,
-319942831u,
-3940200341u,
-362056204u,
-2832368105u,
-1853281226u,
-3296434636u,
-3752508307u,
-604292768u,
-2231940616u,
-1204094681u,
-866194005u,
-2405201650u,
-2466384396u,
-380829379u,
-230033818u,
-2783417588u,
-4249886729u,
-829569301u,
-2988322580u,
-2299983554u,
-74748560u,
-737514425u,
-3153050211u,
-652642663u,
-1270205115u,
-227197032u,
-2773091790u,
-325849216u,
-49998791u,
-4043203010u,
-3662748068u,
-1709364383u,
-1179105165u,
-1478504366u,
-2980456610u,
-1167476429u,
-1590390732u,
-1306256496u,
-292008135u,
-374690995u,
-1809200819u,
-1680595904u,
-646040226u,
-1742445560u,
-2435776844u,
-3703683804u,
-478742495u,
-814967947u,
-2698190177u,
-1003617993u,
-1436118705u,
-217056304u,
-1412287094u,
-2738417466u,
-2933279339u,
-3461877733u,
-1203141205u,
-2119492857u,
-1134895723u,
-1560001021u,
-3786320122u,
-3748116258u,
-3486219595u,
-702138030u,
-1062984182u,
-232789133u,
-1566523968u,
-3885443778u,
-1820171888u,
-3655858585u,
-2316903005u,
-2678779620u,
-395625433u,
-1609107564u,
-3108726411u,
-2937837224u,
-3911907151u,
-557272509u,
-3893435978u,
-1542613576u,
-1079886893u,
-2624566322u,
-1413700616u,
-2796974006u,
-1922556114u,
-562820464u,
-2845409784u,
-54180312u,
-1898782464u,
-3681814953u,
-2417064617u,
-1815464483u,
-911626132u,
-2964575550u,
-1852696128u,
-2319647785u,
-1998904590u,
-619992689u,
-3073207513u,
-1238163512u,
-3199435982u,
-828667254u,
-3561155502u,
-3943095163u,
-1045711849u,
-2238679131u,
-2114975398u,
-713808403u,
-3871787494u,
-2572031161u,
-2360934075u,
-2337781107u,
-262596504u,
-693836699u,
-2129369850u,
-3543189427u,
-962205222u,
-3685581020u,
-692974477u,
-725182211u,
-646123906u,
-2368836544u,
-2505872733u,
-1999977610u,
-1639885802u,
-1475058032u,
-207023609u,
-2773581234u,
-3524857793u,
-3433371102u,
-3243027613u,
-1787668353u,
-985757946u,
-3896012929u,
-702356957u,
-3559331129u,
-884084870u,
-4009998120u,
-648888720u,
-1403349048u,
-1624342778u,
-1766674171u,
-2518582204u,
-3251243146u,
-792751003u,
-1377201813u,
-3629686054u,
-1583734324u,
-3647107626u,
-4258564381u,
-1469878609u,
-1940598241u,
-2755003690u,
-1907120418u,
-109916701u,
-775347954u,
-2090960874u,
-611281803u,
-3470490146u,
-3301663253u,
-1835412158u,
-1803066146u,
-591872433u,
-550703713u,
-1495089683u,
-826492808u,
-817200035u,
-4177474571u,
-688070143u,
-971427632u,
-1442499481u,
-3568640348u,
-2789993738u,
-85808128u,
-2058346726u,
-394058570u,
-3466511434u,
-318905230u,
-4149248030u,
-415308316u,
-165997598u,
-1219639412u,
-1648022659u,
-2857432523u,
-1422508004u,
-468095522u,
-296968649u,
-430250611u,
-1775562314u,
-2976361671u,
-1040036362u,
-1372510167u,
-292746272u,
-3408238954u,
-626061886u,
-1317637569u,
-1237775792u,
-1218490455u,
-2224234499u,
-590942419u,
-713995643u,
-3541889330u,
-4140218960u,
-3529791107u,
-354462673u,
-842607274u,
-365048533u,
-2638303414u,
-3560458014u,
-31621379u,
-4210854794u,
-1273118792u,
-2572743762u,
-3513175801u,
-402066986u,
-602524471u,
-565029192u,
-180576438u,
-1288605959u,
-2896244423u,
-1420543484u,
-1329862227u,
-1791567324u,
-4248690247u,
-12917038u,
-3483481310u,
-2082050731u,
-1611921143u,
-2443766548u,
-2216338811u,
-2528006095u,
-2984009021u,
-674210884u,
-2857608106u,
-2155534809u,
-1023105067u,
-2968955846u,
-3303624302u,
-2502112850u,
-245749006u,
-3175229091u,
-3342796184u,
-3613785362u,
-1614168851u,
-2582149283u,
-895403488u,
-416205023u,
-3792242000u,
-529397534u,
-299415203u,
-4284673348u,
-2096851282u,
-1864524731u,
-2012577738u,
-3426363316u,
-1387308508u,
-1143610148u,
-2027467219u,
-3772856163u,
-3453862623u,
-2661437174u,
-2047145955u,
-2533381447u,
-2059534115u,
-439426587u,
-1537543414u,
-2384289877u,
-3174229055u,
-2658017753u,
-2293148474u,
-2359450158u,
-3930242475u,
-1510302397u,
-3354288821u,
-920095603u,
-2415746928u,
-2729472638u,
-2261143371u,
-848667611u,
-919157153u,
-3322393117u,
-4103299943u,
-413569608u,
-68911216u,
-3334990170u,
-1228068652u,
-1570056373u,
-1905477543u,
-2622302276u,
-2935063895u,
-3224810004u,
-4211768578u,
-828688131u,
-3556122839u,
-1930935348u,
-2605825202u,
-1540993970u,
-3209115883u,
-122847500u,
-665638794u,
-506571051u,
-2691795295u,
-3996966556u,
-714660621u,
-3662432239u,
-470651837u,
-1807432621u,
-3755290953u,
-359878860u,
-2793081615u,
-4065031431u,
-904653062u,
-2317800777u,
-568501094u,
-3492871707u,
-2738806116u,
-2883859610u,
-3242080257u,
-364246691u,
-3601786516u,
-3159362524u,
-1578272201u,
-1283574375u,
-2912186103u,
-2256279032u,
-1540671086u,
-2356088973u,
-2892277779u,
-3441449267u,
-2225005503u,
-3846428419u,
-2014549218u,
-2290734767u,
-2126684614u,
-4235463487u,
-3811556204u,
-174739661u,
-767525888u,
-47684458u,
-4211168099u,
-889063422u,
-469864411u,
-767407110u,
-413337343u,
-1618456644u,
-2814499820u,
-2401124192u,
-632089437u,
-1234980238u,
-1288585402u,
-3153169944u,
-2917822069u,
-1843320264u,
-3794359132u,
-3074573530u,
-258629454u,
-3813357060u,
-3806887248u,
-1665524736u,
-3324533324u,
-3005091922u,
-793108368u,
-1529669805u,
-2332660395u,
-2217730223u,
-2634687611u,
-442806463u,
-1968135266u,
-454523002u,
-3177866230u,
-2808960136u,
-4259114138u,
-4103264843u,
-3103714075u,
-2462967542u,
-1466891491u,
-477973764u,
-834565647u,
-741089037u,
-218837573u,
-1710536528u,
-2469088212u,
-1229072375u,
-2828341u,
-176923431u,
-985763350u,
-4095477420u,
-1984145538u,
-1870791084u,
-674956677u,
-1978138947u,
-1296493993u,
-1818183554u,
-3443333721u,
-2124949983u,
-2549590262u,
-2700850794u,
-2662736367u,
-739638109u,
-4061447096u,
-2960078422u,
-2453781158u,
-929570940u,
-3200328383u,
-2406328791u,
-1419180666u,
-2152455739u,
-2805741044u,
-3305999074u,
-3183816361u,
-2303165050u,
-4922104u,
-63096005u,
-936656347u,
-3104453886u,
-1088673880u,
-1113407526u,
-1457890086u,
-453478383u,
-1107686695u,
-3626027824u,
-1159687359u,
-2248467888u,
-2004578380u,
-3274954621u,
-1787958646u,
-2628726704u,
-1138419798u,
-3735442315u,
-692385301u,
-313807213u,
-2329068673u,
-59375364u,
-3261084359u,
-2088644507u,
-2471153194u,
-788336435u,
-4024527246u,
-141504460u,
-2307553888u,
-1930559950u,
-48975711u,
-2745693338u,
-230161982u,
-3429230862u,
-1335968626u,
-609591304u,
-57435073u,
-4279281136u,
-3152151665u,
-3984484924u,
-3459883943u,
-397478330u,
-1738762229u,
-3033590066u,
-3611539498u,
-1363463523u,
-3319364965u,
-2671169141u,
-3819548561u,
-1691193757u,
-2423834608u,
-2820147055u,
-1378120632u,
-1240565187u,
-3180720050u,
-680831086u,
-3309658414u,
-1986166490u,
-762099827u,
-510883662u,
-2047373648u,
-3606742294u,
-3894965352u,
-2342078853u,
-1091255717u,
-776594727u,
-3217317445u,
-1574468485u,
-3844504016u,
-2819598918u,
-1037401010u,
-2550943503u,
-3867184001u,
-1687911772u,
-165313836u,
-1679575281u,
-2418947263u,
-2038774952u,
-3913543652u,
-3209155736u,
-149905221u,
-3859604717u,
-713919631u,
-4069810796u,
-1882959164u,
-1019939034u,
-2379867302u,
-3666323035u,
-1157389013u,
-2422300650u,
-3366777340u,
-2526452062u,
-1313747885u,
-1039617868u,
-1620553692u,
-2032976978u,
-578789528u,
-1592846839u,
-2270630604u,
-897850577u,
-1603294178u,
-3105664807u,
-1442670138u,
-1728019360u,
-79313861u,
-1683031101u,
-1913067024u,
-4070719870u,
-708986470u,
-2586453359u,
-3993348863u,
-3358251279u,
-3003552537u,
-750174793u,
-836888956u,
-4190747426u,
-4251291318u,
-4145164938u,
-1366883260u,
-1912910955u,
-510192669u,
-1851315039u,
-3574241274u,
-3220062924u,
-2821142039u,
-1317082195u,
-2274293302u,
-1839219569u,
-126586168u,
-3989293643u,
-2680178207u,
-347056948u,
-799681430u,
-2864517481u,
-3180404853u,
-213140045u,
-1956305184u,
-1474675286u,
-3085723423u,
-2841859626u,
-308421914u,
-3670309263u,
-1765052231u,
-245459238u,
-113434331u,
-4079521092u,
-2115235526u,
-2943408816u,
-1055476938u,
-1506442339u,
-2291296392u,
-3267864332u,
-1282145528u,
-3700108015u,
-1932843667u,
-2677701670u,
-6041177u,
-3889648557u,
-1461025478u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; IsAlive(farmhashsu::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashsu::Hash32(data, len++)); IsAlive(farmhashsu::Hash32(data, len++)); len -= 3; return alive > 0; }
-Check(farmhashsu::Hash32WithSeed(data + offset, len, SEED));
-Check(farmhashsu::Hash32(data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashsuTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-cout << farmhashsu::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
-cout << farmhashsu::Hash32(data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashsuTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashsuTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashsuTest::Dump(0, i);
- }
- farmhashsuTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashteTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-1140953930u, 861465670u,
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-890626835u, 800175912u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-3283896453u, 1867689945u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-1110588164u, 4186314283u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-283198166u, 2741341286u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-452473466u, 1706958772u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-236935126u, 2976578695u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-2305012065u, 2169731866u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-3058973506u, 2379411653u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-147814787u, 720739346u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-3425469811u, 3690733394u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-1635026870u, 192883107u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-3969463346u, 1436364519u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-2859809759u, 3808705738u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-4023053163u, 2650381482u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-3476440786u, 3829307897u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-2902102606u, 3600725550u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1448662590u, 397635823u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-180854224u, 2604346966u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-1669465176u, 1341975128u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-1043692997u, 1454396064u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-703505868u, 678706990u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-1933894405u, 3043213226u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-3828089804u, 3632594520u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-3729087873u, 1303930448u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3103338579u, 3064290191u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2295806711u, 1781190011u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-1968445277u, 315203929u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-440398219u, 1891630171u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-4204318635u, 441430649u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-3010839769u, 2837339569u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-4139181436u, 2993479124u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-667183474u, 2084369203u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-1016656857u, 3022024459u,
-3254014218u, 429095991u,
-990500595u, 3056862311u,
-985653208u, 1718653828u,
-623071693u, 366414107u,
-1771289760u, 2293458109u,
-3047342438u, 2991127487u,
-3120876698u, 1684583131u,
-3638043310u, 1170404994u,
-863214540u, 1087193030u,
-199124911u, 520792961u,
-3169775996u, 1577421232u,
-3331828431u, 1013201099u,
-1716848157u, 4033596884u,
-1770708857u, 4229339322u,
-1146169032u, 1434258493u,
-3824360466u, 3242407770u,
-1926419493u, 2649785113u,
-872586426u, 762243036u,
-2736953692u, 816692935u,
-1571283333u, 3555213933u,
-2266795890u, 3781899767u,
-4290630595u, 517646945u,
-3006163611u, 2180594090u,
-959214578u, 558910384u,
-1283799121u, 3047062993u,
-3830962609u, 2391606125u,
-3544509313u, 622325861u,
-834785312u, 382936554u,
-1421463872u, 788479970u,
-1825135056u, 2725923798u,
-580988377u, 2826990641u,
-247825043u, 3167748333u,
-812546227u, 2506885666u,
-2584372201u, 1758123094u,
-1891789696u, 389974094u,
-345313518u, 2022370576u,
-3886113119u, 3338548567u,
-1083486947u, 2583576230u,
-1776047957u, 1771384107u,
-3604937815u, 3198590202u,
-3027522813u, 4155628142u,
-4232136669u, 427759438u,
-4244322689u, 542201663u,
-1549591985u, 2856634168u,
-556609672u, 45845311u,
-1175961330u, 3948351189u,
-4165739882u, 4194218315u,
-1634635545u, 4151937410u,
-713127376u, 1467786451u,
-1327394015u, 2743592929u,
-2638154051u, 810082938u,
-3077742128u, 1062268187u,
-4084325664u, 3810665822u,
-3735739145u, 2794294783u,
-2335576331u, 2560479831u,
-690240711u, 997658837u,
-2442302747u, 3948961926u,
-3958366652u, 3067277639u,
-2059157774u, 1211737169u,
-1516711748u, 2339636583u,
-4188504038u, 59581167u,
-2767897792u, 1389679610u,
-2658147000u, 2643979752u,
-3758739543u, 4189944477u,
-1454470782u, 100876854u,
-2995362413u, 118817200u,
-3252925478u, 2062343506u,
-2804483644u, 3088828656u,
-1231633714u, 4168280671u,
-2931588131u, 3284356565u,
-1255909792u, 3130054947u,
-4173605289u, 1407328702u,
-1677744031u, 3532596884u,
-3162657845u, 3887208531u,
-2256541290u, 3459463480u,
-3740979556u, 259034107u,
-392987633u, 3233195759u,
-3606709555u, 3424793077u,
-315836068u, 3200749877u,
-4065431359u, 760633989u,
-2982018998u, 1811050648u,
-234531934u, 1115203611u,
-3897494162u, 1516407838u,
-1603559457u, 323296368u,
-2632963283u, 1778459926u,
-2879836826u, 2146672889u,
-3486330348u, 492621815u,
-1231665285u, 2457048126u,
-3438440082u, 2217471853u,
-3355404249u, 3275550588u,
-1052645068u, 862072556u,
-4110617119u, 3745267835u,
-2657392572u, 4279236653u,
-1688445808u, 701920051u,
-956734128u, 581695350u,
-3157862788u, 2585726058u,
-1192588249u, 1410111809u,
-1651193125u, 3326135446u,
-1073280453u, 97376972u,
-2513844237u, 2187968410u,
-3976859649u, 4267859263u,
-3429034542u, 564493077u,
-3000537321u, 479241367u,
-3845637831u, 2868987960u,
-51544337u, 1029173765u,
-393624922u, 704325635u,
-2357610553u, 1418509533u,
-2007814586u, 3866658271u,
-3082385053u, 735688735u,
-916110004u, 3283299459u,
-1051684175u, 1083796807u,
-4074716319u, 813690332u,
-144264390u, 1439630796u,
-1508556987u, 675582689u,
-3748881891u, 3195309868u,
-362884708u, 1616408198u,
-43233176u, 837301135u,
-881504822u, 3254795114u,
-1385506591u, 2799925823u,
-1469874582u, 3464841997u,
-497175391u, 3929484338u,
-3975771289u, 1798536177u,
-2926265846u, 1374242438u,
-3675707838u, 4205965408u,
-3153165629u, 1499475160u,
-187287713u, 548490821u,
-3255259608u, 4247675634u,
-1940181471u, 3779953975u,
-687167150u, 2319566715u,
-1742785722u, 785893184u,
-2296977392u, 2778575413u,
-1794720651u, 48131484u,
-4084891412u, 1160134629u,
-3737623280u, 823113169u,
-3423207646u, 3803213486u,
-710625654u, 4116162021u,
-3693420287u, 4167766971u,
-1666602807u, 295320990u,
-3513255468u, 2487440590u,
-234080704u, 4004655503u,
-2971762528u, 1479656873u,
-4090178629u, 4044418876u,
-391947536u, 1462554406u,
-3909295855u, 1239580330u,
-1515601363u, 2011102035u,
-1442068334u, 4265993528u,
-1191921695u, 2291355695u,
-4257172787u, 576405853u,
-314332944u, 4038839101u,
-55559918u, 2378985842u,
-711098718u, 2425317635u,
-1644327317u, 1401013391u,
-4193760037u, 2958260436u,
-3167371443u, 3062418115u,
-3800755475u, 3167030094u,
-3489648204u, 1405430357u,
-526177822u, 2602636307u,
-915406019u, 4264167741u,
-1484090483u, 3070944737u,
-254529415u, 4017058800u,
-1702710265u, 1029665228u,
-2000382906u, 3185573940u,
-1381258384u, 4036354071u,
-2900841028u, 2670703363u,
-2921748807u, 2899069938u,
-4130543625u, 688472265u,
-4186808827u, 1054670286u,
-1132985391u, 2840525968u,
-4175776103u, 338058159u,
-1735964501u, 1539305024u,
-3497121710u, 1568260669u,
-2227290760u, 146827036u,
-3977176001u, 4060134777u,
-857488494u, 250055052u,
-4284109679u, 2502815838u,
-2592281721u, 1603444633u,
-1390562014u, 1556658131u,
-616327404u, 2448966429u,
-3051191726u, 3891353218u,
-1213304082u, 762328245u,
-2239052397u, 1082330589u,
-2455957292u, 201837927u,
-405397452u, 3079886794u,
-2583939798u, 2848283092u,
-3750724631u, 883849006u,
-3204198988u, 3341327098u,
-1855234968u, 1982110346u,
-1485529487u, 541496720u,
-4117290321u, 3607433551u,
-2168864636u, 133643215u,
-1055817409u, 3847827123u,
-2960769387u, 4046101649u,
-1176127003u, 4015671361u,
-4243643405u, 2849988118u,
-517111221u, 1796672358u,
-2045051700u, 3452457457u,
-2948254999u, 2102063419u,
-1556410577u, 1536380876u,
-3776661467u, 3281002516u,
-1735616066u, 1539151988u,
-1087795162u, 3332431596u,
-685631442u, 1147951686u,
-95237878u, 2005032160u,
-4012206915u, 4224354805u,
-3204999386u, 2415262714u,
-1433635018u, 116647396u,
-83167836u, 2881562655u,
-2729416454u, 1029284767u,
-881378302u, 2159170082u,
-555057366u, 1169104445u,
-3963877000u, 1919171906u,
-336034862u, 2017579106u,
-4059340529u, 3020819343u,
-865146997u, 2473524405u,
-944743644u, 1694443528u,
-1804513294u, 2904752429u,
-617975720u, 3671562289u,
-260177668u, 505662155u,
-1885941445u, 2504509403u,
-2260041112u, 1019936943u,
-3722741628u, 1511077569u,
-3100701179u, 1379422864u,
-1535670711u, 773792826u,
-1103819072u, 2089123665u,
-1157547425u, 329152940u,
-4142587430u, 484732447u,
-2475035432u, 1120017626u,
-412145504u, 965125959u,
-324924679u, 2809286837u,
-2842141483u, 4029205195u,
-2974306813u, 515627448u,
-3791551981u, 1097806406u,
-3873078673u, 136118734u,
-1872130856u, 3632422367u,
-3574135531u, 4017075736u,
-1699452298u, 1403506686u,
-344414660u, 1189129691u,
-3487080616u, 1516736273u,
-1805475756u, 2562064338u,
-163335594u, 2732147834u,
-4077452507u, 2984955003u,
-4271866024u, 3071338162u,
-2347111903u, 873829983u,
-1948409509u, 1923531348u,
-459509140u, 771592405u,
-1750124750u, 2334938333u,
-213811117u, 2586632018u,
-185232757u, 4032960199u,
-2447383637u, 284777551u,
-1654276320u, 2687561076u,
-3512945009u, 308584855u,
-1861027147u, 4102279334u,
-3203802620u, 1692079268u,
-4250142168u, 2565680167u,
-1507046104u, 841195925u,
-520565830u, 3674576684u,
-38924274u, 3770488806u,
-2414430882u, 3978473838u,
-3703994407u, 69201295u,
-3099963860u, 1255084262u,
-690971838u, 3539996781u,
-3696902571u, 3593730713u,
-2363435042u, 54945052u,
-1785765213u, 184911581u,
-1586241476u, 1939595371u,
-2534883189u, 2432427547u,
-2374171993u, 2039128933u,
-2955715987u, 2295501078u,
-2741583197u, 1280920000u,
-686818699u, 1238742497u,
-3843660102u, 82177963u,
-1281043691u, 1121403845u,
-1697846708u, 284852964u,
-278661677u, 2889101923u,
-2127558730u, 713121337u,
-872502474u, 511142139u,
-1261140657u, 1747052377u,
-2108187161u, 927011680u,
-955328267u, 3821994995u,
-2707230761u, 4142246789u,
-4134691985u, 1958963937u,
-2498463509u, 1977988705u,
-1419293714u, 1636932722u,
-2567532373u, 4075249328u,
-240575705u, 1956681213u,
-2598802768u, 2025886508u,
-4104757832u, 3026358429u,
-3242615202u, 4026813725u,
-255108733u, 1845587644u,
-3573008472u, 3615577014u,
-1222733548u, 1205557630u,
-917608574u, 1363253259u,
-1541946015u, 3087190425u,
-1138008081u, 1444019663u,
-109793386u, 341851980u,
-857839960u, 2515339233u,
-156283211u, 1906768669u,
-3886713057u, 1276595523u,
-2809830736u, 460237542u,
-3420452099u, 142985419u,
-205970448u, 4198897105u,
-1950698961u, 2069753399u,
-1142216925u, 1113051162u,
-1033680610u, 4278599955u,
-1106466069u, 356742959u,
-531521052u, 3494863964u,
-225629455u, 3735275001u,
-3662626864u, 1750561299u,
-1012864651u, 2101846429u,
-1074553219u, 668829411u,
-992181339u, 3384018814u,
-3330664522u, 860966321u,
-1885071395u, 4233785523u,
-100741310u, 451656820u,
-2148187612u, 1063001151u,
-360256231u, 107312677u,
-3650357479u, 2390172694u,
-22452685u, 237319043u,
-3600462351u, 1216645846u,
-2088767754u, 164402616u,
-2418980170u, 926137824u,
-94638678u, 1689811113u,
-2751052984u, 1767810825u,
-271289013u, 3896132233u,
-103797041u, 1397772514u,
-3441135892u, 3323383489u,
-2491268371u, 1662561885u,
-1612872497u, 2986430557u,
-2756998822u, 207428029u,
-937973965u, 2791656726u,
-1949717207u, 2260498180u,
-2648427775u, 2360400900u,
-2080496169u, 486358863u,
-1582022990u, 1263709570u,
-1396468647u, 1377764574u,
-363008508u, 1293502429u,
-224580012u, 4252610345u,
-1435134775u, 1099809675u,
-533671980u, 1533438766u,
-1820532305u, 2776960536u,
-3374512975u, 3542220540u,
-822810075u, 3716663290u,
-1157398049u, 3752806924u,
-4081637863u, 337070226u,
-3866585976u, 359270190u,
-2110942730u, 3267551635u,
-644850146u, 1306761320u,
-746972907u, 934259457u,
-2341378668u, 2220373824u,
-1242645122u, 4109252858u,
-1625266099u, 1173698481u,
-383517064u, 896322512u,
-3377483696u, 1788337208u,
-455496839u, 3194373887u,
-1837689083u, 1336556841u,
-1658628529u, 2911512007u,
-3838343487u, 2757664765u,
-1537187340u, 3712582785u,
-367022558u, 3071359622u,
-3926147070u, 35432879u,
-3093195926u, 2561488770u,
-4273132307u, 3898950547u,
-2838251049u, 2103926083u,
-2549435227u, 536047554u,
-1858986613u, 2040551642u,
-1147412575u, 1972369852u,
-4166184983u, 3528794619u,
-4077477194u, 3565689036u,
-808048238u, 3826350461u,
-1359641525u, 1197100813u,
-265993036u, 1864569342u,
-725164342u, 2264788336u,
-1831223342u, 3329594980u,
-923017956u, 490608221u,
-3818634478u, 258154469u,
-1441714797u, 1174785921u,
-3833372385u, 3287246572u,
-1677395563u, 3569218731u,
-868981704u, 2163330264u,
-2649450292u, 500120236u,
-465161780u, 746438382u,
-1145009669u, 2520062970u,
-2810524030u, 1561519055u,
-1479878006u, 3864969305u,
-2686075657u, 4042710240u,
-3224066062u, 2774151984u,
-2226179547u, 1643626042u,
-2328730865u, 3160666939u,
-2107011431u, 96459446u,
-3920328742u, 3336407558u,
-829404209u, 1878067032u,
-1235983679u, 4237425634u,
-466519055u, 3870676863u,
-934312076u, 2952135524u,
-276949224u, 4100839753u,
-424001484u, 1955120893u,
-4015478120u, 1265237690u,
-427484362u, 4246879223u,
-3452969617u, 1724363362u,
-1553513184u, 834830418u,
-1858777639u, 3476334357u,
-4144030366u, 2450047160u,
-2950762705u, 4277111759u,
-358032121u, 2511026735u,
-167923105u, 2059208280u,
-251949572u, 3065234219u,
-1535473864u, 556796152u,
-1513237478u, 3150857516u,
-1103404394u, 198182691u,
-1476438092u, 2913077464u,
-207119516u, 3963810232u,
-2954651680u, 1535115487u,
-3051522276u, 4046477658u,
-917804636u, 864395565u,
-632704095u, 140762681u,
-1802040304u, 990407433u,
-3771506212u, 4106024923u,
-1287729497u, 2198985327u,
-4052924496u, 2926590471u,
-3084557148u, 1472898694u,
-1009870118u, 559702706u,
-4265214507u, 82077489u,
-3067891003u, 3295678907u,
-2402308151u, 1096697687u,
-464407878u, 4190838199u,
-4269578403u, 3060919438u,
-2899950405u, 3046872820u,
-733509243u, 1583801700u,
-40453902u, 3879773881u,
-1993425202u, 2185339100u,
-1877837196u, 3912423882u,
-3293122640u, 4104318469u,
-1679617763u, 3703603898u,
-8759461u, 2540185277u,
-1152198475u, 2038345882u,
-2503579743u, 1446869792u,
-2019419351u, 4051584612u,
-3178289407u, 3992503830u,
-2879018745u, 2719373510u,
-700836153u, 1675560450u,
-4121245793u, 2064715719u,
-343595772u, 1996164093u,
-3130433948u, 405251683u,
-2804817126u, 1607133689u,
-463852893u, 2864244470u,
-2224044848u, 4071581802u,
-2537107938u, 2246347953u,
-3207234525u, 2028708916u,
-2272418128u, 803575837u,
-38655481u, 2170452091u,
-3272166407u, 557660441u,
-4019147902u, 3841480082u,
-298459606u, 2600943364u,
-2440657523u, 255451671u,
-3424361375u, 779434428u,
-3088526123u, 490671625u,
-1322855877u, 3452203069u,
-3057021940u, 2285701422u,
-2014993457u, 2390431709u,
-2002090272u, 1568745354u,
-1783152480u, 823305654u,
-4053862835u, 2200236540u,
-3009412313u, 3184047862u,
-3032187389u, 4159715581u,
-2966902888u, 252986948u,
-1849329144u, 3160134214u,
-3420960112u, 3198900547u,
-749160960u, 379139040u,
-1208883495u, 1566527339u,
-3006227299u, 4194096960u,
-556075248u, 497404038u,
-1717327230u, 1496132623u,
-1775955687u, 1719108984u,
-1014328900u, 4189966956u,
-2108574735u, 2584236470u,
-684087286u, 531310503u,
-4264509527u, 773405691u,
-3088905079u, 3456882941u,
-3105682208u, 3382290593u,
-2289363624u, 3296306400u,
-4168438718u, 467441309u,
-777173623u, 3241407531u,
-1183994815u, 1132983260u,
-1610606159u, 2540270567u,
-2649684057u, 1397502982u,
-146657385u, 3318434267u,
-2109315753u, 3348545480u,
-3193669211u, 811750340u,
-1073256162u, 3571673088u,
-546596661u, 1017047954u,
-3403136990u, 2540585554u,
-1477047647u, 4145867423u,
-2826408201u, 3531646869u,
-784952939u, 943914610u,
-2717443875u, 3657384638u,
-1806867885u, 1903578924u,
-3985088434u, 1911188923u,
-1764002686u, 3672748083u,
-1832925325u, 241574049u,
-519948041u, 3181425568u,
-2939747257u, 1634174593u,
-3429894862u, 3529565564u,
-1089679033u, 240953857u,
-2025369941u, 2695166650u,
-517086873u, 2964595704u,
-3017658263u, 3828377737u,
-2144895011u, 994799311u,
-1184683823u, 4260564140u,
-308018483u, 4262383425u,
-1374752558u, 3431057723u,
-1572637805u, 383233885u,
-3188015819u, 4051263539u,
-233319221u, 3794788167u,
-2017406667u, 919677938u,
-4074952232u, 1683612329u,
-4213676186u, 327142514u,
-3032591014u, 4204155962u,
-206775997u, 2283918569u,
-2395147154u, 3427505379u,
-2211319468u, 4153726847u,
-2217060665u, 350160869u,
-2493667051u, 1648200185u,
-3441709766u, 1387233546u,
-140980u, 1891558063u,
-760080239u, 2088061981u,
-1580964938u, 740563169u,
-422986366u, 330624974u,
-4264507722u, 150928357u,
-2738323042u, 2948665536u,
-918718096u, 376390582u,
-3966098971u, 717653678u,
-3219466255u, 3799363969u,
-3424344721u, 3187805406u,
-375347278u, 3490350144u,
-1992212097u, 2263421398u,
-3855037968u, 1928519266u,
-3866327955u, 1129127000u,
-1782515131u, 2746577402u,
-3059200728u, 2108753646u,
-2738070963u, 1336849395u,
-1705302106u, 768287270u,
-1343511943u, 2247006571u,
-1956142255u, 1780259453u,
-3475618043u, 212490675u,
-622521957u, 917121602u,
-1852992332u, 1267987847u,
-3170016833u, 2549835613u,
-3299763344u, 2864033668u,
-3378768767u, 1236609378u,
-4169365948u, 3738062408u,
-2661022773u, 2006922227u,
-2760592161u, 3828932355u,
-2636387819u, 2616619070u,
-1237256330u, 3449066284u,
-2871755260u, 3729280948u,
-3862686086u, 431292293u,
-3285899651u, 786322314u,
-2531158535u, 724901242u,
-2377363130u, 1415970351u,
-1244759631u, 3263135197u,
-965248856u, 174024139u,
-2297418515u, 2954777083u,
-987586766u, 3206261120u,
-4059515114u, 3903854066u,
-1931934525u, 2287507921u,
-1827135136u, 1781944746u,
-574617451u, 2299034788u,
-2650140034u, 4081586725u,
-2482286699u, 1109175923u,
-458483596u, 618705848u,
-4059852729u, 1813855658u,
-4190721328u, 1129462471u,
-4089998050u, 3575732749u,
-2375584220u, 1037031473u,
-1623777358u, 3389003793u,
-546597541u, 352770237u,
-1383747654u, 3122687303u,
-1646071378u, 1164309901u,
-290870767u, 830691298u,
-929335420u, 3193251135u,
-989577914u, 3626554867u,
-591974737u, 3996958215u,
-3163711272u, 3071568023u,
-1516846461u, 3656006011u,
-2698625268u, 2510865430u,
-340274176u, 1167681812u,
-3698796465u, 3155218919u,
-4102288238u, 1673474350u,
-3069708839u, 2704165015u,
-1237411891u, 1854985978u,
-3646837503u, 3625406022u,
-921552000u, 1712976649u,
-3939149151u, 878608872u,
-3406359248u, 1068844551u,
-1834682077u, 4155949943u,
-2437686324u, 3163786257u,
-2645117577u, 1988168803u,
-747285578u, 1626463554u,
-1235300371u, 1256485167u,
-1914142538u, 4141546431u,
-3838102563u, 582664250u,
-1883344352u, 2083771672u,
-2611657933u, 2139079047u,
-2250573853u, 804336148u,
-3066325351u, 2770847216u,
-4275641370u, 1455750577u,
-3346357270u, 1674051445u,
-601221482u, 3992583643u,
-1402445097u, 3622527604u,
-2509017299u, 2966108111u,
-2557027816u, 900741486u,
-1790771021u, 2912643797u,
-2631381069u, 4014551783u,
-90375300u, 300318232u,
-3269968032u, 2679371729u,
-2664752123u, 3517585534u,
-3253901179u, 542270815u,
-1188641600u, 365479232u,
-2210121140u, 760762191u,
-1273768482u, 1216399252u,
-3484324231u, 4287337666u,
-16322182u, 643179562u,
-325675502u, 3652676161u,
-3120716054u, 3330259752u,
-1011990087u, 2990167340u,
-1097584090u, 3262252593u,
-1829409951u, 3665087267u,
-1214854475u, 2134299399u,
-3704419305u, 411263051u,
-1625446136u, 549838529u,
-4283196353u, 1342880802u,
-3460621305u, 1967599860u,
-4282843369u, 1275671016u,
-2544665755u, 853593042u,
-901109753u, 2682611693u,
-110631633u, 797487791u,
-1472073141u, 850464484u,
-797089608u, 3286110054u,
-350397471u, 2775631060u,
-366448238u, 3842907484u,
-2219863904u, 3623364733u,
-1850985302u, 4009616991u,
-294963924u, 3693536939u,
-3061255808u, 1615375832u,
-1920066675u, 4113028420u,
-4032223840u, 2318423400u,
-2701956286u, 4145497671u,
-3991532344u, 2536338351u,
-1679099863u, 1728968857u,
-449740816u, 2686506989u,
-685242457u, 97590863u,
-3258354115u, 1502282913u,
-1235084019u, 2151665147u,
-528459289u, 231097464u,
-2477280726u, 3651607391u,
-2091754612u, 1178454681u,
-980597335u, 1604483865u,
-1842333726u, 4146839064u,
-3213794286u, 2601416506u,
-754220096u, 3571436033u,
-488595746u, 1448097974u,
-4004834921u, 238887261u,
-3320337489u, 1416989070u,
-2928916831u, 4093725287u,
-186020771u, 2367569534u,
-3046087671u, 4090084518u,
-3548184546u, 679517009u,
-1962659444u, 3539886328u,
-4192003933u, 1678423485u,
-3827951761u, 3086277222u,
-2144472852u, 1390394371u,
-2976322029u, 1574517163u,
-3553313841u, 119173722u,
-1702434637u, 1766260771u,
-3629581771u, 1407497759u,
-895654784u, 751439914u,
-4008409498u, 215917713u,
-1482103833u, 695551833u,
-1288382231u, 2656990891u,
-2581779077u, 1570750352u,
-3710689053u, 1741390464u,
-2666411616u, 3533987737u,
-4289478316u, 3576119563u,
-4118694920u, 108199666u,
-3869794273u, 963183826u,
-2081410737u, 3796810515u,
-791123882u, 2525792704u,
-1036883117u, 136547246u,
-875691100u, 2592925324u,
-614302599u, 3013176417u,
-2689342539u, 427154472u,
-532957601u, 1228758574u,
-1898117151u, 1181643858u,
-1908591042u, 1464255968u,
-446980910u, 2984611177u,
-58509511u, 1046943619u,
-3508927906u, 2001585786u,
-2544767379u, 1525438381u,
-552181222u, 1959725830u,
-879448844u, 1348536411u,
-4242243590u, 2861338018u,
-1082052441u, 1034351453u,
-601175800u, 764077711u,
-530635011u, 3785343245u,
-2178026726u, 117256687u,
-2378297261u, 457568934u,
-76438221u, 4104954272u,
-956793873u, 3783168634u,
-2485968477u, 2381948487u,
-4226929450u, 3148473363u,
-2518273601u, 3569490233u,
-879369091u, 2180270337u,
-3674375989u, 1387729170u,
-977997984u, 4270646856u,
-568650985u, 951677556u,
-4213877384u, 2721005055u,
-1073364549u, 2563403831u,
-1678669911u, 66786703u,
-2273631661u, 1149351924u,
-3651298990u, 1581883443u,
-246723096u, 1895026827u,
-3810605772u, 3711056516u,
-4058833288u, 2193790614u,
-2080120290u, 3638638708u,
-2915672708u, 2263003308u,
-2361934197u, 4136767460u,
-1976115991u, 3448840877u,
-2019238520u, 225333538u,
-874340815u, 2976159827u,
-1555273378u, 3797521928u,
-1942347150u, 3262952567u,
-435997738u, 340403353u,
-2817830907u, 2078619498u,
-749534111u, 1178073973u,
-894654712u, 3361226032u,
-841092198u, 3288261538u,
-1696412169u, 1496966875u,
-697501571u, 1059158875u,
-3739946319u, 2481012988u,
-568983526u, 114945840u,
-1559249010u, 2218244008u,
-2841706923u, 1632780103u,
-4020169654u, 2087949619u,
-2438736103u, 24032648u,
-833416317u, 3787017905u,
-2373238993u, 2575395164u,
-3434544481u, 3228481067u,
-2542976862u, 2971726178u,
-2880371864u, 3642087909u,
-2407477975u, 2239080836u,
-1043714217u, 3894199764u,
-2235879182u, 203853421u,
-2933669448u, 2504940536u,
-834683330u, 425935223u,
-3560796393u, 3565833278u,
-1668000829u, 3683399154u,
-3414330886u, 1748785729u,
-1023171602u, 580966986u,
-2531038985u, 3227325488u,
-2657385925u, 2124704694u,
-233442446u, 1107045577u,
-3407293834u, 552770757u,
-3899097693u, 1067532701u,
-115667924u, 1406028344u,
-1707768231u, 3724015962u,
-2419657149u, 18613994u,
-2532882091u, 3476683808u,
-1560838678u, 811220224u,
-895961699u, 3762914298u,
-1328752423u, 1844996900u,
-1420427894u, 1848067707u,
-1210281744u, 904215228u,
-4055325594u, 1118521573u,
-2496554183u, 2579259919u,
-3996647489u, 3657647605u,
-325254059u, 3136157065u,
-3951522674u, 4052925250u,
-3341068436u, 2287683323u,
-1313073005u, 126005630u,
-2505120084u, 1194725057u,
-853746559u, 3555092974u,
-2689238752u, 49515858u,
-1244776042u, 1069300695u,
-61073168u, 1010661841u,
-1269521335u, 1902040126u,
-990632502u, 2378708922u,
-3858321250u, 1400735275u,
-2974699176u, 2771676666u,
-170995186u, 2877798589u,
-545726212u, 2225229957u,
-1086473152u, 3454177594u,
-3859483262u, 1499729584u,
-2088002891u, 2883475137u,
-3222194252u, 4144472319u,
-2212229854u, 4146740722u,
-567988835u, 1051332394u,
-3932046135u, 542648229u,
-3017852446u, 1277887997u,
-162888005u, 1669710469u,
-1492500905u, 553041029u,
-1434876932u, 533989516u,
-3817492747u, 584127807u,
-4147115982u, 2993670925u,
-4020312558u, 710021255u,
-3509733475u, 3587959456u,
-2088550465u, 1745399498u,
-2952242967u, 1259815443u,
-869648362u, 1404723176u,
-3947542735u, 1334333531u,
-3873471582u, 229399758u,
-59634866u, 3239516985u,
-3844250972u, 1275954779u,
-492891666u, 1029533080u,
-1552951157u, 367320647u,
-699480890u, 3684418197u,
-3707014310u, 471105777u,
-1824587258u, 4030809053u,
-3489914436u, 484559105u,
-1235750398u, 1428453396u,
-4230459084u, 4255931645u,
-1848597055u, 4271715616u,
-331780381u, 482425775u,
-2435323270u, 3171911678u,
-3507210587u, 928543347u,
-4197807526u, 3680046204u,
-2766042024u, 2159512867u,
-179373257u, 313902234u,
-4024837592u, 294795361u,
-1622282562u, 647086234u,
-2825039429u, 577214736u,
-4043412446u, 2426981244u,
-1277736097u, 1130129573u,
-2601395338u, 995791646u,
-36668922u, 3344746679u,
-1521532225u, 1645086060u,
-2622763015u, 4122335794u,
-2936887705u, 494465807u,
-2580840343u, 1064648931u,
-1247887787u, 2752145076u,
-1277612417u, 1249660507u,
-2288678613u, 3312498873u,
-2459273912u, 4238535494u,
-3117488020u, 2571979978u,
-2680188909u, 1471227427u,
-1616494033u, 633688562u,
-2268653416u, 3268237290u,
-3021962815u, 1959779970u,
-3321382074u, 766642813u,
-204429780u, 1323319858u,
-3676032891u, 1380896111u,
-4030639049u, 3647601207u,
-1830028502u, 2830263774u,
-1375962216u, 1733961041u,
-939765180u, 521947915u,
-3903267364u, 497472767u,
-1619700946u, 189164145u,
-3115593885u, 486382294u,
-1262445920u, 4062496162u,
-2464795849u, 3770038872u,
-4032121374u, 3235740744u,
-3757765258u, 1777199847u,
-2167243108u, 1912506671u,
-4180515317u, 2276864677u,
-536034089u, 2384915026u,
-162938278u, 1588060152u,
-4018349945u, 2504457929u,
-841450426u, 2790120722u,
-2719983588u, 1471020554u,
-1390856732u, 3623212998u,
-2506944218u, 1035080801u,
-348812127u, 3026631806u,
-746483541u, 2342164722u,
-122104390u, 4074122771u,
-3986865419u, 1674890530u,
-3693306023u, 3011542850u,
-1294951725u, 899303190u,
-3577146915u, 3549160092u,
-1241677652u, 4290680005u,
-3193053279u, 2029187390u,
-3298063095u, 3943068002u,
-3946220635u, 2273781461u,
-889053698u, 1376304022u,
-1486839612u, 2127663659u,
-344127443u, 1646681121u,
-2780117810u, 2142045764u,
-2694572773u, 447810651u,
-2185527146u, 2366308558u,
-290335413u, 584901173u,
-2012370276u, 970504950u,
-3258236042u, 2008155560u,
-3945579565u, 614796295u,
-24452072u, 2695940969u,
-3983727134u, 3444688454u,
-1327044473u, 3545633451u,
-1875293322u, 1739318893u,
-1707527799u, 2683090634u,
-2848082386u, 2814622471u,
-4111401777u, 2774816580u,
-3849839194u, 437560100u,
-2238350150u, 2462124836u,
-665017710u, 512012738u,
-2945294779u, 3305170944u,
-819477765u, 59419271u,
-155125658u, 665292744u,
-444722813u, 3580039116u,
-2355675635u, 663735032u,
-3247800169u, 1579404983u,
-1985115003u, 3397891494u,
-358696453u, 1474896279u,
-516388613u, 710590371u,
-3490497111u, 2514565805u,
-2386143445u, 477509654u,
-412854590u, 3624609754u,
-3214388668u, 3516075816u,
-2731288520u, 1369482895u,
-4033204378u, 1314000850u,
-829769325u, 1935166880u,
-1608191643u, 2607067237u,
-423820371u, 3257747610u,
-1355298041u, 3776931214u,
-4105054901u, 2107080812u,
-1911521879u, 3183054185u,
-3910177801u, 675129307u,
-1209358971u, 4205727791u,
-1435726287u, 3333261712u,
-1400982708u, 1154611403u,
-1663501483u, 2837596667u,
-3164734053u, 2759854023u,
-4012043629u, 1963228038u,
-3981675284u, 2677557877u,
-520119591u, 505138315u,
-897271356u, 1803966773u,
-1016663294u, 616691903u,
-2254742522u, 4032705384u,
-2468470796u, 798395739u,
-3025169002u, 3570037122u,
-1461093710u, 3473799845u,
-3702624858u, 476400898u,
-1043039728u, 2304070437u,
-181576948u, 602972493u,
-3996616030u, 3289878097u,
-2068516226u, 3922247304u,
-1299968266u, 2520311409u,
-1968824721u, 3214794876u,
-1581813122u, 2668800905u,
-3297613974u, 748160407u,
-1145536484u, 1326769504u,
-2973323521u, 3775262814u,
-3218653169u, 902775872u,
-3498603433u, 1372805534u,
-704686363u, 3626542352u,
-2271580579u, 1213925114u,
-46329775u, 3009384989u,
-1330254048u, 1194824134u,
-514204310u, 3781981134u,
-442526164u, 2835608783u,
-3460471867u, 510634034u,
-546406434u, 2716786748u,
-2840500021u, 1669490957u,
-2536189149u, 3251421224u,
-1358736072u, 1089334066u,
-3260749330u, 250756920u,
-2974806681u, 1513718866u,
-82635635u, 4041016629u,
-3391765744u, 2495807367u,
-3962674316u, 2822889695u,
-753413337u, 2008251381u,
-3123390177u, 106212622u,
-490570565u, 1684884205u,
-793892547u, 1927268995u,
-2344148164u, 2251978818u,
-437424236u, 2774023200u,
-2674940754u, 3788056262u,
-2597882666u, 3678660147u,
-3797434193u, 3838215866u,
-279687080u, 2656772270u,
-2190204787u, 1997584981u,
-3384401882u, 3160208845u,
-3629379425u, 2668998785u,
-1050036757u, 2954162084u,
-917091826u, 1744374041u,
-1454282570u, 845687881u,
-2997173625u, 776018378u,
-1137560602u, 1938378389u,
-1748082354u, 2066910012u,
-2677675207u, 918315064u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; { uint64_t h = farmhashte::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
-{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint64_t h = farmhashte::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashteTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint64_t h = farmhashte::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashteTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashteTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashteTest::Dump(0, i);
- }
- farmhashteTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashuoTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-3254014218u, 429095991u,
-165589978u, 1578546616u,
-623071693u, 366414107u,
-249776086u, 1207522198u,
-3120876698u, 1684583131u,
-46987739u, 1157614300u,
-199124911u, 520792961u,
-3614377032u, 586863115u,
-1716848157u, 4033596884u,
-1164298657u, 4140791139u,
-3824360466u, 3242407770u,
-3725511003u, 232064808u,
-2736953692u, 816692935u,
-512845449u, 3748861010u,
-4290630595u, 517646945u,
-22638523u, 648000590u,
-1283799121u, 3047062993u,
-1024246061u, 4027776454u,
-834785312u, 382936554u,
-411505255u, 1973395102u,
-580988377u, 2826990641u,
-3474970689u, 1029055034u,
-2584372201u, 1758123094u,
-589567754u, 325737734u,
-3886113119u, 3338548567u,
-257578986u, 3698087965u,
-3604937815u, 3198590202u,
-2305332220u, 191910725u,
-4244322689u, 542201663u,
-3315355162u, 2135941665u,
-1175961330u, 3948351189u,
-23075771u, 3252374102u,
-713127376u, 1467786451u,
-663013031u, 3444053918u,
-3077742128u, 1062268187u,
-2115441882u, 4081398201u,
-2335576331u, 2560479831u,
-1379288194u, 4225182569u,
-3958366652u, 3067277639u,
-3667516477u, 1709989541u,
-4188504038u, 59581167u,
-2725013602u, 3639843023u,
-3758739543u, 4189944477u,
-2470483982u, 877580602u,
-3252925478u, 2062343506u,
-3981838403u, 3762572073u,
-2931588131u, 3284356565u,
-1129162571u, 732225574u,
-1677744031u, 3532596884u,
-3232041815u, 1652884780u,
-3740979556u, 259034107u,
-2227121257u, 1426140634u,
-315836068u, 3200749877u,
-1386256573u, 24035717u,
-234531934u, 1115203611u,
-1598686658u, 3146815575u,
-2632963283u, 1778459926u,
-739944537u, 579625482u,
-1231665285u, 2457048126u,
-3903349120u, 389846205u,
-1052645068u, 862072556u,
-2834153464u, 1481069623u,
-1688445808u, 701920051u,
-3740748788u, 3388062747u,
-1192588249u, 1410111809u,
-2633463887u, 4050419847u,
-2513844237u, 2187968410u,
-2951683019u, 3015806005u,
-3000537321u, 479241367u,
-252167538u, 1231057113u,
-393624922u, 704325635u,
-1467197045u, 2066433573u,
-3082385053u, 735688735u,
-956434529u, 4028590195u,
-4074716319u, 813690332u,
-2124740535u, 804073145u,
-3748881891u, 3195309868u,
-841856605u, 2585865274u,
-881504822u, 3254795114u,
-1241815736u, 970796142u,
-497175391u, 3929484338u,
-4264993211u, 1835322201u,
-3675707838u, 4205965408u,
-300298607u, 3858319990u,
-3255259608u, 4247675634u,
-1095823272u, 1197245408u,
-1742785722u, 785893184u,
-1702965674u, 850401405u,
-4084891412u, 1160134629u,
-2555998391u, 1972759056u,
-710625654u, 4116162021u,
-3352753742u, 85121177u,
-3513255468u, 2487440590u,
-2480032715u, 2287747045u,
-4090178629u, 4044418876u,
-1703944517u, 486290428u,
-1515601363u, 2011102035u,
-573985957u, 3536053779u,
-4257172787u, 576405853u,
-1523550693u, 1014952061u,
-711098718u, 2425317635u,
-3460807169u, 3688987163u,
-3167371443u, 3062418115u,
-3330028292u, 1713171303u,
-526177822u, 2602636307u,
-1245357025u, 3346699703u,
-254529415u, 4017058800u,
-1829738451u, 2164236533u,
-1381258384u, 4036354071u,
-1749181924u, 4118435443u,
-4130543625u, 688472265u,
-2731071299u, 2547657502u,
-4175776103u, 338058159u,
-3729582129u, 4181845558u,
-2227290760u, 146827036u,
-2459178427u, 1025353883u,
-4284109679u, 2502815838u,
-825124804u, 2533140036u,
-616327404u, 2448966429u,
-413992636u, 2334782461u,
-2239052397u, 1082330589u,
-3381164715u, 199381437u,
-2583939798u, 2848283092u,
-2300168091u, 2156336315u,
-1855234968u, 1982110346u,
-2482046810u, 3158163887u,
-2168864636u, 133643215u,
-3904021624u, 3646514568u,
-1176127003u, 4015671361u,
-100525019u, 3534706803u,
-2045051700u, 3452457457u,
-1492267772u, 2308393828u,
-3776661467u, 3281002516u,
-4246334524u, 743955039u,
-685631442u, 1147951686u,
-2040912376u, 2911148054u,
-3204999386u, 2415262714u,
-313209105u, 777065474u,
-2729416454u, 1029284767u,
-1632078298u, 1817552554u,
-3963877000u, 1919171906u,
-3843219958u, 3073580867u,
-865146997u, 2473524405u,
-2593817617u, 3643076308u,
-617975720u, 3671562289u,
-121812599u, 2902367378u,
-2260041112u, 1019936943u,
-320945955u, 2337845588u,
-1535670711u, 773792826u,
-3152195900u, 4090794518u,
-4142587430u, 484732447u,
-419191319u, 3377973345u,
-324924679u, 2809286837u,
-1562277603u, 1378362199u,
-3791551981u, 1097806406u,
-1386297408u, 2304900033u,
-3574135531u, 4017075736u,
-1161238398u, 1358056883u,
-3487080616u, 1516736273u,
-851615042u, 2927899494u,
-4077452507u, 2984955003u,
-3907754394u, 3578173844u,
-1948409509u, 1923531348u,
-3578472493u, 3710074193u,
-213811117u, 2586632018u,
-1922589216u, 274958014u,
-1654276320u, 2687561076u,
-2569061755u, 3122046057u,
-3203802620u, 1692079268u,
-477806878u, 140587742u,
-520565830u, 3674576684u,
-91246882u, 1010215946u,
-3703994407u, 69201295u,
-776213083u, 3677771507u,
-3696902571u, 3593730713u,
-2907901228u, 3239753796u,
-1586241476u, 1939595371u,
-2268396558u, 3468719670u,
-2955715987u, 2295501078u,
-2775848696u, 1358532390u,
-3843660102u, 82177963u,
-4094477877u, 191727221u,
-278661677u, 2889101923u,
-1352525614u, 2844977667u,
-1261140657u, 1747052377u,
-2334120653u, 645125282u,
-2707230761u, 4142246789u,
-1068639717u, 2288162940u,
-1419293714u, 1636932722u,
-3252686293u, 318543902u,
-2598802768u, 2025886508u,
-2250788464u, 2711763065u,
-255108733u, 1845587644u,
-3719270134u, 3940707863u,
-917608574u, 1363253259u,
-788659330u, 673256220u,
-109793386u, 341851980u,
-2698465479u, 3011229884u,
-3886713057u, 1276595523u,
-2439962760u, 2700515456u,
-205970448u, 4198897105u,
-875511891u, 371715572u,
-1033680610u, 4278599955u,
-3120038721u, 1256300069u,
-225629455u, 3735275001u,
-3961944123u, 1769389163u,
-1074553219u, 668829411u,
-1098679359u, 2573697509u,
-1885071395u, 4233785523u,
-2513878053u, 2030193788u,
-360256231u, 107312677u,
-310517502u, 2618936366u,
-3600462351u, 1216645846u,
-2970730323u, 4278812598u,
-94638678u, 1689811113u,
-4125738800u, 3103759730u,
-103797041u, 1397772514u,
-1669653333u, 572567964u,
-1612872497u, 2986430557u,
-214990655u, 3117607990u,
-1949717207u, 2260498180u,
-1493936866u, 3554860960u,
-1582022990u, 1263709570u,
-1244120487u, 3416600761u,
-224580012u, 4252610345u,
-286306391u, 814956796u,
-1820532305u, 2776960536u,
-3082703465u, 1659265982u,
-1157398049u, 3752806924u,
-3508246460u, 2902716664u,
-2110942730u, 3267551635u,
-902835431u, 405228165u,
-2341378668u, 2220373824u,
-3303626294u, 1175118221u,
-383517064u, 896322512u,
-1697257567u, 2202820683u,
-1837689083u, 1336556841u,
-914535232u, 3634083711u,
-1537187340u, 3712582785u,
-1088201893u, 3270984620u,
-3093195926u, 2561488770u,
-1962968100u, 236189500u,
-2549435227u, 536047554u,
-422609195u, 2958815818u,
-4166184983u, 3528794619u,
-1042329086u, 3914176886u,
-1359641525u, 1197100813u,
-1269739674u, 3301844628u,
-1831223342u, 3329594980u,
-2433669782u, 494908536u,
-1441714797u, 1174785921u,
-1933050423u, 958901065u,
-868981704u, 2163330264u,
-3243110680u, 1443133429u,
-1145009669u, 2520062970u,
-3851564853u, 2664619323u,
-2686075657u, 4042710240u,
-2125408249u, 4165697916u,
-2328730865u, 3160666939u,
-588683409u, 2126275847u,
-829404209u, 1878067032u,
-2567792910u, 897670516u,
-934312076u, 2952135524u,
-504832490u, 3312698056u,
-4015478120u, 1265237690u,
-3376133707u, 967674402u,
-1553513184u, 834830418u,
-2396504772u, 3278582098u,
-2950762705u, 4277111759u,
-4159211303u, 1290097509u,
-251949572u, 3065234219u,
-1832020534u, 312136369u,
-1103404394u, 198182691u,
-1369599600u, 3906710870u,
-2954651680u, 1535115487u,
-2389327507u, 1813520230u,
-632704095u, 140762681u,
-3123202913u, 3336005523u,
-1287729497u, 2198985327u,
-2470730783u, 3821758006u,
-1009870118u, 559702706u,
-4274686257u, 3187546567u,
-2402308151u, 1096697687u,
-678932329u, 3716363135u,
-2899950405u, 3046872820u,
-3754655641u, 2021741414u,
-1993425202u, 2185339100u,
-2838253700u, 3099212100u,
-1679617763u, 3703603898u,
-1135665833u, 3559875668u,
-2503579743u, 1446869792u,
-879818611u, 3788305533u,
-2879018745u, 2719373510u,
-3606051203u, 2166567748u,
-343595772u, 1996164093u,
-1577656121u, 475248376u,
-463852893u, 2864244470u,
-1332049663u, 3326459767u,
-3207234525u, 2028708916u,
-938916154u, 3115246264u,
-3272166407u, 557660441u,
-1265684026u, 245033807u,
-2440657523u, 255451671u,
-3811885130u, 1399880284u,
-1322855877u, 3452203069u,
-1324994449u, 3796404024u,
-2002090272u, 1568745354u,
-3700047753u, 31799506u,
-3009412313u, 3184047862u,
-728680761u, 3848624873u,
-1849329144u, 3160134214u,
-1272923193u, 1474278816u,
-1208883495u, 1566527339u,
-4136466541u, 630825649u,
-1717327230u, 1496132623u,
-2449386742u, 128106940u,
-2108574735u, 2584236470u,
-2872246579u, 397338552u,
-3088905079u, 3456882941u,
-1715915153u, 2940716269u,
-4168438718u, 467441309u,
-872996731u, 3206901319u,
-1610606159u, 2540270567u,
-1301658081u, 2379410194u,
-2109315753u, 3348545480u,
-2041927873u, 2644077493u,
-546596661u, 1017047954u,
-2596792972u, 2783958892u,
-2826408201u, 3531646869u,
-2219352672u, 4217451852u,
-1806867885u, 1903578924u,
-2076465705u, 2373061493u,
-1832925325u, 241574049u,
-1509517110u, 3703614272u,
-3429894862u, 3529565564u,
-4010000614u, 2256197939u,
-517086873u, 2964595704u,
-3501035294u, 4079457298u,
-1184683823u, 4260564140u,
-2339268412u, 3871564102u,
-1572637805u, 383233885u,
-3351411126u, 3419328182u,
-2017406667u, 919677938u,
-29804156u, 46276077u,
-3032591014u, 4204155962u,
-1172319502u, 969309871u,
-2211319468u, 4153726847u,
-3094193193u, 4240669441u,
-3441709766u, 1387233546u,
-4048882438u, 1217896566u,
-1580964938u, 740563169u,
-3691850348u, 3176426539u,
-2738323042u, 2948665536u,
-1474029445u, 3513354882u,
-3219466255u, 3799363969u,
-3961796122u, 1055550923u,
-1992212097u, 2263421398u,
-4289759174u, 2516844140u,
-1782515131u, 2746577402u,
-721928440u, 3529570984u,
-1705302106u, 768287270u,
-3474902815u, 4000011125u,
-3475618043u, 212490675u,
-549130471u, 2970128275u,
-3170016833u, 2549835613u,
-3691104824u, 2694324482u,
-4169365948u, 3738062408u,
-602930397u, 2148954730u,
-2636387819u, 2616619070u,
-301617872u, 374657036u,
-3862686086u, 431292293u,
-4225245165u, 1358580562u,
-2377363130u, 1415970351u,
-3885060756u, 1438379807u,
-2297418515u, 2954777083u,
-3970368221u, 1229801760u,
-1931934525u, 2287507921u,
-1713471510u, 2145608111u,
-2650140034u, 4081586725u,
-4196863572u, 1896558394u,
-4059852729u, 1813855658u,
-2618400836u, 1396056469u,
-2375584220u, 1037031473u,
-249284003u, 2450077637u,
-1383747654u, 3122687303u,
-2664431743u, 3855028730u,
-929335420u, 3193251135u,
-137313762u, 1850894384u,
-3163711272u, 3071568023u,
-418541677u, 3621223039u,
-340274176u, 1167681812u,
-4106647531u, 4022465625u,
-3069708839u, 2704165015u,
-2332023349u, 641449034u,
-921552000u, 1712976649u,
-1876484273u, 2343049860u,
-1834682077u, 4155949943u,
-2061821157u, 4240649383u,
-747285578u, 1626463554u,
-165503115u, 359629739u,
-3838102563u, 582664250u,
-3878924635u, 4117237498u,
-2250573853u, 804336148u,
-331393443u, 4242530387u,
-3346357270u, 1674051445u,
-3348019777u, 1722242971u,
-2509017299u, 2966108111u,
-4189102509u, 3323592310u,
-2631381069u, 4014551783u,
-4250787412u, 3448394212u,
-2664752123u, 3517585534u,
-3605365141u, 1669471183u,
-2210121140u, 760762191u,
-249697459u, 3416920106u,
-16322182u, 643179562u,
-1564226597u, 2134630675u,
-1011990087u, 2990167340u,
-2349550842u, 1642428946u,
-1214854475u, 2134299399u,
-2704221532u, 2104175211u,
-4283196353u, 1342880802u,
-198529755u, 2004468390u,
-2544665755u, 853593042u,
-2090611294u, 2970943872u,
-1472073141u, 850464484u,
-1407609278u, 3062461105u,
-366448238u, 3842907484u,
-488797416u, 1432670231u,
-294963924u, 3693536939u,
-3390549825u, 1583234720u,
-4032223840u, 2318423400u,
-2965642867u, 930822729u,
-1679099863u, 1728968857u,
-900822335u, 702309817u,
-3258354115u, 1502282913u,
-2811888503u, 3924947660u,
-2477280726u, 3651607391u,
-3788310204u, 1300369123u,
-1842333726u, 4146839064u,
-2468893861u, 4091095953u,
-488595746u, 1448097974u,
-1159634090u, 1738834113u,
-2928916831u, 4093725287u,
-530850094u, 291657799u,
-3548184546u, 679517009u,
-399175380u, 2658337143u,
-3827951761u, 3086277222u,
-2067718397u, 3632376023u,
-3553313841u, 119173722u,
-1702434637u, 1766260771u,
-895654784u, 751439914u,
-4008409498u, 215917713u,
-1288382231u, 2656990891u,
-2581779077u, 1570750352u,
-2666411616u, 3533987737u,
-4289478316u, 3576119563u,
-3869794273u, 963183826u,
-2081410737u, 3796810515u,
-1036883117u, 136547246u,
-875691100u, 2592925324u,
-2689342539u, 427154472u,
-532957601u, 1228758574u,
-1908591042u, 1464255968u,
-446980910u, 2984611177u,
-3508927906u, 2001585786u,
-2544767379u, 1525438381u,
-879448844u, 1348536411u,
-4242243590u, 2861338018u,
-601175800u, 764077711u,
-530635011u, 3785343245u,
-2378297261u, 457568934u,
-76438221u, 4104954272u,
-2485968477u, 2381948487u,
-4226929450u, 3148473363u,
-879369091u, 2180270337u,
-3674375989u, 1387729170u,
-568650985u, 951677556u,
-4213877384u, 2721005055u,
-1678669911u, 66786703u,
-2273631661u, 1149351924u,
-246723096u, 1895026827u,
-3810605772u, 3711056516u,
-2080120290u, 3638638708u,
-2915672708u, 2263003308u,
-1976115991u, 3448840877u,
-2019238520u, 225333538u,
-1555273378u, 3797521928u,
-1942347150u, 3262952567u,
-2817830907u, 2078619498u,
-749534111u, 1178073973u,
-841092198u, 3288261538u,
-1696412169u, 1496966875u,
-3739946319u, 2481012988u,
-568983526u, 114945840u,
-2841706923u, 1632780103u,
-4020169654u, 2087949619u,
-833416317u, 3787017905u,
-2373238993u, 2575395164u,
-2542976862u, 2971726178u,
-2880371864u, 3642087909u,
-1043714217u, 3894199764u,
-2235879182u, 203853421u,
-834683330u, 425935223u,
-3560796393u, 3565833278u,
-3414330886u, 1748785729u,
-1023171602u, 580966986u,
-2657385925u, 2124704694u,
-233442446u, 1107045577u,
-3899097693u, 1067532701u,
-115667924u, 1406028344u,
-2419657149u, 18613994u,
-2532882091u, 3476683808u,
-895961699u, 3762914298u,
-1328752423u, 1844996900u,
-1210281744u, 904215228u,
-4055325594u, 1118521573u,
-3996647489u, 3657647605u,
-325254059u, 3136157065u,
-3341068436u, 2287683323u,
-1313073005u, 126005630u,
-853746559u, 3555092974u,
-2689238752u, 49515858u,
-61073168u, 1010661841u,
-1269521335u, 1902040126u,
-3858321250u, 1400735275u,
-2974699176u, 2771676666u,
-545726212u, 2225229957u,
-1086473152u, 3454177594u,
-2088002891u, 2883475137u,
-3222194252u, 4144472319u,
-567988835u, 1051332394u,
-3932046135u, 542648229u,
-162888005u, 1669710469u,
-1492500905u, 553041029u,
-3817492747u, 584127807u,
-4147115982u, 2993670925u,
-3509733475u, 3587959456u,
-2088550465u, 1745399498u,
-869648362u, 1404723176u,
-3947542735u, 1334333531u,
-59634866u, 3239516985u,
-3844250972u, 1275954779u,
-2512155003u, 1685649437u,
-639306006u, 2524620206u,
-576786501u, 655707039u,
-2864351838u, 3736264674u,
-1200907897u, 2384379464u,
-15823708u, 206117476u,
-1193310960u, 1093099415u,
-3696538026u, 4112584792u,
-2069527017u, 547588820u,
-4178147211u, 2827259351u,
-940846775u, 1054995047u,
-2976960697u, 1934305529u,
-2199137382u, 1005722394u,
-1875867180u, 2064356511u,
-4019734130u, 3096333006u,
-2069509024u, 2906358341u,
-2232866485u, 1456016086u,
-1422674894u, 867282151u,
-1612503136u, 1739843072u,
-134947567u, 2978775774u,
-1284167756u, 1090844589u,
-831688783u, 2079216362u,
-1626991196u, 3644714163u,
-3678110059u, 898470030u,
-3916646913u, 3182422972u,
-3630426828u, 969847973u,
-3427164640u, 3463937250u,
-3044785046u, 897322257u,
-3443872170u, 4185408854u,
-2557463241u, 4080940424u,
-2048168570u, 2429169982u,
-3174690447u, 2513494106u,
-1213061732u, 3143736628u,
-3482268149u, 1250714337u,
-31648125u, 3872383625u,
-1565760579u, 36665130u,
-751041229u, 2257179590u,
-2915361862u, 280819225u,
-2907818413u, 4254297769u,
-3493178615u, 3755944354u,
-4043533423u, 1134196225u,
-4177134659u, 127246419u,
-2442615581u, 923049607u,
-1004426206u, 782768297u,
-2410586681u, 1430106871u,
-4103323427u, 3168399477u,
-3716682375u, 3616334719u,
-3413209549u, 656672786u,
-2876965944u, 182894450u,
-456581318u, 2683752067u,
-3877875910u, 3190666241u,
-3240336907u, 4024807233u,
-1681224377u, 1576191191u,
-3599250276u, 2381111980u,
-3495321877u, 3956024585u,
-1611608524u, 3815677453u,
-2062334396u, 1656117707u,
-5457134u, 3234118251u,
-470187419u, 2688566989u,
-3259870297u, 660100446u,
-442236198u, 2542452448u,
-493137955u, 392411099u,
-947967568u, 1234595917u,
-4230082284u, 2762976773u,
-2870085764u, 1455086530u,
-2762099647u, 4011882747u,
-1215981925u, 3227517889u,
-3269061963u, 4037515364u,
-3168911474u, 4255057396u,
-2026092260u, 1736192508u,
-3909727042u, 3114708966u,
-1938800693u, 680793595u,
-1525265867u, 2808224480u,
-2122290603u, 1211197714u,
-3520488321u, 3979192396u,
-3540779343u, 4192918639u,
-2736030448u, 1120335563u,
-1698949078u, 3993310631u,
-1966048551u, 2228221363u,
-597941119u, 3498018399u,
-393987327u, 454500547u,
-1222959566u, 567151340u,
-3774764786u, 1492844524u,
-3308300614u, 805568076u,
-868414882u, 177406999u,
-1608110313u, 642061169u,
-1027515771u, 3131251981u,
-2851936150u, 4272755262u,
-1532845092u, 709643652u,
-682573592u, 1244104217u,
-796769556u, 2500467040u,
-3002618826u, 1112998535u,
-1780193104u, 1243644607u,
-3691719535u, 2958853053u,
-466635014u, 2277292580u,
-4082276003u, 1030800045u,
-1750863246u, 379050598u,
-3576413281u, 731493104u,
-132259176u, 4115195437u,
-1769890695u, 2715470335u,
-1819263183u, 2028531518u,
-2154809766u, 3672399742u,
-76727603u, 4198182186u,
-2304993586u, 1666387627u,
-284366017u, 3359785538u,
-3469807328u, 2926494787u,
-3829072836u, 2493478921u,
-3738499303u, 3311304980u,
-932916545u, 2235559063u,
-2909742396u, 1765719309u,
-1456588655u, 508290328u,
-1490719640u, 3356513470u,
-2908490783u, 251085588u,
-830410677u, 3172220325u,
-3897208579u, 1940535730u,
-151909546u, 2384458112u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; { uint64_t h = farmhashuo::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
-{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint64_t h = farmhashuo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashuoTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint64_t h = farmhashuo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashuoTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashuoTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashuoTest::Dump(0, i);
- }
- farmhashuoTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
-static char data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
-// Initialize data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
- memcpy(data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashxoTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-1140953930u, 861465670u,
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-890626835u, 800175912u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-3283896453u, 1867689945u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-1110588164u, 4186314283u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-283198166u, 2741341286u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-452473466u, 1706958772u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-236935126u, 2976578695u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-2305012065u, 2169731866u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-3058973506u, 2379411653u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-147814787u, 720739346u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-3425469811u, 3690733394u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-1635026870u, 192883107u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-3969463346u, 1436364519u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-2859809759u, 3808705738u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-4023053163u, 2650381482u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-3476440786u, 3829307897u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-2902102606u, 3600725550u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1448662590u, 397635823u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-180854224u, 2604346966u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-1669465176u, 1341975128u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-1043692997u, 1454396064u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-703505868u, 678706990u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-1933894405u, 3043213226u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-3828089804u, 3632594520u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-3729087873u, 1303930448u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3103338579u, 3064290191u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2295806711u, 1781190011u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-1968445277u, 315203929u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-440398219u, 1891630171u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-4204318635u, 441430649u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-3010839769u, 2837339569u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-4139181436u, 2993479124u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-667183474u, 2084369203u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-1016656857u, 3022024459u,
-3254014218u, 429095991u,
-990500595u, 3056862311u,
-985653208u, 1718653828u,
-623071693u, 366414107u,
-1771289760u, 2293458109u,
-3047342438u, 2991127487u,
-3120876698u, 1684583131u,
-3638043310u, 1170404994u,
-863214540u, 1087193030u,
-199124911u, 520792961u,
-3169775996u, 1577421232u,
-3331828431u, 1013201099u,
-1716848157u, 4033596884u,
-1770708857u, 4229339322u,
-1146169032u, 1434258493u,
-3824360466u, 3242407770u,
-1926419493u, 2649785113u,
-872586426u, 762243036u,
-2736953692u, 816692935u,
-1571283333u, 3555213933u,
-2266795890u, 3781899767u,
-4290630595u, 517646945u,
-3006163611u, 2180594090u,
-959214578u, 558910384u,
-1283799121u, 3047062993u,
-3830962609u, 2391606125u,
-3544509313u, 622325861u,
-834785312u, 382936554u,
-1421463872u, 788479970u,
-1825135056u, 2725923798u,
-580988377u, 2826990641u,
-247825043u, 3167748333u,
-812546227u, 2506885666u,
-2584372201u, 1758123094u,
-1891789696u, 389974094u,
-345313518u, 2022370576u,
-3886113119u, 3338548567u,
-1083486947u, 2583576230u,
-1776047957u, 1771384107u,
-3604937815u, 3198590202u,
-3027522813u, 4155628142u,
-4232136669u, 427759438u,
-4244322689u, 542201663u,
-1549591985u, 2856634168u,
-556609672u, 45845311u,
-1175961330u, 3948351189u,
-4165739882u, 4194218315u,
-1634635545u, 4151937410u,
-713127376u, 1467786451u,
-1327394015u, 2743592929u,
-2638154051u, 810082938u,
-3077742128u, 1062268187u,
-4084325664u, 3810665822u,
-3735739145u, 2794294783u,
-2335576331u, 2560479831u,
-690240711u, 997658837u,
-2442302747u, 3948961926u,
-3958366652u, 3067277639u,
-2059157774u, 1211737169u,
-1516711748u, 2339636583u,
-4188504038u, 59581167u,
-2767897792u, 1389679610u,
-2658147000u, 2643979752u,
-3758739543u, 4189944477u,
-1454470782u, 100876854u,
-2995362413u, 118817200u,
-3252925478u, 2062343506u,
-2804483644u, 3088828656u,
-1231633714u, 4168280671u,
-2931588131u, 3284356565u,
-1255909792u, 3130054947u,
-4173605289u, 1407328702u,
-1677744031u, 3532596884u,
-3162657845u, 3887208531u,
-2256541290u, 3459463480u,
-3740979556u, 259034107u,
-392987633u, 3233195759u,
-3606709555u, 3424793077u,
-315836068u, 3200749877u,
-4065431359u, 760633989u,
-2982018998u, 1811050648u,
-234531934u, 1115203611u,
-3897494162u, 1516407838u,
-1603559457u, 323296368u,
-2632963283u, 1778459926u,
-2879836826u, 2146672889u,
-3486330348u, 492621815u,
-1231665285u, 2457048126u,
-3438440082u, 2217471853u,
-3355404249u, 3275550588u,
-1052645068u, 862072556u,
-4110617119u, 3745267835u,
-2657392572u, 4279236653u,
-1688445808u, 701920051u,
-956734128u, 581695350u,
-3157862788u, 2585726058u,
-1192588249u, 1410111809u,
-1651193125u, 3326135446u,
-1073280453u, 97376972u,
-2513844237u, 2187968410u,
-3976859649u, 4267859263u,
-3429034542u, 564493077u,
-3000537321u, 479241367u,
-3845637831u, 2868987960u,
-51544337u, 1029173765u,
-393624922u, 704325635u,
-2357610553u, 1418509533u,
-2007814586u, 3866658271u,
-3082385053u, 735688735u,
-916110004u, 3283299459u,
-1051684175u, 1083796807u,
-4074716319u, 813690332u,
-144264390u, 1439630796u,
-1508556987u, 675582689u,
-3748881891u, 3195309868u,
-362884708u, 1616408198u,
-43233176u, 837301135u,
-881504822u, 3254795114u,
-1385506591u, 2799925823u,
-1469874582u, 3464841997u,
-497175391u, 3929484338u,
-3975771289u, 1798536177u,
-2926265846u, 1374242438u,
-3675707838u, 4205965408u,
-3153165629u, 1499475160u,
-187287713u, 548490821u,
-3255259608u, 4247675634u,
-1940181471u, 3779953975u,
-687167150u, 2319566715u,
-1742785722u, 785893184u,
-2296977392u, 2778575413u,
-1794720651u, 48131484u,
-4084891412u, 1160134629u,
-3737623280u, 823113169u,
-3423207646u, 3803213486u,
-710625654u, 4116162021u,
-3693420287u, 4167766971u,
-1666602807u, 295320990u,
-3513255468u, 2487440590u,
-234080704u, 4004655503u,
-2971762528u, 1479656873u,
-4090178629u, 4044418876u,
-391947536u, 1462554406u,
-3909295855u, 1239580330u,
-1515601363u, 2011102035u,
-1442068334u, 4265993528u,
-1191921695u, 2291355695u,
-4257172787u, 576405853u,
-314332944u, 4038839101u,
-55559918u, 2378985842u,
-711098718u, 2425317635u,
-1644327317u, 1401013391u,
-4193760037u, 2958260436u,
-3167371443u, 3062418115u,
-3800755475u, 3167030094u,
-3489648204u, 1405430357u,
-526177822u, 2602636307u,
-915406019u, 4264167741u,
-1484090483u, 3070944737u,
-254529415u, 4017058800u,
-1702710265u, 1029665228u,
-2000382906u, 3185573940u,
-1381258384u, 4036354071u,
-2900841028u, 2670703363u,
-2921748807u, 2899069938u,
-4130543625u, 688472265u,
-4186808827u, 1054670286u,
-1132985391u, 2840525968u,
-4175776103u, 338058159u,
-1735964501u, 1539305024u,
-3497121710u, 1568260669u,
-2227290760u, 146827036u,
-3977176001u, 4060134777u,
-857488494u, 250055052u,
-4284109679u, 2502815838u,
-2592281721u, 1603444633u,
-1390562014u, 1556658131u,
-616327404u, 2448966429u,
-3051191726u, 3891353218u,
-1213304082u, 762328245u,
-2239052397u, 1082330589u,
-2455957292u, 201837927u,
-405397452u, 3079886794u,
-2583939798u, 2848283092u,
-3750724631u, 883849006u,
-3204198988u, 3341327098u,
-1855234968u, 1982110346u,
-1485529487u, 541496720u,
-4117290321u, 3607433551u,
-2168864636u, 133643215u,
-1055817409u, 3847827123u,
-2960769387u, 4046101649u,
-1176127003u, 4015671361u,
-4243643405u, 2849988118u,
-517111221u, 1796672358u,
-2045051700u, 3452457457u,
-2948254999u, 2102063419u,
-1556410577u, 1536380876u,
-3776661467u, 3281002516u,
-1735616066u, 1539151988u,
-1087795162u, 3332431596u,
-685631442u, 1147951686u,
-95237878u, 2005032160u,
-4012206915u, 4224354805u,
-3204999386u, 2415262714u,
-1433635018u, 116647396u,
-83167836u, 2881562655u,
-2729416454u, 1029284767u,
-881378302u, 2159170082u,
-555057366u, 1169104445u,
-3963877000u, 1919171906u,
-336034862u, 2017579106u,
-4059340529u, 3020819343u,
-865146997u, 2473524405u,
-944743644u, 1694443528u,
-1804513294u, 2904752429u,
-617975720u, 3671562289u,
-260177668u, 505662155u,
-1885941445u, 2504509403u,
-2260041112u, 1019936943u,
-3722741628u, 1511077569u,
-3100701179u, 1379422864u,
-1535670711u, 773792826u,
-1103819072u, 2089123665u,
-1157547425u, 329152940u,
-4142587430u, 484732447u,
-2475035432u, 1120017626u,
-412145504u, 965125959u,
-324924679u, 2809286837u,
-2842141483u, 4029205195u,
-2974306813u, 515627448u,
-3791551981u, 1097806406u,
-3873078673u, 136118734u,
-1872130856u, 3632422367u,
-3574135531u, 4017075736u,
-1699452298u, 1403506686u,
-344414660u, 1189129691u,
-3487080616u, 1516736273u,
-1805475756u, 2562064338u,
-163335594u, 2732147834u,
-4077452507u, 2984955003u,
-4271866024u, 3071338162u,
-2347111903u, 873829983u,
-1948409509u, 1923531348u,
-459509140u, 771592405u,
-1750124750u, 2334938333u,
-213811117u, 2586632018u,
-185232757u, 4032960199u,
-2447383637u, 284777551u,
-1654276320u, 2687561076u,
-3512945009u, 308584855u,
-1861027147u, 4102279334u,
-3203802620u, 1692079268u,
-4250142168u, 2565680167u,
-1507046104u, 841195925u,
-520565830u, 3674576684u,
-38924274u, 3770488806u,
-2414430882u, 3978473838u,
-3703994407u, 69201295u,
-3099963860u, 1255084262u,
-690971838u, 3539996781u,
-3696902571u, 3593730713u,
-2363435042u, 54945052u,
-1785765213u, 184911581u,
-1586241476u, 1939595371u,
-2534883189u, 2432427547u,
-2374171993u, 2039128933u,
-2955715987u, 2295501078u,
-2741583197u, 1280920000u,
-686818699u, 1238742497u,
-3843660102u, 82177963u,
-1281043691u, 1121403845u,
-1697846708u, 284852964u,
-278661677u, 2889101923u,
-2127558730u, 713121337u,
-872502474u, 511142139u,
-1261140657u, 1747052377u,
-2108187161u, 927011680u,
-955328267u, 3821994995u,
-2707230761u, 4142246789u,
-4134691985u, 1958963937u,
-2498463509u, 1977988705u,
-1419293714u, 1636932722u,
-2567532373u, 4075249328u,
-240575705u, 1956681213u,
-2598802768u, 2025886508u,
-4104757832u, 3026358429u,
-3242615202u, 4026813725u,
-255108733u, 1845587644u,
-3573008472u, 3615577014u,
-1222733548u, 1205557630u,
-917608574u, 1363253259u,
-1541946015u, 3087190425u,
-1138008081u, 1444019663u,
-109793386u, 341851980u,
-857839960u, 2515339233u,
-156283211u, 1906768669u,
-3886713057u, 1276595523u,
-2809830736u, 460237542u,
-3420452099u, 142985419u,
-205970448u, 4198897105u,
-1950698961u, 2069753399u,
-1142216925u, 1113051162u,
-1033680610u, 4278599955u,
-1106466069u, 356742959u,
-531521052u, 3494863964u,
-225629455u, 3735275001u,
-3662626864u, 1750561299u,
-1012864651u, 2101846429u,
-1074553219u, 668829411u,
-992181339u, 3384018814u,
-3330664522u, 860966321u,
-1885071395u, 4233785523u,
-100741310u, 451656820u,
-2148187612u, 1063001151u,
-360256231u, 107312677u,
-3650357479u, 2390172694u,
-22452685u, 237319043u,
-3600462351u, 1216645846u,
-2088767754u, 164402616u,
-2418980170u, 926137824u,
-94638678u, 1689811113u,
-2751052984u, 1767810825u,
-271289013u, 3896132233u,
-103797041u, 1397772514u,
-3441135892u, 3323383489u,
-2491268371u, 1662561885u,
-1612872497u, 2986430557u,
-2756998822u, 207428029u,
-937973965u, 2791656726u,
-1949717207u, 2260498180u,
-2648427775u, 2360400900u,
-2080496169u, 486358863u,
-1582022990u, 1263709570u,
-1396468647u, 1377764574u,
-363008508u, 1293502429u,
-224580012u, 4252610345u,
-1435134775u, 1099809675u,
-533671980u, 1533438766u,
-1820532305u, 2776960536u,
-3374512975u, 3542220540u,
-822810075u, 3716663290u,
-1157398049u, 3752806924u,
-4081637863u, 337070226u,
-3866585976u, 359270190u,
-2110942730u, 3267551635u,
-644850146u, 1306761320u,
-746972907u, 934259457u,
-2341378668u, 2220373824u,
-1242645122u, 4109252858u,
-1625266099u, 1173698481u,
-383517064u, 896322512u,
-3377483696u, 1788337208u,
-455496839u, 3194373887u,
-1837689083u, 1336556841u,
-1658628529u, 2911512007u,
-3838343487u, 2757664765u,
-1537187340u, 3712582785u,
-367022558u, 3071359622u,
-3926147070u, 35432879u,
-3093195926u, 2561488770u,
-4273132307u, 3898950547u,
-2838251049u, 2103926083u,
-2549435227u, 536047554u,
-1858986613u, 2040551642u,
-1147412575u, 1972369852u,
-4166184983u, 3528794619u,
-4077477194u, 3565689036u,
-808048238u, 3826350461u,
-1359641525u, 1197100813u,
-265993036u, 1864569342u,
-725164342u, 2264788336u,
-1831223342u, 3329594980u,
-923017956u, 490608221u,
-3818634478u, 258154469u,
-1441714797u, 1174785921u,
-3833372385u, 3287246572u,
-1677395563u, 3569218731u,
-868981704u, 2163330264u,
-2649450292u, 500120236u,
-465161780u, 746438382u,
-1145009669u, 2520062970u,
-2810524030u, 1561519055u,
-1479878006u, 3864969305u,
-2686075657u, 4042710240u,
-3224066062u, 2774151984u,
-2226179547u, 1643626042u,
-2328730865u, 3160666939u,
-2107011431u, 96459446u,
-3920328742u, 3336407558u,
-829404209u, 1878067032u,
-1235983679u, 4237425634u,
-466519055u, 3870676863u,
-934312076u, 2952135524u,
-276949224u, 4100839753u,
-424001484u, 1955120893u,
-4015478120u, 1265237690u,
-427484362u, 4246879223u,
-3452969617u, 1724363362u,
-1553513184u, 834830418u,
-1858777639u, 3476334357u,
-4144030366u, 2450047160u,
-2950762705u, 4277111759u,
-358032121u, 2511026735u,
-167923105u, 2059208280u,
-251949572u, 3065234219u,
-1535473864u, 556796152u,
-1513237478u, 3150857516u,
-1103404394u, 198182691u,
-1476438092u, 2913077464u,
-207119516u, 3963810232u,
-2954651680u, 1535115487u,
-3051522276u, 4046477658u,
-917804636u, 864395565u,
-632704095u, 140762681u,
-1802040304u, 990407433u,
-3771506212u, 4106024923u,
-1287729497u, 2198985327u,
-4052924496u, 2926590471u,
-3084557148u, 1472898694u,
-1009870118u, 559702706u,
-4265214507u, 82077489u,
-3067891003u, 3295678907u,
-2402308151u, 1096697687u,
-464407878u, 4190838199u,
-4269578403u, 3060919438u,
-2899950405u, 3046872820u,
-733509243u, 1583801700u,
-40453902u, 3879773881u,
-1993425202u, 2185339100u,
-1877837196u, 3912423882u,
-3293122640u, 4104318469u,
-1679617763u, 3703603898u,
-8759461u, 2540185277u,
-1152198475u, 2038345882u,
-2503579743u, 1446869792u,
-2019419351u, 4051584612u,
-3178289407u, 3992503830u,
-2879018745u, 2719373510u,
-700836153u, 1675560450u,
-4121245793u, 2064715719u,
-343595772u, 1996164093u,
-3130433948u, 405251683u,
-2804817126u, 1607133689u,
-463852893u, 2864244470u,
-2224044848u, 4071581802u,
-2537107938u, 2246347953u,
-3207234525u, 2028708916u,
-2272418128u, 803575837u,
-38655481u, 2170452091u,
-3272166407u, 557660441u,
-4019147902u, 3841480082u,
-298459606u, 2600943364u,
-2440657523u, 255451671u,
-3424361375u, 779434428u,
-3088526123u, 490671625u,
-1322855877u, 3452203069u,
-3057021940u, 2285701422u,
-2014993457u, 2390431709u,
-2002090272u, 1568745354u,
-1783152480u, 823305654u,
-4053862835u, 2200236540u,
-3009412313u, 3184047862u,
-3032187389u, 4159715581u,
-2966902888u, 252986948u,
-1849329144u, 3160134214u,
-3420960112u, 3198900547u,
-749160960u, 379139040u,
-1208883495u, 1566527339u,
-3006227299u, 4194096960u,
-556075248u, 497404038u,
-1717327230u, 1496132623u,
-1775955687u, 1719108984u,
-1014328900u, 4189966956u,
-2108574735u, 2584236470u,
-684087286u, 531310503u,
-4264509527u, 773405691u,
-3088905079u, 3456882941u,
-3105682208u, 3382290593u,
-2289363624u, 3296306400u,
-4168438718u, 467441309u,
-777173623u, 3241407531u,
-1183994815u, 1132983260u,
-1610606159u, 2540270567u,
-2649684057u, 1397502982u,
-146657385u, 3318434267u,
-2109315753u, 3348545480u,
-3193669211u, 811750340u,
-1073256162u, 3571673088u,
-546596661u, 1017047954u,
-3403136990u, 2540585554u,
-1477047647u, 4145867423u,
-2826408201u, 3531646869u,
-784952939u, 943914610u,
-2717443875u, 3657384638u,
-1806867885u, 1903578924u,
-3985088434u, 1911188923u,
-1764002686u, 3672748083u,
-1832925325u, 241574049u,
-519948041u, 3181425568u,
-2939747257u, 1634174593u,
-3429894862u, 3529565564u,
-1089679033u, 240953857u,
-2025369941u, 2695166650u,
-517086873u, 2964595704u,
-3017658263u, 3828377737u,
-2144895011u, 994799311u,
-1184683823u, 4260564140u,
-308018483u, 4262383425u,
-1374752558u, 3431057723u,
-1572637805u, 383233885u,
-3188015819u, 4051263539u,
-233319221u, 3794788167u,
-2017406667u, 919677938u,
-4074952232u, 1683612329u,
-4213676186u, 327142514u,
-3032591014u, 4204155962u,
-206775997u, 2283918569u,
-2395147154u, 3427505379u,
-2211319468u, 4153726847u,
-2217060665u, 350160869u,
-2493667051u, 1648200185u,
-3441709766u, 1387233546u,
-140980u, 1891558063u,
-760080239u, 2088061981u,
-1580964938u, 740563169u,
-422986366u, 330624974u,
-4264507722u, 150928357u,
-2738323042u, 2948665536u,
-918718096u, 376390582u,
-3966098971u, 717653678u,
-3219466255u, 3799363969u,
-3424344721u, 3187805406u,
-375347278u, 3490350144u,
-1992212097u, 2263421398u,
-3855037968u, 1928519266u,
-3866327955u, 1129127000u,
-1782515131u, 2746577402u,
-3059200728u, 2108753646u,
-2738070963u, 1336849395u,
-1705302106u, 768287270u,
-1343511943u, 2247006571u,
-1956142255u, 1780259453u,
-3475618043u, 212490675u,
-622521957u, 917121602u,
-1852992332u, 1267987847u,
-3170016833u, 2549835613u,
-3299763344u, 2864033668u,
-3378768767u, 1236609378u,
-4169365948u, 3738062408u,
-2661022773u, 2006922227u,
-2760592161u, 3828932355u,
-2636387819u, 2616619070u,
-1237256330u, 3449066284u,
-2871755260u, 3729280948u,
-3862686086u, 431292293u,
-3285899651u, 786322314u,
-2531158535u, 724901242u,
-2377363130u, 1415970351u,
-1244759631u, 3263135197u,
-965248856u, 174024139u,
-2297418515u, 2954777083u,
-987586766u, 3206261120u,
-4059515114u, 3903854066u,
-1931934525u, 2287507921u,
-1827135136u, 1781944746u,
-574617451u, 2299034788u,
-2650140034u, 4081586725u,
-2482286699u, 1109175923u,
-458483596u, 618705848u,
-4059852729u, 1813855658u,
-4190721328u, 1129462471u,
-4089998050u, 3575732749u,
-2375584220u, 1037031473u,
-1623777358u, 3389003793u,
-546597541u, 352770237u,
-1383747654u, 3122687303u,
-1646071378u, 1164309901u,
-290870767u, 830691298u,
-929335420u, 3193251135u,
-989577914u, 3626554867u,
-591974737u, 3996958215u,
-3163711272u, 3071568023u,
-1516846461u, 3656006011u,
-2698625268u, 2510865430u,
-340274176u, 1167681812u,
-3698796465u, 3155218919u,
-4102288238u, 1673474350u,
-3069708839u, 2704165015u,
-1237411891u, 1854985978u,
-3646837503u, 3625406022u,
-921552000u, 1712976649u,
-3939149151u, 878608872u,
-3406359248u, 1068844551u,
-1834682077u, 4155949943u,
-2437686324u, 3163786257u,
-2645117577u, 1988168803u,
-747285578u, 1626463554u,
-1235300371u, 1256485167u,
-1914142538u, 4141546431u,
-3838102563u, 582664250u,
-1883344352u, 2083771672u,
-2611657933u, 2139079047u,
-2250573853u, 804336148u,
-3066325351u, 2770847216u,
-4275641370u, 1455750577u,
-3346357270u, 1674051445u,
-601221482u, 3992583643u,
-1402445097u, 3622527604u,
-2509017299u, 2966108111u,
-2557027816u, 900741486u,
-1790771021u, 2912643797u,
-2631381069u, 4014551783u,
-90375300u, 300318232u,
-3269968032u, 2679371729u,
-2664752123u, 3517585534u,
-3253901179u, 542270815u,
-1188641600u, 365479232u,
-2210121140u, 760762191u,
-1273768482u, 1216399252u,
-3484324231u, 4287337666u,
-16322182u, 643179562u,
-325675502u, 3652676161u,
-3120716054u, 3330259752u,
-1011990087u, 2990167340u,
-1097584090u, 3262252593u,
-1829409951u, 3665087267u,
-1214854475u, 2134299399u,
-3704419305u, 411263051u,
-1625446136u, 549838529u,
-4283196353u, 1342880802u,
-3460621305u, 1967599860u,
-4282843369u, 1275671016u,
-2544665755u, 853593042u,
-901109753u, 2682611693u,
-110631633u, 797487791u,
-1472073141u, 850464484u,
-797089608u, 3286110054u,
-350397471u, 2775631060u,
-366448238u, 3842907484u,
-2219863904u, 3623364733u,
-1850985302u, 4009616991u,
-294963924u, 3693536939u,
-3061255808u, 1615375832u,
-1920066675u, 4113028420u,
-4032223840u, 2318423400u,
-2701956286u, 4145497671u,
-3991532344u, 2536338351u,
-1679099863u, 1728968857u,
-449740816u, 2686506989u,
-685242457u, 97590863u,
-3258354115u, 1502282913u,
-1235084019u, 2151665147u,
-528459289u, 231097464u,
-2477280726u, 3651607391u,
-2091754612u, 1178454681u,
-980597335u, 1604483865u,
-1842333726u, 4146839064u,
-3213794286u, 2601416506u,
-754220096u, 3571436033u,
-488595746u, 1448097974u,
-4004834921u, 238887261u,
-3320337489u, 1416989070u,
-2928916831u, 4093725287u,
-186020771u, 2367569534u,
-3046087671u, 4090084518u,
-3548184546u, 679517009u,
-1962659444u, 3539886328u,
-4192003933u, 1678423485u,
-3827951761u, 3086277222u,
-2144472852u, 1390394371u,
-2976322029u, 1574517163u,
-3553313841u, 119173722u,
-1702434637u, 1766260771u,
-3629581771u, 1407497759u,
-895654784u, 751439914u,
-4008409498u, 215917713u,
-1482103833u, 695551833u,
-1288382231u, 2656990891u,
-2581779077u, 1570750352u,
-3710689053u, 1741390464u,
-2666411616u, 3533987737u,
-4289478316u, 3576119563u,
-4118694920u, 108199666u,
-3869794273u, 963183826u,
-2081410737u, 3796810515u,
-791123882u, 2525792704u,
-1036883117u, 136547246u,
-875691100u, 2592925324u,
-614302599u, 3013176417u,
-2689342539u, 427154472u,
-532957601u, 1228758574u,
-1898117151u, 1181643858u,
-1908591042u, 1464255968u,
-446980910u, 2984611177u,
-58509511u, 1046943619u,
-3508927906u, 2001585786u,
-2544767379u, 1525438381u,
-552181222u, 1959725830u,
-879448844u, 1348536411u,
-4242243590u, 2861338018u,
-1082052441u, 1034351453u,
-601175800u, 764077711u,
-530635011u, 3785343245u,
-2178026726u, 117256687u,
-2378297261u, 457568934u,
-76438221u, 4104954272u,
-956793873u, 3783168634u,
-2485968477u, 2381948487u,
-4226929450u, 3148473363u,
-2518273601u, 3569490233u,
-879369091u, 2180270337u,
-3674375989u, 1387729170u,
-977997984u, 4270646856u,
-568650985u, 951677556u,
-4213877384u, 2721005055u,
-1073364549u, 2563403831u,
-1678669911u, 66786703u,
-2273631661u, 1149351924u,
-3651298990u, 1581883443u,
-246723096u, 1895026827u,
-3810605772u, 3711056516u,
-4058833288u, 2193790614u,
-2080120290u, 3638638708u,
-2915672708u, 2263003308u,
-2361934197u, 4136767460u,
-1976115991u, 3448840877u,
-2019238520u, 225333538u,
-874340815u, 2976159827u,
-1555273378u, 3797521928u,
-1942347150u, 3262952567u,
-435997738u, 340403353u,
-2817830907u, 2078619498u,
-749534111u, 1178073973u,
-894654712u, 3361226032u,
-841092198u, 3288261538u,
-1696412169u, 1496966875u,
-697501571u, 1059158875u,
-3739946319u, 2481012988u,
-568983526u, 114945840u,
-1559249010u, 2218244008u,
-2841706923u, 1632780103u,
-4020169654u, 2087949619u,
-2438736103u, 24032648u,
-833416317u, 3787017905u,
-2373238993u, 2575395164u,
-3434544481u, 3228481067u,
-2542976862u, 2971726178u,
-2880371864u, 3642087909u,
-2407477975u, 2239080836u,
-1043714217u, 3894199764u,
-2235879182u, 203853421u,
-2933669448u, 2504940536u,
-834683330u, 425935223u,
-3560796393u, 3565833278u,
-1668000829u, 3683399154u,
-3414330886u, 1748785729u,
-1023171602u, 580966986u,
-2531038985u, 3227325488u,
-2657385925u, 2124704694u,
-233442446u, 1107045577u,
-3407293834u, 552770757u,
-3899097693u, 1067532701u,
-115667924u, 1406028344u,
-1707768231u, 3724015962u,
-2419657149u, 18613994u,
-2532882091u, 3476683808u,
-1560838678u, 811220224u,
-895961699u, 3762914298u,
-1328752423u, 1844996900u,
-1420427894u, 1848067707u,
-1210281744u, 904215228u,
-4055325594u, 1118521573u,
-2496554183u, 2579259919u,
-3996647489u, 3657647605u,
-325254059u, 3136157065u,
-3951522674u, 4052925250u,
-3341068436u, 2287683323u,
-1313073005u, 126005630u,
-2505120084u, 1194725057u,
-853746559u, 3555092974u,
-2689238752u, 49515858u,
-1244776042u, 1069300695u,
-61073168u, 1010661841u,
-1269521335u, 1902040126u,
-990632502u, 2378708922u,
-3858321250u, 1400735275u,
-2974699176u, 2771676666u,
-170995186u, 2877798589u,
-545726212u, 2225229957u,
-1086473152u, 3454177594u,
-3859483262u, 1499729584u,
-2088002891u, 2883475137u,
-3222194252u, 4144472319u,
-2212229854u, 4146740722u,
-567988835u, 1051332394u,
-3932046135u, 542648229u,
-3017852446u, 1277887997u,
-162888005u, 1669710469u,
-1492500905u, 553041029u,
-1434876932u, 533989516u,
-3817492747u, 584127807u,
-4147115982u, 2993670925u,
-4020312558u, 710021255u,
-3509733475u, 3587959456u,
-2088550465u, 1745399498u,
-2952242967u, 1259815443u,
-869648362u, 1404723176u,
-3947542735u, 1334333531u,
-3873471582u, 229399758u,
-59634866u, 3239516985u,
-3844250972u, 1275954779u,
-1385684948u, 2243700741u,
-2512155003u, 1685649437u,
-639306006u, 2524620206u,
-955360345u, 1646776457u,
-576786501u, 655707039u,
-2864351838u, 3736264674u,
-655621239u, 362070173u,
-1200907897u, 2384379464u,
-15823708u, 206117476u,
-3652870937u, 122927134u,
-1193310960u, 1093099415u,
-3696538026u, 4112584792u,
-1834541277u, 845639252u,
-2069527017u, 547588820u,
-4178147211u, 2827259351u,
-1764455305u, 3312003602u,
-940846775u, 1054995047u,
-2976960697u, 1934305529u,
-3095615046u, 3354962706u,
-2199137382u, 1005722394u,
-1875867180u, 2064356511u,
-3363633633u, 2688499147u,
-4019734130u, 3096333006u,
-2069509024u, 2906358341u,
-3247463123u, 4191788132u,
-2232866485u, 1456016086u,
-1422674894u, 867282151u,
-1851386407u, 1268304058u,
-1612503136u, 1739843072u,
-134947567u, 2978775774u,
-2051592101u, 1017127033u,
-1284167756u, 1090844589u,
-831688783u, 2079216362u,
-2079309682u, 1950585801u,
-1626991196u, 3644714163u,
-3678110059u, 898470030u,
-1117570988u, 2517572125u,
-3916646913u, 3182422972u,
-3630426828u, 969847973u,
-2835126238u, 53541366u,
-3427164640u, 3463937250u,
-3044785046u, 897322257u,
-103038235u, 3804506837u,
-3443872170u, 4185408854u,
-2557463241u, 4080940424u,
-3669923099u, 2789619871u,
-2048168570u, 2429169982u,
-3174690447u, 2513494106u,
-3099587829u, 2627855577u,
-1213061732u, 3143736628u,
-3482268149u, 1250714337u,
-3553412672u, 2689632914u,
-31648125u, 3872383625u,
-1565760579u, 36665130u,
-1282106920u, 359361724u,
-751041229u, 2257179590u,
-2915361862u, 280819225u,
-954406473u, 4101682199u,
-2907818413u, 4254297769u,
-3493178615u, 3755944354u,
-3539557658u, 3330196096u,
-4043533423u, 1134196225u,
-4177134659u, 127246419u,
-4213770762u, 1978302978u,
-2442615581u, 923049607u,
-1004426206u, 782768297u,
-2702745496u, 1880389457u,
-2410586681u, 1430106871u,
-4103323427u, 3168399477u,
-201787012u, 3105353527u,
-3716682375u, 3616334719u,
-3413209549u, 656672786u,
-526032790u, 2895072131u,
-2876965944u, 182894450u,
-456581318u, 2683752067u,
-1287916294u, 1270745752u,
-3877875910u, 3190666241u,
-3240336907u, 4024807233u,
-4227999465u, 2389301430u,
-1681224377u, 1576191191u,
-3599250276u, 2381111980u,
-3995044500u, 995595530u,
-3495321877u, 3956024585u,
-1611608524u, 3815677453u,
-1520987487u, 3669102590u,
-2062334396u, 1656117707u,
-5457134u, 3234118251u,
-4242065111u, 596879987u,
-470187419u, 2688566989u,
-3259870297u, 660100446u,
-1042378442u, 2206034096u,
-442236198u, 2542452448u,
-493137955u, 392411099u,
-3111186954u, 438250493u,
-947967568u, 1234595917u,
-4230082284u, 2762976773u,
-421203727u, 3728409592u,
-2870085764u, 1455086530u,
-2762099647u, 4011882747u,
-1785430706u, 3684427488u,
-1215981925u, 3227517889u,
-3269061963u, 4037515364u,
-1749401388u, 2167451566u,
-3168911474u, 4255057396u,
-2026092260u, 1736192508u,
-4123254745u, 2319366806u,
-3909727042u, 3114708966u,
-1938800693u, 680793595u,
-3933041672u, 616863613u,
-1525265867u, 2808224480u,
-2122290603u, 1211197714u,
-1186177814u, 2395325006u,
-3520488321u, 3979192396u,
-3540779343u, 4192918639u,
-1763872074u, 3402419930u,
-2736030448u, 1120335563u,
-1698949078u, 3993310631u,
-2947659998u, 1461045789u,
-1966048551u, 2228221363u,
-597941119u, 3498018399u,
-1441110751u, 2229999711u,
-393987327u, 454500547u,
-1222959566u, 567151340u,
-2496952483u, 1708770195u,
-3774764786u, 1492844524u,
-3308300614u, 805568076u,
-4068812294u, 3404648243u,
-868414882u, 177406999u,
-1608110313u, 642061169u,
-2093999089u, 222470301u,
-1027515771u, 3131251981u,
-2851936150u, 4272755262u,
-2763002551u, 1881527822u,
-1532845092u, 709643652u,
-682573592u, 1244104217u,
-440905170u, 1111321746u,
-796769556u, 2500467040u,
-3002618826u, 1112998535u,
-1188525643u, 4212674512u,
-1780193104u, 1243644607u,
-3691719535u, 2958853053u,
-2813437721u, 4036584207u,
-466635014u, 2277292580u,
-4082276003u, 1030800045u,
-1899531424u, 609466946u,
-1750863246u, 379050598u,
-3576413281u, 731493104u,
-2707384133u, 2289193651u,
-132259176u, 4115195437u,
-1769890695u, 2715470335u,
-3348954692u, 2166575624u,
-1819263183u, 2028531518u,
-2154809766u, 3672399742u,
-1142139448u, 88299682u,
-76727603u, 4198182186u,
-2304993586u, 1666387627u,
-2488475423u, 3832777692u,
-284366017u, 3359785538u,
-3469807328u, 2926494787u,
-1914195188u, 1134129972u,
-3829072836u, 2493478921u,
-3738499303u, 3311304980u,
-726951526u, 911080963u,
-932916545u, 2235559063u,
-2909742396u, 1765719309u,
-465269850u, 3803621553u,
-1456588655u, 508290328u,
-1490719640u, 3356513470u,
-2262196163u, 1451774941u,
-2908490783u, 251085588u,
-830410677u, 3172220325u,
-4039692645u, 1383603170u,
-3897208579u, 1940535730u,
-151909546u, 2384458112u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
-if (offset == -1) { int alive = 0; { uint64_t h = farmhashxo::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
-{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
-{ uint64_t h = farmhashxo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashxoTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
-{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-{ uint64_t h = farmhashxo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashxoTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashxoTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashxoTest::Dump(0, i);
- }
- farmhashxoTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-
-int main() {
- farmhashccTest::RunTest();
- farmhashmkTest::RunTest();
- farmhashnaTest::RunTest();
- farmhashntTest::RunTest();
- farmhashsaTest::RunTest();
- farmhashsuTest::RunTest();
- farmhashteTest::RunTest();
- farmhashuoTest::RunTest();
- farmhashxoTest::RunTest();
- __builtin_unreachable();
-}
-
-#endif // FARMHASHSELFTEST
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
+ else return farmhashmk::Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
+ return Mur(Hash32(s + 24, len - 24) + seed, h);
+}
+
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+#undef Bswap
+#define Bswap Bswap64
+
+STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
+ return val ^ (val >> 47);
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
+ return Hash128to64(Uint128(u, v));
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
+ // Murmur-inspired hashing.
+ uint64_t a = (u ^ v) * mul;
+ a ^= (a >> 47);
+ uint64_t b = (v ^ a) * mul;
+ b ^= (b >> 47);
+ b *= mul;
+ return b;
+}
+
+STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
+ if (len >= 8) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) + k2;
+ uint64_t b = Fetch(s + len - 8);
+ uint64_t c = Rotate(b, 37) * mul + a;
+ uint64_t d = (Rotate(a, 25) + b) * mul;
+ return HashLen16(c, d, mul);
+ }
+ if (len >= 4) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch32(s);
+ return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
+ }
+ if (len > 0) {
+ uint8_t a = s[0];
+ uint8_t b = s[len >> 1];
+ uint8_t c = s[len - 1];
+ uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
+ uint32_t z = len + (static_cast<uint32_t>(c) << 2);
+ return ShiftMix(y * k2 ^ z * k0) * k2;
+ }
+ return k2;
+}
+
+// Return a 16-byte hash for 48 bytes. Quick and dirty.
+// Callers do best to use "random-looking" values for a and b.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
+ a += w;
+ b = Rotate(b + a + z, 21);
+ uint64_t c = a;
+ a += x;
+ a += y;
+ b += Rotate(a, 44);
+ return make_pair(a + z, b + c);
+}
+
+// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ const char* s, uint64_t a, uint64_t b) {
+ return WeakHashLen32WithSeeds(Fetch(s),
+ Fetch(s + 8),
+ Fetch(s + 16),
+ Fetch(s + 24),
+ a,
+ b);
+}
+
+
+
+// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
+// of any length representable in signed long. Based on City and Murmur.
+STATIC_INLINE uint128_t CityMurmur(const char *s, size_t len, uint128_t seed) {
+ uint64_t a = Uint128Low64(seed);
+ uint64_t b = Uint128High64(seed);
+ uint64_t c = 0;
+ uint64_t d = 0;
+ signed long l = len - 16;
+ if (l <= 0) { // len <= 16
+ a = ShiftMix(a * k1) * k1;
+ c = b * k1 + HashLen0to16(s, len);
+ d = ShiftMix(a + (len >= 8 ? Fetch(s) : c));
+ } else { // len > 16
+ c = HashLen16(Fetch(s + len - 8) + k1, a);
+ d = HashLen16(b + len, c + Fetch(s + len - 16));
+ a += d;
+ do {
+ a ^= ShiftMix(Fetch(s) * k1) * k1;
+ a *= k1;
+ b ^= a;
+ c ^= ShiftMix(Fetch(s + 8) * k1) * k1;
+ c *= k1;
+ d ^= c;
+ s += 16;
+ l -= 16;
+ } while (l > 0);
+ }
+ a = HashLen16(a, c);
+ b = HashLen16(d, b);
+ return Uint128(a ^ b, HashLen16(b, a));
+}
+
+uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) {
+ if (len < 128) {
+ return CityMurmur(s, len, seed);
+ }
+
+ // We expect len >= 128 to be the common case. Keep 56 bytes of state:
+ // v, w, x, y, and z.
+ pair<uint64_t, uint64_t> v, w;
+ uint64_t x = Uint128Low64(seed);
+ uint64_t y = Uint128High64(seed);
+ uint64_t z = len * k1;
+ v.first = Rotate(y ^ k1, 49) * k1 + Fetch(s);
+ v.second = Rotate(v.first, 42) * k1 + Fetch(s + 8);
+ w.first = Rotate(y + z, 35) * k1 + x;
+ w.second = Rotate(x + Fetch(s + 88), 53) * k1;
+
+ // This is the same inner loop as CityHash64(), manually unrolled.
+ do {
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ s += 64;
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ s += 64;
+ len -= 128;
+ } while (LIKELY(len >= 128));
+ x += Rotate(v.first + z, 49) * k0;
+ y = y * k0 + Rotate(w.second, 37);
+ z = z * k0 + Rotate(w.first, 27);
+ w.first *= 9;
+ v.first *= k0;
+ // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
+ for (size_t tail_done = 0; tail_done < len; ) {
+ tail_done += 32;
+ y = Rotate(x + y, 42) * k0 + v.second;
+ w.first += Fetch(s + len - tail_done + 16);
+ x = x * k0 + w.first;
+ z += w.second + Fetch(s + len - tail_done);
+ w.second += v.first;
+ v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
+ v.first *= k0;
+ }
+ // At this point our 56 bytes of state should contain more than
+ // enough information for a strong 128-bit hash. We use two
+ // different 56-byte-to-8-byte hashes to get a 16-byte final result.
+ x = HashLen16(x, v.first);
+ y = HashLen16(y + z, w.first);
+ return Uint128(HashLen16(x + v.second, w.second) + y,
+ HashLen16(x + w.second, y + v.second));
+}
+
+STATIC_INLINE uint128_t CityHash128(const char *s, size_t len) {
+ return len >= 16 ?
+ CityHash128WithSeed(s + 16, len - 16,
+ Uint128(Fetch(s), Fetch(s + 8) + k0)) :
+ CityHash128WithSeed(s, len, Uint128(k0, k1));
+}
+
+uint128_t Fingerprint128(const char* s, size_t len) {
+ return CityHash128(s, len);
+}
+} // namespace farmhashcc
+namespace NAMESPACE_FOR_HASH_FUNCTIONS {
+
+// BASIC STRING HASHING
+
+// Hash function for a byte array. See also Hash(), below.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint32_t Hash32(const char* s, size_t len) {
+ return DebugTweak(
+ (can_use_sse41 & x86_64) ? farmhashnt::Hash32(s, len) :
+ (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32(s, len) :
+ can_use_sse42 ? farmhashsa::Hash32(s, len) :
+ farmhashmk::Hash32(s, len));
+}
+
+// Hash function for a byte array. For convenience, a 32-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
+ return DebugTweak(
+ (can_use_sse41 & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
+ (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32WithSeed(s, len, seed) :
+ can_use_sse42 ? farmhashsa::Hash32WithSeed(s, len, seed) :
+ farmhashmk::Hash32WithSeed(s, len, seed));
+}
+
+// Hash function for a byte array. For convenience, a 64-bit seed is also
+// hashed into the result. See also Hash(), below.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64(const char* s, size_t len) {
+ return DebugTweak(
+ (can_use_sse42 & x86_64) ?
+ farmhashte::Hash64(s, len) :
+ farmhashxo::Hash64(s, len));
+}
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+size_t Hash(const char* s, size_t len) {
+ return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
+}
+
+// Hash function for a byte array. For convenience, a 64-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
+ return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
+}
+
+// Hash function for a byte array. For convenience, two seeds are also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
+}
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint128_t Hash128(const char* s, size_t len) {
+ return DebugTweak(farmhashcc::Fingerprint128(s, len));
+}
+
+// Hash function for a byte array. For convenience, a 128-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) {
+ return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
+}
+
+// BASIC NON-STRING HASHING
+
+// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
+
+// Fingerprint function for a byte array. Most useful in 32-bit binaries.
+uint32_t Fingerprint32(const char* s, size_t len) {
+ return farmhashmk::Hash32(s, len);
+}
+
+// Fingerprint function for a byte array.
+uint64_t Fingerprint64(const char* s, size_t len) {
+ return farmhashna::Hash64(s, len);
+}
+
+// Fingerprint function for a byte array.
+uint128_t Fingerprint128(const char* s, size_t len) {
+ return farmhashcc::Fingerprint128(s, len);
+}
+
+// Older and still available but perhaps not as fast as the above:
+// farmhashns::Hash32{,WithSeed}()
+
+} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
+
+#if FARMHASHSELFTEST
+
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashccTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+1039179260u, 1690343979u, 1018511555u, 2464489001u,
+20368522u, 2663783964u, 175201532u, 1619210592u,
+4081014168u,
+2576519988u,
+3285042206u, 502478099u, 739479538u, 1500332790u,
+13754768u, 3789353455u, 3473868058u, 1909255088u,
+2212771159u,
+1112731063u,
+826915357u, 2893489933u, 118369799u, 1848668220u,
+1308219822u, 249416982u, 64306364u, 4221800195u,
+1020067935u,
+3955445564u,
+563346294u, 550236731u, 2339016688u, 1826259714u,
+3872358639u, 2295981050u, 1870005390u, 4015628802u,
+1451961420u,
+653440099u,
+1292493871u, 164377749u, 1717712483u, 463414587u,
+3924343675u, 1050492084u, 3566618804u, 2046983362u,
+31917516u,
+2957164615u,
+230718965u, 999595115u, 3534822176u, 2175709186u,
+965707431u, 441796222u, 2481718051u, 1827777486u,
+2590087362u,
+3879448744u,
+3515079898u, 1601433082u, 982764532u, 254808716u,
+1293372530u, 4205605817u, 947001462u, 1138890052u,
+176305566u,
+2447367541u,
+2973802542u, 4123621138u, 3083865840u, 1706367795u,
+792114347u, 2880110657u, 440613768u, 195054868u,
+1359016305u,
+3363804638u,
+649488537u, 1624045597u, 1441938215u, 3147758996u,
+3199173578u, 2597283203u, 2191333609u, 3763129144u,
+1117290165u,
+1062549743u,
+2565615889u, 1046361554u, 1581968261u, 1058773671u,
+1123053168u, 3807622275u, 1486749916u, 3900816089u,
+2437877004u,
+1894455839u,
+1912520953u, 1914997013u, 561048608u, 1643267444u,
+3671572006u, 194811086u, 1468911468u, 2179206286u,
+673206794u,
+3486923651u,
+3741426466u, 3292160512u, 697001377u, 1900763774u,
+3726097344u, 629282039u, 3578723715u, 2868028489u,
+3269862919u,
+2303349487u,
+3643953525u, 2307255916u, 849996280u, 732080434u,
+909961480u, 3542445214u, 2628347095u, 4236856917u,
+1380660650u,
+2631821908u,
+2007289004u, 3509705198u, 3788541675u, 789457322u,
+3090670546u, 638977894u, 3503881773u, 947102987u,
+1525325287u,
+1816697045u,
+2706647405u, 288763142u, 3505438495u, 481308609u,
+2882636782u, 3745162621u, 3503467033u, 428247823u,
+176408838u,
+333551502u,
+1001068721u, 1681483651u, 75380831u, 4191469679u,
+3627361839u, 2736617386u, 3120737438u, 1297502456u,
+864896482u,
+85674920u,
+2886047255u, 4119881331u, 2496990525u, 3442502055u,
+1806582817u, 3186345024u, 4099591287u, 2560171465u,
+3489229104u,
+3065015872u,
+2755089808u, 3098442882u, 378524719u, 2664097023u,
+1771960725u, 2901182183u, 55258521u, 1266621443u,
+581644891u,
+37790450u,
+1800731704u, 3601350920u, 53428754u, 2759476837u,
+3391093099u, 1496510311u, 2511119507u, 2636877410u,
+631613207u,
+1573846064u,
+260484875u, 1088212603u, 2369525206u, 322522428u,
+3191396600u, 2076543340u, 1552496658u, 2739811558u,
+3867875546u,
+2051584261u,
+2126250818u, 901517871u, 3651631165u, 1323139145u,
+1521111765u, 477802997u, 3508559783u, 383954241u,
+3804516756u,
+4250206331u,
+2655954340u, 2484996477u, 1417544845u, 1520282298u,
+2745204366u, 2869345147u, 1872738335u, 2592877343u,
+1619744564u,
+1804962124u,
+3458679890u, 423948620u, 273645618u, 4187865426u,
+376057175u, 2943431463u, 3581950599u, 1035398331u,
+1088213445u,
+861988903u,
+1323370244u, 777069428u, 506235917u, 369720851u,
+2789995854u, 230915180u, 1505086948u, 940361236u,
+3727873235u,
+1159167499u,
+1860302871u, 3456858862u, 3923555152u, 2131072714u,
+2910461068u, 3671950363u, 2010742682u, 4088068851u,
+3616470388u,
+2087714788u,
+221675509u, 1230154072u, 3450704646u, 1463226695u,
+1998357699u, 266026801u, 619568740u, 3560427266u,
+4148162586u,
+3150417316u,
+1356375822u, 2056097622u, 627905802u, 3881675638u,
+2309738053u, 971916703u, 3447805361u, 1673575328u,
+673084328u,
+3317849401u,
+2836362782u, 2377208890u, 3275350588u, 158350552u,
+2553241779u, 2497264995u, 3262882649u, 3897937187u,
+1598963653u,
+3068514414u,
+601541505u, 374517071u, 3380795976u, 235752573u,
+284670003u, 2990192160u, 904937105u, 2306579150u,
+2117362589u,
+1635274830u,
+3355572906u, 170799903u, 1226685528u, 664567688u,
+413219134u, 878324258u, 4026159448u, 3620649295u,
+1823625377u,
+3175888439u,
+1759344347u, 2640637095u, 3549558u, 2192984935u,
+978623493u, 804017880u, 3877562323u, 3843116489u,
+1641748342u,
+1853539444u,
+3001178468u, 3443560727u, 2685426077u, 1653064722u,
+349231508u, 2726789654u, 3136215581u, 768402830u,
+269384321u,
+531936536u,
+2592883487u, 1343156334u, 3628619802u, 1477143570u,
+4269458419u, 3285611028u, 959104925u, 2712290710u,
+3480237248u,
+835796333u,
+2020636251u, 1191914589u, 126521603u, 4288023938u,
+3731699932u, 2136758855u, 985780142u, 193807575u,
+1850544433u,
+653947619u,
+3929316796u, 381871169u, 950486363u, 1787262279u,
+360480382u, 1800636585u, 1039258631u, 3682073259u,
+1262819303u,
+1786000319u,
+1570627191u, 893065837u, 301304916u, 1478469809u,
+623018819u, 2742232545u, 2058913014u, 1706060059u,
+2421125401u,
+1315829592u,
+3208766775u, 1805586156u, 575853086u, 3085025513u,
+4010908260u, 2344058256u, 3814407434u, 1458485673u,
+2474514786u,
+3581895658u,
+2710719679u, 190812706u, 2135454262u, 2620080728u,
+3400757986u, 1669914857u, 1559978393u, 1629811331u,
+3096616493u,
+1391424435u,
+4158376003u, 1015657076u, 794783832u, 479952178u,
+1150290207u, 2497437906u, 231815090u, 755078067u,
+3832053281u,
+63649475u,
+2415822606u, 4105027719u, 1706992318u, 1106598740u,
+3941945667u, 1271300761u, 505882259u, 760186809u,
+2657183368u,
+1925422058u,
+1039773764u, 880219458u, 4275949176u, 1556833823u,
+925882132u, 4216310340u, 757497522u, 461833914u,
+3884002070u,
+2790957660u,
+2100050089u, 651959176u, 1380301291u, 1289124125u,
+452314403u, 226156280u, 3306924715u, 1750807758u,
+2290180542u,
+1953760569u,
+2253069096u, 3960924806u, 1786291620u, 60736185u,
+2569018293u, 3870479674u, 2247005661u, 2239850953u,
+4261808536u,
+3282975782u,
+780945879u, 3349849383u, 1579362556u, 2265045884u,
+905088740u, 725212379u, 3156479246u, 2501620391u,
+3062836263u,
+4070422690u,
+996797869u, 4082582315u, 976105756u, 303983602u,
+1862104804u, 3864508254u, 3383979677u, 2835500286u,
+2798364010u,
+519359476u,
+3447342725u, 194373889u, 3313466630u, 232399983u,
+2841787856u, 1672751454u, 3345183154u, 1805381384u,
+2226129336u,
+2847829057u,
+2350774567u, 2838540121u, 2757948482u, 1017002062u,
+2329150951u, 2171488196u, 3668619047u, 3874977844u,
+3287966998u,
+262346753u,
+2493054715u, 2298644430u, 2926101182u, 1528457638u,
+598656233u, 2615845874u, 989110727u, 820441411u,
+253617372u,
+2201077208u,
+2047569338u, 3114356329u, 3335563734u, 2967673540u,
+768438341u, 1417708203u, 3873718246u, 1538441843u,
+1279167650u,
+3917966776u,
+2218481734u, 1015935150u, 1957845042u, 1318150213u,
+3146423971u, 4218994877u, 1162470863u, 1519718292u,
+2594658906u,
+665870414u,
+3430347817u, 3933868731u, 1597041394u, 3138684682u,
+3398212027u, 1064647658u, 1576321132u, 14792918u,
+224938029u,
+3706456050u,
+847274786u, 2645698692u, 1743374687u, 2343133224u,
+3066596790u, 2857270120u, 200596308u, 452055528u,
+2319312082u,
+3488655402u,
+4146865894u, 608206438u, 2699777051u, 3687240713u,
+327957508u, 3664730153u, 568134564u, 2993484554u,
+4159860363u,
+4274533921u,
+1079994063u, 2360220210u, 3609597760u, 3639708902u,
+2836180437u, 1069910270u, 1892427666u, 1874729790u,
+1267712826u,
+121886940u,
+3572289214u, 2475945610u, 783779452u, 588827737u,
+1531395014u, 2085084212u, 2219189792u, 3981444548u,
+2218885336u,
+1691622694u,
+2053232885u, 1386558530u, 2182946189u, 2365247285u,
+1871081313u, 2935751853u, 38413723u, 543465863u,
+900691890u,
+2899905665u,
+575120562u, 93133904u, 457154948u, 2983705792u,
+4232229200u, 2038565963u, 614693984u, 3405328302u,
+4083090010u,
+2088004171u,
+244031209u, 1861889294u, 2417109253u, 3299562328u,
+4158642443u, 4199064449u, 3161611046u, 885015950u,
+3677904099u,
+2969861785u,
+772348805u, 1712263832u, 3219357614u, 484271305u,
+3645706114u, 2059620251u, 409557488u, 2278896731u,
+224475749u,
+3523022952u,
+2057140088u, 449131785u, 1149879244u, 4255363996u,
+3602720135u, 1690010854u, 2503998822u, 2750828466u,
+3340671802u,
+1447583863u,
+2649684943u, 2764747249u, 3046070595u, 3441726138u,
+3840332559u, 3156747501u, 1288666680u, 1472744459u,
+3452391933u,
+1617542784u,
+217869690u, 3718469527u, 348639731u, 590532355u,
+43789787u, 22606314u, 1621559290u, 2231743261u,
+2234620879u,
+544748955u,
+3169387920u, 203343594u, 3272552527u, 1078282365u,
+809576321u, 854207584u, 3625491053u, 1193737267u,
+1628966807u,
+2661421060u,
+2433442061u, 3886639039u, 2149304418u, 303000565u,
+1432830882u, 137378235u, 1135974068u, 318705754u,
+2491227157u,
+2627534472u,
+3520352233u, 2488397682u, 3969194920u, 3843962181u,
+2135981459u, 2611933220u, 799460731u, 2300968851u,
+3412851628u,
+3070914013u,
+3555224260u, 4125937572u, 240359903u, 722496673u,
+2061023600u, 3843919221u, 2759960043u, 1191155322u,
+1504041490u,
+3735253656u,
+1773124736u, 101110011u, 1627699578u, 2645634551u,
+263603947u, 1388368439u, 677146538u, 1644201982u,
+2625699644u,
+2403862553u,
+2426069017u, 3613511705u, 915141802u, 2981654265u,
+3474818167u, 2611101773u, 627891434u, 762754924u,
+2143021902u,
+51067670u,
+4017746573u, 2269879853u, 3037857950u, 2388899692u,
+582729171u, 1886116725u, 2281219772u, 264704948u,
+3509984037u,
+4078683368u,
+2172959411u, 1807195632u, 3357092302u, 2253764928u,
+2320369390u, 3076335959u, 2623583210u, 168378015u,
+1435562650u,
+1100977467u,
+3160490319u, 2550328495u, 2396855930u, 1347823908u,
+1617990918u, 3849653099u, 3224111576u, 1681539821u,
+4171542880u,
+552200045u,
+3562947778u, 1676237880u, 3747732307u, 2453332913u,
+865530667u, 3566636849u, 3485502777u, 336779723u,
+2535942410u,
+1685000184u,
+820545711u, 1893670486u, 1273910461u, 1193758569u,
+970365241u, 381205962u, 3612810852u, 1160577445u,
+541488143u,
+4005031080u,
+2333965236u, 2419855455u, 3484533538u, 3073937876u,
+908466956u, 661391539u, 2342122412u, 1467049112u,
+1785800827u,
+135343033u,
+139643209u, 2438375667u, 974654058u, 3216478230u,
+3807620420u, 779043363u, 2812846449u, 333254784u,
+1025244024u,
+2242303095u,
+2476683742u, 350018683u, 174652916u, 933097576u,
+826905896u, 559603581u, 2777181260u, 164915169u,
+4070353203u,
+1459055748u,
+297303985u, 3103837241u, 3812514233u, 232265137u,
+2032819099u, 1523091376u, 3531238208u, 1403510182u,
+2886832080u,
+2599705941u,
+2789695716u, 68437968u, 3823813791u, 1040994569u,
+3024194990u, 2461740520u, 3735391266u, 2042207153u,
+2461678616u,
+3519231840u,
+1344224923u, 411442756u, 1179779351u, 7661528u,
+778352196u, 3288808867u, 589356197u, 2627504511u,
+3374744599u,
+3312172905u,
+357423007u, 3539567796u, 4044452215u, 1445118403u,
+2937983820u, 184089910u, 346201845u, 2427295202u,
+1345448010u,
+2884434843u,
+3085001879u, 2640105409u, 315310640u, 3530289798u,
+3362974764u, 963602652u, 75228477u, 3509381180u,
+4012777756u,
+2380345941u,
+1073137836u, 2083960378u, 1220315185u, 3628720934u,
+3508867818u, 67148343u, 3558085158u, 1753943368u,
+863309561u,
+2844713625u,
+441921850u, 854732254u, 816793316u, 2555428747u,
+3440623414u, 1707304366u, 3189874375u, 1623229221u,
+1220335976u,
+806745430u,
+3909262947u, 1680369031u, 2926179486u, 3410391660u,
+3991630434u, 2876458763u, 1179167079u, 536360759u,
+1592117159u,
+1514343977u,
+1032622306u, 2057494855u, 784938958u, 178402996u,
+1152907972u, 2326185495u, 2939973666u, 4181120253u,
+552831733u,
+664251856u,
+1297139539u, 1969357631u, 1474065957u, 3055419017u,
+3395829380u, 3316562752u, 2168409017u, 614624786u,
+3585854336u,
+668291094u,
+1162889217u, 3773171307u, 2263271126u, 355089668u,
+3195850578u, 3396793277u, 3519870267u, 527857605u,
+3972392320u,
+2224315010u,
+4047225561u, 3271434798u, 3192704713u, 2798505213u,
+3932215896u, 3792924012u, 3796843756u, 453872975u,
+4050552799u,
+1056432676u,
+928166947u, 121311642u, 930989547u, 2087070683u,
+1288978057u, 1556325239u, 1812435626u, 1682385724u,
+1214364933u,
+904760776u,
+3957045528u, 3949822847u, 2411065880u, 3716420732u,
+3424837835u, 3833550693u, 1799375326u, 2012368921u,
+2768764136u,
+1786111037u,
+4055479315u, 3751639533u, 2808224623u, 3492656387u,
+1306824780u, 2624000170u, 3134795218u, 1778409297u,
+3900821801u,
+593336325u,
+2772069220u, 2980873673u, 3574497158u, 3994780459u,
+4246519854u, 3482758570u, 4228015183u, 33101083u,
+1769887734u,
+4158035314u,
+3690638998u, 1119035482u, 4134969651u, 2483207353u,
+3932823321u, 285829887u, 3485140138u, 1304815138u,
+995608264u,
+3133997465u,
+1195477617u, 2147693728u, 3506673112u, 4234467492u,
+1183174337u, 1395340482u, 769199343u, 193262308u,
+2798920256u,
+3827889422u,
+3399695609u, 3036045724u, 2999477386u, 3567001759u,
+2682864314u, 1414023907u, 3699872975u, 3369870701u,
+2662284872u,
+2179640019u,
+2485080099u, 3234415609u, 3755915606u, 1339453220u,
+1567403399u, 2076272391u, 293946298u, 3861962750u,
+1291949822u,
+2916864995u,
+132642326u, 2215117062u, 2205863575u, 2488805750u,
+405632860u, 3248129390u, 2952606864u, 896734759u,
+2047417173u,
+3865951392u,
+657296855u, 1328547532u, 3966511825u, 3959682388u,
+4171801020u, 2981416957u, 1868896247u, 790081075u,
+3143666398u,
+2950766549u,
+2065854887u, 2737081890u, 995061774u, 1510712611u,
+2865954809u, 565044286u, 1565631102u, 1500654931u,
+494822108u,
+2803515503u,
+1058154996u, 3506280187u, 856885925u, 4204610546u,
+800905649u, 1130711562u, 558146282u, 2053400666u,
+449794061u,
+2643520245u,
+2101248725u, 3123292429u, 3583524041u, 983372394u,
+1587743780u, 672870813u, 444833475u, 100741452u,
+366232251u,
+1717951248u,
+524144122u, 1362432726u, 1304947719u, 674306020u,
+405665887u, 4081931036u, 1580408204u, 2343242778u,
+3901654006u,
+2627173567u,
+3015148205u, 814686701u, 1327920712u, 1346494176u,
+2468632605u, 2259795544u, 2519278184u, 2129281928u,
+2860266380u,
+4001619412u,
+1154910973u, 2841022216u, 1199925485u, 1372200293u,
+2713179055u, 3609776550u, 2896463880u, 1056406892u,
+177413841u,
+40180172u,
+3274788406u, 660921784u, 1686225028u, 4003382965u,
+2532691887u, 4256809101u, 1186018983u, 667359096u,
+2375266493u,
+2760222015u,
+745187078u, 312264012u, 396822261u, 2588536966u,
+2026998998u, 1766454365u, 3218807676u, 3915487497u,
+2630550356u,
+4130063378u,
+4231937074u, 752212123u, 3085144349u, 3267186363u,
+4103872100u, 4193207863u, 1306401710u, 3014853131u,
+1067760598u,
+2306188342u,
+2437881506u, 4258185052u, 2506507580u, 130876929u,
+1076894205u, 4106981702u, 2799540844u, 945747327u,
+1436722291u,
+2499772225u,
+2571537041u, 2038830635u, 2066826058u, 2892892912u,
+524875858u, 3392572161u, 2869992096u, 1308273341u,
+923668994u,
+1980407857u,
+2275009652u, 240598096u, 2658376530u, 3505603048u,
+1022603789u, 582423424u, 846379327u, 4092636095u,
+4177298326u,
+1004173023u,
+2154027018u, 2993634669u, 1098364089u, 3035642175u,
+1335688126u, 1376393415u, 1252369770u, 3815033328u,
+1999309358u,
+1234054757u,
+1388595255u, 2859334775u, 366532860u, 3453410395u,
+4226967708u, 1321729870u, 2078463405u, 156766592u,
+3157683394u,
+3549293384u,
+3348214547u, 2879648344u, 1144813399u, 2758966254u,
+647753581u, 813615926u, 2035441590u, 1961053117u,
+600168686u,
+2192833387u,
+3156481401u, 3627320321u, 383550248u, 81209584u,
+2339331745u, 1284116690u, 1980144976u, 2955724163u,
+789301728u,
+3842040415u,
+1115881490u, 965249078u, 4098663322u, 1870257033u,
+2923150701u, 4217108433u, 183816559u, 2104089285u,
+2640095343u,
+3173757052u,
+927847464u, 2383114981u, 4287174363u, 1886129652u,
+70635161u, 1182924521u, 1121440038u, 4246220730u,
+3890583049u,
+975913757u,
+2436253031u, 1074894869u, 1301280627u, 992471939u,
+735658128u, 244441856u, 1541612456u, 3457776165u,
+3503534059u,
+1931651133u,
+349142786u, 3669028584u, 1828812038u, 99128389u,
+1364272849u, 1963678455u, 3971963311u, 2316950886u,
+1308901796u,
+2789591580u,
+1460494965u, 2380227479u, 1577190651u, 1755822080u,
+2911014607u, 859387544u, 13023113u, 2319243370u,
+2522582211u,
+2299110490u,
+3342378874u, 2589323490u, 1884430765u, 3739058655u,
+2419330954u, 355389916u, 273950915u, 3670136553u,
+410946824u,
+3174041420u,
+2609010298u, 3059091350u, 2300275014u, 725729828u,
+2548380995u, 1738849964u, 1257081412u, 79430455u,
+810321297u,
+3246190593u,
+1007937684u, 912115394u, 40880059u, 3450073327u,
+4289832174u, 2253485111u, 1065639151u, 2953189309u,
+124779113u,
+654299738u,
+115760833u, 1250932069u, 884995826u, 3998908281u,
+1382882981u, 1134187162u, 3202324501u, 487502928u,
+3032756345u,
+4057517628u,
+933197381u, 2319223127u, 2044528655u, 2554572663u,
+4049450620u, 1620812836u, 2832905391u, 2273005481u,
+1913090121u,
+1055456023u,
+510593296u, 3285343192u, 2912822536u, 1645225063u,
+638418430u, 452701300u, 1025483165u, 1639370512u,
+167948643u,
+2809842730u,
+2983135664u, 407521332u, 1543756616u, 3949773145u,
+4283462892u, 659962275u, 3878013463u, 1000748756u,
+4053212051u,
+4099239406u,
+3467581965u, 354635541u, 21301844u, 3831212473u,
+3189450571u, 2264401966u, 4096484849u, 1736448515u,
+3976926096u,
+3727194724u,
+2243487039u, 585209095u, 3143046007u, 969558123u,
+3037113502u, 3594170243u, 2835860223u, 3775493975u,
+2787220812u,
+2274252217u,
+2915380701u, 3077533278u, 1252871826u, 1519790952u,
+205297661u, 2950557658u, 3956882191u, 2724439401u,
+3694608025u,
+124028038u,
+216019153u, 1533010676u, 2259986336u, 2014061617u,
+2068617849u, 3078123052u, 2692046098u, 1582812948u,
+396916232u,
+1470894001u,
+1694309312u, 300268215u, 1553892743u, 671176040u,
+1544988994u, 2793402821u, 4194972569u, 2296476154u,
+748354332u,
+3491325898u,
+4261053291u, 1104998242u, 797816835u, 243564059u,
+2197717393u, 299029458u, 1675252188u, 3139770041u,
+583018574u,
+2532106100u,
+2099391658u, 3760526730u, 3422719327u, 3556917689u,
+2374009285u, 2130865894u, 3710563151u, 1437538307u,
+3938030842u,
+2006930694u,
+2151243336u, 1939741287u, 1957068175u, 2135147479u,
+649553342u, 1713643042u, 4188696599u, 1698739939u,
+3549427584u,
+1016382174u,
+322644378u, 2476164549u, 2037263020u, 88036019u,
+2548960923u, 539867919u, 2871157727u, 4031659929u,
+754087252u,
+972656559u,
+4246379429u, 3877308578u, 2059459630u, 3614934323u,
+1410565271u, 2102980459u, 215395636u, 1083393481u,
+3775523015u,
+2062750105u,
+2475645882u, 3041186774u, 3534315423u, 758607219u,
+1686100614u, 180500983u, 1155581185u, 1476664671u,
+2918661695u,
+3812731350u,
+4003853737u, 4148884881u, 1468469436u, 3278880418u,
+1045838071u, 1049161262u, 360450415u, 3158065524u,
+814443735u,
+3391401707u,
+729968410u, 738771593u, 3662738792u, 1672830580u,
+4199496163u, 188487238u, 219098233u, 2141731267u,
+3890250614u,
+2988780375u,
+4026279523u, 3489429375u, 2468433807u, 1178270701u,
+2685094218u, 2716621497u, 3718335529u, 2273344755u,
+701110882u,
+1925717409u,
+1515176562u, 2325460593u, 3954798930u, 784566105u,
+3769422266u, 1641530321u, 2703876862u, 2907480267u,
+1828076455u,
+1805635221u,
+3883381245u, 1476756210u, 2072514392u, 3658557081u,
+2003610746u, 2556845550u, 729594004u, 3303898266u,
+1968227254u,
+423204951u,
+231828688u, 4223697811u, 698619045u, 3636824418u,
+2738779239u, 2333529003u, 2833158642u, 580285428u,
+3038148234u,
+1012378004u,
+1113647298u, 1424593483u, 4053247723u, 1167152941u,
+2677383578u, 3419485379u, 2135673840u, 440478166u,
+1682229112u,
+3226724137u,
+1217439806u, 3828726923u, 3636576271u, 3467643156u,
+2005614908u, 2655346461u, 2345488441u, 1027557096u,
+3594084220u,
+1372306343u,
+2342583762u, 4291342905u, 4094931814u, 3254771759u,
+821978248u, 2404930117u, 1143937655u, 3156949255u,
+3460606610u,
+449701786u,
+3474906110u, 1932585294u, 2283357584u, 1808481478u,
+3522851029u, 3040164731u, 1530172182u, 2950426149u,
+1402416557u,
+756419859u,
+4132576145u, 724994790u, 2852015871u, 2177908339u,
+899914731u, 139675671u, 1423281870u, 3198458070u,
+807581308u,
+2021611521u,
+1801452575u, 1425984297u, 2833835949u, 1536827865u,
+3902351840u, 164546042u, 1872840974u, 3986194780u,
+792156290u,
+3378681896u,
+941547959u, 3931328334u, 3661060482u, 2386420777u,
+3920146272u, 3458621279u, 3348500844u, 2269586542u,
+797371473u,
+3188953649u,
+80514771u, 2913333490u, 1246325623u, 3253846094u,
+1723906239u, 1606413555u, 587500718u, 1412413859u,
+2310046829u,
+2113313263u,
+3855635608u, 47271944u, 1112281934u, 3440228404u,
+2633519166u, 425094457u, 307659635u, 67338587u,
+2412987939u,
+2363930989u,
+2853008596u, 2844637339u, 922568813u, 130379293u,
+2825204405u, 2904442145u, 1176875333u, 1511685505u,
+599177514u,
+1872681372u,
+682394826u, 1888849790u, 3635304282u, 1761257265u,
+1571292431u, 355247075u, 1177210823u, 1691529530u,
+3629531121u,
+3760474006u,
+1129340625u, 868116266u, 3908237785u, 1942124366u,
+1266630014u, 3214841995u, 334023850u, 1110037019u,
+369650727u,
+1288666741u,
+70535706u, 20230114u, 4284225520u, 727856157u,
+293696779u, 1244943770u, 3976592462u, 560421917u,
+4171688499u,
+2438786950u,
+1218144639u, 3809125983u, 1302395746u, 534542359u,
+2121993015u, 2899519374u, 3192177626u, 1761707794u,
+3101683464u,
+1555403906u,
+3225675390u, 1875263768u, 4278894569u, 651707603u,
+2111591484u, 3802716028u, 2900262228u, 1181469202u,
+3254743797u,
+1822684466u,
+860641829u, 3046128268u, 1284833012u, 1125261608u,
+461384524u, 2331344566u, 1274400010u, 990498321u,
+3462536298u,
+3796842585u,
+2346607194u, 279495949u, 3951194590u, 3522664971u,
+3169688303u, 726831706u, 1123875117u, 1816166599u,
+3759808754u,
+2918558151u,
+3713203220u, 3369939267u, 466047109u, 384042536u,
+587271104u, 2191634696u, 2449929095u, 1157932232u,
+2084466674u,
+841370485u,
+3241372562u, 4277738486u, 2150836793u, 1173569449u,
+778768930u, 2594706485u, 3065269405u, 3019263663u,
+2660146610u,
+2789946230u,
+77056913u, 728174395u, 3647185904u, 804562358u,
+2697276483u, 881311175u, 1178696435u, 2059173891u,
+2308303791u,
+221481230u,
+50241451u, 3689414100u, 1969074761u, 2732071529u,
+1900890356u, 840789500u, 2100609300u, 985565597u,
+1220850414u,
+2456636259u,
+223607678u, 1016310244u, 1937434395u, 85717256u,
+275058190u, 3712011133u, 171916016u, 2389569096u,
+3679765802u,
+3575358777u,
+3481108261u, 3178286380u, 2489642395u, 2931039055u,
+3086601621u, 3079518902u, 3027718495u, 2506894644u,
+2976869602u,
+2134336365u,
+2420172217u, 918054427u, 661522682u, 1403791357u,
+3587174388u, 2623673551u, 1355661457u, 4159477684u,
+1109013587u,
+3112183488u,
+2217849279u, 3500291996u, 2419603731u, 2929886201u,
+3854470013u, 1358382103u, 1357666555u, 21053566u,
+2716621233u,
+3094836862u,
+3309729704u, 57086558u, 839187419u, 2757944838u,
+3651040558u, 3607536716u, 3691257732u, 2312878285u,
+1202511724u,
+183479927u,
+2509829803u, 109313218u, 478173887u, 2072044014u,
+190631406u, 2495604975u, 1010416260u, 3679857586u,
+726566957u,
+258500881u,
+1805873908u, 3081447051u, 2352101327u, 534922207u,
+1584552873u, 813470716u, 255914637u, 249169434u,
+3193498057u,
+1038802706u,
+2590158653u, 3147907290u, 663060128u, 1156177857u,
+634616100u, 312879189u, 1545020368u, 2054634247u,
+3271451914u,
+3438291534u,
+2181454946u, 3864535432u, 2398586877u, 896491075u,
+2810631478u, 2770357487u, 3372930052u, 898070638u,
+2051007323u,
+392959778u,
+36645539u, 3743556044u, 4134529680u, 4124451188u,
+566806297u, 2936523982u, 1304761965u, 537399498u,
+1940818842u,
+40862381u,
+36288410u, 3063605629u, 2826611650u, 3961972098u,
+1871578006u, 2392095486u, 1136931591u, 513864488u,
+173276451u,
+3039055682u,
+3543322032u, 1943592006u, 657217094u, 1751698246u,
+2969618445u, 456616022u, 900309519u, 113892716u,
+1126392103u,
+1235651045u,
+1882073852u, 2136610853u, 2353639710u, 2819956700u,
+3980083530u, 828773559u, 224069850u, 902434120u,
+2802008036u,
+94358995u,
+2777723394u, 2812641403u, 2525832595u, 4157388110u,
+4235563782u, 937800324u, 141690749u, 568062536u,
+550123849u,
+1330316521u,
+1949488696u, 2296431366u, 1958465262u, 3564751729u,
+3748252207u, 120455129u, 1607318832u, 2525729790u,
+2640987481u,
+2332096657u,
+1775969159u, 1555085077u, 2913525137u, 1347085183u,
+2376253113u, 3194050574u, 1806090610u, 678641356u,
+1499146713u,
+383849715u,
+3299835823u, 2284860330u, 2614269636u, 3913628844u,
+2761334210u, 1959484587u, 529797021u, 239966995u,
+3102194829u,
+3602307804u,
+1122192627u, 3577510006u, 164486066u, 1680137310u,
+1473396395u, 1467801424u, 903493660u, 1185943071u,
+2798556505u,
+2306744492u,
+3167201310u, 3577947177u, 3067592134u, 2905506289u,
+1210366329u, 204484056u, 2347778932u, 3862374472u,
+3277439508u,
+4187414621u,
+1646699310u, 621385800u, 3934869089u, 3975491588u,
+3580085916u, 1925674500u, 2436305348u, 3983301539u,
+2739439523u,
+3291507446u,
+3395637920u, 3753389171u, 2955202032u, 2654255623u,
+3771089254u, 2140443405u, 2779834738u, 3261942805u,
+3526889244u,
+1842009139u,
+4048484340u, 2106218403u, 2161244271u, 772152700u,
+1158647659u, 3776791619u, 3882186721u, 699525237u,
+2954670460u,
+1007105869u,
+3359152025u, 1146388699u, 1401550303u, 2326582541u,
+4181783540u, 1085644043u, 1942143795u, 1038368308u,
+1526153809u,
+4042547244u,
+1891441000u, 2573991874u, 1281441253u, 3635098284u,
+1980545715u, 825985487u, 3934748116u, 4228386979u,
+1480870944u,
+1042194545u,
+2397771642u, 2248490001u, 3817869868u, 878654626u,
+3785629484u, 1672470870u, 3229367873u, 1894538933u,
+1010692731u,
+1733824268u,
+656620328u, 3048283803u, 3353340056u, 2324965120u,
+4192585951u, 2284524675u, 3483884368u, 1510168293u,
+1554942691u,
+1309709396u,
+1241133168u, 3162179280u, 4046378054u, 3171681593u,
+1165297136u, 3496703563u, 150437903u, 1948622072u,
+1076332463u,
+2292479143u,
+1464229958u, 3479738093u, 2328067598u, 2334503110u,
+833324834u, 3981605747u, 3002629155u, 2854644186u,
+2832201336u,
+95796957u,
+3269249397u, 2358313329u, 3411860910u, 4283292480u,
+2802208697u, 1305947955u, 2156803420u, 1991340283u,
+189678024u,
+447602599u,
+1055411517u, 1531748363u, 1555852656u, 412402681u,
+3774988152u, 20597551u, 2925024131u, 1423989620u,
+3749428061u,
+1541439448u,
+112270416u, 1936224776u, 132162941u, 3772011507u,
+3814102518u, 1908807815u, 444154079u, 823765347u,
+3362275567u,
+3419047430u,
+2108287005u, 2315102125u, 658593738u, 3195094029u,
+3721937534u, 3176229204u, 3398835373u, 1271898712u,
+1142546577u,
+3185986817u,
+3562705803u, 2046119567u, 912990621u, 1829977672u,
+3459576979u, 1118045834u, 1369529376u, 3320601076u,
+3954988953u,
+4002467635u,
+3359456351u, 1314849568u, 1766750942u, 2998874853u,
+1181800239u, 707328036u, 3314954697u, 2066721120u,
+598194215u,
+1124451278u,
+3156679616u, 3742684743u, 2960199690u, 2683497915u,
+2566077529u, 937014607u, 102095219u, 4262922475u,
+3132264275u,
+1262099830u,
+862722905u, 2717653494u, 3245583534u, 3427209989u,
+3220278124u, 85457091u, 2222333500u, 3513997967u,
+3522324951u,
+2830855552u,
+2215004781u, 3482411840u, 4227160614u, 2030964411u,
+1741393851u, 2643723748u, 942813508u, 403442675u,
+3112048748u,
+530556423u,
+3817755244u, 3543286628u, 2247276090u, 1532920842u,
+4101962711u, 1446540991u, 3297821473u, 1861255389u,
+1984398u,
+2366525138u,
+377589481u, 3549193828u, 1427765914u, 506831657u,
+277278988u, 1447652775u, 3214362239u, 3142198690u,
+2843087541u,
+468915015u,
+807895062u, 2198723907u, 4031145069u, 2417156212u,
+4027298697u, 637175947u, 1229254212u, 1773257887u,
+1659444818u,
+451148891u,
+2099741368u, 735351990u, 2534775713u, 3261804619u,
+712519954u, 3527962772u, 3758642738u, 4245823575u,
+1281314264u,
+1167866160u,
+1489546151u, 1197354389u, 1043278102u, 2563326586u,
+371937794u, 2320164817u, 3189512691u, 573685198u,
+4108603513u,
+3758899588u,
+3507030163u, 2947201212u, 2529492585u, 578234375u,
+3362349842u, 3318878925u, 3611203517u, 3059253190u,
+4270755916u,
+4291274625u,
+4237586791u, 4137422245u, 2927218651u, 2444687041u,
+797128811u, 2043057612u, 396533859u, 2665256178u,
+3346510674u,
+1779586176u,
+3076562062u, 1882746214u, 921095362u, 2026988397u,
+514514911u, 3886379478u, 4218272420u, 1480386793u,
+3900160816u,
+2292273451u,
+1276138356u, 1125461821u, 1912885715u, 3365266013u,
+1333211627u, 4085009861u, 1390530102u, 3347984752u,
+2721771301u,
+1419492325u,
+4066766256u, 3250852311u, 820111852u, 1382201318u,
+2366036798u, 938032241u, 3100979439u, 487048687u,
+2292851045u,
+3241399180u,
+3912670510u, 2416437067u, 2973194517u, 3507707986u,
+1935099406u, 2533441488u, 104616731u, 2892622820u,
+3801190339u,
+4239188808u,
+807238241u, 3300121546u, 2249406147u, 4032114017u,
+3713738189u, 3324425575u, 4275607376u, 3663120298u,
+4173658372u,
+3984289690u,
+1827636846u, 3264588778u, 3297165529u, 558623533u,
+2728945672u, 1566297318u, 3447249966u, 481719551u,
+1596842050u,
+1838185946u,
+265271620u, 1050246315u, 4046655705u, 1844193138u,
+3807563245u, 1075384804u, 1292554949u, 1506525927u,
+2921816148u,
+2051885269u,
+1930534041u, 3872721086u, 1564489377u, 2272482181u,
+2849358683u, 589618304u, 2262072443u, 290363051u,
+299168363u,
+3867603931u,
+2868688756u, 2545263115u, 1092098533u, 3885725603u,
+2352430409u, 1981595469u, 2047946646u, 1332642839u,
+793806516u,
+214858837u,
+1061484659u, 3192394476u, 1115054785u, 3690637234u,
+996792368u, 2023479706u, 3046498231u, 4205835102u,
+3870714754u,
+257472875u,
+3549864599u, 2040276129u, 2414778670u, 812235477u,
+2674248196u, 1864096101u, 2257492689u, 1332556794u,
+1079540713u,
+465530720u,
+2304763972u, 830724724u, 3354588920u, 2510713652u,
+3103749409u, 468835585u, 1707620787u, 3038024846u,
+1000303198u,
+3462270146u,
+2748698899u, 2100348093u, 511537258u, 1237187486u,
+102049383u, 2268226698u, 3162251739u, 4219404629u,
+838822407u,
+1481440623u,
+2989224077u, 2676681975u, 3246551821u, 3812079906u,
+370572963u, 2283154352u, 3084789986u, 1961085583u,
+1955640586u,
+2409348147u,
+2284780581u, 1634818716u, 4018221729u, 2320761377u,
+3566831899u, 1799560520u, 91431959u, 1754113747u,
+1459430477u,
+3613658517u,
+924489906u, 3406317699u, 866289774u, 3924821603u,
+1265394945u, 1870668109u, 151949856u, 2747006534u,
+3111906201u,
+64039467u,
+2314447545u, 2600195638u, 4095795204u, 4162096026u,
+1026756826u, 2460047982u, 52686887u, 823198739u,
+1518045160u,
+2867527376u,
+566410761u, 2200433819u, 2114146405u, 2893790965u,
+881504901u, 974783212u, 490815659u, 937300283u,
+1523735309u,
+2511976468u,
+2634644947u, 355119367u, 1373773092u, 309232995u,
+3088671051u, 787126032u, 3442836843u, 4289194567u,
+2177850062u,
+1174136430u,
+3248982914u, 3129039732u, 1166851580u, 2196451882u,
+469595580u, 2130837700u, 3783349021u, 3745262548u,
+1236930515u,
+3032131496u,
+1525591437u, 1823628217u, 1939019255u, 1950270463u,
+3659899927u, 3688643445u, 3004399289u, 1155199552u,
+357547234u,
+2213110526u,
+3122658210u, 2667800490u, 2718690333u, 3512372076u,
+1098611683u, 2657518392u, 4248458835u, 3109874532u,
+1592908438u,
+2864927516u,
+3635248840u, 1251777186u, 3797340158u, 3508496870u,
+303354834u, 1482394062u, 2087100120u, 1595931912u,
+608574156u,
+723367884u,
+907938402u, 3357047807u, 1619629851u, 3092082995u,
+89030300u, 916336992u, 1861180168u, 3436334155u,
+1375000544u,
+3472936241u,
+1321217853u, 791356402u, 2872410224u, 2326250297u,
+2657644088u, 1748314108u, 4146771421u, 2913114440u,
+2924821844u,
+2101101496u,
+3268017251u, 2109603066u, 690665520u, 1830067573u,
+951427661u, 2982533150u, 3884512506u, 2358657479u,
+2833210784u,
+3419798214u,
+3785893994u, 2103940206u, 86759766u, 4031230616u,
+3745237192u, 2739453927u, 497038072u, 3303159408u,
+1251537249u,
+1993408196u,
+3185905715u, 2885948408u, 3154277110u, 2444150313u,
+2505582079u, 2120610195u, 3266465773u, 1814611964u,
+3080050407u,
+1079915522u,
+1819346505u, 2529946763u, 892097374u, 3740257161u,
+3618100441u, 1079900094u, 3607172225u, 737863389u,
+360704560u,
+3341993089u,
+1139047381u, 3132219631u, 1248981859u, 1109338159u,
+2004908615u, 4022302594u, 4166640860u, 2959140950u,
+3949235962u,
+2832278473u,
+2200524012u, 2634933043u, 2495844522u, 2613799818u,
+4034096813u, 683271795u, 1673546817u, 1363163726u,
+1805395136u,
+511749501u,
+1231032599u, 2305979751u, 345737783u, 3339868854u,
+2931857933u, 2323251738u, 1332068477u, 51846558u,
+3927238177u,
+1387182179u,
+1701238601u, 1419275173u, 2580882268u, 3357874599u,
+1726558907u, 1292901039u, 1371322339u, 1311713044u,
+3526735232u,
+4017884184u,
+3366093428u, 77140994u, 2128996229u, 1357915765u,
+4019691901u, 483989024u, 2390311750u, 2766065288u,
+3938587520u,
+3064810344u,
+1054589198u, 1274997019u, 4040589616u, 1277751144u,
+2274907047u, 4170399945u, 2886368209u, 4168922115u,
+3901237033u,
+3252972311u,
+2205185840u, 3403097556u, 3385493699u, 2809751370u,
+555319628u, 399539034u, 2998971454u, 1521596214u,
+178870216u,
+1471733541u,
+519629198u, 514159209u, 1500582242u, 1928616587u,
+2686427928u, 4133138798u, 1225914083u, 1432713584u,
+3559310915u,
+3925489366u,
+1055613123u, 4126676029u, 2723867653u, 3290604111u,
+1377022957u, 2373608155u, 3615237379u, 594338683u,
+2645257602u,
+2408427260u,
+917033274u, 750455097u, 625657657u, 121713200u,
+2191273413u, 4043949724u, 3293146785u, 3809297972u,
+3947296919u,
+115456894u,
+1529576616u, 1459278275u, 2157117997u, 1747859293u,
+4106665903u, 996939232u, 2007976332u, 4274649009u,
+1017725787u,
+4244666096u,
+1219631331u, 3072426253u, 3547691720u, 1620822012u,
+1397717508u, 2031597325u, 3345983430u, 2459068000u,
+3645130467u,
+2308642742u,
+359955852u, 1348467968u, 1133123059u, 2435919062u,
+2800365907u, 4213217210u, 4056565603u, 2811666556u,
+2318007236u,
+3823652401u,
+3654086429u, 1273260424u, 1591610446u, 943349350u,
+3441227678u, 3779964757u, 233818224u, 3469971032u,
+3764095096u,
+4009204587u,
+678472092u, 1990559652u, 2583121088u, 2978143652u,
+2496370864u, 2139539656u, 4287972050u, 295832576u,
+3536742861u,
+2257466133u,
+2738052161u, 1988611898u, 2466189642u, 3294419573u,
+2311186273u, 474374532u, 3081964174u, 2515138278u,
+835731677u,
+1178182694u,
+3352119543u, 2884763225u, 3462399574u, 2900817210u,
+1993698511u, 2868445043u, 2746444849u, 1205258179u,
+2353442946u,
+4079040070u,
+3624133102u, 2907136076u, 2902521697u, 426813211u,
+1418185512u, 3711189488u, 1351506552u, 1934749519u,
+46595543u,
+401688809u,
+3514602124u, 1396852607u, 1951477943u, 2502249173u,
+3199695820u, 2890250638u, 4205072507u, 1715623846u,
+3266686789u,
+3218688128u,
+1697759742u, 851227671u, 2358709645u, 4174233268u,
+500583683u, 3805940955u, 736234120u, 2710563712u,
+1949664540u,
+3139414003u,
+4293073253u, 1284406972u, 1785182449u, 1051548274u,
+2994248357u, 2499882522u, 717208669u, 2039517285u,
+518424929u,
+143136433u,
+2303774671u, 1272930860u, 2286410920u, 788459311u,
+273225293u, 2439291703u, 2254505236u, 3446287701u,
+3655156558u,
+1546628787u,
+340081500u, 3285722006u, 1324810435u, 1053980860u,
+1779472859u, 2700355724u, 686005017u, 3762376315u,
+3963193100u,
+1370881135u,
+661300087u, 1152753704u, 2349891598u, 3910051187u,
+2109444785u, 1311123870u, 2639837565u, 1896770931u,
+1081414128u,
+869877586u,
+4284220400u, 63045374u, 235968615u, 184451062u,
+1271099822u, 1319179857u, 3274963209u, 4172272710u,
+3388797445u,
+2965973320u,
+3793110097u, 3327241723u, 2991804005u, 1199544355u,
+771553759u, 2031749842u, 2596517372u, 1199888213u,
+858347951u,
+3340178832u,
+2903875412u, 763490382u, 76949161u, 2056544406u,
+1145227689u, 998233136u, 2354530024u, 427713587u,
+3537837347u,
+604661755u,
+923986833u, 1023730418u, 798294227u, 432557449u,
+801802449u, 1861313429u, 3899128441u, 4068407979u,
+2352677083u,
+3783539925u,
+10731973u, 3390767975u, 3949540249u, 1920121661u,
+3248580201u, 641956426u, 2104847395u, 604835744u,
+1491663404u,
+4255204651u,
+1520970746u, 2845653368u, 3247412938u, 3730629005u,
+855569514u, 3073294700u, 2429691698u, 3818342476u,
+3938869985u,
+2731201328u,
+2335202643u, 778117742u, 13298408u, 228780590u,
+2871715314u, 3253688653u, 4150999702u, 3846220408u,
+930808u,
+1397128726u,
+1964216488u, 2781092828u, 116285375u, 2271239476u,
+3724347554u, 2931203895u, 3893169206u, 1883912528u,
+2093892660u,
+3658787024u,
+3095016046u, 1094059199u, 3640239610u, 558564267u,
+2102812456u, 464734873u, 925262247u, 1609838036u,
+588364741u,
+1731409233u,
+1576165139u, 3933979268u, 375316394u, 4247099643u,
+3670508019u, 4080496835u, 2371248533u, 183762693u,
+2078935389u,
+2699810414u,
+1491815683u, 2999180789u, 1831158425u, 1603373553u,
+2006136905u, 3210230591u, 416748595u, 1536971415u,
+3271869367u,
+1266062739u,
+2138414557u, 3337114778u, 1634586826u, 36472629u,
+4482244u, 568009609u, 2721216780u, 4037289545u,
+2235138807u,
+1789351460u,
+4067539527u, 1323062829u, 3864620647u, 4192026301u,
+4278901241u, 1399025382u, 2826652805u, 1363860382u,
+1801770651u,
+1613381526u,
+1165249276u, 4046576622u, 2535596946u, 3260388176u,
+1078898578u, 2259750862u, 643387587u, 237144235u,
+4199571427u,
+3440917581u,
+3067939258u, 2018625455u, 1460528353u, 3138629939u,
+1666223528u, 3841139376u, 2528281125u, 885565193u,
+2609492686u,
+2517257479u,
+560864620u, 2261471820u, 3491559165u, 1329620416u,
+622383582u, 1759597655u, 2877873893u, 584692817u,
+1901728399u,
+2599000260u,
+3169771644u, 296332336u, 774719455u, 4175920823u,
+2287316070u, 4115615023u, 1073335619u, 4240292725u,
+1359158837u,
+1960974237u,
+3173724597u, 1619084286u, 2876340752u, 4065675347u,
+480741335u, 1237329941u, 701055566u, 3729009837u,
+1314736422u,
+4003180069u,
+3118519317u, 3035354420u, 3380357671u, 4020909015u,
+253958714u, 3545798863u, 3008185002u, 2624719888u,
+3219955575u,
+3060719376u,
+573101682u, 1580316843u, 2610493412u, 3490983536u,
+3601975611u, 851470366u, 635384901u, 3427048824u,
+1470002757u,
+3592460087u,
+2265226856u, 4124282457u, 2106385486u, 3334305617u,
+4208282753u, 3798749815u, 225396466u, 118791182u,
+2523395972u,
+194595464u,
+2563824631u, 2521301383u, 4224409406u, 468670274u,
+1761966400u, 1300908277u, 2570709228u, 1847901526u,
+1470099163u,
+2690466752u,
+1472536718u, 2399279735u, 4150607803u, 1775080054u,
+2082537685u, 4080034578u, 1256001880u, 392967725u,
+2055838940u,
+3349115816u,
+1745947263u, 2213925887u, 1836572741u, 2417722792u,
+636223705u, 2423329294u, 3960951311u, 1543591052u,
+1547914361u,
+2760945653u,
+3519014111u, 313543871u, 4119598884u, 1071003714u,
+2192556597u, 1526995535u, 3929839778u, 536388591u,
+3040873792u,
+3752682932u,
+1640614237u, 2432794021u, 385337403u, 2794410617u,
+2386128075u, 1055206708u, 1422747714u, 3759330929u,
+2533597496u,
+30440955u,
+1482899460u, 3350385050u, 616259409u, 3980103795u,
+1211364140u, 1040071544u, 594746920u, 1645973936u,
+2547331531u,
+1097726368u,
+700666526u, 2976247482u, 1144906608u, 996506677u,
+1997130756u, 800321417u, 1392942823u, 1601662248u,
+2079778663u,
+529512908u,
+2925120134u, 4106433085u, 630221833u, 2423086156u,
+1119859778u, 1726827981u, 1870859181u, 2559832707u,
+1792284257u,
+2059356387u,
+3572353364u, 3229407475u, 575621095u, 3221893291u,
+2372428048u, 2020123035u, 961449593u, 2243824063u,
+3803906611u,
+3735348189u,
+2981620804u, 4180681078u, 1555330629u, 230736535u,
+2075526640u, 749652975u, 713664372u, 2152096659u,
+2142067223u,
+3322302242u,
+1421646830u, 2092832615u, 1213735101u, 3192136753u,
+1106723940u, 3455398230u, 2541685524u, 2529956739u,
+3789430647u,
+1950084508u,
+2157395621u, 850457360u, 2758902426u, 2848030169u,
+6506379u, 1162213157u, 2981459221u, 272690871u,
+3059420255u,
+4242691285u,
+588065598u, 1206949936u, 3968214184u, 566348532u,
+126142880u, 1480567086u, 2959621988u, 2050218418u,
+2242731195u,
+3833514449u,
+1898070331u, 3687399477u, 3891859374u, 868185955u,
+2335308774u, 3676335246u, 3871121805u, 2189032743u,
+3275728647u,
+860492892u,
+1590764344u, 4130384758u, 262871548u, 3004764525u,
+2685542071u, 991231482u, 435122019u, 3031116998u,
+2898921700u,
+2917932604u,
+4238665148u, 2459072654u, 3444612545u, 4207731740u,
+1808564313u, 2798532269u, 3944553556u, 3926395409u,
+1633200670u,
+4138335224u,
+2524878605u, 4184292650u, 3563398268u, 4288943552u,
+3802121210u, 957502058u, 2410820887u, 4227117506u,
+4018625153u,
+4284329158u,
+530216712u, 2978986531u, 863452221u, 1910162118u,
+4088211378u, 4091971261u, 3150811451u, 4200871487u,
+3794038652u,
+3041564310u,
+2045287082u, 887805614u, 2889167251u, 4120352181u,
+1699912580u, 3478922097u, 3211994687u, 3136177842u,
+1500806861u,
+3211881347u,
+2147976385u, 3342722260u, 3359650541u, 4197378460u,
+781354073u, 1533623029u, 2204677828u, 3228172832u,
+3248592437u,
+3355841359u,
+560815159u, 1144951236u, 4027015711u, 2882625391u,
+339363613u, 2354572719u, 1769831876u, 4238589331u,
+1519732871u,
+2185834614u,
+1601096831u, 129709881u, 39655633u, 367604993u,
+1737681770u, 3259114599u, 2767070452u, 872365177u,
+1574125529u,
+3405020189u,
+4181346685u, 1134030380u, 403769171u, 2193351164u,
+1426232618u, 2885309450u, 3033612627u, 924948363u,
+935514094u,
+3202053329u,
+912294839u, 1618472324u, 4159158431u, 3744999487u,
+777064358u, 3974213124u, 1990246048u, 309725290u,
+2449849392u,
+1943692420u,
+2288635750u, 2433793635u, 2168904061u, 683315308u,
+3081493019u, 3477759434u, 3815496269u, 2823504699u,
+586945121u,
+3088963200u,
+3492287335u, 636875049u, 1111206944u, 2037346120u,
+1282050044u, 1409681512u, 1786128584u, 755810950u,
+2332676758u,
+2178142310u,
+957827166u, 1014983590u, 1888800725u, 3608595803u,
+3200072714u, 2534008478u, 659336139u, 1281728287u,
+4060560529u,
+2915575125u,
+3521503774u, 2926487340u, 1096297674u, 653489861u,
+2352326980u, 2561136777u, 1224141198u, 1250479629u,
+1297625391u,
+2409997371u,
+1942483722u, 2481835750u, 1394715707u, 1673070941u,
+2456039704u, 3980558014u, 3547934764u, 1882038812u,
+1078160498u,
+2488279087u,
+1848235245u, 1211914722u, 2264928765u, 2807773070u,
+270145554u, 583747883u, 3826009010u, 2996618216u,
+425727157u,
+992726957u,
+3384462280u, 726650661u, 1955043265u, 1923879512u,
+1854693773u, 2987614542u, 2660044993u, 2457260810u,
+426299370u,
+2671892900u,
+1827308087u, 3083953443u, 1791749638u, 3265087416u,
+2119752201u, 2547122538u, 3990783236u, 1912713468u,
+3688865211u,
+1815780016u,
+303699291u, 2416763742u, 2690891610u, 1535193548u,
+1107803989u, 1504143133u, 2235270371u, 2545884083u,
+2276278682u,
+411724404u,
+3416925704u, 2565792091u, 3383911757u, 546058824u,
+3374654444u, 2364630415u, 2693473470u, 2622125691u,
+261864817u,
+55682470u,
+857617568u, 141304067u, 1885488541u, 155368182u,
+1281949051u, 3384522408u, 3254816901u, 1959816782u,
+1452224057u,
+2830267691u,
+3709231247u, 58988202u, 4218130458u, 2984061349u,
+1888707848u, 4223605071u, 4241442486u, 375269213u,
+3208327038u,
+2199916493u,
+550337252u, 2855061437u, 276088636u, 114362204u,
+2321163647u, 2127813633u, 3289403024u, 2686973202u,
+2717376797u,
+3593428039u,
+3648831666u, 890925902u, 3289404818u, 3289516821u,
+4248913260u, 1858916580u, 3303932308u, 1752797086u,
+1628149686u,
+3245893605u,
+1568537311u, 2844194502u, 1593855770u, 2408174109u,
+124797514u, 2085649512u, 3188565660u, 2264996276u,
+1926696513u,
+3053957740u,
+2238806881u, 2189050973u, 203685243u, 379855590u,
+3920271562u, 1058600179u, 3698061923u, 4255106849u,
+608401664u,
+1598041932u,
+3318266418u, 2535016555u, 852760884u, 1918098822u,
+2200437599u, 1532285043u, 3425662132u, 3561293706u,
+2231633206u,
+4108785088u,
+3359152801u, 173534780u, 208383607u, 2862988169u,
+2406642243u, 426814583u, 2777335795u, 3322703596u,
+954190623u,
+615093090u,
+4179102978u, 2452847930u, 100239619u, 42471741u,
+818352432u, 2190624654u, 504379960u, 3631619975u,
+633412456u,
+1018421783u,
+842645419u, 711808707u, 3424580813u, 2132457941u,
+1158335882u, 3567952480u, 2302183699u, 1145788151u,
+3474264138u,
+3105085243u,
+3115506027u, 2783713015u, 3871785309u, 539583269u,
+1400252405u, 3857849984u, 4231186588u, 1278653799u,
+1760227022u,
+761044088u,
+3838185417u, 2439542532u, 585283357u, 2055995220u,
+937117124u, 3831944855u, 1823586038u, 3287917855u,
+485082427u,
+3209172809u,
+1984570176u, 2818337297u, 2691869057u, 3790476953u,
+839035557u, 3203129010u, 669981176u, 4121157385u,
+3519870450u,
+3792633352u,
+3017650322u, 1603459507u, 4225677666u, 376555451u,
+473780127u, 2018786277u, 3299822439u, 1010254499u,
+2383887565u,
+3155009499u,
+3108110655u, 2641738274u, 3684908622u, 1606463047u,
+3311068174u, 52708046u, 754181455u, 1018079176u,
+3915670272u,
+3366999425u,
+1012880204u, 1339439715u, 466437962u, 1402662350u,
+2504046911u, 736323938u, 2037800124u, 1725908589u,
+716341840u,
+1750123474u,
+3366342464u, 1743666195u, 2975303189u, 3821364027u,
+3253707772u, 3635548377u, 3840413796u, 1955642085u,
+1018315169u,
+1258092848u,
+2095540656u, 1076256607u, 117289557u, 1311658655u,
+2118301000u, 68721550u, 2886814107u, 2712432819u,
+4201862886u,
+753807148u,
+1940229047u, 731347296u, 1068901393u, 3873155894u,
+2852787666u, 1973464853u, 79735652u, 3966380587u,
+3245740712u,
+2525773438u,
+734938109u, 3045656416u, 3335746354u, 4099732691u,
+1911896517u, 1697006473u, 1145487066u, 1605663299u,
+3053606724u,
+2386289465u,
+3821211369u, 1006215345u, 1256304829u, 1053001668u,
+1289194958u, 118761054u, 1853688730u, 2803418011u,
+188650809u,
+3763686458u,
+1006829556u, 2961984133u, 3390525025u, 2061199893u,
+141792681u, 2439893463u, 2652982650u, 1804942682u,
+1546510005u,
+1246961405u,
+2407577046u, 565772575u, 3751844810u, 2943166103u,
+3750052451u, 3022527280u, 25162928u, 397381043u,
+1818337632u,
+3447363730u,
+3936437150u, 2569420703u, 2215592390u, 2171555672u,
+3665571006u, 4021712412u, 2939158353u, 4057813172u,
+1823237318u,
+103999245u,
+3251978010u, 3591914940u, 3582495283u, 2519035265u,
+3905726135u, 3180393349u, 2743117123u, 55247368u,
+3325286701u,
+705195946u,
+1857526853u, 1480518550u, 3809990433u, 1398189338u,
+3126362926u, 3959531492u, 1503658285u, 1977847740u,
+3043964489u,
+2613086143u,
+1518119282u, 4238434900u, 3905746486u, 3064949667u,
+1028122931u, 3309119457u, 4071194920u, 3096098907u,
+4137180520u,
+494467959u,
+1231408687u, 1691606157u, 1793452569u, 2722196118u,
+3478603952u, 1059665738u, 2282032278u, 3990268388u,
+1719514651u,
+4248311578u,
+3799146721u, 898026304u, 3367808954u, 4162472815u,
+170495870u, 1308116609u, 3428285344u, 1714716475u,
+395576794u,
+4153638621u,
+2999745812u, 3483315953u, 304980828u, 595337120u,
+3486516729u, 2331563143u, 2583609459u, 1885928417u,
+3834283777u,
+979337825u,
+932057378u, 3124081189u, 1930356777u, 3865887996u,
+4178282217u, 4214219408u, 3669465884u, 1472413856u,
+3356866587u,
+1012769806u,
+3043639963u, 996996396u, 207308216u, 982967331u,
+2991319933u, 318066902u, 721489670u, 1249967713u,
+749240921u,
+591392325u,
+2379365192u, 2250868849u, 2163259329u, 143191325u,
+3778285606u, 982149096u, 3536906200u, 2244353244u,
+1443862317u,
+3161549210u,
+2183127464u, 2015409516u, 547003700u, 2032484282u,
+523677821u, 4275663308u, 3827205526u, 3903778273u,
+2444530525u,
+2543645801u,
+1173958423u, 784740616u, 2878693675u, 3127696736u,
+3832037316u, 3161002398u, 4084166400u, 4213346853u,
+223390424u,
+4273380883u,
+2130315482u, 3429606032u, 3367732613u, 1912357694u,
+422632590u, 1266957023u, 3437535648u, 736404240u,
+2281709372u,
+415859912u,
+212948797u, 351612650u, 3920561440u, 112963586u,
+2230727543u, 2851076612u, 1990662634u, 2264296857u,
+3131463650u,
+2704034623u,
+3541637839u, 2954232792u, 533986918u, 4158757533u,
+65174248u, 4232639593u, 865906667u, 1948225652u,
+779656112u,
+3873989249u,
+2372984749u, 2346988193u, 1104345713u, 1165654138u,
+4045762610u, 3588205178u, 461363991u, 1111215752u,
+1389675192u,
+2404325151u,
+2152228101u, 3808973622u, 1901235912u, 3458690696u,
+314513238u, 2539459143u, 2847998873u, 952026138u,
+2325705328u,
+407844712u,
+3727960715u, 2996448351u, 2374336760u, 3138756390u,
+2600015243u, 539980418u, 1876285352u, 1670330799u,
+1709360377u,
+2868531654u,
+494777964u, 2773053597u, 599486162u, 3962209577u,
+1871328846u, 2171933018u, 110279472u, 384074780u,
+4147021936u,
+2333589647u,
+4251778066u, 40493468u, 3099342316u, 4108779767u,
+2812424588u, 954542332u, 2040682331u, 2251152306u,
+45915516u,
+259525626u,
+1045384743u, 4134656562u, 749389261u, 874399445u,
+616549904u, 2200447504u, 436024539u, 78972290u,
+3210485762u,
+1907985531u,
+3013721395u, 4214533685u, 4198804243u, 534879265u,
+1517190881u, 3756787754u, 1152563554u, 1718750948u,
+777737463u,
+1402478860u,
+1824562784u, 1879401449u, 3515818786u, 513165201u,
+1423491227u, 2103067918u, 2291777410u, 1097943000u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; IsAlive(farmhashcc::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashcc::Hash32(data, len++)); { uint128_t u = farmhashcc::Fingerprint128(data, len++); uint64_t h = Uint128Low64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); h = Uint128High64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
+Check(farmhashcc::Hash32WithSeed(data + offset, len, SEED));
+Check(farmhashcc::Hash32(data + offset, len));
+{ uint128_t u = farmhashcc::Fingerprint128(data + offset, len); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint128_t u = farmhashcc::CityHash128WithSeed(data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashccTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+cout << farmhashcc::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
+cout << farmhashcc::Hash32(data + offset, len) << "u," << endl;
+{ uint128_t u = farmhashcc::Fingerprint128(data + offset, len); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint128_t u = farmhashcc::CityHash128WithSeed(data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashccTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashccTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashccTest::Dump(0, i);
+ }
+ farmhashccTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashmkTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+4081014168u,
+2576519988u,
+2212771159u,
+1112731063u,
+1020067935u,
+3955445564u,
+1451961420u,
+653440099u,
+31917516u,
+2957164615u,
+2590087362u,
+3879448744u,
+176305566u,
+2447367541u,
+1359016305u,
+3363804638u,
+1117290165u,
+1062549743u,
+2437877004u,
+1894455839u,
+673206794u,
+3486923651u,
+3269862919u,
+2303349487u,
+1380660650u,
+595525107u,
+1525325287u,
+2025609358u,
+176408838u,
+1592885012u,
+864896482u,
+2101378090u,
+3489229104u,
+2118965695u,
+581644891u,
+2718789079u,
+631613207u,
+4228658372u,
+3867875546u,
+3531368319u,
+3804516756u,
+3317755099u,
+1619744564u,
+2884717286u,
+1088213445u,
+2667691076u,
+3727873235u,
+2330406762u,
+3616470388u,
+967660719u,
+4148162586u,
+315219121u,
+673084328u,
+3047602355u,
+1598963653u,
+1267826661u,
+2117362589u,
+2861192253u,
+1823625377u,
+1380350078u,
+1641748342u,
+1176094482u,
+269384321u,
+2178982315u,
+3480237248u,
+2660755208u,
+1850544433u,
+3429699438u,
+1262819303u,
+640556464u,
+2421125401u,
+2188368608u,
+2612932825u,
+1474432581u,
+173790449u,
+2124882189u,
+831272654u,
+622960146u,
+4238751051u,
+3250317967u,
+2120810248u,
+1948231495u,
+1389029321u,
+2200398357u,
+2134232963u,
+2948072329u,
+617717625u,
+681164587u,
+114859387u,
+430545646u,
+57239089u,
+3163338012u,
+3482496399u,
+557662576u,
+1102441413u,
+2670159360u,
+991116729u,
+846014240u,
+4233741566u,
+1802317242u,
+3129528802u,
+1459456375u,
+1305643039u,
+3258671612u,
+1578285833u,
+868590079u,
+1631034517u,
+1695432937u,
+561078856u,
+1004115553u,
+3086090507u,
+3818348650u,
+731596645u,
+780926790u,
+2544205955u,
+158479164u,
+3983514188u,
+2004735250u,
+3436218400u,
+673684751u,
+1463431419u,
+2880490219u,
+3223748024u,
+2218318859u,
+1474466194u,
+2636437533u,
+2206794961u,
+140995728u,
+1186394086u,
+1805716888u,
+1640037724u,
+3942729099u,
+1944727013u,
+918951560u,
+498666871u,
+3486974657u,
+2967205462u,
+1167253804u,
+1884281041u,
+2866015002u,
+4158319270u,
+2627220079u,
+3733319624u,
+3317092271u,
+438323662u,
+3195868065u,
+3426606709u,
+360708338u,
+1905491012u,
+650004803u,
+1351266252u,
+3133279000u,
+3722811115u,
+2722412434u,
+918432408u,
+3678271248u,
+269599647u,
+621514057u,
+3117077855u,
+1545425390u,
+2597567410u,
+1221437820u,
+3493254589u,
+102787342u,
+918861168u,
+348795089u,
+3439883229u,
+2353641807u,
+2209585469u,
+4035884492u,
+2686995435u,
+1649888022u,
+3852893848u,
+3042700028u,
+314103172u,
+726977769u,
+2489830276u,
+2872753660u,
+1316214989u,
+1488801501u,
+1811420390u,
+639581627u,
+2362837215u,
+3634581834u,
+3648576802u,
+1257314182u,
+762118371u,
+4268447045u,
+730167096u,
+755561509u,
+882614845u,
+3696972894u,
+228263661u,
+1478636142u,
+2767751651u,
+1532617116u,
+3838657661u,
+1944359935u,
+1401102137u,
+3772933173u,
+1050098254u,
+1658079354u,
+1846025728u,
+2204244794u,
+2017217424u,
+1275162853u,
+1429816745u,
+2175565479u,
+1716109139u,
+1187506761u,
+2434641075u,
+2725597783u,
+1795687662u,
+1393312782u,
+3511565397u,
+627885430u,
+4145733164u,
+2519005353u,
+231414775u,
+1242015635u,
+2760723497u,
+2185540568u,
+727314436u,
+2358790354u,
+1186393454u,
+4234795645u,
+350567813u,
+866773875u,
+3145590392u,
+1158374055u,
+3903123687u,
+1862119793u,
+2204587556u,
+4266276976u,
+4151548555u,
+915250402u,
+2874695320u,
+2360311410u,
+1099212769u,
+1271542714u,
+3473148363u,
+1637325418u,
+1807795989u,
+2493819794u,
+3800917924u,
+4001205856u,
+2582153621u,
+3365872040u,
+2890146216u,
+2626363824u,
+3133351295u,
+4046827296u,
+3053118771u,
+4113026751u,
+884356716u,
+3828347401u,
+10608262u,
+830987972u,
+1841080500u,
+3202717763u,
+3561778749u,
+1906000052u,
+3058284660u,
+1432904514u,
+2567431677u,
+2550162530u,
+665557986u,
+936887821u,
+2101205308u,
+4253535847u,
+1662043545u,
+1253611611u,
+2091370094u,
+2635077370u,
+2602176041u,
+3624115809u,
+748442714u,
+2709749154u,
+1023493343u,
+860291012u,
+3924715584u,
+1536436740u,
+2551145800u,
+2391782865u,
+1467705048u,
+2583909796u,
+3616666170u,
+1162857372u,
+4228631071u,
+1510132376u,
+2739165009u,
+2656606142u,
+3454996358u,
+3155038853u,
+1022087316u,
+100044110u,
+494208296u,
+2746186477u,
+4216782431u,
+225448834u,
+3728320521u,
+335282866u,
+3148194874u,
+953503703u,
+1293353960u,
+202372387u,
+1326119870u,
+4045123735u,
+3819994846u,
+1629004186u,
+1081099186u,
+3591584153u,
+1670825804u,
+3404257979u,
+3262192301u,
+2572846095u,
+3714992543u,
+4264142572u,
+529616678u,
+2882154574u,
+3006354178u,
+3865969421u,
+2007174907u,
+308283107u,
+2629833703u,
+3159124075u,
+1146492131u,
+494104332u,
+493149727u,
+1342910585u,
+521642387u,
+2201695937u,
+2517980959u,
+2426821287u,
+777374655u,
+2228189792u,
+4027055486u,
+228976000u,
+3842083468u,
+1723920223u,
+1192126094u,
+787744493u,
+2740368380u,
+2284153001u,
+2773829458u,
+442000614u,
+387830783u,
+2169780670u,
+2253144627u,
+3532502484u,
+1969684059u,
+1165351416u,
+3055056536u,
+3582324253u,
+231419363u,
+770979865u,
+3213983597u,
+3690452836u,
+935794639u,
+3230602762u,
+2841762457u,
+407598927u,
+1164479891u,
+3721799696u,
+354738136u,
+1801566618u,
+3206038542u,
+2621379981u,
+1943487262u,
+3534745636u,
+1074424589u,
+1304517521u,
+4133400969u,
+2339317978u,
+2135116860u,
+4180643791u,
+2415309340u,
+1855926417u,
+3418648630u,
+1968113037u,
+597304222u,
+3668824865u,
+3810008716u,
+3014702569u,
+3151212026u,
+156057449u,
+373134533u,
+2068234004u,
+191580563u,
+3832754488u,
+2924104199u,
+2026044494u,
+4065780435u,
+122565840u,
+4194985167u,
+2744823717u,
+2494098735u,
+3753793370u,
+1885739217u,
+2488161225u,
+3643797615u,
+2653367310u,
+2494061477u,
+189968132u,
+899646597u,
+392100396u,
+4012318310u,
+3855777086u,
+3566860954u,
+2698574996u,
+2414249905u,
+1330623339u,
+1263222732u,
+1277741760u,
+2194959402u,
+1629656136u,
+120494320u,
+1072368005u,
+1084245077u,
+4011372748u,
+1366613353u,
+3108643228u,
+3332219532u,
+2114746095u,
+3964007334u,
+371687128u,
+1084813876u,
+126459896u,
+4292782331u,
+321283184u,
+398168499u,
+3604983506u,
+560701543u,
+2073961354u,
+4240841868u,
+4151211362u,
+1338986875u,
+4093476832u,
+2269279497u,
+3500846299u,
+2510225147u,
+598000444u,
+1330391422u,
+1432533385u,
+4171226231u,
+426821154u,
+2932270996u,
+3378981077u,
+2217871549u,
+1619647984u,
+4051608043u,
+3180237819u,
+12919578u,
+1375401767u,
+371320427u,
+2986640571u,
+2336669859u,
+3796464715u,
+1892383284u,
+306814912u,
+2125823211u,
+1863678891u,
+3249703818u,
+3840225752u,
+281579900u,
+264680257u,
+4266359110u,
+4182229890u,
+2239659703u,
+3627947372u,
+2373929191u,
+224082765u,
+4053639058u,
+1862360303u,
+3187739624u,
+3392706679u,
+948039509u,
+817505760u,
+1215842393u,
+3462222651u,
+536021853u,
+182346832u,
+2731944883u,
+2346674384u,
+2640961678u,
+3446695687u,
+2271722179u,
+1301069656u,
+2803881468u,
+2832614405u,
+1691544398u,
+698756814u,
+3980620906u,
+3565421410u,
+754769376u,
+4115923404u,
+3909962218u,
+2747614077u,
+2888289845u,
+1016920862u,
+2790946178u,
+3067070960u,
+3173251481u,
+1572132982u,
+255048203u,
+2996538818u,
+3405398987u,
+136106013u,
+3581605228u,
+4277437977u,
+2147300534u,
+3728426265u,
+3483629996u,
+1478452694u,
+20756076u,
+2774992067u,
+432987927u,
+1516771026u,
+3511588664u,
+2130994978u,
+509385406u,
+873090347u,
+2163904107u,
+4192239086u,
+2532489989u,
+1090772651u,
+3910797408u,
+3710882132u,
+155010959u,
+1369823531u,
+1599664937u,
+4035593587u,
+1212746925u,
+795822552u,
+116689518u,
+3674240941u,
+1135576664u,
+756750261u,
+1027431362u,
+390555140u,
+2228460216u,
+1506940482u,
+3733857700u,
+3048762971u,
+2511703196u,
+548609887u,
+1607354252u,
+659053982u,
+259884450u,
+1793130460u,
+4083364495u,
+3148555881u,
+1764350138u,
+2436485683u,
+4031563025u,
+3261860724u,
+2475833430u,
+2101726086u,
+3191176464u,
+2646658847u,
+2127042126u,
+771316100u,
+2115922959u,
+3208515045u,
+2355437783u,
+3621147793u,
+1580163615u,
+3211555675u,
+3299188490u,
+191613920u,
+466733956u,
+2939029038u,
+1509152039u,
+130591314u,
+1892874677u,
+1646908044u,
+3452406523u,
+3998376606u,
+1199243832u,
+2187108812u,
+3189230066u,
+4161151481u,
+3371454980u,
+3681788646u,
+180842187u,
+3685022399u,
+3058749895u,
+3250165163u,
+2895367943u,
+2627101723u,
+771755098u,
+1332921024u,
+3638871848u,
+514215135u,
+3591227378u,
+2300310870u,
+3689533503u,
+851607114u,
+114330368u,
+2709027386u,
+1743034877u,
+1013693860u,
+288169008u,
+3545190686u,
+1052165084u,
+3995862307u,
+96902755u,
+1097819851u,
+2645431442u,
+2184148618u,
+2151206566u,
+350979797u,
+3467920900u,
+421116779u,
+1246252u,
+4057835428u,
+329324407u,
+4104482417u,
+844624570u,
+3306265806u,
+3787625025u,
+4263241191u,
+3251413927u,
+2921204431u,
+2931915325u,
+992134330u,
+3986338354u,
+1327895216u,
+1458363596u,
+1480608532u,
+728594368u,
+3804366693u,
+794404223u,
+1643240863u,
+793417255u,
+4167916443u,
+2683488959u,
+3124925324u,
+4184843652u,
+3750971752u,
+308509829u,
+1054550805u,
+2797511972u,
+4043123412u,
+1587158240u,
+4050518606u,
+3030062190u,
+2589912753u,
+603440067u,
+937013191u,
+1071662315u,
+2100661456u,
+2602005741u,
+435516078u,
+2260470147u,
+1256268350u,
+3612035u,
+3368856141u,
+151516099u,
+3081868591u,
+3363755681u,
+2049963149u,
+2885320434u,
+84682005u,
+2411758308u,
+2695174275u,
+3099904644u,
+1787308684u,
+1132379308u,
+564634346u,
+510236510u,
+2804443681u,
+3931864252u,
+2064427949u,
+1893979229u,
+2916544974u,
+1885887717u,
+2978018250u,
+494192125u,
+2642662373u,
+901112508u,
+636035003u,
+1658643797u,
+172746975u,
+517504890u,
+3440019372u,
+4144498044u,
+1854755456u,
+3672653905u,
+4176892856u,
+382159097u,
+282871690u,
+3629300472u,
+2500754041u,
+1677659759u,
+1067175061u,
+161654075u,
+1672575536u,
+346120493u,
+2730229631u,
+203466442u,
+1244549529u,
+199761971u,
+2744895408u,
+3195315331u,
+2124618519u,
+3261045496u,
+985339699u,
+3385585455u,
+1545740710u,
+3636652160u,
+2167020081u,
+1207897204u,
+28752417u,
+2895834146u,
+3640845375u,
+3750293073u,
+548997850u,
+4207814196u,
+4183030708u,
+2462810989u,
+3929965401u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; IsAlive(farmhashmk::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashmk::Hash32(data, len++)); IsAlive(farmhashmk::Hash32(data, len++)); len -= 3; return alive > 0; }
+Check(farmhashmk::Hash32WithSeed(data + offset, len, SEED));
+Check(farmhashmk::Hash32(data + offset, len));
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashmkTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+cout << farmhashmk::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
+cout << farmhashmk::Hash32(data + offset, len) << "u," << endl;
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashmkTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashmkTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashmkTest::Dump(0, i);
+ }
+ farmhashmkTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashnaTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+1140953930u, 861465670u,
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+890626835u, 800175912u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+3283896453u, 1867689945u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+1110588164u, 4186314283u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+283198166u, 2741341286u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+452473466u, 1706958772u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+236935126u, 2976578695u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+2305012065u, 2169731866u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+3058973506u, 2379411653u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+147814787u, 720739346u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+3425469811u, 3690733394u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+1635026870u, 192883107u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+3969463346u, 1436364519u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+2859809759u, 3808705738u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+4023053163u, 2650381482u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+3476440786u, 3829307897u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+2902102606u, 3600725550u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1448662590u, 397635823u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+180854224u, 2604346966u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+1669465176u, 1341975128u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+1043692997u, 1454396064u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+703505868u, 678706990u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+1933894405u, 3043213226u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+3828089804u, 3632594520u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+3729087873u, 1303930448u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3103338579u, 3064290191u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2295806711u, 1781190011u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+1968445277u, 315203929u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+440398219u, 1891630171u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+4204318635u, 441430649u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+3010839769u, 2837339569u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+4139181436u, 2993479124u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+667183474u, 2084369203u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+1016656857u, 3022024459u,
+3254014218u, 429095991u,
+165589978u, 1578546616u,
+985653208u, 1718653828u,
+623071693u, 366414107u,
+249776086u, 1207522198u,
+3047342438u, 2991127487u,
+3120876698u, 1684583131u,
+46987739u, 1157614300u,
+863214540u, 1087193030u,
+199124911u, 520792961u,
+3614377032u, 586863115u,
+3331828431u, 1013201099u,
+1716848157u, 4033596884u,
+1164298657u, 4140791139u,
+1146169032u, 1434258493u,
+3824360466u, 3242407770u,
+3725511003u, 232064808u,
+872586426u, 762243036u,
+2736953692u, 816692935u,
+512845449u, 3748861010u,
+2266795890u, 3781899767u,
+4290630595u, 517646945u,
+22638523u, 648000590u,
+959214578u, 558910384u,
+1283799121u, 3047062993u,
+1024246061u, 4027776454u,
+3544509313u, 622325861u,
+834785312u, 382936554u,
+411505255u, 1973395102u,
+1825135056u, 2725923798u,
+580988377u, 2826990641u,
+3474970689u, 1029055034u,
+812546227u, 2506885666u,
+2584372201u, 1758123094u,
+589567754u, 325737734u,
+345313518u, 2022370576u,
+3886113119u, 3338548567u,
+257578986u, 3698087965u,
+1776047957u, 1771384107u,
+3604937815u, 3198590202u,
+2305332220u, 191910725u,
+4232136669u, 427759438u,
+4244322689u, 542201663u,
+3315355162u, 2135941665u,
+556609672u, 45845311u,
+1175961330u, 3948351189u,
+23075771u, 3252374102u,
+1634635545u, 4151937410u,
+713127376u, 1467786451u,
+663013031u, 3444053918u,
+2638154051u, 810082938u,
+3077742128u, 1062268187u,
+2115441882u, 4081398201u,
+3735739145u, 2794294783u,
+2335576331u, 2560479831u,
+1379288194u, 4225182569u,
+2442302747u, 3948961926u,
+3958366652u, 3067277639u,
+3667516477u, 1709989541u,
+1516711748u, 2339636583u,
+4188504038u, 59581167u,
+2725013602u, 3639843023u,
+2658147000u, 2643979752u,
+3758739543u, 4189944477u,
+2470483982u, 877580602u,
+2995362413u, 118817200u,
+3252925478u, 2062343506u,
+3981838403u, 3762572073u,
+1231633714u, 4168280671u,
+2931588131u, 3284356565u,
+1129162571u, 732225574u,
+4173605289u, 1407328702u,
+1677744031u, 3532596884u,
+3232041815u, 1652884780u,
+2256541290u, 3459463480u,
+3740979556u, 259034107u,
+2227121257u, 1426140634u,
+3606709555u, 3424793077u,
+315836068u, 3200749877u,
+1386256573u, 24035717u,
+2982018998u, 1811050648u,
+234531934u, 1115203611u,
+1598686658u, 3146815575u,
+1603559457u, 323296368u,
+2632963283u, 1778459926u,
+739944537u, 579625482u,
+3486330348u, 492621815u,
+1231665285u, 2457048126u,
+3903349120u, 389846205u,
+3355404249u, 3275550588u,
+1052645068u, 862072556u,
+2834153464u, 1481069623u,
+2657392572u, 4279236653u,
+1688445808u, 701920051u,
+3740748788u, 3388062747u,
+1873358321u, 2152785640u,
+883382081u, 1005815394u,
+1020177209u, 734239551u,
+2371453141u, 100326520u,
+3488500412u, 1279682138u,
+2610427744u, 49703572u,
+3026361211u, 605900428u,
+302392721u, 2509302188u,
+1416453607u, 2815915291u,
+1862819968u, 519710058u,
+2450888314u, 4017598378u,
+937074653u, 3035635454u,
+1590230729u, 3268013438u,
+2710029305u, 12886044u,
+3711259084u, 2627383582u,
+3895772404u, 648534979u,
+260307902u, 855990313u,
+3669691805u, 263366740u,
+2938543471u, 414331688u,
+3080542944u, 3405007814u,
+3565059103u, 1190977418u,
+390836981u, 1606450012u,
+2649808239u, 2514169310u,
+2747519432u, 4129538640u,
+1721522849u, 492099164u,
+792990594u, 3625507637u,
+2271095827u, 2993032712u,
+2302363854u, 4013112951u,
+1111617969u, 2183845740u,
+795918276u, 1116991810u,
+3110898804u, 3963062126u,
+2737064702u, 462795667u,
+937372240u, 1343017609u,
+1091041189u, 2790555455u,
+277024217u, 25485284u,
+1166522068u, 1623631848u,
+241727183u, 2836158787u,
+3112996740u, 573836428u,
+2721658101u, 1937681565u,
+4175169209u, 3190765433u,
+1970000788u, 1668258120u,
+114616703u, 954762543u,
+199237753u, 4094644498u,
+2522281978u, 732086117u,
+1756889687u, 2936126607u,
+2437031370u, 4103143808u,
+3883389541u, 3171090854u,
+2483004780u, 1927385370u,
+2360538162u, 2740855009u,
+4241185118u, 1492209542u,
+1672737098u, 2148675559u,
+1789864670u, 2434313103u,
+2319172611u, 2760941207u,
+2636210123u, 1338083267u,
+1128080590u, 822806371u,
+1199583556u, 314727461u,
+1335160250u, 2084630531u,
+1156261526u, 316766066u,
+112090465u, 3129033323u,
+2746885618u, 636616055u,
+2582210744u, 1721064910u,
+3468394263u, 470463518u,
+2076016059u, 408721884u,
+2121041886u, 378460278u,
+1915948002u, 357324860u,
+2301682622u, 2691859523u,
+1869756364u, 2429314418u,
+2193146527u, 1185564327u,
+2614088922u, 1975527044u,
+919067651u, 2855948894u,
+3662539576u, 1943802836u,
+3529473373u, 1490330107u,
+366036094u, 3384241033u,
+4276268604u, 448403661u,
+4271796078u, 1910401882u,
+3077107698u, 299427366u,
+2035665349u, 3201262636u,
+3738454258u, 2554452696u,
+3588997135u, 3363895827u,
+1267505995u, 1852004679u,
+2237827073u, 2803250686u,
+3468044908u, 2143572850u,
+1728158656u, 1022551180u,
+1996680960u, 839529273u,
+2400647871u, 2201096054u,
+3606433628u, 2597259793u,
+3544595875u, 3909443124u,
+819278607u, 3447346709u,
+806136613u, 2711436388u,
+3656063205u, 837475154u,
+694525336u, 4070212073u,
+4011303412u, 1068395209u,
+438095290u, 484603494u,
+2673730227u, 737767009u,
+642310823u, 3914002299u,
+308425103u, 268427550u,
+1334387085u, 4069797497u,
+4280783219u, 2914011058u,
+4243643405u, 2849988118u,
+2504230175u, 1817156623u,
+2804200483u, 3406991497u,
+2948254999u, 2102063419u,
+1071272117u, 514889942u,
+571972433u, 1246595599u,
+1735616066u, 1539151988u,
+1230831543u, 277987182u,
+4269526481u, 991511607u,
+95237878u, 2005032160u,
+1291113144u, 626619670u,
+3560835907u, 164940926u,
+1433635018u, 116647396u,
+3039097112u, 2868163232u,
+1141645918u, 1764165478u,
+881378302u, 2159170082u,
+2953647681u, 1011320066u,
+184856151u, 1723308975u,
+336034862u, 2017579106u,
+1476681709u, 147523618u,
+3896252223u, 2264728166u,
+944743644u, 1694443528u,
+2690700128u, 1947321519u,
+735478508u, 4058183171u,
+260177668u, 505662155u,
+2391691262u, 1920739747u,
+3216960415u, 1898176786u,
+3722741628u, 1511077569u,
+449636564u, 983350414u,
+2580237367u, 2055059789u,
+1103819072u, 2089123665u,
+3873755579u, 2718467458u,
+3124338704u, 3204250304u,
+2475035432u, 1120017626u,
+3873758287u, 1982999824u,
+2950794582u, 780634378u,
+2842141483u, 4029205195u,
+1656892865u, 3330993377u,
+80890710u, 1953796601u,
+3873078673u, 136118734u,
+2317676604u, 4199091610u,
+1864448181u, 3063437608u,
+1699452298u, 1403506686u,
+1513069466u, 2348491299u,
+4273657745u, 4055855649u,
+1805475756u, 2562064338u,
+973124563u, 4197091358u,
+172861513u, 2858726767u,
+4271866024u, 3071338162u,
+3590386266u, 2328277259u,
+1096050703u, 1189614342u,
+459509140u, 771592405u,
+817999971u, 3740825152u,
+520400189u, 1941874618u,
+185232757u, 4032960199u,
+3928245258u, 3527721294u,
+1301118856u, 752188080u,
+3512945009u, 308584855u,
+2105373972u, 752872278u,
+3823368815u, 3760952096u,
+4250142168u, 2565680167u,
+3646354146u, 1259957455u,
+1085857127u, 3471066607u,
+38924274u, 3770488806u,
+1083869477u, 3312508103u,
+71956383u, 3738784936u,
+3099963860u, 1255084262u,
+4286969992u, 3621849251u,
+1190908967u, 1831557743u,
+2363435042u, 54945052u,
+4059585566u, 4023974274u,
+1788578453u, 3442180039u,
+2534883189u, 2432427547u,
+3909757989u, 731996369u,
+4168347425u, 1356028512u,
+2741583197u, 1280920000u,
+312887059u, 3259015297u,
+3946278527u, 4135481831u,
+1281043691u, 1121403845u,
+3312292477u, 1819941269u,
+1741932545u, 3293015483u,
+2127558730u, 713121337u,
+2635469238u, 486003418u,
+4015067527u, 2976737859u,
+2108187161u, 927011680u,
+1970188338u, 4177613234u,
+1799789551u, 2118505126u,
+4134691985u, 1958963937u,
+1929210029u, 2555835851u,
+2768832862u, 910892050u,
+2567532373u, 4075249328u,
+86689814u, 3726640307u,
+1392137718u, 1240000030u,
+4104757832u, 3026358429u,
+313797689u, 1435798509u,
+3101500919u, 1241665335u,
+3573008472u, 3615577014u,
+3767659003u, 3134294021u,
+4063565523u, 2296824134u,
+1541946015u, 3087190425u,
+2693152531u, 2199672572u,
+2123763822u, 1034244398u,
+857839960u, 2515339233u,
+2228007483u, 1628096047u,
+2116502287u, 2502657424u,
+2809830736u, 460237542u,
+450205998u, 3646921704u,
+3818199357u, 1808504491u,
+1950698961u, 2069753399u,
+3657033172u, 3734547671u,
+4067859590u, 3292597295u,
+1106466069u, 356742959u,
+2469567432u, 3495418823u,
+183440071u, 3248055817u,
+3662626864u, 1750561299u,
+3926138664u, 4088592524u,
+567122118u, 3810297651u,
+992181339u, 3384018814u,
+3272124369u, 3177596743u,
+320086295u, 2316548367u,
+100741310u, 451656820u,
+4086604273u, 3759628395u,
+2553391092u, 1745659881u,
+3650357479u, 2390172694u,
+330172533u, 767377322u,
+526742034u, 4102497288u,
+2088767754u, 164402616u,
+2482632320u, 2352347393u,
+1873658044u, 3861555476u,
+2751052984u, 1767810825u,
+20037241u, 545143220u,
+2594532522u, 472304191u,
+3441135892u, 3323383489u,
+258785117u, 2977745165u,
+2781737565u, 2963590112u,
+2756998822u, 207428029u,
+2581558559u, 3824717027u,
+1258619503u, 3472047571u,
+2648427775u, 2360400900u,
+2393763818u, 2332399088u,
+3932701729u, 884421165u,
+1396468647u, 1377764574u,
+4061795938u, 1559119087u,
+3343596838u, 3604258095u,
+1435134775u, 1099809675u,
+908163739u, 1418405656u,
+368446627u, 3741651161u,
+3374512975u, 3542220540u,
+3244772570u, 200009340u,
+3198975081u, 2521038253u,
+4081637863u, 337070226u,
+3235259030u, 3897262827u,
+736956644u, 641040550u,
+644850146u, 1306761320u,
+4219448634u, 193750500u,
+3293278106u, 1383997679u,
+1242645122u, 4109252858u,
+450747727u, 3716617561u,
+362725793u, 2252520167u,
+3377483696u, 1788337208u,
+8130777u, 3226734120u,
+759239140u, 1012411364u,
+1658628529u, 2911512007u,
+1002580201u, 1681898320u,
+3039016929u, 4294520281u,
+367022558u, 3071359622u,
+3205848570u, 152989999u,
+3839042136u, 2357687350u,
+4273132307u, 3898950547u,
+1176841812u, 1314157485u,
+75443951u, 1027027239u,
+1858986613u, 2040551642u,
+36574105u, 2603059541u,
+3456147251u, 2137668425u,
+4077477194u, 3565689036u,
+491832241u, 363703593u,
+2579177168u, 3589545214u,
+265993036u, 1864569342u,
+4149035573u, 3189253455u,
+1072259310u, 3153745937u,
+923017956u, 490608221u,
+855846773u, 845706553u,
+1018226240u, 1604548872u,
+3833372385u, 3287246572u,
+2757959551u, 2452872151u,
+1553870564u, 1713154780u,
+2649450292u, 500120236u,
+84251717u, 661869670u,
+1444911517u, 2489716881u,
+2810524030u, 1561519055u,
+3884088359u, 2509890699u,
+4247155916u, 1005636939u,
+3224066062u, 2774151984u,
+2035978240u, 2514910366u,
+1478837908u, 3144450144u,
+2107011431u, 96459446u,
+3587732908u, 2389230590u,
+3287635953u, 250533792u,
+1235983679u, 4237425634u,
+3704645833u, 3882376657u,
+2976369049u, 1187061987u,
+276949224u, 4100839753u,
+1698347543u, 1629662314u,
+1556151829u, 3784939568u,
+427484362u, 4246879223u,
+3155311770u, 4285163791u,
+1693376813u, 124492786u,
+1858777639u, 3476334357u,
+1941442701u, 1121980173u,
+3485932087u, 820852908u,
+358032121u, 2511026735u,
+1873607283u, 2556067450u,
+2248275536u, 1528632094u,
+1535473864u, 556796152u,
+1499201704u, 1472623890u,
+1526518503u, 3692729434u,
+1476438092u, 2913077464u,
+335109599u, 2167614601u,
+4121131078u, 3158127917u,
+3051522276u, 4046477658u,
+2857717851u, 1863977403u,
+1341023343u, 692059110u,
+1802040304u, 990407433u,
+3285847572u, 319814144u,
+561105582u, 1540183799u,
+4052924496u, 2926590471u,
+2244539806u, 439121871u,
+3317903224u, 3178387550u,
+4265214507u, 82077489u,
+1978918971u, 4279668976u,
+128732476u, 2853224222u,
+464407878u, 4190838199u,
+997819001u, 3250520802u,
+2330081301u, 4095846095u,
+733509243u, 1583801700u,
+722314527u, 3552883023u,
+1403784280u, 432327540u,
+1877837196u, 3912423882u,
+505219998u, 696031431u,
+908238873u, 4189387259u,
+8759461u, 2540185277u,
+3385159748u, 381355877u,
+2519951681u, 1679786240u,
+2019419351u, 4051584612u,
+1933923923u, 3768201861u,
+1670133081u, 3454981037u,
+700836153u, 1675560450u,
+371560700u, 338262316u,
+847351840u, 2222395828u,
+3130433948u, 405251683u,
+3037574880u, 184098830u,
+453340528u, 1385561439u,
+2224044848u, 4071581802u,
+1431235296u, 5570097u,
+570114376u, 2287305551u,
+2272418128u, 803575837u,
+3943113491u, 414959787u,
+708083137u, 2452657767u,
+4019147902u, 3841480082u,
+3791794715u, 2965956183u,
+2763690963u, 2350937598u,
+3424361375u, 779434428u,
+1274947212u, 686105485u,
+3426668051u, 3692865672u,
+3057021940u, 2285701422u,
+349809124u, 1379278508u,
+3623750518u, 215970497u,
+1783152480u, 823305654u,
+216118434u, 1787189830u,
+3692048450u, 2272612521u,
+3032187389u, 4159715581u,
+1388133148u, 1611772864u,
+2544383526u, 552925303u,
+3420960112u, 3198900547u,
+3503230228u, 2603352423u,
+2318375898u, 4064071435u,
+3006227299u, 4194096960u,
+1283392422u, 1510460996u,
+174272138u, 3671038966u,
+1775955687u, 1719108984u,
+1763892006u, 1385029063u,
+4083790740u, 406757708u,
+684087286u, 531310503u,
+3329923157u, 3492083607u,
+1059031410u, 3037314475u,
+3105682208u, 3382290593u,
+2292208503u, 426380557u,
+97373678u, 3842309471u,
+777173623u, 3241407531u,
+303065016u, 1477104583u,
+4234905200u, 2512514774u,
+2649684057u, 1397502982u,
+1802596032u, 3973022223u,
+2543566442u, 3139578968u,
+3193669211u, 811750340u,
+4013496209u, 567361887u,
+4169410406u, 3622282782u,
+3403136990u, 2540585554u,
+895210040u, 3862229802u,
+1145435213u, 4146963980u,
+784952939u, 943914610u,
+573034522u, 464420660u,
+2356867109u, 3054347639u,
+3985088434u, 1911188923u,
+583391304u, 176468511u,
+2990150068u, 2338031599u,
+519948041u, 3181425568u,
+496106033u, 4110294665u,
+2736756930u, 1196757691u,
+1089679033u, 240953857u,
+3399092928u, 4040779538u,
+2843673626u, 240495962u,
+3017658263u, 3828377737u,
+4243717901u, 2448373688u,
+2759616657u, 2246245780u,
+308018483u, 4262383425u,
+2731780771u, 328023017u,
+2884443148u, 841480070u,
+3188015819u, 4051263539u,
+2298178908u, 2944209234u,
+1372958390u, 4164532914u,
+4074952232u, 1683612329u,
+2155036654u, 1872815858u,
+2041174279u, 2368092311u,
+206775997u, 2283918569u,
+645945606u, 115406202u,
+4206471368u, 3923500892u,
+2217060665u, 350160869u,
+706531239u, 2824302286u,
+509981657u, 1469342315u,
+140980u, 1891558063u,
+164887091u, 3094962711u,
+3437115622u, 13327420u,
+422986366u, 330624974u,
+3630863408u, 2425505046u,
+824008515u, 3543885677u,
+918718096u, 376390582u,
+3224043675u, 3724791476u,
+1837192976u, 2968738516u,
+3424344721u, 3187805406u,
+1550978788u, 1743089918u,
+4251270061u, 645016762u,
+3855037968u, 1928519266u,
+1373803416u, 2289007286u,
+1889218686u, 1610271373u,
+3059200728u, 2108753646u,
+582042641u, 812347242u,
+3188172418u, 191994904u,
+1343511943u, 2247006571u,
+463291708u, 2697254095u,
+1534175504u, 1106275740u,
+622521957u, 917121602u,
+4095777215u, 3955972648u,
+3852234638u, 2845309942u,
+3299763344u, 2864033668u,
+2554947496u, 799569078u,
+2551629074u, 1102873346u,
+2661022773u, 2006922227u,
+2900438444u, 1448194126u,
+1321567432u, 1983773590u,
+1237256330u, 3449066284u,
+1691553115u, 3274671549u,
+4271625619u, 2741371614u,
+3285899651u, 786322314u,
+1586632825u, 564385522u,
+2530557509u, 2974240289u,
+1244759631u, 3263135197u,
+3592389776u, 3570296884u,
+2749873561u, 521432811u,
+987586766u, 3206261120u,
+1327840078u, 4078716491u,
+1753812954u, 976892272u,
+1827135136u, 1781944746u,
+1328622957u, 1015377974u,
+3439601008u, 2209584557u,
+2482286699u, 1109175923u,
+874877499u, 2036083451u,
+483570344u, 1091877599u,
+4190721328u, 1129462471u,
+640035849u, 1867372700u,
+920761165u, 3273688770u,
+1623777358u, 3389003793u,
+3241132743u, 2734783008u,
+696674661u, 2502161880u,
+1646071378u, 1164309901u,
+350411888u, 1978005963u,
+2253937037u, 7371540u,
+989577914u, 3626554867u,
+3214796883u, 531343826u,
+398899695u, 1145247203u,
+1516846461u, 3656006011u,
+529303412u, 3318455811u,
+3062828129u, 1696355359u,
+3698796465u, 3155218919u,
+1457595996u, 3191404246u,
+1395609912u, 2917345728u,
+1237411891u, 1854985978u,
+1091884675u, 3504488111u,
+3109924189u, 1628881950u,
+3939149151u, 878608872u,
+778235395u, 1052990614u,
+903730231u, 2069566979u,
+2437686324u, 3163786257u,
+2257884264u, 2123173186u,
+939764916u, 2933010098u,
+1235300371u, 1256485167u,
+1950274665u, 2180372319u,
+2648400302u, 122035049u,
+1883344352u, 2083771672u,
+3712110541u, 321199441u,
+1896357377u, 508560958u,
+3066325351u, 2770847216u,
+3177982504u, 296902736u,
+1486926688u, 456842861u,
+601221482u, 3992583643u,
+2794121515u, 1533934172u,
+1706465470u, 4281971893u,
+2557027816u, 900741486u,
+227175484u, 550595824u,
+690918144u, 2825943628u,
+90375300u, 300318232u,
+1985329734u, 1440763373u,
+3670603707u, 2533900859u,
+3253901179u, 542270815u,
+3677388841u, 307706478u,
+2570910669u, 3320103693u,
+1273768482u, 1216399252u,
+1652924805u, 1043647584u,
+1120323676u, 639941430u,
+325675502u, 3652676161u,
+4241680335u, 1545838362u,
+1991398008u, 4100211814u,
+1097584090u, 3262252593u,
+2254324292u, 1765019121u,
+4060211241u, 2315856188u,
+3704419305u, 411263051u,
+238929055u, 3540688404u,
+3094544537u, 3250435765u,
+3460621305u, 1967599860u,
+2016157366u, 847389916u,
+1659615591u, 4020453639u,
+901109753u, 2682611693u,
+1661364280u, 177155177u,
+3210561911u, 3802058181u,
+797089608u, 3286110054u,
+2110358240u, 1353279028u,
+2479975820u, 471725410u,
+2219863904u, 3623364733u,
+3167128228u, 1052188336u,
+3656587111u, 721788662u,
+3061255808u, 1615375832u,
+924941453u, 2547780700u,
+3328169224u, 1310964134u,
+2701956286u, 4145497671u,
+1421461094u, 1221397398u,
+1589183618u, 1492533854u,
+449740816u, 2686506989u,
+3035198924u, 1682886232u,
+2529760244u, 3342031659u,
+1235084019u, 2151665147u,
+2315686577u, 3282027660u,
+1140138691u, 2754346599u,
+2091754612u, 1178454681u,
+4226896579u, 2942520471u,
+2122168506u, 3751680858u,
+3213794286u, 2601416506u,
+4142747914u, 3951404257u,
+4243249649u, 748595836u,
+4004834921u, 238887261u,
+1927321047u, 2217148444u,
+205977665u, 1885975275u,
+186020771u, 2367569534u,
+2941662631u, 2608559272u,
+3342096731u, 741809437u,
+1962659444u, 3539886328u,
+3036596491u, 2282550094u,
+2366462727u, 2748286642u,
+2144472852u, 1390394371u,
+1257385924u, 2205425874u,
+2119055686u, 46865323u,
+3597555910u, 3188438773u,
+2372320753u, 3641116924u,
+3116286108u, 2680722658u,
+3371014971u, 2058751609u,
+2966943726u, 2345078707u,
+2330535244u, 4013841927u,
+1169588594u, 857915866u,
+1875260989u, 3175831309u,
+3193475664u, 1955181430u,
+923161569u, 4068653043u,
+776445899u, 954196929u,
+61509556u, 4248237857u,
+3808667664u, 581227317u,
+2893240187u, 4159497403u,
+4212264930u, 3973886195u,
+2077539039u, 851579036u,
+2957587591u, 772351886u,
+1173659554u, 946748363u,
+2794103714u, 2094375930u,
+4234750213u, 3671645488u,
+2614250782u, 2620465358u,
+3122317317u, 2365436865u,
+3393973390u, 523513960u,
+3645735309u, 2766686992u,
+2023960931u, 2312244996u,
+1875932218u, 3253711056u,
+3622416881u, 3274929205u,
+612094988u, 1555465129u,
+2114270406u, 3553762793u,
+1832633644u, 1087551556u,
+3306195841u, 1702313921u,
+3675066046u, 1735998785u,
+1690923980u, 1482649756u,
+1171351291u, 2043136409u,
+1962596992u, 461214626u,
+3278253346u, 1392428048u,
+3744621107u, 1028502697u,
+3991171462u, 1014064003u,
+3642345425u, 3186995039u,
+6114625u, 3359104346u,
+414856965u, 2814387514u,
+3583605071u, 2497896367u,
+1024572712u, 1927582962u,
+2892797583u, 845302635u,
+328548052u, 1523379748u,
+3392622118u, 1347167673u,
+1012316581u, 37767602u,
+2647726017u, 1070326065u,
+2075035198u, 4202817168u,
+2502924707u, 2612406822u,
+2187115553u, 1180137213u,
+701024148u, 1481965992u,
+3223787553u, 2083541843u,
+203230202u, 3876887380u,
+1334816273u, 2870251538u,
+2186205850u, 3985213979u,
+333533378u, 806507642u,
+1010064531u, 713520765u,
+3084131515u, 2637421459u,
+1703168933u, 1517562266u,
+4089081247u, 3231042924u,
+3079916123u, 3154574447u,
+2253948262u, 1725190035u,
+2452539325u, 1343734533u,
+213706059u, 2519409656u,
+108055211u, 2916327746u,
+587001593u, 1917607088u,
+4202913084u, 926304016u,
+469255411u, 4042080256u,
+3498936874u, 246692543u,
+495780578u, 438717281u,
+2259272650u, 4011324645u,
+2836854664u, 2317249321u,
+946828752u, 1280403658u,
+1905648354u, 2034241661u,
+774652981u, 1285694082u,
+2200307766u, 2158671727u,
+1135162148u, 232040752u,
+397012087u, 1717527689u,
+1720414106u, 918797022u,
+2580119304u, 3568069742u,
+2904461070u, 3893453420u,
+973817938u, 667499332u,
+3785870412u, 2088861715u,
+1565179401u, 600903026u,
+591806775u, 3512242245u,
+997964515u, 2339605347u,
+1134342772u, 3234226304u,
+4084179455u, 302315791u,
+2445626811u, 2590372496u,
+345572299u, 2274770442u,
+3600587867u, 3706939009u,
+1430507980u, 2656330434u,
+1079209397u, 2122849632u,
+1423705223u, 3826321888u,
+3683385276u, 1057038163u,
+1242840526u, 3987000643u,
+2398253089u, 1538190921u,
+1295898647u, 3570196893u,
+3065138774u, 3111336863u,
+2524949549u, 4203895425u,
+3025864372u, 968800353u,
+1023721001u, 3763083325u,
+526350786u, 635552097u,
+2308118370u, 2166472723u,
+2196937373u, 2643841788u,
+3040011470u, 4010301879u,
+2782379560u, 3474682856u,
+4201389782u, 4223278891u,
+1457302296u, 2251842132u,
+1090062008u, 3188219189u,
+292733931u, 1424229089u,
+1590782640u, 1365212370u,
+3975957073u, 3982969588u,
+2927147928u, 1048291071u,
+2766680094u, 884908196u,
+35237839u, 2221180633u,
+2490333812u, 4098360768u,
+4029081103u, 3490831871u,
+2392516272u, 3455379186u,
+3948800722u, 335456628u,
+2105117968u, 4181629008u,
+1044201772u, 3335754111u,
+540133451u, 3313113759u,
+3786107905u, 2627207327u,
+3540337875u, 3473113388u,
+3430536378u, 2514123129u,
+2124531276u, 3872633376u,
+3272957388u, 3501994650u,
+2418881542u, 487365389u,
+3877672368u, 1512866656u,
+3486531087u, 2102955203u,
+1136054817u, 3004241477u,
+1549075351u, 1302002008u,
+3936430045u, 2258587644u,
+4109233936u, 3679809321u,
+3467083076u, 2484463221u,
+1594979755u, 529218470u,
+3527024461u, 1147434678u,
+106799023u, 1823161970u,
+1704656738u, 1675883700u,
+3308746763u, 1875093248u,
+1352868568u, 1898561846u,
+2508994984u, 3177750780u,
+4217929592u, 400784472u,
+80090315u, 3564414786u,
+3841585648u, 3379293868u,
+160353261u, 2413172925u,
+2378499279u, 673436726u,
+1505702418u, 1330977363u,
+1853298225u, 3201741245u,
+2135714208u, 4069554166u,
+3715612384u, 3692488887u,
+3680311316u, 4274382900u,
+914186796u, 2264886523u,
+3869634032u, 1254199592u,
+1131020455u, 194781179u,
+429923922u, 2763792336u,
+2052895198u, 3997373194u,
+3440090658u, 2165746386u,
+1575500242u, 3463310191u,
+2064974716u, 3779513671u,
+3106421434u, 880320527u,
+3281914119u, 286569042u,
+3909096631u, 122359727u,
+1429837716u, 252230074u,
+4111461225u, 762273136u,
+93658514u, 2766407143u,
+3623657004u, 3869801679u,
+3925695921u, 2390397316u,
+2499025338u, 2741806539u,
+2507199021u, 1659221866u,
+361292116u, 4048761557u,
+3797133396u, 1517903247u,
+3121647246u, 3884308578u,
+1697201500u, 1558800262u,
+4150812360u, 3161302278u,
+2610217849u, 641564641u,
+183814518u, 2075245419u,
+611996508u, 2223461433u,
+329123979u, 121860586u,
+860985829u, 1137889144u,
+4018949439u, 2904348960u,
+947795261u, 1992594155u,
+4255427501u, 2281583851u,
+2892637604u, 1478186924u,
+3050771207u, 2767035539u,
+373510582u, 1963520320u,
+3763848370u, 3756817798u,
+627269409u, 1806905031u,
+1814444610u, 3646665053u,
+1822693920u, 278515794u,
+584050483u, 4142579188u,
+2149745808u, 3193071606u,
+1179706341u, 2693495182u,
+3259749808u, 644172091u,
+880509048u, 3340630542u,
+3365160815u, 2384445068u,
+3053081915u, 2840648309u,
+1986990122u, 1084703471u,
+2370410550u, 1627743573u,
+2244943480u, 4057483496u,
+2611595995u, 2470013639u,
+4024732359u, 3987190386u,
+873421687u, 2447660175u,
+3226583022u, 767655877u,
+2528024413u, 1962070688u,
+1233635843u, 2163464207u,
+659054446u, 854207134u,
+258410943u, 4197831420u,
+2515400215u, 3100476924u,
+1961549594u, 2219491151u,
+3997658851u, 163850514u,
+470325051u, 2598261204u,
+3052145580u, 59836528u,
+1376188597u, 966733415u,
+850667549u, 3622479237u,
+1083731990u, 1525777459u,
+4005126532u, 1428155540u,
+2781907007u, 943739431u,
+1493961005u, 2839096988u,
+2000057832u, 1941829603u,
+1901484772u, 939810041u,
+3377407371u, 3090115837u,
+3310840540u, 2068409688u,
+3261383939u, 2212130277u,
+2594774045u, 2912652418u,
+4179816101u, 3534504531u,
+3349254805u, 2796552902u,
+1385421283u, 4259908631u,
+3714780837u, 3070073945u,
+3372846298u, 3835884044u,
+3047965714u, 3009018735u,
+744091167u, 1861124263u,
+2764936304u, 1338171648u,
+4222019554u, 1395200692u,
+1371426007u, 3338031581u,
+2525665319u, 4196233786u,
+2332743921u, 1474702008u,
+2274266301u, 4255175517u,
+2290169528u, 1793910997u,
+2188254024u, 354202001u,
+3864458796u, 4280290498u,
+1554419340u, 1733094688u,
+2010552302u, 1561807039u,
+664313606u, 2548990879u,
+1084699349u, 3233936866u,
+973895284u, 2386881969u,
+1831995860u, 2961465052u,
+1428704144u, 3269904970u,
+231648253u, 2602483763u,
+4125013173u, 3319187387u,
+3347011944u, 1892898231u,
+4019114049u, 868879116u,
+4085937045u, 2378411019u,
+1072588531u, 3547435717u,
+2208070766u, 1069899078u,
+3142980597u, 2337088907u,
+1593338562u, 919414554u,
+688077849u, 3625708135u,
+1472447348u, 1947711896u,
+3953006207u, 877438080u,
+845995820u, 3150361443u,
+3053496713u, 2484577841u,
+224271045u, 2914958001u,
+2682612949u, 806655563u,
+2436224507u, 1907729235u,
+2920583824u, 1251814062u,
+2070814520u, 4034325578u,
+497847539u, 2714317144u,
+385182008u, 640855184u,
+1327075087u, 1062468773u,
+1757405994u, 1374270191u,
+4263183176u, 3041193150u,
+1037871524u, 3633173991u,
+4231821821u, 2830131945u,
+3505072908u, 2830570613u,
+4195208715u, 575398021u,
+3992840257u, 3691788221u,
+1949847968u, 2999344380u,
+3183782163u, 3723754342u,
+759716128u, 3284107364u,
+1714496583u, 15918244u,
+820509475u, 2553936299u,
+2201876606u, 4237151697u,
+2605688266u, 3253705097u,
+1008333207u, 712158730u,
+1722280252u, 1933868287u,
+4152736859u, 2097020806u,
+584426382u, 2836501956u,
+2522777566u, 1996172430u,
+2122199776u, 1069285218u,
+1474209360u, 690831894u,
+107482532u, 3695525410u,
+670591796u, 768977505u,
+2412057331u, 3647886687u,
+3110327607u, 1072658422u,
+379861934u, 1557579480u,
+4124127129u, 2271365865u,
+3880613089u, 739218494u,
+547346027u, 388559045u,
+3147335977u, 176230425u,
+3094853730u, 2554321205u,
+1495176194u, 4093461535u,
+3521297827u, 4108148413u,
+1913727929u, 1177947623u,
+1911655402u, 1053371241u,
+3265708874u, 1266515850u,
+1045540427u, 3194420196u,
+3717104621u, 1144474110u,
+1464392345u, 52070157u,
+4144237690u, 3350490823u,
+4166253320u, 2747410691u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; { uint64_t h = farmhashna::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
+{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint64_t h = farmhashna::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashnaTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint64_t h = farmhashna::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashnaTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashnaTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashnaTest::Dump(0, i);
+ }
+ farmhashnaTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashntTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+2681724312u,
+797982799u,
+921001710u,
+2134990486u,
+2244477846u,
+2992121793u,
+3943596029u,
+452431531u,
+2557197665u,
+2532580744u,
+3099673830u,
+3696623795u,
+3281581178u,
+1882212500u,
+275903667u,
+3033004529u,
+1402319660u,
+2699376854u,
+4222949502u,
+1712034059u,
+1330324210u,
+2921867846u,
+1728752234u,
+326029180u,
+3349570000u,
+1612122221u,
+1646032583u,
+1432476832u,
+3552092450u,
+1499109081u,
+1554038301u,
+3190844552u,
+540224401u,
+489963606u,
+1562872448u,
+2128624475u,
+1262831810u,
+1672724608u,
+2077310004u,
+1911523866u,
+294527927u,
+1389770549u,
+2026137563u,
+629449419u,
+2489287368u,
+645684964u,
+230403464u,
+3272648435u,
+165370827u,
+1230085527u,
+3628174014u,
+851743255u,
+1554380634u,
+3667013118u,
+2290487377u,
+1909203251u,
+1498556724u,
+4165088768u,
+197618179u,
+914413116u,
+1913303225u,
+3117299654u,
+1357272220u,
+507436733u,
+1413396341u,
+146044391u,
+429095991u,
+3056862311u,
+366414107u,
+2293458109u,
+1684583131u,
+1170404994u,
+520792961u,
+1577421232u,
+4033596884u,
+4229339322u,
+3242407770u,
+2649785113u,
+816692935u,
+3555213933u,
+517646945u,
+2180594090u,
+3047062993u,
+2391606125u,
+382936554u,
+788479970u,
+2826990641u,
+3167748333u,
+1758123094u,
+389974094u,
+3338548567u,
+2583576230u,
+3198590202u,
+4155628142u,
+542201663u,
+2856634168u,
+3948351189u,
+4194218315u,
+1467786451u,
+2743592929u,
+1062268187u,
+3810665822u,
+2560479831u,
+997658837u,
+3067277639u,
+1211737169u,
+59581167u,
+1389679610u,
+4189944477u,
+100876854u,
+2062343506u,
+3088828656u,
+3284356565u,
+3130054947u,
+3532596884u,
+3887208531u,
+259034107u,
+3233195759u,
+3200749877u,
+760633989u,
+1115203611u,
+1516407838u,
+1778459926u,
+2146672889u,
+2457048126u,
+2217471853u,
+862072556u,
+3745267835u,
+701920051u,
+581695350u,
+1410111809u,
+3326135446u,
+2187968410u,
+4267859263u,
+479241367u,
+2868987960u,
+704325635u,
+1418509533u,
+735688735u,
+3283299459u,
+813690332u,
+1439630796u,
+3195309868u,
+1616408198u,
+3254795114u,
+2799925823u,
+3929484338u,
+1798536177u,
+4205965408u,
+1499475160u,
+4247675634u,
+3779953975u,
+785893184u,
+2778575413u,
+1160134629u,
+823113169u,
+4116162021u,
+4167766971u,
+2487440590u,
+4004655503u,
+4044418876u,
+1462554406u,
+2011102035u,
+4265993528u,
+576405853u,
+4038839101u,
+2425317635u,
+1401013391u,
+3062418115u,
+3167030094u,
+2602636307u,
+4264167741u,
+4017058800u,
+1029665228u,
+4036354071u,
+2670703363u,
+688472265u,
+1054670286u,
+338058159u,
+1539305024u,
+146827036u,
+4060134777u,
+2502815838u,
+1603444633u,
+2448966429u,
+3891353218u,
+1082330589u,
+201837927u,
+2848283092u,
+883849006u,
+1982110346u,
+541496720u,
+133643215u,
+3847827123u,
+4015671361u,
+2849988118u,
+3452457457u,
+2102063419u,
+3281002516u,
+1539151988u,
+1147951686u,
+2005032160u,
+2415262714u,
+116647396u,
+1029284767u,
+2159170082u,
+1919171906u,
+2017579106u,
+2473524405u,
+1694443528u,
+3671562289u,
+505662155u,
+1019936943u,
+1511077569u,
+773792826u,
+2089123665u,
+484732447u,
+1120017626u,
+2809286837u,
+4029205195u,
+1097806406u,
+136118734u,
+4017075736u,
+1403506686u,
+1516736273u,
+2562064338u,
+2984955003u,
+3071338162u,
+1923531348u,
+771592405u,
+2586632018u,
+4032960199u,
+2687561076u,
+308584855u,
+1692079268u,
+2565680167u,
+3674576684u,
+3770488806u,
+69201295u,
+1255084262u,
+3593730713u,
+54945052u,
+1939595371u,
+2432427547u,
+2295501078u,
+1280920000u,
+82177963u,
+1121403845u,
+2889101923u,
+713121337u,
+1747052377u,
+927011680u,
+4142246789u,
+1958963937u,
+1636932722u,
+4075249328u,
+2025886508u,
+3026358429u,
+1845587644u,
+3615577014u,
+1363253259u,
+3087190425u,
+341851980u,
+2515339233u,
+1276595523u,
+460237542u,
+4198897105u,
+2069753399u,
+4278599955u,
+356742959u,
+3735275001u,
+1750561299u,
+668829411u,
+3384018814u,
+4233785523u,
+451656820u,
+107312677u,
+2390172694u,
+1216645846u,
+164402616u,
+1689811113u,
+1767810825u,
+1397772514u,
+3323383489u,
+2986430557u,
+207428029u,
+2260498180u,
+2360400900u,
+1263709570u,
+1377764574u,
+4252610345u,
+1099809675u,
+2776960536u,
+3542220540u,
+3752806924u,
+337070226u,
+3267551635u,
+1306761320u,
+2220373824u,
+4109252858u,
+896322512u,
+1788337208u,
+1336556841u,
+2911512007u,
+3712582785u,
+3071359622u,
+2561488770u,
+3898950547u,
+536047554u,
+2040551642u,
+3528794619u,
+3565689036u,
+1197100813u,
+1864569342u,
+3329594980u,
+490608221u,
+1174785921u,
+3287246572u,
+2163330264u,
+500120236u,
+2520062970u,
+1561519055u,
+4042710240u,
+2774151984u,
+3160666939u,
+96459446u,
+1878067032u,
+4237425634u,
+2952135524u,
+4100839753u,
+1265237690u,
+4246879223u,
+834830418u,
+3476334357u,
+4277111759u,
+2511026735u,
+3065234219u,
+556796152u,
+198182691u,
+2913077464u,
+1535115487u,
+4046477658u,
+140762681u,
+990407433u,
+2198985327u,
+2926590471u,
+559702706u,
+82077489u,
+1096697687u,
+4190838199u,
+3046872820u,
+1583801700u,
+2185339100u,
+3912423882u,
+3703603898u,
+2540185277u,
+1446869792u,
+4051584612u,
+2719373510u,
+1675560450u,
+1996164093u,
+405251683u,
+2864244470u,
+4071581802u,
+2028708916u,
+803575837u,
+557660441u,
+3841480082u,
+255451671u,
+779434428u,
+3452203069u,
+2285701422u,
+1568745354u,
+823305654u,
+3184047862u,
+4159715581u,
+3160134214u,
+3198900547u,
+1566527339u,
+4194096960u,
+1496132623u,
+1719108984u,
+2584236470u,
+531310503u,
+3456882941u,
+3382290593u,
+467441309u,
+3241407531u,
+2540270567u,
+1397502982u,
+3348545480u,
+811750340u,
+1017047954u,
+2540585554u,
+3531646869u,
+943914610u,
+1903578924u,
+1911188923u,
+241574049u,
+3181425568u,
+3529565564u,
+240953857u,
+2964595704u,
+3828377737u,
+4260564140u,
+4262383425u,
+383233885u,
+4051263539u,
+919677938u,
+1683612329u,
+4204155962u,
+2283918569u,
+4153726847u,
+350160869u,
+1387233546u,
+1891558063u,
+740563169u,
+330624974u,
+2948665536u,
+376390582u,
+3799363969u,
+3187805406u,
+2263421398u,
+1928519266u,
+2746577402u,
+2108753646u,
+768287270u,
+2247006571u,
+212490675u,
+917121602u,
+2549835613u,
+2864033668u,
+3738062408u,
+2006922227u,
+2616619070u,
+3449066284u,
+431292293u,
+786322314u,
+1415970351u,
+3263135197u,
+2954777083u,
+3206261120u,
+2287507921u,
+1781944746u,
+4081586725u,
+1109175923u,
+1813855658u,
+1129462471u,
+1037031473u,
+3389003793u,
+3122687303u,
+1164309901u,
+3193251135u,
+3626554867u,
+3071568023u,
+3656006011u,
+1167681812u,
+3155218919u,
+2704165015u,
+1854985978u,
+1712976649u,
+878608872u,
+4155949943u,
+3163786257u,
+1626463554u,
+1256485167u,
+582664250u,
+2083771672u,
+804336148u,
+2770847216u,
+1674051445u,
+3992583643u,
+2966108111u,
+900741486u,
+4014551783u,
+300318232u,
+3517585534u,
+542270815u,
+760762191u,
+1216399252u,
+643179562u,
+3652676161u,
+2990167340u,
+3262252593u,
+2134299399u,
+411263051u,
+1342880802u,
+1967599860u,
+853593042u,
+2682611693u,
+850464484u,
+3286110054u,
+3842907484u,
+3623364733u,
+3693536939u,
+1615375832u,
+2318423400u,
+4145497671u,
+1728968857u,
+2686506989u,
+1502282913u,
+2151665147u,
+3651607391u,
+1178454681u,
+4146839064u,
+2601416506u,
+1448097974u,
+238887261u,
+4093725287u,
+2367569534u,
+679517009u,
+3539886328u,
+3086277222u,
+1390394371u,
+119173722u,
+1766260771u,
+751439914u,
+215917713u,
+2656990891u,
+1570750352u,
+3533987737u,
+3576119563u,
+963183826u,
+3796810515u,
+136547246u,
+2592925324u,
+427154472u,
+1228758574u,
+1464255968u,
+2984611177u,
+2001585786u,
+1525438381u,
+1348536411u,
+2861338018u,
+764077711u,
+3785343245u,
+457568934u,
+4104954272u,
+2381948487u,
+3148473363u,
+2180270337u,
+1387729170u,
+951677556u,
+2721005055u,
+66786703u,
+1149351924u,
+1895026827u,
+3711056516u,
+3638638708u,
+2263003308u,
+3448840877u,
+225333538u,
+3797521928u,
+3262952567u,
+2078619498u,
+1178073973u,
+3288261538u,
+1496966875u,
+2481012988u,
+114945840u,
+1632780103u,
+2087949619u,
+3787017905u,
+2575395164u,
+2971726178u,
+3642087909u,
+3894199764u,
+203853421u,
+425935223u,
+3565833278u,
+1748785729u,
+580966986u,
+2124704694u,
+1107045577u,
+1067532701u,
+1406028344u,
+18613994u,
+3476683808u,
+3762914298u,
+1844996900u,
+904215228u,
+1118521573u,
+3657647605u,
+3136157065u,
+2287683323u,
+126005630u,
+3555092974u,
+49515858u,
+1010661841u,
+1902040126u,
+1400735275u,
+2771676666u,
+2225229957u,
+3454177594u,
+2883475137u,
+4144472319u,
+1051332394u,
+542648229u,
+1669710469u,
+553041029u,
+584127807u,
+2993670925u,
+3587959456u,
+1745399498u,
+1404723176u,
+1334333531u,
+3239516985u,
+1275954779u,
+367320647u,
+3684418197u,
+4030809053u,
+484559105u,
+4255931645u,
+4271715616u,
+3171911678u,
+928543347u,
+2159512867u,
+313902234u,
+647086234u,
+577214736u,
+1130129573u,
+995791646u,
+1645086060u,
+4122335794u,
+1064648931u,
+2752145076u,
+3312498873u,
+4238535494u,
+1471227427u,
+633688562u,
+1959779970u,
+766642813u,
+1380896111u,
+3647601207u,
+1733961041u,
+521947915u,
+189164145u,
+486382294u,
+3770038872u,
+3235740744u,
+1912506671u,
+2276864677u,
+1588060152u,
+2504457929u,
+1471020554u,
+3623212998u,
+3026631806u,
+2342164722u,
+1674890530u,
+3011542850u,
+3549160092u,
+4290680005u,
+3943068002u,
+2273781461u,
+2127663659u,
+1646681121u,
+447810651u,
+2366308558u,
+970504950u,
+2008155560u,
+2695940969u,
+3444688454u,
+1739318893u,
+2683090634u,
+2774816580u,
+437560100u,
+512012738u,
+3305170944u,
+665292744u,
+3580039116u,
+1579404983u,
+3397891494u,
+710590371u,
+2514565805u,
+3624609754u,
+3516075816u,
+1314000850u,
+1935166880u,
+3257747610u,
+3776931214u,
+3183054185u,
+675129307u,
+3333261712u,
+1154611403u,
+2759854023u,
+1963228038u,
+505138315u,
+1803966773u,
+4032705384u,
+798395739u,
+3473799845u,
+476400898u,
+602972493u,
+3289878097u,
+2520311409u,
+3214794876u,
+748160407u,
+1326769504u,
+902775872u,
+1372805534u,
+1213925114u,
+3009384989u,
+3781981134u,
+2835608783u,
+2716786748u,
+1669490957u,
+1089334066u,
+250756920u,
+4041016629u,
+2495807367u,
+2008251381u,
+106212622u,
+1927268995u,
+2251978818u,
+3788056262u,
+3678660147u,
+2656772270u,
+1997584981u,
+2668998785u,
+2954162084u,
+845687881u,
+776018378u,
+2066910012u,
+918315064u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; IsAlive(farmhashnt::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashnt::Hash32(data, len++)); IsAlive(farmhashnt::Hash32(data, len++)); len -= 3; return alive > 0; }
+Check(farmhashnt::Hash32WithSeed(data + offset, len, SEED));
+Check(farmhashnt::Hash32(data + offset, len));
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashntTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+cout << farmhashnt::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
+cout << farmhashnt::Hash32(data + offset, len) << "u," << endl;
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashntTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashntTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashntTest::Dump(0, i);
+ }
+ farmhashntTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashsaTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+4081014168u,
+2576519988u,
+2212771159u,
+1112731063u,
+1020067935u,
+3955445564u,
+1451961420u,
+653440099u,
+31917516u,
+2957164615u,
+2590087362u,
+3879448744u,
+176305566u,
+2447367541u,
+1359016305u,
+3363804638u,
+1117290165u,
+1062549743u,
+2437877004u,
+1894455839u,
+673206794u,
+3486923651u,
+3269862919u,
+2303349487u,
+1380660650u,
+595525107u,
+1525325287u,
+2025609358u,
+176408838u,
+1592885012u,
+864896482u,
+2101378090u,
+3489229104u,
+2118965695u,
+581644891u,
+2718789079u,
+631613207u,
+4228658372u,
+3867875546u,
+3531368319u,
+3804516756u,
+3317755099u,
+1619744564u,
+2884717286u,
+1088213445u,
+2667691076u,
+3727873235u,
+2330406762u,
+858590707u,
+123802208u,
+4150036245u,
+182283099u,
+1478882570u,
+3282617403u,
+819171187u,
+1172627392u,
+4254302102u,
+2957028020u,
+437030323u,
+2452147680u,
+2868246750u,
+3530169402u,
+3154852132u,
+215019192u,
+357580983u,
+1354454461u,
+1108813287u,
+2324008118u,
+2315997713u,
+4181601562u,
+1360882441u,
+92423273u,
+3048866755u,
+3369188505u,
+3664371439u,
+2920710428u,
+1027891570u,
+2653166430u,
+3461888315u,
+1475780447u,
+292769636u,
+1737473313u,
+4064110516u,
+4170160075u,
+762850927u,
+3630603695u,
+2803307356u,
+844987665u,
+460980967u,
+3005635467u,
+2802568977u,
+588668033u,
+2148940781u,
+3239099984u,
+1266953698u,
+3197808789u,
+3519942533u,
+2511995334u,
+2553810188u,
+871667697u,
+1358675720u,
+1499319171u,
+2044931270u,
+1210355103u,
+807152540u,
+3262320756u,
+2810214575u,
+1813386141u,
+4089465863u,
+903928165u,
+1388899322u,
+3209183659u,
+834536144u,
+2733354550u,
+2742289921u,
+3689042563u,
+2655593281u,
+4169686303u,
+415985561u,
+138892376u,
+516115393u,
+65683883u,
+4162865100u,
+889944635u,
+313566528u,
+3346420907u,
+1504303591u,
+2256809275u,
+742243229u,
+779775302u,
+3140940172u,
+2312556111u,
+2304095772u,
+1151741606u,
+2194712422u,
+1714084652u,
+3272736835u,
+1311540658u,
+191179665u,
+3996605106u,
+1657345233u,
+4205442903u,
+1553339212u,
+2351843044u,
+1647502006u,
+2525516233u,
+292202846u,
+1498646290u,
+1429323381u,
+974274898u,
+3759331561u,
+2881238887u,
+826787221u,
+1069622448u,
+221991032u,
+1462969082u,
+2799661508u,
+364022781u,
+2594244377u,
+797773898u,
+4097839290u,
+1529150125u,
+2456805570u,
+541503425u,
+3936326142u,
+3112719954u,
+775223581u,
+3074018423u,
+3198488875u,
+1772191849u,
+2456535211u,
+3154686028u,
+1520862019u,
+4005829426u,
+1306433767u,
+1943028506u,
+2246000782u,
+1057766454u,
+3761996982u,
+3441075333u,
+898641979u,
+3450209088u,
+3941329307u,
+3289922449u,
+3085075827u,
+1814193220u,
+690422997u,
+2627846676u,
+2653520704u,
+3739145533u,
+3996776010u,
+2287072592u,
+1346671698u,
+3082629900u,
+2298811274u,
+3639722036u,
+1729419228u,
+1836765953u,
+3708118742u,
+213436u,
+950223749u,
+3734247682u,
+2924575678u,
+1382024841u,
+2431637732u,
+3448846682u,
+1341301397u,
+4206956590u,
+1730650902u,
+2581075456u,
+1542359141u,
+707222542u,
+2925350541u,
+3846303536u,
+3579103295u,
+3932175763u,
+1339615732u,
+848825750u,
+1070170828u,
+1964973818u,
+577060344u,
+607721296u,
+4031023048u,
+406883794u,
+3991905552u,
+1198544082u,
+872468460u,
+1044847096u,
+3159976313u,
+3020028266u,
+2108700400u,
+3373767922u,
+264431841u,
+2817097007u,
+3700061048u,
+1733731531u,
+3459415893u,
+80378591u,
+1479875104u,
+19735612u,
+1382658977u,
+3416562245u,
+1959852842u,
+2384002344u,
+124683828u,
+3725782174u,
+2300301222u,
+393852269u,
+1302492002u,
+3623776492u,
+3787086417u,
+1730024749u,
+1710531361u,
+443700716u,
+1461987482u,
+671998131u,
+3018380746u,
+2592292305u,
+3390799372u,
+3945101155u,
+3743494852u,
+3716045582u,
+996005166u,
+320698449u,
+3420221765u,
+1518157951u,
+2555810666u,
+3381929684u,
+2019638523u,
+3088262796u,
+2072178906u,
+3433649364u,
+203906916u,
+34663784u,
+290301305u,
+1188021504u,
+3754681145u,
+3920313139u,
+2840496520u,
+1656802962u,
+2288475489u,
+3399185138u,
+1296000826u,
+2362384746u,
+309633360u,
+2719851778u,
+776035930u,
+3200733043u,
+365690832u,
+3326378243u,
+1500331457u,
+1625708592u,
+4230903462u,
+715344888u,
+3363777768u,
+2243620288u,
+2890765789u,
+553154234u,
+4044100108u,
+4056887320u,
+1185656496u,
+3671476744u,
+1064586897u,
+1154949698u,
+3493481974u,
+1294573722u,
+1869224012u,
+2530084956u,
+995321553u,
+833419249u,
+563815282u,
+250258043u,
+2970801822u,
+441007535u,
+42246961u,
+2820426655u,
+2878882436u,
+2363245780u,
+2138489282u,
+2972360481u,
+2312619393u,
+3598664848u,
+3071556076u,
+776990325u,
+3220427357u,
+2257939577u,
+3817305903u,
+1502979698u,
+3159755934u,
+3955997276u,
+2423850008u,
+1959927572u,
+1219782288u,
+4119776679u,
+1124253854u,
+3678052422u,
+2620644947u,
+1262408666u,
+3480072280u,
+2627137665u,
+807538749u,
+3276646337u,
+518510128u,
+1137828655u,
+1498449110u,
+3031692317u,
+1125635969u,
+1130096111u,
+780007336u,
+3111856399u,
+1014917264u,
+780877352u,
+2909458336u,
+4235949214u,
+2423879289u,
+275888892u,
+3891926795u,
+3538163953u,
+54815161u,
+162228302u,
+258154068u,
+3554455591u,
+1801469029u,
+2801563220u,
+726560058u,
+2450221940u,
+3677582978u,
+440993800u,
+424762443u,
+2624525253u,
+2587715329u,
+2292264424u,
+1074856749u,
+3294752007u,
+3164112672u,
+2399146799u,
+1920182465u,
+3858835361u,
+193755240u,
+3333610311u,
+1757504059u,
+2576027039u,
+2775253365u,
+2939191561u,
+1046147275u,
+235149906u,
+4262218222u,
+2900542726u,
+2260154702u,
+1019551635u,
+1194720570u,
+3519118691u,
+3039483153u,
+84918216u,
+3053381097u,
+2572396843u,
+3849763371u,
+2782686780u,
+3710049554u,
+3403430713u,
+2346080784u,
+2496307442u,
+1597281872u,
+696018239u,
+704625714u,
+623026921u,
+3182413559u,
+3794540330u,
+305497722u,
+1592680199u,
+2377854072u,
+3060601746u,
+3953057908u,
+3941551588u,
+1033716182u,
+2765716854u,
+1309699058u,
+3519400181u,
+3073370877u,
+115583008u,
+4032909296u,
+2944563574u,
+3762753718u,
+192842727u,
+1711348701u,
+3086147235u,
+1658229443u,
+1479783872u,
+3839977157u,
+225619117u,
+1349684817u,
+1964813173u,
+565753187u,
+2530252046u,
+840014353u,
+1645183704u,
+3668429078u,
+3438418557u,
+639704059u,
+360837811u,
+2531807958u,
+1572353913u,
+2116037299u,
+1948437512u,
+744553393u,
+2380697034u,
+3775234105u,
+3816065157u,
+301868653u,
+2960939561u,
+3306528247u,
+2389296549u,
+805918610u,
+1759358265u,
+1760876328u,
+2827601706u,
+2944594708u,
+3313666458u,
+2022601495u,
+730938791u,
+193539397u,
+2026103244u,
+802928398u,
+2630934308u,
+782805818u,
+3499326016u,
+293509489u,
+3646131514u,
+3182478647u,
+854800333u,
+2284531628u,
+438528022u,
+2339298129u,
+1692289216u,
+2427728723u,
+46501288u,
+350652353u,
+1355971222u,
+889682372u,
+944799254u,
+2763906061u,
+2807550612u,
+2683762637u,
+100870317u,
+2449357318u,
+2638348436u,
+4206088869u,
+1788948473u,
+3537588549u,
+2782490204u,
+134406470u,
+2409190528u,
+2362439849u,
+1861661528u,
+2101513194u,
+1424834765u,
+3581765745u,
+3185999525u,
+2057487100u,
+2303941176u,
+3639628788u,
+1180265315u,
+230437935u,
+2108319366u,
+1131685143u,
+1055685292u,
+1509007009u,
+1258485140u,
+560525005u,
+3598799040u,
+3835680585u,
+1851859628u,
+332858996u,
+641769248u,
+4252450037u,
+865386707u,
+720719117u,
+3133612164u,
+3833045874u,
+3492515435u,
+2465970289u,
+4234420011u,
+573859916u,
+252532886u,
+870392318u,
+4051320920u,
+894929092u,
+3748361688u,
+699355960u,
+1885212350u,
+1609756949u,
+461896870u,
+1337065461u,
+1775211059u,
+1786193749u,
+2815154643u,
+2128729882u,
+969639529u,
+3960427545u,
+859416958u,
+2739758802u,
+2698032197u,
+2813292418u,
+1985467524u,
+396604317u,
+4122172759u,
+1201259789u,
+4282051702u,
+3270018895u,
+961215209u,
+961075860u,
+4211926998u,
+4088374597u,
+577510509u,
+3058349487u,
+4025377754u,
+2815478438u,
+471023164u,
+3947959608u,
+4161486934u,
+2299888461u,
+1103571511u,
+2450153872u,
+1839939275u,
+108299608u,
+858086440u,
+1030152945u,
+3895328530u,
+3009080718u,
+3690840454u,
+3847025277u,
+152331362u,
+161365689u,
+831319961u,
+2166017294u,
+3945322722u,
+4059970216u,
+1420824131u,
+2770648308u,
+1567250186u,
+2181067149u,
+1939743488u,
+3080158120u,
+3435218248u,
+2495237495u,
+3814085102u,
+3180983013u,
+3199054292u,
+2204745908u,
+1140337267u,
+2213569784u,
+1941879842u,
+2105562605u,
+3618835614u,
+2247103645u,
+2492473487u,
+856414299u,
+166022030u,
+4080104712u,
+3218935344u,
+3284220561u,
+4261581452u,
+1206944836u,
+3496705432u,
+2215996876u,
+3154627465u,
+3384005496u,
+742170556u,
+1333047620u,
+802680366u,
+156833431u,
+2682100354u,
+2493654830u,
+584848366u,
+1691693131u,
+2169934170u,
+779968026u,
+2099545800u,
+1423039695u,
+4292110968u,
+4266576788u,
+149142597u,
+748501873u,
+3865014822u,
+1913588198u,
+130285614u,
+3500768879u,
+915458923u,
+3071792750u,
+1339986633u,
+4143929149u,
+4048379479u,
+725193827u,
+1375113643u,
+2425277412u,
+4144659274u,
+465714768u,
+226991589u,
+2212127704u,
+3936145258u,
+2891024846u,
+3816000225u,
+979331165u,
+1749907536u,
+53847318u,
+1462525833u,
+2961425455u,
+368859113u,
+3572721452u,
+453048644u,
+1628629918u,
+3497673923u,
+3619079585u,
+139870565u,
+1518176798u,
+3933074281u,
+1878623729u,
+2074035641u,
+3016759257u,
+1313053591u,
+2557706970u,
+2348296582u,
+962370022u,
+2337285014u,
+1618936717u,
+1915877085u,
+2743743122u,
+3250783882u,
+1346652536u,
+143311109u,
+2443788461u,
+1048248964u,
+2806619339u,
+3263266976u,
+1668146349u,
+3397428868u,
+3276188862u,
+1774196343u,
+1993847813u,
+2771079610u,
+476672419u,
+2119050359u,
+2918326659u,
+2245402721u,
+2692910474u,
+2374383269u,
+342400227u,
+2961437795u,
+3899230368u,
+337787132u,
+3664444935u,
+1269451153u,
+2971526729u,
+1486511182u,
+791070133u,
+2570319890u,
+3482497490u,
+2134230518u,
+4273391202u,
+1825511330u,
+3947753714u,
+1389755724u,
+3995075516u,
+2081052615u,
+3626343470u,
+4213603435u,
+2137917278u,
+2898987303u,
+3059215715u,
+3383237881u,
+3003674434u,
+409174425u,
+1911915604u,
+2087728055u,
+2942005882u,
+3386522440u,
+714936074u,
+261924004u,
+3268784033u,
+1141188757u,
+2413217552u,
+1515163433u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; IsAlive(farmhashsa::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashsa::Hash32(data, len++)); IsAlive(farmhashsa::Hash32(data, len++)); len -= 3; return alive > 0; }
+Check(farmhashsa::Hash32WithSeed(data + offset, len, SEED));
+Check(farmhashsa::Hash32(data + offset, len));
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashsaTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+cout << farmhashsa::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
+cout << farmhashsa::Hash32(data + offset, len) << "u," << endl;
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashsaTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashsaTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashsaTest::Dump(0, i);
+ }
+ farmhashsaTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashsuTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+4081014168u,
+2576519988u,
+2212771159u,
+1112731063u,
+1020067935u,
+3955445564u,
+1451961420u,
+653440099u,
+31917516u,
+2957164615u,
+2590087362u,
+3879448744u,
+176305566u,
+2447367541u,
+1359016305u,
+3363804638u,
+1117290165u,
+1062549743u,
+2437877004u,
+1894455839u,
+673206794u,
+3486923651u,
+3269862919u,
+2303349487u,
+1380660650u,
+595525107u,
+1525325287u,
+2025609358u,
+176408838u,
+1592885012u,
+864896482u,
+2101378090u,
+3489229104u,
+2118965695u,
+581644891u,
+2718789079u,
+631613207u,
+4228658372u,
+3867875546u,
+3531368319u,
+3804516756u,
+3317755099u,
+1619744564u,
+2884717286u,
+1088213445u,
+2667691076u,
+3727873235u,
+2330406762u,
+858590707u,
+457744844u,
+4150036245u,
+2000404290u,
+1478882570u,
+901678172u,
+819171187u,
+195942998u,
+4254302102u,
+3967266927u,
+437030323u,
+4018009204u,
+2868246750u,
+3540087514u,
+3154852132u,
+3319116625u,
+357580983u,
+3177665294u,
+1108813287u,
+1253366798u,
+2315997713u,
+510718750u,
+1360882441u,
+2770216279u,
+3048866755u,
+3406961221u,
+3664371439u,
+1151145514u,
+1027891570u,
+2699067992u,
+3461888315u,
+198061905u,
+292769636u,
+1106771795u,
+4064110516u,
+3258279756u,
+762850927u,
+1818699721u,
+2803307356u,
+3919169404u,
+460980967u,
+3125535078u,
+2802568977u,
+3582546426u,
+2148940781u,
+3963274378u,
+1266953698u,
+204185123u,
+1100034381u,
+3009193601u,
+4200651967u,
+274889605u,
+2700589508u,
+952511689u,
+3765324859u,
+3465498478u,
+4014967037u,
+2070988082u,
+2972423530u,
+3068638223u,
+4156773651u,
+489509804u,
+1323863238u,
+3731914806u,
+2846098469u,
+2728930632u,
+346814072u,
+848146907u,
+551160669u,
+4165126521u,
+2039095001u,
+4179859388u,
+2434936359u,
+2764414551u,
+238491210u,
+732483969u,
+3366512764u,
+478307468u,
+4124179572u,
+4142733597u,
+1953448206u,
+4199329278u,
+865077060u,
+2627662116u,
+2802499360u,
+3141206831u,
+1959218197u,
+911371451u,
+125987200u,
+2821366175u,
+2530992747u,
+2409206225u,
+117991880u,
+2133402461u,
+895510531u,
+428719601u,
+3036014536u,
+1223783733u,
+733793540u,
+970650405u,
+547701766u,
+570764615u,
+3224485368u,
+3192714940u,
+319942831u,
+3940200341u,
+362056204u,
+2832368105u,
+1853281226u,
+3296434636u,
+3752508307u,
+604292768u,
+2231940616u,
+1204094681u,
+866194005u,
+2405201650u,
+2466384396u,
+380829379u,
+230033818u,
+2783417588u,
+4249886729u,
+829569301u,
+2988322580u,
+2299983554u,
+74748560u,
+737514425u,
+3153050211u,
+652642663u,
+1270205115u,
+227197032u,
+2773091790u,
+325849216u,
+49998791u,
+4043203010u,
+3662748068u,
+1709364383u,
+1179105165u,
+1478504366u,
+2980456610u,
+1167476429u,
+1590390732u,
+1306256496u,
+292008135u,
+374690995u,
+1809200819u,
+1680595904u,
+646040226u,
+1742445560u,
+2435776844u,
+3703683804u,
+478742495u,
+814967947u,
+2698190177u,
+1003617993u,
+1436118705u,
+217056304u,
+1412287094u,
+2738417466u,
+2933279339u,
+3461877733u,
+1203141205u,
+2119492857u,
+1134895723u,
+1560001021u,
+3786320122u,
+3748116258u,
+3486219595u,
+702138030u,
+1062984182u,
+232789133u,
+1566523968u,
+3885443778u,
+1820171888u,
+3655858585u,
+2316903005u,
+2678779620u,
+395625433u,
+1609107564u,
+3108726411u,
+2937837224u,
+3911907151u,
+557272509u,
+3893435978u,
+1542613576u,
+1079886893u,
+2624566322u,
+1413700616u,
+2796974006u,
+1922556114u,
+562820464u,
+2845409784u,
+54180312u,
+1898782464u,
+3681814953u,
+2417064617u,
+1815464483u,
+911626132u,
+2964575550u,
+1852696128u,
+2319647785u,
+1998904590u,
+619992689u,
+3073207513u,
+1238163512u,
+3199435982u,
+828667254u,
+3561155502u,
+3943095163u,
+1045711849u,
+2238679131u,
+2114975398u,
+713808403u,
+3871787494u,
+2572031161u,
+2360934075u,
+2337781107u,
+262596504u,
+693836699u,
+2129369850u,
+3543189427u,
+962205222u,
+3685581020u,
+692974477u,
+725182211u,
+646123906u,
+2368836544u,
+2505872733u,
+1999977610u,
+1639885802u,
+1475058032u,
+207023609u,
+2773581234u,
+3524857793u,
+3433371102u,
+3243027613u,
+1787668353u,
+985757946u,
+3896012929u,
+702356957u,
+3559331129u,
+884084870u,
+4009998120u,
+648888720u,
+1403349048u,
+1624342778u,
+1766674171u,
+2518582204u,
+3251243146u,
+792751003u,
+1377201813u,
+3629686054u,
+1583734324u,
+3647107626u,
+4258564381u,
+1469878609u,
+1940598241u,
+2755003690u,
+1907120418u,
+109916701u,
+775347954u,
+2090960874u,
+611281803u,
+3470490146u,
+3301663253u,
+1835412158u,
+1803066146u,
+591872433u,
+550703713u,
+1495089683u,
+826492808u,
+817200035u,
+4177474571u,
+688070143u,
+971427632u,
+1442499481u,
+3568640348u,
+2789993738u,
+85808128u,
+2058346726u,
+394058570u,
+3466511434u,
+318905230u,
+4149248030u,
+415308316u,
+165997598u,
+1219639412u,
+1648022659u,
+2857432523u,
+1422508004u,
+468095522u,
+296968649u,
+430250611u,
+1775562314u,
+2976361671u,
+1040036362u,
+1372510167u,
+292746272u,
+3408238954u,
+626061886u,
+1317637569u,
+1237775792u,
+1218490455u,
+2224234499u,
+590942419u,
+713995643u,
+3541889330u,
+4140218960u,
+3529791107u,
+354462673u,
+842607274u,
+365048533u,
+2638303414u,
+3560458014u,
+31621379u,
+4210854794u,
+1273118792u,
+2572743762u,
+3513175801u,
+402066986u,
+602524471u,
+565029192u,
+180576438u,
+1288605959u,
+2896244423u,
+1420543484u,
+1329862227u,
+1791567324u,
+4248690247u,
+12917038u,
+3483481310u,
+2082050731u,
+1611921143u,
+2443766548u,
+2216338811u,
+2528006095u,
+2984009021u,
+674210884u,
+2857608106u,
+2155534809u,
+1023105067u,
+2968955846u,
+3303624302u,
+2502112850u,
+245749006u,
+3175229091u,
+3342796184u,
+3613785362u,
+1614168851u,
+2582149283u,
+895403488u,
+416205023u,
+3792242000u,
+529397534u,
+299415203u,
+4284673348u,
+2096851282u,
+1864524731u,
+2012577738u,
+3426363316u,
+1387308508u,
+1143610148u,
+2027467219u,
+3772856163u,
+3453862623u,
+2661437174u,
+2047145955u,
+2533381447u,
+2059534115u,
+439426587u,
+1537543414u,
+2384289877u,
+3174229055u,
+2658017753u,
+2293148474u,
+2359450158u,
+3930242475u,
+1510302397u,
+3354288821u,
+920095603u,
+2415746928u,
+2729472638u,
+2261143371u,
+848667611u,
+919157153u,
+3322393117u,
+4103299943u,
+413569608u,
+68911216u,
+3334990170u,
+1228068652u,
+1570056373u,
+1905477543u,
+2622302276u,
+2935063895u,
+3224810004u,
+4211768578u,
+828688131u,
+3556122839u,
+1930935348u,
+2605825202u,
+1540993970u,
+3209115883u,
+122847500u,
+665638794u,
+506571051u,
+2691795295u,
+3996966556u,
+714660621u,
+3662432239u,
+470651837u,
+1807432621u,
+3755290953u,
+359878860u,
+2793081615u,
+4065031431u,
+904653062u,
+2317800777u,
+568501094u,
+3492871707u,
+2738806116u,
+2883859610u,
+3242080257u,
+364246691u,
+3601786516u,
+3159362524u,
+1578272201u,
+1283574375u,
+2912186103u,
+2256279032u,
+1540671086u,
+2356088973u,
+2892277779u,
+3441449267u,
+2225005503u,
+3846428419u,
+2014549218u,
+2290734767u,
+2126684614u,
+4235463487u,
+3811556204u,
+174739661u,
+767525888u,
+47684458u,
+4211168099u,
+889063422u,
+469864411u,
+767407110u,
+413337343u,
+1618456644u,
+2814499820u,
+2401124192u,
+632089437u,
+1234980238u,
+1288585402u,
+3153169944u,
+2917822069u,
+1843320264u,
+3794359132u,
+3074573530u,
+258629454u,
+3813357060u,
+3806887248u,
+1665524736u,
+3324533324u,
+3005091922u,
+793108368u,
+1529669805u,
+2332660395u,
+2217730223u,
+2634687611u,
+442806463u,
+1968135266u,
+454523002u,
+3177866230u,
+2808960136u,
+4259114138u,
+4103264843u,
+3103714075u,
+2462967542u,
+1466891491u,
+477973764u,
+834565647u,
+741089037u,
+218837573u,
+1710536528u,
+2469088212u,
+1229072375u,
+2828341u,
+176923431u,
+985763350u,
+4095477420u,
+1984145538u,
+1870791084u,
+674956677u,
+1978138947u,
+1296493993u,
+1818183554u,
+3443333721u,
+2124949983u,
+2549590262u,
+2700850794u,
+2662736367u,
+739638109u,
+4061447096u,
+2960078422u,
+2453781158u,
+929570940u,
+3200328383u,
+2406328791u,
+1419180666u,
+2152455739u,
+2805741044u,
+3305999074u,
+3183816361u,
+2303165050u,
+4922104u,
+63096005u,
+936656347u,
+3104453886u,
+1088673880u,
+1113407526u,
+1457890086u,
+453478383u,
+1107686695u,
+3626027824u,
+1159687359u,
+2248467888u,
+2004578380u,
+3274954621u,
+1787958646u,
+2628726704u,
+1138419798u,
+3735442315u,
+692385301u,
+313807213u,
+2329068673u,
+59375364u,
+3261084359u,
+2088644507u,
+2471153194u,
+788336435u,
+4024527246u,
+141504460u,
+2307553888u,
+1930559950u,
+48975711u,
+2745693338u,
+230161982u,
+3429230862u,
+1335968626u,
+609591304u,
+57435073u,
+4279281136u,
+3152151665u,
+3984484924u,
+3459883943u,
+397478330u,
+1738762229u,
+3033590066u,
+3611539498u,
+1363463523u,
+3319364965u,
+2671169141u,
+3819548561u,
+1691193757u,
+2423834608u,
+2820147055u,
+1378120632u,
+1240565187u,
+3180720050u,
+680831086u,
+3309658414u,
+1986166490u,
+762099827u,
+510883662u,
+2047373648u,
+3606742294u,
+3894965352u,
+2342078853u,
+1091255717u,
+776594727u,
+3217317445u,
+1574468485u,
+3844504016u,
+2819598918u,
+1037401010u,
+2550943503u,
+3867184001u,
+1687911772u,
+165313836u,
+1679575281u,
+2418947263u,
+2038774952u,
+3913543652u,
+3209155736u,
+149905221u,
+3859604717u,
+713919631u,
+4069810796u,
+1882959164u,
+1019939034u,
+2379867302u,
+3666323035u,
+1157389013u,
+2422300650u,
+3366777340u,
+2526452062u,
+1313747885u,
+1039617868u,
+1620553692u,
+2032976978u,
+578789528u,
+1592846839u,
+2270630604u,
+897850577u,
+1603294178u,
+3105664807u,
+1442670138u,
+1728019360u,
+79313861u,
+1683031101u,
+1913067024u,
+4070719870u,
+708986470u,
+2586453359u,
+3993348863u,
+3358251279u,
+3003552537u,
+750174793u,
+836888956u,
+4190747426u,
+4251291318u,
+4145164938u,
+1366883260u,
+1912910955u,
+510192669u,
+1851315039u,
+3574241274u,
+3220062924u,
+2821142039u,
+1317082195u,
+2274293302u,
+1839219569u,
+126586168u,
+3989293643u,
+2680178207u,
+347056948u,
+799681430u,
+2864517481u,
+3180404853u,
+213140045u,
+1956305184u,
+1474675286u,
+3085723423u,
+2841859626u,
+308421914u,
+3670309263u,
+1765052231u,
+245459238u,
+113434331u,
+4079521092u,
+2115235526u,
+2943408816u,
+1055476938u,
+1506442339u,
+2291296392u,
+3267864332u,
+1282145528u,
+3700108015u,
+1932843667u,
+2677701670u,
+6041177u,
+3889648557u,
+1461025478u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; IsAlive(farmhashsu::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashsu::Hash32(data, len++)); IsAlive(farmhashsu::Hash32(data, len++)); len -= 3; return alive > 0; }
+Check(farmhashsu::Hash32WithSeed(data + offset, len, SEED));
+Check(farmhashsu::Hash32(data + offset, len));
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashsuTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+cout << farmhashsu::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
+cout << farmhashsu::Hash32(data + offset, len) << "u," << endl;
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashsuTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashsuTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashsuTest::Dump(0, i);
+ }
+ farmhashsuTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashteTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+1140953930u, 861465670u,
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+890626835u, 800175912u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+3283896453u, 1867689945u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+1110588164u, 4186314283u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+283198166u, 2741341286u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+452473466u, 1706958772u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+236935126u, 2976578695u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+2305012065u, 2169731866u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+3058973506u, 2379411653u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+147814787u, 720739346u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+3425469811u, 3690733394u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+1635026870u, 192883107u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+3969463346u, 1436364519u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+2859809759u, 3808705738u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+4023053163u, 2650381482u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+3476440786u, 3829307897u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+2902102606u, 3600725550u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1448662590u, 397635823u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+180854224u, 2604346966u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+1669465176u, 1341975128u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+1043692997u, 1454396064u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+703505868u, 678706990u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+1933894405u, 3043213226u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+3828089804u, 3632594520u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+3729087873u, 1303930448u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3103338579u, 3064290191u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2295806711u, 1781190011u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+1968445277u, 315203929u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+440398219u, 1891630171u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+4204318635u, 441430649u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+3010839769u, 2837339569u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+4139181436u, 2993479124u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+667183474u, 2084369203u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+1016656857u, 3022024459u,
+3254014218u, 429095991u,
+990500595u, 3056862311u,
+985653208u, 1718653828u,
+623071693u, 366414107u,
+1771289760u, 2293458109u,
+3047342438u, 2991127487u,
+3120876698u, 1684583131u,
+3638043310u, 1170404994u,
+863214540u, 1087193030u,
+199124911u, 520792961u,
+3169775996u, 1577421232u,
+3331828431u, 1013201099u,
+1716848157u, 4033596884u,
+1770708857u, 4229339322u,
+1146169032u, 1434258493u,
+3824360466u, 3242407770u,
+1926419493u, 2649785113u,
+872586426u, 762243036u,
+2736953692u, 816692935u,
+1571283333u, 3555213933u,
+2266795890u, 3781899767u,
+4290630595u, 517646945u,
+3006163611u, 2180594090u,
+959214578u, 558910384u,
+1283799121u, 3047062993u,
+3830962609u, 2391606125u,
+3544509313u, 622325861u,
+834785312u, 382936554u,
+1421463872u, 788479970u,
+1825135056u, 2725923798u,
+580988377u, 2826990641u,
+247825043u, 3167748333u,
+812546227u, 2506885666u,
+2584372201u, 1758123094u,
+1891789696u, 389974094u,
+345313518u, 2022370576u,
+3886113119u, 3338548567u,
+1083486947u, 2583576230u,
+1776047957u, 1771384107u,
+3604937815u, 3198590202u,
+3027522813u, 4155628142u,
+4232136669u, 427759438u,
+4244322689u, 542201663u,
+1549591985u, 2856634168u,
+556609672u, 45845311u,
+1175961330u, 3948351189u,
+4165739882u, 4194218315u,
+1634635545u, 4151937410u,
+713127376u, 1467786451u,
+1327394015u, 2743592929u,
+2638154051u, 810082938u,
+3077742128u, 1062268187u,
+4084325664u, 3810665822u,
+3735739145u, 2794294783u,
+2335576331u, 2560479831u,
+690240711u, 997658837u,
+2442302747u, 3948961926u,
+3958366652u, 3067277639u,
+2059157774u, 1211737169u,
+1516711748u, 2339636583u,
+4188504038u, 59581167u,
+2767897792u, 1389679610u,
+2658147000u, 2643979752u,
+3758739543u, 4189944477u,
+1454470782u, 100876854u,
+2995362413u, 118817200u,
+3252925478u, 2062343506u,
+2804483644u, 3088828656u,
+1231633714u, 4168280671u,
+2931588131u, 3284356565u,
+1255909792u, 3130054947u,
+4173605289u, 1407328702u,
+1677744031u, 3532596884u,
+3162657845u, 3887208531u,
+2256541290u, 3459463480u,
+3740979556u, 259034107u,
+392987633u, 3233195759u,
+3606709555u, 3424793077u,
+315836068u, 3200749877u,
+4065431359u, 760633989u,
+2982018998u, 1811050648u,
+234531934u, 1115203611u,
+3897494162u, 1516407838u,
+1603559457u, 323296368u,
+2632963283u, 1778459926u,
+2879836826u, 2146672889u,
+3486330348u, 492621815u,
+1231665285u, 2457048126u,
+3438440082u, 2217471853u,
+3355404249u, 3275550588u,
+1052645068u, 862072556u,
+4110617119u, 3745267835u,
+2657392572u, 4279236653u,
+1688445808u, 701920051u,
+956734128u, 581695350u,
+3157862788u, 2585726058u,
+1192588249u, 1410111809u,
+1651193125u, 3326135446u,
+1073280453u, 97376972u,
+2513844237u, 2187968410u,
+3976859649u, 4267859263u,
+3429034542u, 564493077u,
+3000537321u, 479241367u,
+3845637831u, 2868987960u,
+51544337u, 1029173765u,
+393624922u, 704325635u,
+2357610553u, 1418509533u,
+2007814586u, 3866658271u,
+3082385053u, 735688735u,
+916110004u, 3283299459u,
+1051684175u, 1083796807u,
+4074716319u, 813690332u,
+144264390u, 1439630796u,
+1508556987u, 675582689u,
+3748881891u, 3195309868u,
+362884708u, 1616408198u,
+43233176u, 837301135u,
+881504822u, 3254795114u,
+1385506591u, 2799925823u,
+1469874582u, 3464841997u,
+497175391u, 3929484338u,
+3975771289u, 1798536177u,
+2926265846u, 1374242438u,
+3675707838u, 4205965408u,
+3153165629u, 1499475160u,
+187287713u, 548490821u,
+3255259608u, 4247675634u,
+1940181471u, 3779953975u,
+687167150u, 2319566715u,
+1742785722u, 785893184u,
+2296977392u, 2778575413u,
+1794720651u, 48131484u,
+4084891412u, 1160134629u,
+3737623280u, 823113169u,
+3423207646u, 3803213486u,
+710625654u, 4116162021u,
+3693420287u, 4167766971u,
+1666602807u, 295320990u,
+3513255468u, 2487440590u,
+234080704u, 4004655503u,
+2971762528u, 1479656873u,
+4090178629u, 4044418876u,
+391947536u, 1462554406u,
+3909295855u, 1239580330u,
+1515601363u, 2011102035u,
+1442068334u, 4265993528u,
+1191921695u, 2291355695u,
+4257172787u, 576405853u,
+314332944u, 4038839101u,
+55559918u, 2378985842u,
+711098718u, 2425317635u,
+1644327317u, 1401013391u,
+4193760037u, 2958260436u,
+3167371443u, 3062418115u,
+3800755475u, 3167030094u,
+3489648204u, 1405430357u,
+526177822u, 2602636307u,
+915406019u, 4264167741u,
+1484090483u, 3070944737u,
+254529415u, 4017058800u,
+1702710265u, 1029665228u,
+2000382906u, 3185573940u,
+1381258384u, 4036354071u,
+2900841028u, 2670703363u,
+2921748807u, 2899069938u,
+4130543625u, 688472265u,
+4186808827u, 1054670286u,
+1132985391u, 2840525968u,
+4175776103u, 338058159u,
+1735964501u, 1539305024u,
+3497121710u, 1568260669u,
+2227290760u, 146827036u,
+3977176001u, 4060134777u,
+857488494u, 250055052u,
+4284109679u, 2502815838u,
+2592281721u, 1603444633u,
+1390562014u, 1556658131u,
+616327404u, 2448966429u,
+3051191726u, 3891353218u,
+1213304082u, 762328245u,
+2239052397u, 1082330589u,
+2455957292u, 201837927u,
+405397452u, 3079886794u,
+2583939798u, 2848283092u,
+3750724631u, 883849006u,
+3204198988u, 3341327098u,
+1855234968u, 1982110346u,
+1485529487u, 541496720u,
+4117290321u, 3607433551u,
+2168864636u, 133643215u,
+1055817409u, 3847827123u,
+2960769387u, 4046101649u,
+1176127003u, 4015671361u,
+4243643405u, 2849988118u,
+517111221u, 1796672358u,
+2045051700u, 3452457457u,
+2948254999u, 2102063419u,
+1556410577u, 1536380876u,
+3776661467u, 3281002516u,
+1735616066u, 1539151988u,
+1087795162u, 3332431596u,
+685631442u, 1147951686u,
+95237878u, 2005032160u,
+4012206915u, 4224354805u,
+3204999386u, 2415262714u,
+1433635018u, 116647396u,
+83167836u, 2881562655u,
+2729416454u, 1029284767u,
+881378302u, 2159170082u,
+555057366u, 1169104445u,
+3963877000u, 1919171906u,
+336034862u, 2017579106u,
+4059340529u, 3020819343u,
+865146997u, 2473524405u,
+944743644u, 1694443528u,
+1804513294u, 2904752429u,
+617975720u, 3671562289u,
+260177668u, 505662155u,
+1885941445u, 2504509403u,
+2260041112u, 1019936943u,
+3722741628u, 1511077569u,
+3100701179u, 1379422864u,
+1535670711u, 773792826u,
+1103819072u, 2089123665u,
+1157547425u, 329152940u,
+4142587430u, 484732447u,
+2475035432u, 1120017626u,
+412145504u, 965125959u,
+324924679u, 2809286837u,
+2842141483u, 4029205195u,
+2974306813u, 515627448u,
+3791551981u, 1097806406u,
+3873078673u, 136118734u,
+1872130856u, 3632422367u,
+3574135531u, 4017075736u,
+1699452298u, 1403506686u,
+344414660u, 1189129691u,
+3487080616u, 1516736273u,
+1805475756u, 2562064338u,
+163335594u, 2732147834u,
+4077452507u, 2984955003u,
+4271866024u, 3071338162u,
+2347111903u, 873829983u,
+1948409509u, 1923531348u,
+459509140u, 771592405u,
+1750124750u, 2334938333u,
+213811117u, 2586632018u,
+185232757u, 4032960199u,
+2447383637u, 284777551u,
+1654276320u, 2687561076u,
+3512945009u, 308584855u,
+1861027147u, 4102279334u,
+3203802620u, 1692079268u,
+4250142168u, 2565680167u,
+1507046104u, 841195925u,
+520565830u, 3674576684u,
+38924274u, 3770488806u,
+2414430882u, 3978473838u,
+3703994407u, 69201295u,
+3099963860u, 1255084262u,
+690971838u, 3539996781u,
+3696902571u, 3593730713u,
+2363435042u, 54945052u,
+1785765213u, 184911581u,
+1586241476u, 1939595371u,
+2534883189u, 2432427547u,
+2374171993u, 2039128933u,
+2955715987u, 2295501078u,
+2741583197u, 1280920000u,
+686818699u, 1238742497u,
+3843660102u, 82177963u,
+1281043691u, 1121403845u,
+1697846708u, 284852964u,
+278661677u, 2889101923u,
+2127558730u, 713121337u,
+872502474u, 511142139u,
+1261140657u, 1747052377u,
+2108187161u, 927011680u,
+955328267u, 3821994995u,
+2707230761u, 4142246789u,
+4134691985u, 1958963937u,
+2498463509u, 1977988705u,
+1419293714u, 1636932722u,
+2567532373u, 4075249328u,
+240575705u, 1956681213u,
+2598802768u, 2025886508u,
+4104757832u, 3026358429u,
+3242615202u, 4026813725u,
+255108733u, 1845587644u,
+3573008472u, 3615577014u,
+1222733548u, 1205557630u,
+917608574u, 1363253259u,
+1541946015u, 3087190425u,
+1138008081u, 1444019663u,
+109793386u, 341851980u,
+857839960u, 2515339233u,
+156283211u, 1906768669u,
+3886713057u, 1276595523u,
+2809830736u, 460237542u,
+3420452099u, 142985419u,
+205970448u, 4198897105u,
+1950698961u, 2069753399u,
+1142216925u, 1113051162u,
+1033680610u, 4278599955u,
+1106466069u, 356742959u,
+531521052u, 3494863964u,
+225629455u, 3735275001u,
+3662626864u, 1750561299u,
+1012864651u, 2101846429u,
+1074553219u, 668829411u,
+992181339u, 3384018814u,
+3330664522u, 860966321u,
+1885071395u, 4233785523u,
+100741310u, 451656820u,
+2148187612u, 1063001151u,
+360256231u, 107312677u,
+3650357479u, 2390172694u,
+22452685u, 237319043u,
+3600462351u, 1216645846u,
+2088767754u, 164402616u,
+2418980170u, 926137824u,
+94638678u, 1689811113u,
+2751052984u, 1767810825u,
+271289013u, 3896132233u,
+103797041u, 1397772514u,
+3441135892u, 3323383489u,
+2491268371u, 1662561885u,
+1612872497u, 2986430557u,
+2756998822u, 207428029u,
+937973965u, 2791656726u,
+1949717207u, 2260498180u,
+2648427775u, 2360400900u,
+2080496169u, 486358863u,
+1582022990u, 1263709570u,
+1396468647u, 1377764574u,
+363008508u, 1293502429u,
+224580012u, 4252610345u,
+1435134775u, 1099809675u,
+533671980u, 1533438766u,
+1820532305u, 2776960536u,
+3374512975u, 3542220540u,
+822810075u, 3716663290u,
+1157398049u, 3752806924u,
+4081637863u, 337070226u,
+3866585976u, 359270190u,
+2110942730u, 3267551635u,
+644850146u, 1306761320u,
+746972907u, 934259457u,
+2341378668u, 2220373824u,
+1242645122u, 4109252858u,
+1625266099u, 1173698481u,
+383517064u, 896322512u,
+3377483696u, 1788337208u,
+455496839u, 3194373887u,
+1837689083u, 1336556841u,
+1658628529u, 2911512007u,
+3838343487u, 2757664765u,
+1537187340u, 3712582785u,
+367022558u, 3071359622u,
+3926147070u, 35432879u,
+3093195926u, 2561488770u,
+4273132307u, 3898950547u,
+2838251049u, 2103926083u,
+2549435227u, 536047554u,
+1858986613u, 2040551642u,
+1147412575u, 1972369852u,
+4166184983u, 3528794619u,
+4077477194u, 3565689036u,
+808048238u, 3826350461u,
+1359641525u, 1197100813u,
+265993036u, 1864569342u,
+725164342u, 2264788336u,
+1831223342u, 3329594980u,
+923017956u, 490608221u,
+3818634478u, 258154469u,
+1441714797u, 1174785921u,
+3833372385u, 3287246572u,
+1677395563u, 3569218731u,
+868981704u, 2163330264u,
+2649450292u, 500120236u,
+465161780u, 746438382u,
+1145009669u, 2520062970u,
+2810524030u, 1561519055u,
+1479878006u, 3864969305u,
+2686075657u, 4042710240u,
+3224066062u, 2774151984u,
+2226179547u, 1643626042u,
+2328730865u, 3160666939u,
+2107011431u, 96459446u,
+3920328742u, 3336407558u,
+829404209u, 1878067032u,
+1235983679u, 4237425634u,
+466519055u, 3870676863u,
+934312076u, 2952135524u,
+276949224u, 4100839753u,
+424001484u, 1955120893u,
+4015478120u, 1265237690u,
+427484362u, 4246879223u,
+3452969617u, 1724363362u,
+1553513184u, 834830418u,
+1858777639u, 3476334357u,
+4144030366u, 2450047160u,
+2950762705u, 4277111759u,
+358032121u, 2511026735u,
+167923105u, 2059208280u,
+251949572u, 3065234219u,
+1535473864u, 556796152u,
+1513237478u, 3150857516u,
+1103404394u, 198182691u,
+1476438092u, 2913077464u,
+207119516u, 3963810232u,
+2954651680u, 1535115487u,
+3051522276u, 4046477658u,
+917804636u, 864395565u,
+632704095u, 140762681u,
+1802040304u, 990407433u,
+3771506212u, 4106024923u,
+1287729497u, 2198985327u,
+4052924496u, 2926590471u,
+3084557148u, 1472898694u,
+1009870118u, 559702706u,
+4265214507u, 82077489u,
+3067891003u, 3295678907u,
+2402308151u, 1096697687u,
+464407878u, 4190838199u,
+4269578403u, 3060919438u,
+2899950405u, 3046872820u,
+733509243u, 1583801700u,
+40453902u, 3879773881u,
+1993425202u, 2185339100u,
+1877837196u, 3912423882u,
+3293122640u, 4104318469u,
+1679617763u, 3703603898u,
+8759461u, 2540185277u,
+1152198475u, 2038345882u,
+2503579743u, 1446869792u,
+2019419351u, 4051584612u,
+3178289407u, 3992503830u,
+2879018745u, 2719373510u,
+700836153u, 1675560450u,
+4121245793u, 2064715719u,
+343595772u, 1996164093u,
+3130433948u, 405251683u,
+2804817126u, 1607133689u,
+463852893u, 2864244470u,
+2224044848u, 4071581802u,
+2537107938u, 2246347953u,
+3207234525u, 2028708916u,
+2272418128u, 803575837u,
+38655481u, 2170452091u,
+3272166407u, 557660441u,
+4019147902u, 3841480082u,
+298459606u, 2600943364u,
+2440657523u, 255451671u,
+3424361375u, 779434428u,
+3088526123u, 490671625u,
+1322855877u, 3452203069u,
+3057021940u, 2285701422u,
+2014993457u, 2390431709u,
+2002090272u, 1568745354u,
+1783152480u, 823305654u,
+4053862835u, 2200236540u,
+3009412313u, 3184047862u,
+3032187389u, 4159715581u,
+2966902888u, 252986948u,
+1849329144u, 3160134214u,
+3420960112u, 3198900547u,
+749160960u, 379139040u,
+1208883495u, 1566527339u,
+3006227299u, 4194096960u,
+556075248u, 497404038u,
+1717327230u, 1496132623u,
+1775955687u, 1719108984u,
+1014328900u, 4189966956u,
+2108574735u, 2584236470u,
+684087286u, 531310503u,
+4264509527u, 773405691u,
+3088905079u, 3456882941u,
+3105682208u, 3382290593u,
+2289363624u, 3296306400u,
+4168438718u, 467441309u,
+777173623u, 3241407531u,
+1183994815u, 1132983260u,
+1610606159u, 2540270567u,
+2649684057u, 1397502982u,
+146657385u, 3318434267u,
+2109315753u, 3348545480u,
+3193669211u, 811750340u,
+1073256162u, 3571673088u,
+546596661u, 1017047954u,
+3403136990u, 2540585554u,
+1477047647u, 4145867423u,
+2826408201u, 3531646869u,
+784952939u, 943914610u,
+2717443875u, 3657384638u,
+1806867885u, 1903578924u,
+3985088434u, 1911188923u,
+1764002686u, 3672748083u,
+1832925325u, 241574049u,
+519948041u, 3181425568u,
+2939747257u, 1634174593u,
+3429894862u, 3529565564u,
+1089679033u, 240953857u,
+2025369941u, 2695166650u,
+517086873u, 2964595704u,
+3017658263u, 3828377737u,
+2144895011u, 994799311u,
+1184683823u, 4260564140u,
+308018483u, 4262383425u,
+1374752558u, 3431057723u,
+1572637805u, 383233885u,
+3188015819u, 4051263539u,
+233319221u, 3794788167u,
+2017406667u, 919677938u,
+4074952232u, 1683612329u,
+4213676186u, 327142514u,
+3032591014u, 4204155962u,
+206775997u, 2283918569u,
+2395147154u, 3427505379u,
+2211319468u, 4153726847u,
+2217060665u, 350160869u,
+2493667051u, 1648200185u,
+3441709766u, 1387233546u,
+140980u, 1891558063u,
+760080239u, 2088061981u,
+1580964938u, 740563169u,
+422986366u, 330624974u,
+4264507722u, 150928357u,
+2738323042u, 2948665536u,
+918718096u, 376390582u,
+3966098971u, 717653678u,
+3219466255u, 3799363969u,
+3424344721u, 3187805406u,
+375347278u, 3490350144u,
+1992212097u, 2263421398u,
+3855037968u, 1928519266u,
+3866327955u, 1129127000u,
+1782515131u, 2746577402u,
+3059200728u, 2108753646u,
+2738070963u, 1336849395u,
+1705302106u, 768287270u,
+1343511943u, 2247006571u,
+1956142255u, 1780259453u,
+3475618043u, 212490675u,
+622521957u, 917121602u,
+1852992332u, 1267987847u,
+3170016833u, 2549835613u,
+3299763344u, 2864033668u,
+3378768767u, 1236609378u,
+4169365948u, 3738062408u,
+2661022773u, 2006922227u,
+2760592161u, 3828932355u,
+2636387819u, 2616619070u,
+1237256330u, 3449066284u,
+2871755260u, 3729280948u,
+3862686086u, 431292293u,
+3285899651u, 786322314u,
+2531158535u, 724901242u,
+2377363130u, 1415970351u,
+1244759631u, 3263135197u,
+965248856u, 174024139u,
+2297418515u, 2954777083u,
+987586766u, 3206261120u,
+4059515114u, 3903854066u,
+1931934525u, 2287507921u,
+1827135136u, 1781944746u,
+574617451u, 2299034788u,
+2650140034u, 4081586725u,
+2482286699u, 1109175923u,
+458483596u, 618705848u,
+4059852729u, 1813855658u,
+4190721328u, 1129462471u,
+4089998050u, 3575732749u,
+2375584220u, 1037031473u,
+1623777358u, 3389003793u,
+546597541u, 352770237u,
+1383747654u, 3122687303u,
+1646071378u, 1164309901u,
+290870767u, 830691298u,
+929335420u, 3193251135u,
+989577914u, 3626554867u,
+591974737u, 3996958215u,
+3163711272u, 3071568023u,
+1516846461u, 3656006011u,
+2698625268u, 2510865430u,
+340274176u, 1167681812u,
+3698796465u, 3155218919u,
+4102288238u, 1673474350u,
+3069708839u, 2704165015u,
+1237411891u, 1854985978u,
+3646837503u, 3625406022u,
+921552000u, 1712976649u,
+3939149151u, 878608872u,
+3406359248u, 1068844551u,
+1834682077u, 4155949943u,
+2437686324u, 3163786257u,
+2645117577u, 1988168803u,
+747285578u, 1626463554u,
+1235300371u, 1256485167u,
+1914142538u, 4141546431u,
+3838102563u, 582664250u,
+1883344352u, 2083771672u,
+2611657933u, 2139079047u,
+2250573853u, 804336148u,
+3066325351u, 2770847216u,
+4275641370u, 1455750577u,
+3346357270u, 1674051445u,
+601221482u, 3992583643u,
+1402445097u, 3622527604u,
+2509017299u, 2966108111u,
+2557027816u, 900741486u,
+1790771021u, 2912643797u,
+2631381069u, 4014551783u,
+90375300u, 300318232u,
+3269968032u, 2679371729u,
+2664752123u, 3517585534u,
+3253901179u, 542270815u,
+1188641600u, 365479232u,
+2210121140u, 760762191u,
+1273768482u, 1216399252u,
+3484324231u, 4287337666u,
+16322182u, 643179562u,
+325675502u, 3652676161u,
+3120716054u, 3330259752u,
+1011990087u, 2990167340u,
+1097584090u, 3262252593u,
+1829409951u, 3665087267u,
+1214854475u, 2134299399u,
+3704419305u, 411263051u,
+1625446136u, 549838529u,
+4283196353u, 1342880802u,
+3460621305u, 1967599860u,
+4282843369u, 1275671016u,
+2544665755u, 853593042u,
+901109753u, 2682611693u,
+110631633u, 797487791u,
+1472073141u, 850464484u,
+797089608u, 3286110054u,
+350397471u, 2775631060u,
+366448238u, 3842907484u,
+2219863904u, 3623364733u,
+1850985302u, 4009616991u,
+294963924u, 3693536939u,
+3061255808u, 1615375832u,
+1920066675u, 4113028420u,
+4032223840u, 2318423400u,
+2701956286u, 4145497671u,
+3991532344u, 2536338351u,
+1679099863u, 1728968857u,
+449740816u, 2686506989u,
+685242457u, 97590863u,
+3258354115u, 1502282913u,
+1235084019u, 2151665147u,
+528459289u, 231097464u,
+2477280726u, 3651607391u,
+2091754612u, 1178454681u,
+980597335u, 1604483865u,
+1842333726u, 4146839064u,
+3213794286u, 2601416506u,
+754220096u, 3571436033u,
+488595746u, 1448097974u,
+4004834921u, 238887261u,
+3320337489u, 1416989070u,
+2928916831u, 4093725287u,
+186020771u, 2367569534u,
+3046087671u, 4090084518u,
+3548184546u, 679517009u,
+1962659444u, 3539886328u,
+4192003933u, 1678423485u,
+3827951761u, 3086277222u,
+2144472852u, 1390394371u,
+2976322029u, 1574517163u,
+3553313841u, 119173722u,
+1702434637u, 1766260771u,
+3629581771u, 1407497759u,
+895654784u, 751439914u,
+4008409498u, 215917713u,
+1482103833u, 695551833u,
+1288382231u, 2656990891u,
+2581779077u, 1570750352u,
+3710689053u, 1741390464u,
+2666411616u, 3533987737u,
+4289478316u, 3576119563u,
+4118694920u, 108199666u,
+3869794273u, 963183826u,
+2081410737u, 3796810515u,
+791123882u, 2525792704u,
+1036883117u, 136547246u,
+875691100u, 2592925324u,
+614302599u, 3013176417u,
+2689342539u, 427154472u,
+532957601u, 1228758574u,
+1898117151u, 1181643858u,
+1908591042u, 1464255968u,
+446980910u, 2984611177u,
+58509511u, 1046943619u,
+3508927906u, 2001585786u,
+2544767379u, 1525438381u,
+552181222u, 1959725830u,
+879448844u, 1348536411u,
+4242243590u, 2861338018u,
+1082052441u, 1034351453u,
+601175800u, 764077711u,
+530635011u, 3785343245u,
+2178026726u, 117256687u,
+2378297261u, 457568934u,
+76438221u, 4104954272u,
+956793873u, 3783168634u,
+2485968477u, 2381948487u,
+4226929450u, 3148473363u,
+2518273601u, 3569490233u,
+879369091u, 2180270337u,
+3674375989u, 1387729170u,
+977997984u, 4270646856u,
+568650985u, 951677556u,
+4213877384u, 2721005055u,
+1073364549u, 2563403831u,
+1678669911u, 66786703u,
+2273631661u, 1149351924u,
+3651298990u, 1581883443u,
+246723096u, 1895026827u,
+3810605772u, 3711056516u,
+4058833288u, 2193790614u,
+2080120290u, 3638638708u,
+2915672708u, 2263003308u,
+2361934197u, 4136767460u,
+1976115991u, 3448840877u,
+2019238520u, 225333538u,
+874340815u, 2976159827u,
+1555273378u, 3797521928u,
+1942347150u, 3262952567u,
+435997738u, 340403353u,
+2817830907u, 2078619498u,
+749534111u, 1178073973u,
+894654712u, 3361226032u,
+841092198u, 3288261538u,
+1696412169u, 1496966875u,
+697501571u, 1059158875u,
+3739946319u, 2481012988u,
+568983526u, 114945840u,
+1559249010u, 2218244008u,
+2841706923u, 1632780103u,
+4020169654u, 2087949619u,
+2438736103u, 24032648u,
+833416317u, 3787017905u,
+2373238993u, 2575395164u,
+3434544481u, 3228481067u,
+2542976862u, 2971726178u,
+2880371864u, 3642087909u,
+2407477975u, 2239080836u,
+1043714217u, 3894199764u,
+2235879182u, 203853421u,
+2933669448u, 2504940536u,
+834683330u, 425935223u,
+3560796393u, 3565833278u,
+1668000829u, 3683399154u,
+3414330886u, 1748785729u,
+1023171602u, 580966986u,
+2531038985u, 3227325488u,
+2657385925u, 2124704694u,
+233442446u, 1107045577u,
+3407293834u, 552770757u,
+3899097693u, 1067532701u,
+115667924u, 1406028344u,
+1707768231u, 3724015962u,
+2419657149u, 18613994u,
+2532882091u, 3476683808u,
+1560838678u, 811220224u,
+895961699u, 3762914298u,
+1328752423u, 1844996900u,
+1420427894u, 1848067707u,
+1210281744u, 904215228u,
+4055325594u, 1118521573u,
+2496554183u, 2579259919u,
+3996647489u, 3657647605u,
+325254059u, 3136157065u,
+3951522674u, 4052925250u,
+3341068436u, 2287683323u,
+1313073005u, 126005630u,
+2505120084u, 1194725057u,
+853746559u, 3555092974u,
+2689238752u, 49515858u,
+1244776042u, 1069300695u,
+61073168u, 1010661841u,
+1269521335u, 1902040126u,
+990632502u, 2378708922u,
+3858321250u, 1400735275u,
+2974699176u, 2771676666u,
+170995186u, 2877798589u,
+545726212u, 2225229957u,
+1086473152u, 3454177594u,
+3859483262u, 1499729584u,
+2088002891u, 2883475137u,
+3222194252u, 4144472319u,
+2212229854u, 4146740722u,
+567988835u, 1051332394u,
+3932046135u, 542648229u,
+3017852446u, 1277887997u,
+162888005u, 1669710469u,
+1492500905u, 553041029u,
+1434876932u, 533989516u,
+3817492747u, 584127807u,
+4147115982u, 2993670925u,
+4020312558u, 710021255u,
+3509733475u, 3587959456u,
+2088550465u, 1745399498u,
+2952242967u, 1259815443u,
+869648362u, 1404723176u,
+3947542735u, 1334333531u,
+3873471582u, 229399758u,
+59634866u, 3239516985u,
+3844250972u, 1275954779u,
+492891666u, 1029533080u,
+1552951157u, 367320647u,
+699480890u, 3684418197u,
+3707014310u, 471105777u,
+1824587258u, 4030809053u,
+3489914436u, 484559105u,
+1235750398u, 1428453396u,
+4230459084u, 4255931645u,
+1848597055u, 4271715616u,
+331780381u, 482425775u,
+2435323270u, 3171911678u,
+3507210587u, 928543347u,
+4197807526u, 3680046204u,
+2766042024u, 2159512867u,
+179373257u, 313902234u,
+4024837592u, 294795361u,
+1622282562u, 647086234u,
+2825039429u, 577214736u,
+4043412446u, 2426981244u,
+1277736097u, 1130129573u,
+2601395338u, 995791646u,
+36668922u, 3344746679u,
+1521532225u, 1645086060u,
+2622763015u, 4122335794u,
+2936887705u, 494465807u,
+2580840343u, 1064648931u,
+1247887787u, 2752145076u,
+1277612417u, 1249660507u,
+2288678613u, 3312498873u,
+2459273912u, 4238535494u,
+3117488020u, 2571979978u,
+2680188909u, 1471227427u,
+1616494033u, 633688562u,
+2268653416u, 3268237290u,
+3021962815u, 1959779970u,
+3321382074u, 766642813u,
+204429780u, 1323319858u,
+3676032891u, 1380896111u,
+4030639049u, 3647601207u,
+1830028502u, 2830263774u,
+1375962216u, 1733961041u,
+939765180u, 521947915u,
+3903267364u, 497472767u,
+1619700946u, 189164145u,
+3115593885u, 486382294u,
+1262445920u, 4062496162u,
+2464795849u, 3770038872u,
+4032121374u, 3235740744u,
+3757765258u, 1777199847u,
+2167243108u, 1912506671u,
+4180515317u, 2276864677u,
+536034089u, 2384915026u,
+162938278u, 1588060152u,
+4018349945u, 2504457929u,
+841450426u, 2790120722u,
+2719983588u, 1471020554u,
+1390856732u, 3623212998u,
+2506944218u, 1035080801u,
+348812127u, 3026631806u,
+746483541u, 2342164722u,
+122104390u, 4074122771u,
+3986865419u, 1674890530u,
+3693306023u, 3011542850u,
+1294951725u, 899303190u,
+3577146915u, 3549160092u,
+1241677652u, 4290680005u,
+3193053279u, 2029187390u,
+3298063095u, 3943068002u,
+3946220635u, 2273781461u,
+889053698u, 1376304022u,
+1486839612u, 2127663659u,
+344127443u, 1646681121u,
+2780117810u, 2142045764u,
+2694572773u, 447810651u,
+2185527146u, 2366308558u,
+290335413u, 584901173u,
+2012370276u, 970504950u,
+3258236042u, 2008155560u,
+3945579565u, 614796295u,
+24452072u, 2695940969u,
+3983727134u, 3444688454u,
+1327044473u, 3545633451u,
+1875293322u, 1739318893u,
+1707527799u, 2683090634u,
+2848082386u, 2814622471u,
+4111401777u, 2774816580u,
+3849839194u, 437560100u,
+2238350150u, 2462124836u,
+665017710u, 512012738u,
+2945294779u, 3305170944u,
+819477765u, 59419271u,
+155125658u, 665292744u,
+444722813u, 3580039116u,
+2355675635u, 663735032u,
+3247800169u, 1579404983u,
+1985115003u, 3397891494u,
+358696453u, 1474896279u,
+516388613u, 710590371u,
+3490497111u, 2514565805u,
+2386143445u, 477509654u,
+412854590u, 3624609754u,
+3214388668u, 3516075816u,
+2731288520u, 1369482895u,
+4033204378u, 1314000850u,
+829769325u, 1935166880u,
+1608191643u, 2607067237u,
+423820371u, 3257747610u,
+1355298041u, 3776931214u,
+4105054901u, 2107080812u,
+1911521879u, 3183054185u,
+3910177801u, 675129307u,
+1209358971u, 4205727791u,
+1435726287u, 3333261712u,
+1400982708u, 1154611403u,
+1663501483u, 2837596667u,
+3164734053u, 2759854023u,
+4012043629u, 1963228038u,
+3981675284u, 2677557877u,
+520119591u, 505138315u,
+897271356u, 1803966773u,
+1016663294u, 616691903u,
+2254742522u, 4032705384u,
+2468470796u, 798395739u,
+3025169002u, 3570037122u,
+1461093710u, 3473799845u,
+3702624858u, 476400898u,
+1043039728u, 2304070437u,
+181576948u, 602972493u,
+3996616030u, 3289878097u,
+2068516226u, 3922247304u,
+1299968266u, 2520311409u,
+1968824721u, 3214794876u,
+1581813122u, 2668800905u,
+3297613974u, 748160407u,
+1145536484u, 1326769504u,
+2973323521u, 3775262814u,
+3218653169u, 902775872u,
+3498603433u, 1372805534u,
+704686363u, 3626542352u,
+2271580579u, 1213925114u,
+46329775u, 3009384989u,
+1330254048u, 1194824134u,
+514204310u, 3781981134u,
+442526164u, 2835608783u,
+3460471867u, 510634034u,
+546406434u, 2716786748u,
+2840500021u, 1669490957u,
+2536189149u, 3251421224u,
+1358736072u, 1089334066u,
+3260749330u, 250756920u,
+2974806681u, 1513718866u,
+82635635u, 4041016629u,
+3391765744u, 2495807367u,
+3962674316u, 2822889695u,
+753413337u, 2008251381u,
+3123390177u, 106212622u,
+490570565u, 1684884205u,
+793892547u, 1927268995u,
+2344148164u, 2251978818u,
+437424236u, 2774023200u,
+2674940754u, 3788056262u,
+2597882666u, 3678660147u,
+3797434193u, 3838215866u,
+279687080u, 2656772270u,
+2190204787u, 1997584981u,
+3384401882u, 3160208845u,
+3629379425u, 2668998785u,
+1050036757u, 2954162084u,
+917091826u, 1744374041u,
+1454282570u, 845687881u,
+2997173625u, 776018378u,
+1137560602u, 1938378389u,
+1748082354u, 2066910012u,
+2677675207u, 918315064u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; { uint64_t h = farmhashte::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
+{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint64_t h = farmhashte::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashteTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint64_t h = farmhashte::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashteTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashteTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashteTest::Dump(0, i);
+ }
+ farmhashteTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashuoTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+3254014218u, 429095991u,
+165589978u, 1578546616u,
+623071693u, 366414107u,
+249776086u, 1207522198u,
+3120876698u, 1684583131u,
+46987739u, 1157614300u,
+199124911u, 520792961u,
+3614377032u, 586863115u,
+1716848157u, 4033596884u,
+1164298657u, 4140791139u,
+3824360466u, 3242407770u,
+3725511003u, 232064808u,
+2736953692u, 816692935u,
+512845449u, 3748861010u,
+4290630595u, 517646945u,
+22638523u, 648000590u,
+1283799121u, 3047062993u,
+1024246061u, 4027776454u,
+834785312u, 382936554u,
+411505255u, 1973395102u,
+580988377u, 2826990641u,
+3474970689u, 1029055034u,
+2584372201u, 1758123094u,
+589567754u, 325737734u,
+3886113119u, 3338548567u,
+257578986u, 3698087965u,
+3604937815u, 3198590202u,
+2305332220u, 191910725u,
+4244322689u, 542201663u,
+3315355162u, 2135941665u,
+1175961330u, 3948351189u,
+23075771u, 3252374102u,
+713127376u, 1467786451u,
+663013031u, 3444053918u,
+3077742128u, 1062268187u,
+2115441882u, 4081398201u,
+2335576331u, 2560479831u,
+1379288194u, 4225182569u,
+3958366652u, 3067277639u,
+3667516477u, 1709989541u,
+4188504038u, 59581167u,
+2725013602u, 3639843023u,
+3758739543u, 4189944477u,
+2470483982u, 877580602u,
+3252925478u, 2062343506u,
+3981838403u, 3762572073u,
+2931588131u, 3284356565u,
+1129162571u, 732225574u,
+1677744031u, 3532596884u,
+3232041815u, 1652884780u,
+3740979556u, 259034107u,
+2227121257u, 1426140634u,
+315836068u, 3200749877u,
+1386256573u, 24035717u,
+234531934u, 1115203611u,
+1598686658u, 3146815575u,
+2632963283u, 1778459926u,
+739944537u, 579625482u,
+1231665285u, 2457048126u,
+3903349120u, 389846205u,
+1052645068u, 862072556u,
+2834153464u, 1481069623u,
+1688445808u, 701920051u,
+3740748788u, 3388062747u,
+1192588249u, 1410111809u,
+2633463887u, 4050419847u,
+2513844237u, 2187968410u,
+2951683019u, 3015806005u,
+3000537321u, 479241367u,
+252167538u, 1231057113u,
+393624922u, 704325635u,
+1467197045u, 2066433573u,
+3082385053u, 735688735u,
+956434529u, 4028590195u,
+4074716319u, 813690332u,
+2124740535u, 804073145u,
+3748881891u, 3195309868u,
+841856605u, 2585865274u,
+881504822u, 3254795114u,
+1241815736u, 970796142u,
+497175391u, 3929484338u,
+4264993211u, 1835322201u,
+3675707838u, 4205965408u,
+300298607u, 3858319990u,
+3255259608u, 4247675634u,
+1095823272u, 1197245408u,
+1742785722u, 785893184u,
+1702965674u, 850401405u,
+4084891412u, 1160134629u,
+2555998391u, 1972759056u,
+710625654u, 4116162021u,
+3352753742u, 85121177u,
+3513255468u, 2487440590u,
+2480032715u, 2287747045u,
+4090178629u, 4044418876u,
+1703944517u, 486290428u,
+1515601363u, 2011102035u,
+573985957u, 3536053779u,
+4257172787u, 576405853u,
+1523550693u, 1014952061u,
+711098718u, 2425317635u,
+3460807169u, 3688987163u,
+3167371443u, 3062418115u,
+3330028292u, 1713171303u,
+526177822u, 2602636307u,
+1245357025u, 3346699703u,
+254529415u, 4017058800u,
+1829738451u, 2164236533u,
+1381258384u, 4036354071u,
+1749181924u, 4118435443u,
+4130543625u, 688472265u,
+2731071299u, 2547657502u,
+4175776103u, 338058159u,
+3729582129u, 4181845558u,
+2227290760u, 146827036u,
+2459178427u, 1025353883u,
+4284109679u, 2502815838u,
+825124804u, 2533140036u,
+616327404u, 2448966429u,
+413992636u, 2334782461u,
+2239052397u, 1082330589u,
+3381164715u, 199381437u,
+2583939798u, 2848283092u,
+2300168091u, 2156336315u,
+1855234968u, 1982110346u,
+2482046810u, 3158163887u,
+2168864636u, 133643215u,
+3904021624u, 3646514568u,
+1176127003u, 4015671361u,
+100525019u, 3534706803u,
+2045051700u, 3452457457u,
+1492267772u, 2308393828u,
+3776661467u, 3281002516u,
+4246334524u, 743955039u,
+685631442u, 1147951686u,
+2040912376u, 2911148054u,
+3204999386u, 2415262714u,
+313209105u, 777065474u,
+2729416454u, 1029284767u,
+1632078298u, 1817552554u,
+3963877000u, 1919171906u,
+3843219958u, 3073580867u,
+865146997u, 2473524405u,
+2593817617u, 3643076308u,
+617975720u, 3671562289u,
+121812599u, 2902367378u,
+2260041112u, 1019936943u,
+320945955u, 2337845588u,
+1535670711u, 773792826u,
+3152195900u, 4090794518u,
+4142587430u, 484732447u,
+419191319u, 3377973345u,
+324924679u, 2809286837u,
+1562277603u, 1378362199u,
+3791551981u, 1097806406u,
+1386297408u, 2304900033u,
+3574135531u, 4017075736u,
+1161238398u, 1358056883u,
+3487080616u, 1516736273u,
+851615042u, 2927899494u,
+4077452507u, 2984955003u,
+3907754394u, 3578173844u,
+1948409509u, 1923531348u,
+3578472493u, 3710074193u,
+213811117u, 2586632018u,
+1922589216u, 274958014u,
+1654276320u, 2687561076u,
+2569061755u, 3122046057u,
+3203802620u, 1692079268u,
+477806878u, 140587742u,
+520565830u, 3674576684u,
+91246882u, 1010215946u,
+3703994407u, 69201295u,
+776213083u, 3677771507u,
+3696902571u, 3593730713u,
+2907901228u, 3239753796u,
+1586241476u, 1939595371u,
+2268396558u, 3468719670u,
+2955715987u, 2295501078u,
+2775848696u, 1358532390u,
+3843660102u, 82177963u,
+4094477877u, 191727221u,
+278661677u, 2889101923u,
+1352525614u, 2844977667u,
+1261140657u, 1747052377u,
+2334120653u, 645125282u,
+2707230761u, 4142246789u,
+1068639717u, 2288162940u,
+1419293714u, 1636932722u,
+3252686293u, 318543902u,
+2598802768u, 2025886508u,
+2250788464u, 2711763065u,
+255108733u, 1845587644u,
+3719270134u, 3940707863u,
+917608574u, 1363253259u,
+788659330u, 673256220u,
+109793386u, 341851980u,
+2698465479u, 3011229884u,
+3886713057u, 1276595523u,
+2439962760u, 2700515456u,
+205970448u, 4198897105u,
+875511891u, 371715572u,
+1033680610u, 4278599955u,
+3120038721u, 1256300069u,
+225629455u, 3735275001u,
+3961944123u, 1769389163u,
+1074553219u, 668829411u,
+1098679359u, 2573697509u,
+1885071395u, 4233785523u,
+2513878053u, 2030193788u,
+360256231u, 107312677u,
+310517502u, 2618936366u,
+3600462351u, 1216645846u,
+2970730323u, 4278812598u,
+94638678u, 1689811113u,
+4125738800u, 3103759730u,
+103797041u, 1397772514u,
+1669653333u, 572567964u,
+1612872497u, 2986430557u,
+214990655u, 3117607990u,
+1949717207u, 2260498180u,
+1493936866u, 3554860960u,
+1582022990u, 1263709570u,
+1244120487u, 3416600761u,
+224580012u, 4252610345u,
+286306391u, 814956796u,
+1820532305u, 2776960536u,
+3082703465u, 1659265982u,
+1157398049u, 3752806924u,
+3508246460u, 2902716664u,
+2110942730u, 3267551635u,
+902835431u, 405228165u,
+2341378668u, 2220373824u,
+3303626294u, 1175118221u,
+383517064u, 896322512u,
+1697257567u, 2202820683u,
+1837689083u, 1336556841u,
+914535232u, 3634083711u,
+1537187340u, 3712582785u,
+1088201893u, 3270984620u,
+3093195926u, 2561488770u,
+1962968100u, 236189500u,
+2549435227u, 536047554u,
+422609195u, 2958815818u,
+4166184983u, 3528794619u,
+1042329086u, 3914176886u,
+1359641525u, 1197100813u,
+1269739674u, 3301844628u,
+1831223342u, 3329594980u,
+2433669782u, 494908536u,
+1441714797u, 1174785921u,
+1933050423u, 958901065u,
+868981704u, 2163330264u,
+3243110680u, 1443133429u,
+1145009669u, 2520062970u,
+3851564853u, 2664619323u,
+2686075657u, 4042710240u,
+2125408249u, 4165697916u,
+2328730865u, 3160666939u,
+588683409u, 2126275847u,
+829404209u, 1878067032u,
+2567792910u, 897670516u,
+934312076u, 2952135524u,
+504832490u, 3312698056u,
+4015478120u, 1265237690u,
+3376133707u, 967674402u,
+1553513184u, 834830418u,
+2396504772u, 3278582098u,
+2950762705u, 4277111759u,
+4159211303u, 1290097509u,
+251949572u, 3065234219u,
+1832020534u, 312136369u,
+1103404394u, 198182691u,
+1369599600u, 3906710870u,
+2954651680u, 1535115487u,
+2389327507u, 1813520230u,
+632704095u, 140762681u,
+3123202913u, 3336005523u,
+1287729497u, 2198985327u,
+2470730783u, 3821758006u,
+1009870118u, 559702706u,
+4274686257u, 3187546567u,
+2402308151u, 1096697687u,
+678932329u, 3716363135u,
+2899950405u, 3046872820u,
+3754655641u, 2021741414u,
+1993425202u, 2185339100u,
+2838253700u, 3099212100u,
+1679617763u, 3703603898u,
+1135665833u, 3559875668u,
+2503579743u, 1446869792u,
+879818611u, 3788305533u,
+2879018745u, 2719373510u,
+3606051203u, 2166567748u,
+343595772u, 1996164093u,
+1577656121u, 475248376u,
+463852893u, 2864244470u,
+1332049663u, 3326459767u,
+3207234525u, 2028708916u,
+938916154u, 3115246264u,
+3272166407u, 557660441u,
+1265684026u, 245033807u,
+2440657523u, 255451671u,
+3811885130u, 1399880284u,
+1322855877u, 3452203069u,
+1324994449u, 3796404024u,
+2002090272u, 1568745354u,
+3700047753u, 31799506u,
+3009412313u, 3184047862u,
+728680761u, 3848624873u,
+1849329144u, 3160134214u,
+1272923193u, 1474278816u,
+1208883495u, 1566527339u,
+4136466541u, 630825649u,
+1717327230u, 1496132623u,
+2449386742u, 128106940u,
+2108574735u, 2584236470u,
+2872246579u, 397338552u,
+3088905079u, 3456882941u,
+1715915153u, 2940716269u,
+4168438718u, 467441309u,
+872996731u, 3206901319u,
+1610606159u, 2540270567u,
+1301658081u, 2379410194u,
+2109315753u, 3348545480u,
+2041927873u, 2644077493u,
+546596661u, 1017047954u,
+2596792972u, 2783958892u,
+2826408201u, 3531646869u,
+2219352672u, 4217451852u,
+1806867885u, 1903578924u,
+2076465705u, 2373061493u,
+1832925325u, 241574049u,
+1509517110u, 3703614272u,
+3429894862u, 3529565564u,
+4010000614u, 2256197939u,
+517086873u, 2964595704u,
+3501035294u, 4079457298u,
+1184683823u, 4260564140u,
+2339268412u, 3871564102u,
+1572637805u, 383233885u,
+3351411126u, 3419328182u,
+2017406667u, 919677938u,
+29804156u, 46276077u,
+3032591014u, 4204155962u,
+1172319502u, 969309871u,
+2211319468u, 4153726847u,
+3094193193u, 4240669441u,
+3441709766u, 1387233546u,
+4048882438u, 1217896566u,
+1580964938u, 740563169u,
+3691850348u, 3176426539u,
+2738323042u, 2948665536u,
+1474029445u, 3513354882u,
+3219466255u, 3799363969u,
+3961796122u, 1055550923u,
+1992212097u, 2263421398u,
+4289759174u, 2516844140u,
+1782515131u, 2746577402u,
+721928440u, 3529570984u,
+1705302106u, 768287270u,
+3474902815u, 4000011125u,
+3475618043u, 212490675u,
+549130471u, 2970128275u,
+3170016833u, 2549835613u,
+3691104824u, 2694324482u,
+4169365948u, 3738062408u,
+602930397u, 2148954730u,
+2636387819u, 2616619070u,
+301617872u, 374657036u,
+3862686086u, 431292293u,
+4225245165u, 1358580562u,
+2377363130u, 1415970351u,
+3885060756u, 1438379807u,
+2297418515u, 2954777083u,
+3970368221u, 1229801760u,
+1931934525u, 2287507921u,
+1713471510u, 2145608111u,
+2650140034u, 4081586725u,
+4196863572u, 1896558394u,
+4059852729u, 1813855658u,
+2618400836u, 1396056469u,
+2375584220u, 1037031473u,
+249284003u, 2450077637u,
+1383747654u, 3122687303u,
+2664431743u, 3855028730u,
+929335420u, 3193251135u,
+137313762u, 1850894384u,
+3163711272u, 3071568023u,
+418541677u, 3621223039u,
+340274176u, 1167681812u,
+4106647531u, 4022465625u,
+3069708839u, 2704165015u,
+2332023349u, 641449034u,
+921552000u, 1712976649u,
+1876484273u, 2343049860u,
+1834682077u, 4155949943u,
+2061821157u, 4240649383u,
+747285578u, 1626463554u,
+165503115u, 359629739u,
+3838102563u, 582664250u,
+3878924635u, 4117237498u,
+2250573853u, 804336148u,
+331393443u, 4242530387u,
+3346357270u, 1674051445u,
+3348019777u, 1722242971u,
+2509017299u, 2966108111u,
+4189102509u, 3323592310u,
+2631381069u, 4014551783u,
+4250787412u, 3448394212u,
+2664752123u, 3517585534u,
+3605365141u, 1669471183u,
+2210121140u, 760762191u,
+249697459u, 3416920106u,
+16322182u, 643179562u,
+1564226597u, 2134630675u,
+1011990087u, 2990167340u,
+2349550842u, 1642428946u,
+1214854475u, 2134299399u,
+2704221532u, 2104175211u,
+4283196353u, 1342880802u,
+198529755u, 2004468390u,
+2544665755u, 853593042u,
+2090611294u, 2970943872u,
+1472073141u, 850464484u,
+1407609278u, 3062461105u,
+366448238u, 3842907484u,
+488797416u, 1432670231u,
+294963924u, 3693536939u,
+3390549825u, 1583234720u,
+4032223840u, 2318423400u,
+2965642867u, 930822729u,
+1679099863u, 1728968857u,
+900822335u, 702309817u,
+3258354115u, 1502282913u,
+2811888503u, 3924947660u,
+2477280726u, 3651607391u,
+3788310204u, 1300369123u,
+1842333726u, 4146839064u,
+2468893861u, 4091095953u,
+488595746u, 1448097974u,
+1159634090u, 1738834113u,
+2928916831u, 4093725287u,
+530850094u, 291657799u,
+3548184546u, 679517009u,
+399175380u, 2658337143u,
+3827951761u, 3086277222u,
+2067718397u, 3632376023u,
+3553313841u, 119173722u,
+1702434637u, 1766260771u,
+895654784u, 751439914u,
+4008409498u, 215917713u,
+1288382231u, 2656990891u,
+2581779077u, 1570750352u,
+2666411616u, 3533987737u,
+4289478316u, 3576119563u,
+3869794273u, 963183826u,
+2081410737u, 3796810515u,
+1036883117u, 136547246u,
+875691100u, 2592925324u,
+2689342539u, 427154472u,
+532957601u, 1228758574u,
+1908591042u, 1464255968u,
+446980910u, 2984611177u,
+3508927906u, 2001585786u,
+2544767379u, 1525438381u,
+879448844u, 1348536411u,
+4242243590u, 2861338018u,
+601175800u, 764077711u,
+530635011u, 3785343245u,
+2378297261u, 457568934u,
+76438221u, 4104954272u,
+2485968477u, 2381948487u,
+4226929450u, 3148473363u,
+879369091u, 2180270337u,
+3674375989u, 1387729170u,
+568650985u, 951677556u,
+4213877384u, 2721005055u,
+1678669911u, 66786703u,
+2273631661u, 1149351924u,
+246723096u, 1895026827u,
+3810605772u, 3711056516u,
+2080120290u, 3638638708u,
+2915672708u, 2263003308u,
+1976115991u, 3448840877u,
+2019238520u, 225333538u,
+1555273378u, 3797521928u,
+1942347150u, 3262952567u,
+2817830907u, 2078619498u,
+749534111u, 1178073973u,
+841092198u, 3288261538u,
+1696412169u, 1496966875u,
+3739946319u, 2481012988u,
+568983526u, 114945840u,
+2841706923u, 1632780103u,
+4020169654u, 2087949619u,
+833416317u, 3787017905u,
+2373238993u, 2575395164u,
+2542976862u, 2971726178u,
+2880371864u, 3642087909u,
+1043714217u, 3894199764u,
+2235879182u, 203853421u,
+834683330u, 425935223u,
+3560796393u, 3565833278u,
+3414330886u, 1748785729u,
+1023171602u, 580966986u,
+2657385925u, 2124704694u,
+233442446u, 1107045577u,
+3899097693u, 1067532701u,
+115667924u, 1406028344u,
+2419657149u, 18613994u,
+2532882091u, 3476683808u,
+895961699u, 3762914298u,
+1328752423u, 1844996900u,
+1210281744u, 904215228u,
+4055325594u, 1118521573u,
+3996647489u, 3657647605u,
+325254059u, 3136157065u,
+3341068436u, 2287683323u,
+1313073005u, 126005630u,
+853746559u, 3555092974u,
+2689238752u, 49515858u,
+61073168u, 1010661841u,
+1269521335u, 1902040126u,
+3858321250u, 1400735275u,
+2974699176u, 2771676666u,
+545726212u, 2225229957u,
+1086473152u, 3454177594u,
+2088002891u, 2883475137u,
+3222194252u, 4144472319u,
+567988835u, 1051332394u,
+3932046135u, 542648229u,
+162888005u, 1669710469u,
+1492500905u, 553041029u,
+3817492747u, 584127807u,
+4147115982u, 2993670925u,
+3509733475u, 3587959456u,
+2088550465u, 1745399498u,
+869648362u, 1404723176u,
+3947542735u, 1334333531u,
+59634866u, 3239516985u,
+3844250972u, 1275954779u,
+2512155003u, 1685649437u,
+639306006u, 2524620206u,
+576786501u, 655707039u,
+2864351838u, 3736264674u,
+1200907897u, 2384379464u,
+15823708u, 206117476u,
+1193310960u, 1093099415u,
+3696538026u, 4112584792u,
+2069527017u, 547588820u,
+4178147211u, 2827259351u,
+940846775u, 1054995047u,
+2976960697u, 1934305529u,
+2199137382u, 1005722394u,
+1875867180u, 2064356511u,
+4019734130u, 3096333006u,
+2069509024u, 2906358341u,
+2232866485u, 1456016086u,
+1422674894u, 867282151u,
+1612503136u, 1739843072u,
+134947567u, 2978775774u,
+1284167756u, 1090844589u,
+831688783u, 2079216362u,
+1626991196u, 3644714163u,
+3678110059u, 898470030u,
+3916646913u, 3182422972u,
+3630426828u, 969847973u,
+3427164640u, 3463937250u,
+3044785046u, 897322257u,
+3443872170u, 4185408854u,
+2557463241u, 4080940424u,
+2048168570u, 2429169982u,
+3174690447u, 2513494106u,
+1213061732u, 3143736628u,
+3482268149u, 1250714337u,
+31648125u, 3872383625u,
+1565760579u, 36665130u,
+751041229u, 2257179590u,
+2915361862u, 280819225u,
+2907818413u, 4254297769u,
+3493178615u, 3755944354u,
+4043533423u, 1134196225u,
+4177134659u, 127246419u,
+2442615581u, 923049607u,
+1004426206u, 782768297u,
+2410586681u, 1430106871u,
+4103323427u, 3168399477u,
+3716682375u, 3616334719u,
+3413209549u, 656672786u,
+2876965944u, 182894450u,
+456581318u, 2683752067u,
+3877875910u, 3190666241u,
+3240336907u, 4024807233u,
+1681224377u, 1576191191u,
+3599250276u, 2381111980u,
+3495321877u, 3956024585u,
+1611608524u, 3815677453u,
+2062334396u, 1656117707u,
+5457134u, 3234118251u,
+470187419u, 2688566989u,
+3259870297u, 660100446u,
+442236198u, 2542452448u,
+493137955u, 392411099u,
+947967568u, 1234595917u,
+4230082284u, 2762976773u,
+2870085764u, 1455086530u,
+2762099647u, 4011882747u,
+1215981925u, 3227517889u,
+3269061963u, 4037515364u,
+3168911474u, 4255057396u,
+2026092260u, 1736192508u,
+3909727042u, 3114708966u,
+1938800693u, 680793595u,
+1525265867u, 2808224480u,
+2122290603u, 1211197714u,
+3520488321u, 3979192396u,
+3540779343u, 4192918639u,
+2736030448u, 1120335563u,
+1698949078u, 3993310631u,
+1966048551u, 2228221363u,
+597941119u, 3498018399u,
+393987327u, 454500547u,
+1222959566u, 567151340u,
+3774764786u, 1492844524u,
+3308300614u, 805568076u,
+868414882u, 177406999u,
+1608110313u, 642061169u,
+1027515771u, 3131251981u,
+2851936150u, 4272755262u,
+1532845092u, 709643652u,
+682573592u, 1244104217u,
+796769556u, 2500467040u,
+3002618826u, 1112998535u,
+1780193104u, 1243644607u,
+3691719535u, 2958853053u,
+466635014u, 2277292580u,
+4082276003u, 1030800045u,
+1750863246u, 379050598u,
+3576413281u, 731493104u,
+132259176u, 4115195437u,
+1769890695u, 2715470335u,
+1819263183u, 2028531518u,
+2154809766u, 3672399742u,
+76727603u, 4198182186u,
+2304993586u, 1666387627u,
+284366017u, 3359785538u,
+3469807328u, 2926494787u,
+3829072836u, 2493478921u,
+3738499303u, 3311304980u,
+932916545u, 2235559063u,
+2909742396u, 1765719309u,
+1456588655u, 508290328u,
+1490719640u, 3356513470u,
+2908490783u, 251085588u,
+830410677u, 3172220325u,
+3897208579u, 1940535730u,
+151909546u, 2384458112u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; { uint64_t h = farmhashuo::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
+{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint64_t h = farmhashuo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashuoTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint64_t h = farmhashuo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashuoTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashuoTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashuoTest::Dump(0, i);
+ }
+ farmhashuoTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
+static char data[kDataSize];
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
+// Initialize data to pseudorandom values.
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
+ memcpy(data + i, &u, 1); // uint8_t -> char
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashxoTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+1140953930u, 861465670u,
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+890626835u, 800175912u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+3283896453u, 1867689945u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+1110588164u, 4186314283u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+283198166u, 2741341286u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+452473466u, 1706958772u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+236935126u, 2976578695u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+2305012065u, 2169731866u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+3058973506u, 2379411653u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+147814787u, 720739346u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+3425469811u, 3690733394u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+1635026870u, 192883107u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+3969463346u, 1436364519u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+2859809759u, 3808705738u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+4023053163u, 2650381482u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+3476440786u, 3829307897u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+2902102606u, 3600725550u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1448662590u, 397635823u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+180854224u, 2604346966u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+1669465176u, 1341975128u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+1043692997u, 1454396064u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+703505868u, 678706990u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+1933894405u, 3043213226u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+3828089804u, 3632594520u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+3729087873u, 1303930448u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3103338579u, 3064290191u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2295806711u, 1781190011u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+1968445277u, 315203929u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+440398219u, 1891630171u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+4204318635u, 441430649u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+3010839769u, 2837339569u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+4139181436u, 2993479124u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+667183474u, 2084369203u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+1016656857u, 3022024459u,
+3254014218u, 429095991u,
+990500595u, 3056862311u,
+985653208u, 1718653828u,
+623071693u, 366414107u,
+1771289760u, 2293458109u,
+3047342438u, 2991127487u,
+3120876698u, 1684583131u,
+3638043310u, 1170404994u,
+863214540u, 1087193030u,
+199124911u, 520792961u,
+3169775996u, 1577421232u,
+3331828431u, 1013201099u,
+1716848157u, 4033596884u,
+1770708857u, 4229339322u,
+1146169032u, 1434258493u,
+3824360466u, 3242407770u,
+1926419493u, 2649785113u,
+872586426u, 762243036u,
+2736953692u, 816692935u,
+1571283333u, 3555213933u,
+2266795890u, 3781899767u,
+4290630595u, 517646945u,
+3006163611u, 2180594090u,
+959214578u, 558910384u,
+1283799121u, 3047062993u,
+3830962609u, 2391606125u,
+3544509313u, 622325861u,
+834785312u, 382936554u,
+1421463872u, 788479970u,
+1825135056u, 2725923798u,
+580988377u, 2826990641u,
+247825043u, 3167748333u,
+812546227u, 2506885666u,
+2584372201u, 1758123094u,
+1891789696u, 389974094u,
+345313518u, 2022370576u,
+3886113119u, 3338548567u,
+1083486947u, 2583576230u,
+1776047957u, 1771384107u,
+3604937815u, 3198590202u,
+3027522813u, 4155628142u,
+4232136669u, 427759438u,
+4244322689u, 542201663u,
+1549591985u, 2856634168u,
+556609672u, 45845311u,
+1175961330u, 3948351189u,
+4165739882u, 4194218315u,
+1634635545u, 4151937410u,
+713127376u, 1467786451u,
+1327394015u, 2743592929u,
+2638154051u, 810082938u,
+3077742128u, 1062268187u,
+4084325664u, 3810665822u,
+3735739145u, 2794294783u,
+2335576331u, 2560479831u,
+690240711u, 997658837u,
+2442302747u, 3948961926u,
+3958366652u, 3067277639u,
+2059157774u, 1211737169u,
+1516711748u, 2339636583u,
+4188504038u, 59581167u,
+2767897792u, 1389679610u,
+2658147000u, 2643979752u,
+3758739543u, 4189944477u,
+1454470782u, 100876854u,
+2995362413u, 118817200u,
+3252925478u, 2062343506u,
+2804483644u, 3088828656u,
+1231633714u, 4168280671u,
+2931588131u, 3284356565u,
+1255909792u, 3130054947u,
+4173605289u, 1407328702u,
+1677744031u, 3532596884u,
+3162657845u, 3887208531u,
+2256541290u, 3459463480u,
+3740979556u, 259034107u,
+392987633u, 3233195759u,
+3606709555u, 3424793077u,
+315836068u, 3200749877u,
+4065431359u, 760633989u,
+2982018998u, 1811050648u,
+234531934u, 1115203611u,
+3897494162u, 1516407838u,
+1603559457u, 323296368u,
+2632963283u, 1778459926u,
+2879836826u, 2146672889u,
+3486330348u, 492621815u,
+1231665285u, 2457048126u,
+3438440082u, 2217471853u,
+3355404249u, 3275550588u,
+1052645068u, 862072556u,
+4110617119u, 3745267835u,
+2657392572u, 4279236653u,
+1688445808u, 701920051u,
+956734128u, 581695350u,
+3157862788u, 2585726058u,
+1192588249u, 1410111809u,
+1651193125u, 3326135446u,
+1073280453u, 97376972u,
+2513844237u, 2187968410u,
+3976859649u, 4267859263u,
+3429034542u, 564493077u,
+3000537321u, 479241367u,
+3845637831u, 2868987960u,
+51544337u, 1029173765u,
+393624922u, 704325635u,
+2357610553u, 1418509533u,
+2007814586u, 3866658271u,
+3082385053u, 735688735u,
+916110004u, 3283299459u,
+1051684175u, 1083796807u,
+4074716319u, 813690332u,
+144264390u, 1439630796u,
+1508556987u, 675582689u,
+3748881891u, 3195309868u,
+362884708u, 1616408198u,
+43233176u, 837301135u,
+881504822u, 3254795114u,
+1385506591u, 2799925823u,
+1469874582u, 3464841997u,
+497175391u, 3929484338u,
+3975771289u, 1798536177u,
+2926265846u, 1374242438u,
+3675707838u, 4205965408u,
+3153165629u, 1499475160u,
+187287713u, 548490821u,
+3255259608u, 4247675634u,
+1940181471u, 3779953975u,
+687167150u, 2319566715u,
+1742785722u, 785893184u,
+2296977392u, 2778575413u,
+1794720651u, 48131484u,
+4084891412u, 1160134629u,
+3737623280u, 823113169u,
+3423207646u, 3803213486u,
+710625654u, 4116162021u,
+3693420287u, 4167766971u,
+1666602807u, 295320990u,
+3513255468u, 2487440590u,
+234080704u, 4004655503u,
+2971762528u, 1479656873u,
+4090178629u, 4044418876u,
+391947536u, 1462554406u,
+3909295855u, 1239580330u,
+1515601363u, 2011102035u,
+1442068334u, 4265993528u,
+1191921695u, 2291355695u,
+4257172787u, 576405853u,
+314332944u, 4038839101u,
+55559918u, 2378985842u,
+711098718u, 2425317635u,
+1644327317u, 1401013391u,
+4193760037u, 2958260436u,
+3167371443u, 3062418115u,
+3800755475u, 3167030094u,
+3489648204u, 1405430357u,
+526177822u, 2602636307u,
+915406019u, 4264167741u,
+1484090483u, 3070944737u,
+254529415u, 4017058800u,
+1702710265u, 1029665228u,
+2000382906u, 3185573940u,
+1381258384u, 4036354071u,
+2900841028u, 2670703363u,
+2921748807u, 2899069938u,
+4130543625u, 688472265u,
+4186808827u, 1054670286u,
+1132985391u, 2840525968u,
+4175776103u, 338058159u,
+1735964501u, 1539305024u,
+3497121710u, 1568260669u,
+2227290760u, 146827036u,
+3977176001u, 4060134777u,
+857488494u, 250055052u,
+4284109679u, 2502815838u,
+2592281721u, 1603444633u,
+1390562014u, 1556658131u,
+616327404u, 2448966429u,
+3051191726u, 3891353218u,
+1213304082u, 762328245u,
+2239052397u, 1082330589u,
+2455957292u, 201837927u,
+405397452u, 3079886794u,
+2583939798u, 2848283092u,
+3750724631u, 883849006u,
+3204198988u, 3341327098u,
+1855234968u, 1982110346u,
+1485529487u, 541496720u,
+4117290321u, 3607433551u,
+2168864636u, 133643215u,
+1055817409u, 3847827123u,
+2960769387u, 4046101649u,
+1176127003u, 4015671361u,
+4243643405u, 2849988118u,
+517111221u, 1796672358u,
+2045051700u, 3452457457u,
+2948254999u, 2102063419u,
+1556410577u, 1536380876u,
+3776661467u, 3281002516u,
+1735616066u, 1539151988u,
+1087795162u, 3332431596u,
+685631442u, 1147951686u,
+95237878u, 2005032160u,
+4012206915u, 4224354805u,
+3204999386u, 2415262714u,
+1433635018u, 116647396u,
+83167836u, 2881562655u,
+2729416454u, 1029284767u,
+881378302u, 2159170082u,
+555057366u, 1169104445u,
+3963877000u, 1919171906u,
+336034862u, 2017579106u,
+4059340529u, 3020819343u,
+865146997u, 2473524405u,
+944743644u, 1694443528u,
+1804513294u, 2904752429u,
+617975720u, 3671562289u,
+260177668u, 505662155u,
+1885941445u, 2504509403u,
+2260041112u, 1019936943u,
+3722741628u, 1511077569u,
+3100701179u, 1379422864u,
+1535670711u, 773792826u,
+1103819072u, 2089123665u,
+1157547425u, 329152940u,
+4142587430u, 484732447u,
+2475035432u, 1120017626u,
+412145504u, 965125959u,
+324924679u, 2809286837u,
+2842141483u, 4029205195u,
+2974306813u, 515627448u,
+3791551981u, 1097806406u,
+3873078673u, 136118734u,
+1872130856u, 3632422367u,
+3574135531u, 4017075736u,
+1699452298u, 1403506686u,
+344414660u, 1189129691u,
+3487080616u, 1516736273u,
+1805475756u, 2562064338u,
+163335594u, 2732147834u,
+4077452507u, 2984955003u,
+4271866024u, 3071338162u,
+2347111903u, 873829983u,
+1948409509u, 1923531348u,
+459509140u, 771592405u,
+1750124750u, 2334938333u,
+213811117u, 2586632018u,
+185232757u, 4032960199u,
+2447383637u, 284777551u,
+1654276320u, 2687561076u,
+3512945009u, 308584855u,
+1861027147u, 4102279334u,
+3203802620u, 1692079268u,
+4250142168u, 2565680167u,
+1507046104u, 841195925u,
+520565830u, 3674576684u,
+38924274u, 3770488806u,
+2414430882u, 3978473838u,
+3703994407u, 69201295u,
+3099963860u, 1255084262u,
+690971838u, 3539996781u,
+3696902571u, 3593730713u,
+2363435042u, 54945052u,
+1785765213u, 184911581u,
+1586241476u, 1939595371u,
+2534883189u, 2432427547u,
+2374171993u, 2039128933u,
+2955715987u, 2295501078u,
+2741583197u, 1280920000u,
+686818699u, 1238742497u,
+3843660102u, 82177963u,
+1281043691u, 1121403845u,
+1697846708u, 284852964u,
+278661677u, 2889101923u,
+2127558730u, 713121337u,
+872502474u, 511142139u,
+1261140657u, 1747052377u,
+2108187161u, 927011680u,
+955328267u, 3821994995u,
+2707230761u, 4142246789u,
+4134691985u, 1958963937u,
+2498463509u, 1977988705u,
+1419293714u, 1636932722u,
+2567532373u, 4075249328u,
+240575705u, 1956681213u,
+2598802768u, 2025886508u,
+4104757832u, 3026358429u,
+3242615202u, 4026813725u,
+255108733u, 1845587644u,
+3573008472u, 3615577014u,
+1222733548u, 1205557630u,
+917608574u, 1363253259u,
+1541946015u, 3087190425u,
+1138008081u, 1444019663u,
+109793386u, 341851980u,
+857839960u, 2515339233u,
+156283211u, 1906768669u,
+3886713057u, 1276595523u,
+2809830736u, 460237542u,
+3420452099u, 142985419u,
+205970448u, 4198897105u,
+1950698961u, 2069753399u,
+1142216925u, 1113051162u,
+1033680610u, 4278599955u,
+1106466069u, 356742959u,
+531521052u, 3494863964u,
+225629455u, 3735275001u,
+3662626864u, 1750561299u,
+1012864651u, 2101846429u,
+1074553219u, 668829411u,
+992181339u, 3384018814u,
+3330664522u, 860966321u,
+1885071395u, 4233785523u,
+100741310u, 451656820u,
+2148187612u, 1063001151u,
+360256231u, 107312677u,
+3650357479u, 2390172694u,
+22452685u, 237319043u,
+3600462351u, 1216645846u,
+2088767754u, 164402616u,
+2418980170u, 926137824u,
+94638678u, 1689811113u,
+2751052984u, 1767810825u,
+271289013u, 3896132233u,
+103797041u, 1397772514u,
+3441135892u, 3323383489u,
+2491268371u, 1662561885u,
+1612872497u, 2986430557u,
+2756998822u, 207428029u,
+937973965u, 2791656726u,
+1949717207u, 2260498180u,
+2648427775u, 2360400900u,
+2080496169u, 486358863u,
+1582022990u, 1263709570u,
+1396468647u, 1377764574u,
+363008508u, 1293502429u,
+224580012u, 4252610345u,
+1435134775u, 1099809675u,
+533671980u, 1533438766u,
+1820532305u, 2776960536u,
+3374512975u, 3542220540u,
+822810075u, 3716663290u,
+1157398049u, 3752806924u,
+4081637863u, 337070226u,
+3866585976u, 359270190u,
+2110942730u, 3267551635u,
+644850146u, 1306761320u,
+746972907u, 934259457u,
+2341378668u, 2220373824u,
+1242645122u, 4109252858u,
+1625266099u, 1173698481u,
+383517064u, 896322512u,
+3377483696u, 1788337208u,
+455496839u, 3194373887u,
+1837689083u, 1336556841u,
+1658628529u, 2911512007u,
+3838343487u, 2757664765u,
+1537187340u, 3712582785u,
+367022558u, 3071359622u,
+3926147070u, 35432879u,
+3093195926u, 2561488770u,
+4273132307u, 3898950547u,
+2838251049u, 2103926083u,
+2549435227u, 536047554u,
+1858986613u, 2040551642u,
+1147412575u, 1972369852u,
+4166184983u, 3528794619u,
+4077477194u, 3565689036u,
+808048238u, 3826350461u,
+1359641525u, 1197100813u,
+265993036u, 1864569342u,
+725164342u, 2264788336u,
+1831223342u, 3329594980u,
+923017956u, 490608221u,
+3818634478u, 258154469u,
+1441714797u, 1174785921u,
+3833372385u, 3287246572u,
+1677395563u, 3569218731u,
+868981704u, 2163330264u,
+2649450292u, 500120236u,
+465161780u, 746438382u,
+1145009669u, 2520062970u,
+2810524030u, 1561519055u,
+1479878006u, 3864969305u,
+2686075657u, 4042710240u,
+3224066062u, 2774151984u,
+2226179547u, 1643626042u,
+2328730865u, 3160666939u,
+2107011431u, 96459446u,
+3920328742u, 3336407558u,
+829404209u, 1878067032u,
+1235983679u, 4237425634u,
+466519055u, 3870676863u,
+934312076u, 2952135524u,
+276949224u, 4100839753u,
+424001484u, 1955120893u,
+4015478120u, 1265237690u,
+427484362u, 4246879223u,
+3452969617u, 1724363362u,
+1553513184u, 834830418u,
+1858777639u, 3476334357u,
+4144030366u, 2450047160u,
+2950762705u, 4277111759u,
+358032121u, 2511026735u,
+167923105u, 2059208280u,
+251949572u, 3065234219u,
+1535473864u, 556796152u,
+1513237478u, 3150857516u,
+1103404394u, 198182691u,
+1476438092u, 2913077464u,
+207119516u, 3963810232u,
+2954651680u, 1535115487u,
+3051522276u, 4046477658u,
+917804636u, 864395565u,
+632704095u, 140762681u,
+1802040304u, 990407433u,
+3771506212u, 4106024923u,
+1287729497u, 2198985327u,
+4052924496u, 2926590471u,
+3084557148u, 1472898694u,
+1009870118u, 559702706u,
+4265214507u, 82077489u,
+3067891003u, 3295678907u,
+2402308151u, 1096697687u,
+464407878u, 4190838199u,
+4269578403u, 3060919438u,
+2899950405u, 3046872820u,
+733509243u, 1583801700u,
+40453902u, 3879773881u,
+1993425202u, 2185339100u,
+1877837196u, 3912423882u,
+3293122640u, 4104318469u,
+1679617763u, 3703603898u,
+8759461u, 2540185277u,
+1152198475u, 2038345882u,
+2503579743u, 1446869792u,
+2019419351u, 4051584612u,
+3178289407u, 3992503830u,
+2879018745u, 2719373510u,
+700836153u, 1675560450u,
+4121245793u, 2064715719u,
+343595772u, 1996164093u,
+3130433948u, 405251683u,
+2804817126u, 1607133689u,
+463852893u, 2864244470u,
+2224044848u, 4071581802u,
+2537107938u, 2246347953u,
+3207234525u, 2028708916u,
+2272418128u, 803575837u,
+38655481u, 2170452091u,
+3272166407u, 557660441u,
+4019147902u, 3841480082u,
+298459606u, 2600943364u,
+2440657523u, 255451671u,
+3424361375u, 779434428u,
+3088526123u, 490671625u,
+1322855877u, 3452203069u,
+3057021940u, 2285701422u,
+2014993457u, 2390431709u,
+2002090272u, 1568745354u,
+1783152480u, 823305654u,
+4053862835u, 2200236540u,
+3009412313u, 3184047862u,
+3032187389u, 4159715581u,
+2966902888u, 252986948u,
+1849329144u, 3160134214u,
+3420960112u, 3198900547u,
+749160960u, 379139040u,
+1208883495u, 1566527339u,
+3006227299u, 4194096960u,
+556075248u, 497404038u,
+1717327230u, 1496132623u,
+1775955687u, 1719108984u,
+1014328900u, 4189966956u,
+2108574735u, 2584236470u,
+684087286u, 531310503u,
+4264509527u, 773405691u,
+3088905079u, 3456882941u,
+3105682208u, 3382290593u,
+2289363624u, 3296306400u,
+4168438718u, 467441309u,
+777173623u, 3241407531u,
+1183994815u, 1132983260u,
+1610606159u, 2540270567u,
+2649684057u, 1397502982u,
+146657385u, 3318434267u,
+2109315753u, 3348545480u,
+3193669211u, 811750340u,
+1073256162u, 3571673088u,
+546596661u, 1017047954u,
+3403136990u, 2540585554u,
+1477047647u, 4145867423u,
+2826408201u, 3531646869u,
+784952939u, 943914610u,
+2717443875u, 3657384638u,
+1806867885u, 1903578924u,
+3985088434u, 1911188923u,
+1764002686u, 3672748083u,
+1832925325u, 241574049u,
+519948041u, 3181425568u,
+2939747257u, 1634174593u,
+3429894862u, 3529565564u,
+1089679033u, 240953857u,
+2025369941u, 2695166650u,
+517086873u, 2964595704u,
+3017658263u, 3828377737u,
+2144895011u, 994799311u,
+1184683823u, 4260564140u,
+308018483u, 4262383425u,
+1374752558u, 3431057723u,
+1572637805u, 383233885u,
+3188015819u, 4051263539u,
+233319221u, 3794788167u,
+2017406667u, 919677938u,
+4074952232u, 1683612329u,
+4213676186u, 327142514u,
+3032591014u, 4204155962u,
+206775997u, 2283918569u,
+2395147154u, 3427505379u,
+2211319468u, 4153726847u,
+2217060665u, 350160869u,
+2493667051u, 1648200185u,
+3441709766u, 1387233546u,
+140980u, 1891558063u,
+760080239u, 2088061981u,
+1580964938u, 740563169u,
+422986366u, 330624974u,
+4264507722u, 150928357u,
+2738323042u, 2948665536u,
+918718096u, 376390582u,
+3966098971u, 717653678u,
+3219466255u, 3799363969u,
+3424344721u, 3187805406u,
+375347278u, 3490350144u,
+1992212097u, 2263421398u,
+3855037968u, 1928519266u,
+3866327955u, 1129127000u,
+1782515131u, 2746577402u,
+3059200728u, 2108753646u,
+2738070963u, 1336849395u,
+1705302106u, 768287270u,
+1343511943u, 2247006571u,
+1956142255u, 1780259453u,
+3475618043u, 212490675u,
+622521957u, 917121602u,
+1852992332u, 1267987847u,
+3170016833u, 2549835613u,
+3299763344u, 2864033668u,
+3378768767u, 1236609378u,
+4169365948u, 3738062408u,
+2661022773u, 2006922227u,
+2760592161u, 3828932355u,
+2636387819u, 2616619070u,
+1237256330u, 3449066284u,
+2871755260u, 3729280948u,
+3862686086u, 431292293u,
+3285899651u, 786322314u,
+2531158535u, 724901242u,
+2377363130u, 1415970351u,
+1244759631u, 3263135197u,
+965248856u, 174024139u,
+2297418515u, 2954777083u,
+987586766u, 3206261120u,
+4059515114u, 3903854066u,
+1931934525u, 2287507921u,
+1827135136u, 1781944746u,
+574617451u, 2299034788u,
+2650140034u, 4081586725u,
+2482286699u, 1109175923u,
+458483596u, 618705848u,
+4059852729u, 1813855658u,
+4190721328u, 1129462471u,
+4089998050u, 3575732749u,
+2375584220u, 1037031473u,
+1623777358u, 3389003793u,
+546597541u, 352770237u,
+1383747654u, 3122687303u,
+1646071378u, 1164309901u,
+290870767u, 830691298u,
+929335420u, 3193251135u,
+989577914u, 3626554867u,
+591974737u, 3996958215u,
+3163711272u, 3071568023u,
+1516846461u, 3656006011u,
+2698625268u, 2510865430u,
+340274176u, 1167681812u,
+3698796465u, 3155218919u,
+4102288238u, 1673474350u,
+3069708839u, 2704165015u,
+1237411891u, 1854985978u,
+3646837503u, 3625406022u,
+921552000u, 1712976649u,
+3939149151u, 878608872u,
+3406359248u, 1068844551u,
+1834682077u, 4155949943u,
+2437686324u, 3163786257u,
+2645117577u, 1988168803u,
+747285578u, 1626463554u,
+1235300371u, 1256485167u,
+1914142538u, 4141546431u,
+3838102563u, 582664250u,
+1883344352u, 2083771672u,
+2611657933u, 2139079047u,
+2250573853u, 804336148u,
+3066325351u, 2770847216u,
+4275641370u, 1455750577u,
+3346357270u, 1674051445u,
+601221482u, 3992583643u,
+1402445097u, 3622527604u,
+2509017299u, 2966108111u,
+2557027816u, 900741486u,
+1790771021u, 2912643797u,
+2631381069u, 4014551783u,
+90375300u, 300318232u,
+3269968032u, 2679371729u,
+2664752123u, 3517585534u,
+3253901179u, 542270815u,
+1188641600u, 365479232u,
+2210121140u, 760762191u,
+1273768482u, 1216399252u,
+3484324231u, 4287337666u,
+16322182u, 643179562u,
+325675502u, 3652676161u,
+3120716054u, 3330259752u,
+1011990087u, 2990167340u,
+1097584090u, 3262252593u,
+1829409951u, 3665087267u,
+1214854475u, 2134299399u,
+3704419305u, 411263051u,
+1625446136u, 549838529u,
+4283196353u, 1342880802u,
+3460621305u, 1967599860u,
+4282843369u, 1275671016u,
+2544665755u, 853593042u,
+901109753u, 2682611693u,
+110631633u, 797487791u,
+1472073141u, 850464484u,
+797089608u, 3286110054u,
+350397471u, 2775631060u,
+366448238u, 3842907484u,
+2219863904u, 3623364733u,
+1850985302u, 4009616991u,
+294963924u, 3693536939u,
+3061255808u, 1615375832u,
+1920066675u, 4113028420u,
+4032223840u, 2318423400u,
+2701956286u, 4145497671u,
+3991532344u, 2536338351u,
+1679099863u, 1728968857u,
+449740816u, 2686506989u,
+685242457u, 97590863u,
+3258354115u, 1502282913u,
+1235084019u, 2151665147u,
+528459289u, 231097464u,
+2477280726u, 3651607391u,
+2091754612u, 1178454681u,
+980597335u, 1604483865u,
+1842333726u, 4146839064u,
+3213794286u, 2601416506u,
+754220096u, 3571436033u,
+488595746u, 1448097974u,
+4004834921u, 238887261u,
+3320337489u, 1416989070u,
+2928916831u, 4093725287u,
+186020771u, 2367569534u,
+3046087671u, 4090084518u,
+3548184546u, 679517009u,
+1962659444u, 3539886328u,
+4192003933u, 1678423485u,
+3827951761u, 3086277222u,
+2144472852u, 1390394371u,
+2976322029u, 1574517163u,
+3553313841u, 119173722u,
+1702434637u, 1766260771u,
+3629581771u, 1407497759u,
+895654784u, 751439914u,
+4008409498u, 215917713u,
+1482103833u, 695551833u,
+1288382231u, 2656990891u,
+2581779077u, 1570750352u,
+3710689053u, 1741390464u,
+2666411616u, 3533987737u,
+4289478316u, 3576119563u,
+4118694920u, 108199666u,
+3869794273u, 963183826u,
+2081410737u, 3796810515u,
+791123882u, 2525792704u,
+1036883117u, 136547246u,
+875691100u, 2592925324u,
+614302599u, 3013176417u,
+2689342539u, 427154472u,
+532957601u, 1228758574u,
+1898117151u, 1181643858u,
+1908591042u, 1464255968u,
+446980910u, 2984611177u,
+58509511u, 1046943619u,
+3508927906u, 2001585786u,
+2544767379u, 1525438381u,
+552181222u, 1959725830u,
+879448844u, 1348536411u,
+4242243590u, 2861338018u,
+1082052441u, 1034351453u,
+601175800u, 764077711u,
+530635011u, 3785343245u,
+2178026726u, 117256687u,
+2378297261u, 457568934u,
+76438221u, 4104954272u,
+956793873u, 3783168634u,
+2485968477u, 2381948487u,
+4226929450u, 3148473363u,
+2518273601u, 3569490233u,
+879369091u, 2180270337u,
+3674375989u, 1387729170u,
+977997984u, 4270646856u,
+568650985u, 951677556u,
+4213877384u, 2721005055u,
+1073364549u, 2563403831u,
+1678669911u, 66786703u,
+2273631661u, 1149351924u,
+3651298990u, 1581883443u,
+246723096u, 1895026827u,
+3810605772u, 3711056516u,
+4058833288u, 2193790614u,
+2080120290u, 3638638708u,
+2915672708u, 2263003308u,
+2361934197u, 4136767460u,
+1976115991u, 3448840877u,
+2019238520u, 225333538u,
+874340815u, 2976159827u,
+1555273378u, 3797521928u,
+1942347150u, 3262952567u,
+435997738u, 340403353u,
+2817830907u, 2078619498u,
+749534111u, 1178073973u,
+894654712u, 3361226032u,
+841092198u, 3288261538u,
+1696412169u, 1496966875u,
+697501571u, 1059158875u,
+3739946319u, 2481012988u,
+568983526u, 114945840u,
+1559249010u, 2218244008u,
+2841706923u, 1632780103u,
+4020169654u, 2087949619u,
+2438736103u, 24032648u,
+833416317u, 3787017905u,
+2373238993u, 2575395164u,
+3434544481u, 3228481067u,
+2542976862u, 2971726178u,
+2880371864u, 3642087909u,
+2407477975u, 2239080836u,
+1043714217u, 3894199764u,
+2235879182u, 203853421u,
+2933669448u, 2504940536u,
+834683330u, 425935223u,
+3560796393u, 3565833278u,
+1668000829u, 3683399154u,
+3414330886u, 1748785729u,
+1023171602u, 580966986u,
+2531038985u, 3227325488u,
+2657385925u, 2124704694u,
+233442446u, 1107045577u,
+3407293834u, 552770757u,
+3899097693u, 1067532701u,
+115667924u, 1406028344u,
+1707768231u, 3724015962u,
+2419657149u, 18613994u,
+2532882091u, 3476683808u,
+1560838678u, 811220224u,
+895961699u, 3762914298u,
+1328752423u, 1844996900u,
+1420427894u, 1848067707u,
+1210281744u, 904215228u,
+4055325594u, 1118521573u,
+2496554183u, 2579259919u,
+3996647489u, 3657647605u,
+325254059u, 3136157065u,
+3951522674u, 4052925250u,
+3341068436u, 2287683323u,
+1313073005u, 126005630u,
+2505120084u, 1194725057u,
+853746559u, 3555092974u,
+2689238752u, 49515858u,
+1244776042u, 1069300695u,
+61073168u, 1010661841u,
+1269521335u, 1902040126u,
+990632502u, 2378708922u,
+3858321250u, 1400735275u,
+2974699176u, 2771676666u,
+170995186u, 2877798589u,
+545726212u, 2225229957u,
+1086473152u, 3454177594u,
+3859483262u, 1499729584u,
+2088002891u, 2883475137u,
+3222194252u, 4144472319u,
+2212229854u, 4146740722u,
+567988835u, 1051332394u,
+3932046135u, 542648229u,
+3017852446u, 1277887997u,
+162888005u, 1669710469u,
+1492500905u, 553041029u,
+1434876932u, 533989516u,
+3817492747u, 584127807u,
+4147115982u, 2993670925u,
+4020312558u, 710021255u,
+3509733475u, 3587959456u,
+2088550465u, 1745399498u,
+2952242967u, 1259815443u,
+869648362u, 1404723176u,
+3947542735u, 1334333531u,
+3873471582u, 229399758u,
+59634866u, 3239516985u,
+3844250972u, 1275954779u,
+1385684948u, 2243700741u,
+2512155003u, 1685649437u,
+639306006u, 2524620206u,
+955360345u, 1646776457u,
+576786501u, 655707039u,
+2864351838u, 3736264674u,
+655621239u, 362070173u,
+1200907897u, 2384379464u,
+15823708u, 206117476u,
+3652870937u, 122927134u,
+1193310960u, 1093099415u,
+3696538026u, 4112584792u,
+1834541277u, 845639252u,
+2069527017u, 547588820u,
+4178147211u, 2827259351u,
+1764455305u, 3312003602u,
+940846775u, 1054995047u,
+2976960697u, 1934305529u,
+3095615046u, 3354962706u,
+2199137382u, 1005722394u,
+1875867180u, 2064356511u,
+3363633633u, 2688499147u,
+4019734130u, 3096333006u,
+2069509024u, 2906358341u,
+3247463123u, 4191788132u,
+2232866485u, 1456016086u,
+1422674894u, 867282151u,
+1851386407u, 1268304058u,
+1612503136u, 1739843072u,
+134947567u, 2978775774u,
+2051592101u, 1017127033u,
+1284167756u, 1090844589u,
+831688783u, 2079216362u,
+2079309682u, 1950585801u,
+1626991196u, 3644714163u,
+3678110059u, 898470030u,
+1117570988u, 2517572125u,
+3916646913u, 3182422972u,
+3630426828u, 969847973u,
+2835126238u, 53541366u,
+3427164640u, 3463937250u,
+3044785046u, 897322257u,
+103038235u, 3804506837u,
+3443872170u, 4185408854u,
+2557463241u, 4080940424u,
+3669923099u, 2789619871u,
+2048168570u, 2429169982u,
+3174690447u, 2513494106u,
+3099587829u, 2627855577u,
+1213061732u, 3143736628u,
+3482268149u, 1250714337u,
+3553412672u, 2689632914u,
+31648125u, 3872383625u,
+1565760579u, 36665130u,
+1282106920u, 359361724u,
+751041229u, 2257179590u,
+2915361862u, 280819225u,
+954406473u, 4101682199u,
+2907818413u, 4254297769u,
+3493178615u, 3755944354u,
+3539557658u, 3330196096u,
+4043533423u, 1134196225u,
+4177134659u, 127246419u,
+4213770762u, 1978302978u,
+2442615581u, 923049607u,
+1004426206u, 782768297u,
+2702745496u, 1880389457u,
+2410586681u, 1430106871u,
+4103323427u, 3168399477u,
+201787012u, 3105353527u,
+3716682375u, 3616334719u,
+3413209549u, 656672786u,
+526032790u, 2895072131u,
+2876965944u, 182894450u,
+456581318u, 2683752067u,
+1287916294u, 1270745752u,
+3877875910u, 3190666241u,
+3240336907u, 4024807233u,
+4227999465u, 2389301430u,
+1681224377u, 1576191191u,
+3599250276u, 2381111980u,
+3995044500u, 995595530u,
+3495321877u, 3956024585u,
+1611608524u, 3815677453u,
+1520987487u, 3669102590u,
+2062334396u, 1656117707u,
+5457134u, 3234118251u,
+4242065111u, 596879987u,
+470187419u, 2688566989u,
+3259870297u, 660100446u,
+1042378442u, 2206034096u,
+442236198u, 2542452448u,
+493137955u, 392411099u,
+3111186954u, 438250493u,
+947967568u, 1234595917u,
+4230082284u, 2762976773u,
+421203727u, 3728409592u,
+2870085764u, 1455086530u,
+2762099647u, 4011882747u,
+1785430706u, 3684427488u,
+1215981925u, 3227517889u,
+3269061963u, 4037515364u,
+1749401388u, 2167451566u,
+3168911474u, 4255057396u,
+2026092260u, 1736192508u,
+4123254745u, 2319366806u,
+3909727042u, 3114708966u,
+1938800693u, 680793595u,
+3933041672u, 616863613u,
+1525265867u, 2808224480u,
+2122290603u, 1211197714u,
+1186177814u, 2395325006u,
+3520488321u, 3979192396u,
+3540779343u, 4192918639u,
+1763872074u, 3402419930u,
+2736030448u, 1120335563u,
+1698949078u, 3993310631u,
+2947659998u, 1461045789u,
+1966048551u, 2228221363u,
+597941119u, 3498018399u,
+1441110751u, 2229999711u,
+393987327u, 454500547u,
+1222959566u, 567151340u,
+2496952483u, 1708770195u,
+3774764786u, 1492844524u,
+3308300614u, 805568076u,
+4068812294u, 3404648243u,
+868414882u, 177406999u,
+1608110313u, 642061169u,
+2093999089u, 222470301u,
+1027515771u, 3131251981u,
+2851936150u, 4272755262u,
+2763002551u, 1881527822u,
+1532845092u, 709643652u,
+682573592u, 1244104217u,
+440905170u, 1111321746u,
+796769556u, 2500467040u,
+3002618826u, 1112998535u,
+1188525643u, 4212674512u,
+1780193104u, 1243644607u,
+3691719535u, 2958853053u,
+2813437721u, 4036584207u,
+466635014u, 2277292580u,
+4082276003u, 1030800045u,
+1899531424u, 609466946u,
+1750863246u, 379050598u,
+3576413281u, 731493104u,
+2707384133u, 2289193651u,
+132259176u, 4115195437u,
+1769890695u, 2715470335u,
+3348954692u, 2166575624u,
+1819263183u, 2028531518u,
+2154809766u, 3672399742u,
+1142139448u, 88299682u,
+76727603u, 4198182186u,
+2304993586u, 1666387627u,
+2488475423u, 3832777692u,
+284366017u, 3359785538u,
+3469807328u, 2926494787u,
+1914195188u, 1134129972u,
+3829072836u, 2493478921u,
+3738499303u, 3311304980u,
+726951526u, 911080963u,
+932916545u, 2235559063u,
+2909742396u, 1765719309u,
+465269850u, 3803621553u,
+1456588655u, 508290328u,
+1490719640u, 3356513470u,
+2262196163u, 1451774941u,
+2908490783u, 251085588u,
+830410677u, 3172220325u,
+4039692645u, 1383603170u,
+3897208579u, 1940535730u,
+151909546u, 2384458112u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
+if (offset == -1) { int alive = 0; { uint64_t h = farmhashxo::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
+{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
+{ uint64_t h = farmhashxo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashxoTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
+{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+{ uint64_t h = farmhashxo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashxoTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashxoTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashxoTest::Dump(0, i);
+ }
+ farmhashxoTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+
+int main() {
+ farmhashccTest::RunTest();
+ farmhashmkTest::RunTest();
+ farmhashnaTest::RunTest();
+ farmhashntTest::RunTest();
+ farmhashsaTest::RunTest();
+ farmhashsuTest::RunTest();
+ farmhashteTest::RunTest();
+ farmhashuoTest::RunTest();
+ farmhashxoTest::RunTest();
+ __builtin_unreachable();
+}
+
+#endif // FARMHASHSELFTEST
diff --git a/contrib/libs/farmhash/farmhash.h b/contrib/libs/farmhash/farmhash.h
index 0f1802ea82..95388de696 100644
--- a/contrib/libs/farmhash/farmhash.h
+++ b/contrib/libs/farmhash/farmhash.h
@@ -1,328 +1,328 @@
-// Copyright (c) 2014 Google, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-// FarmHash, by Geoff Pike
-
-//
-// http://code.google.com/p/farmhash/
-//
-// This file provides a few functions for hashing strings and other
-// data. All of them are high-quality functions in the sense that
-// they do well on standard tests such as Austin Appleby's SMHasher.
-// They're also fast. FarmHash is the successor to CityHash.
-//
-// Functions in the FarmHash family are not suitable for cryptography.
-//
-// WARNING: This code has been only lightly tested on big-endian platforms!
-// It is known to work well on little-endian platforms that have a small penalty
-// for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs.
-// It should work on all 32-bit and 64-bit platforms that allow unaligned reads;
-// bug reports are welcome.
-//
-// By the way, for some hash functions, given strings a and b, the hash
-// of a+b is easily derived from the hashes of a and b. This property
-// doesn't hold for any hash functions in this file.
-
-#ifndef FARM_HASH_H_
-#define FARM_HASH_H_
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h> // for memcpy and memset
-#include <utility>
-
-#ifndef NAMESPACE_FOR_HASH_FUNCTIONS
-#define NAMESPACE_FOR_HASH_FUNCTIONS util
-#endif
-
-namespace NAMESPACE_FOR_HASH_FUNCTIONS {
-
-#if defined(FARMHASH_UINT128_T_DEFINED)
-#if defined(__clang__)
-#if !defined(uint128_t)
-#define uint128_t __uint128_t
-#endif
-#endif
-inline uint64_t Uint128Low64(const uint128_t x) {
- return static_cast<uint64_t>(x);
-}
-inline uint64_t Uint128High64(const uint128_t x) {
- return static_cast<uint64_t>(x >> 64);
-}
-inline uint128_t Uint128(uint64_t lo, uint64_t hi) {
- return lo + (((uint128_t)hi) << 64);
-}
-#else
-typedef std::pair<uint64_t, uint64_t> uint128_t;
-inline uint64_t Uint128Low64(const uint128_t x) { return x.first; }
-inline uint64_t Uint128High64(const uint128_t x) { return x.second; }
-inline uint128_t Uint128(uint64_t lo, uint64_t hi) { return uint128_t(lo, hi); }
-#endif
-
-
-// BASIC STRING HASHING
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-size_t Hash(const char* s, size_t len);
-
-// Hash function for a byte array. Most useful in 32-bit binaries.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint32_t Hash32(const char* s, size_t len);
-
-// Hash function for a byte array. For convenience, a 32-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed);
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64(const char* s, size_t len);
-
-// Hash function for a byte array. For convenience, a 64-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed);
-
-// Hash function for a byte array. For convenience, two seeds are also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64WithSeeds(const char* s, size_t len,
- uint64_t seed0, uint64_t seed1);
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint128_t Hash128(const char* s, size_t len);
-
-// Hash function for a byte array. For convenience, a 128-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed);
-
-// BASIC NON-STRING HASHING
-
-// Hash 128 input bits down to 64 bits of output.
-// This is intended to be a reasonably good hash function.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-inline uint64_t Hash128to64(uint128_t x) {
- // Murmur-inspired hashing.
- const uint64_t kMul = 0x9ddfea08eb382d69ULL;
- uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
- a ^= (a >> 47);
- uint64_t b = (Uint128High64(x) ^ a) * kMul;
- b ^= (b >> 47);
- b *= kMul;
- return b;
-}
-
-// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
-
-// Fingerprint function for a byte array. Most useful in 32-bit binaries.
-uint32_t Fingerprint32(const char* s, size_t len);
-
-// Fingerprint function for a byte array.
-uint64_t Fingerprint64(const char* s, size_t len);
-
-// Fingerprint function for a byte array.
-uint128_t Fingerprint128(const char* s, size_t len);
-
-// This is intended to be a good fingerprinting primitive.
-// See below for more overloads.
-inline uint64_t Fingerprint(uint128_t x) {
- // Murmur-inspired hashing.
- const uint64_t kMul = 0x9ddfea08eb382d69ULL;
- uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
- a ^= (a >> 47);
- uint64_t b = (Uint128High64(x) ^ a) * kMul;
- b ^= (b >> 44);
- b *= kMul;
- b ^= (b >> 41);
- b *= kMul;
- return b;
-}
-
-// This is intended to be a good fingerprinting primitive.
-inline uint64_t Fingerprint(uint64_t x) {
- // Murmur-inspired hashing.
- const uint64_t kMul = 0x9ddfea08eb382d69ULL;
- uint64_t b = x * kMul;
- b ^= (b >> 44);
- b *= kMul;
- b ^= (b >> 41);
- b *= kMul;
- return b;
-}
-
-#ifndef FARMHASH_NO_CXX_STRING
-
-// Convenience functions to hash or fingerprint C++ strings.
-// These require that Str::data() return a pointer to the first char
-// (as a const char*) and that Str::length() return the string's length;
-// they work with std::string, for example.
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline size_t Hash(const Str& s) {
- assert(sizeof(s[0]) == 1);
- return Hash(s.data(), s.length());
-}
-
-// Hash function for a byte array. Most useful in 32-bit binaries.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline uint32_t Hash32(const Str& s) {
- assert(sizeof(s[0]) == 1);
- return Hash32(s.data(), s.length());
-}
-
-// Hash function for a byte array. For convenience, a 32-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline uint32_t Hash32WithSeed(const Str& s, uint32_t seed) {
- assert(sizeof(s[0]) == 1);
- return Hash32WithSeed(s.data(), s.length(), seed);
-}
-
-// Hash 128 input bits down to 64 bits of output.
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline uint64_t Hash64(const Str& s) {
- assert(sizeof(s[0]) == 1);
- return Hash64(s.data(), s.length());
-}
-
-// Hash function for a byte array. For convenience, a 64-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline uint64_t Hash64WithSeed(const Str& s, uint64_t seed) {
- assert(sizeof(s[0]) == 1);
- return Hash64WithSeed(s.data(), s.length(), seed);
-}
-
-// Hash function for a byte array. For convenience, two seeds are also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline uint64_t Hash64WithSeeds(const Str& s, uint64_t seed0, uint64_t seed1) {
- assert(sizeof(s[0]) == 1);
- return Hash64WithSeeds(s.data(), s.length(), seed0, seed1);
-}
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline uint128_t Hash128(const Str& s) {
- assert(sizeof(s[0]) == 1);
- return Hash128(s.data(), s.length());
-}
-
-// Hash function for a byte array. For convenience, a 128-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-template <typename Str>
-inline uint128_t Hash128WithSeed(const Str& s, uint128_t seed) {
- assert(sizeof(s[0]) == 1);
- return Hash128(s.data(), s.length(), seed);
-}
-
-// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
-
-// Fingerprint function for a byte array. Most useful in 32-bit binaries.
-template <typename Str>
-inline uint32_t Fingerprint32(const Str& s) {
- assert(sizeof(s[0]) == 1);
- return Fingerprint32(s.data(), s.length());
-}
-
-// Fingerprint 128 input bits down to 64 bits of output.
-// Fingerprint function for a byte array.
-template <typename Str>
-inline uint64_t Fingerprint64(const Str& s) {
- assert(sizeof(s[0]) == 1);
- return Fingerprint64(s.data(), s.length());
-}
-
-// Fingerprint function for a byte array.
-template <typename Str>
-inline uint128_t Fingerprint128(const Str& s) {
- assert(sizeof(s[0]) == 1);
- return Fingerprint128(s.data(), s.length());
-}
-
-#endif
-
-} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-
-/* gently define FARMHASH_BIG_ENDIAN when detected big-endian machine */
-#if defined(__BIG_ENDIAN__)
- #if !defined(FARMHASH_BIG_ENDIAN)
- #define FARMHASH_BIG_ENDIAN
- #endif
-#elif defined(__LITTLE_ENDIAN__)
- // nothing for little-endian
-#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER == __ORDER_LITTLE_ENDIAN__)
- // nothing for little-endian
-#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER == __ORDER_BIG_ENDIAN__)
- #if !defined(FARMHASH_BIG_ENDIAN)
- #define FARMHASH_BIG_ENDIAN
- #endif
-#elif defined(__linux__) || defined(__CYGWIN__) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
- #include <endian.h> // libc6-dev, GLIBC
- #if BYTE_ORDER == BIG_ENDIAN
- #if !defined(FARMHASH_BIG_ENDIAN)
- #define FARMHASH_BIG_ENDIAN
- #endif
- #endif
-#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
- #include <sys/endian.h>
- #if BYTE_ORDER == BIG_ENDIAN
- #if !defined(FARMHASH_BIG_ENDIAN)
- #define FARMHASH_BIG_ENDIAN
- #endif
- #endif
-#elif defined(_WIN32)
- // Windows is (currently) little-endian
-#else
- #error "Unable to determine endianness!"
-#endif /* __BIG_ENDIAN__ */
-
-#endif // FARM_HASH_H_
+// Copyright (c) 2014 Google, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+// FarmHash, by Geoff Pike
+
+//
+// http://code.google.com/p/farmhash/
+//
+// This file provides a few functions for hashing strings and other
+// data. All of them are high-quality functions in the sense that
+// they do well on standard tests such as Austin Appleby's SMHasher.
+// They're also fast. FarmHash is the successor to CityHash.
+//
+// Functions in the FarmHash family are not suitable for cryptography.
+//
+// WARNING: This code has been only lightly tested on big-endian platforms!
+// It is known to work well on little-endian platforms that have a small penalty
+// for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs.
+// It should work on all 32-bit and 64-bit platforms that allow unaligned reads;
+// bug reports are welcome.
+//
+// By the way, for some hash functions, given strings a and b, the hash
+// of a+b is easily derived from the hashes of a and b. This property
+// doesn't hold for any hash functions in this file.
+
+#ifndef FARM_HASH_H_
+#define FARM_HASH_H_
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h> // for memcpy and memset
+#include <utility>
+
+#ifndef NAMESPACE_FOR_HASH_FUNCTIONS
+#define NAMESPACE_FOR_HASH_FUNCTIONS util
+#endif
+
+namespace NAMESPACE_FOR_HASH_FUNCTIONS {
+
+#if defined(FARMHASH_UINT128_T_DEFINED)
+#if defined(__clang__)
+#if !defined(uint128_t)
+#define uint128_t __uint128_t
+#endif
+#endif
+inline uint64_t Uint128Low64(const uint128_t x) {
+ return static_cast<uint64_t>(x);
+}
+inline uint64_t Uint128High64(const uint128_t x) {
+ return static_cast<uint64_t>(x >> 64);
+}
+inline uint128_t Uint128(uint64_t lo, uint64_t hi) {
+ return lo + (((uint128_t)hi) << 64);
+}
+#else
+typedef std::pair<uint64_t, uint64_t> uint128_t;
+inline uint64_t Uint128Low64(const uint128_t x) { return x.first; }
+inline uint64_t Uint128High64(const uint128_t x) { return x.second; }
+inline uint128_t Uint128(uint64_t lo, uint64_t hi) { return uint128_t(lo, hi); }
+#endif
+
+
+// BASIC STRING HASHING
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+size_t Hash(const char* s, size_t len);
+
+// Hash function for a byte array. Most useful in 32-bit binaries.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint32_t Hash32(const char* s, size_t len);
+
+// Hash function for a byte array. For convenience, a 32-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed);
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64(const char* s, size_t len);
+
+// Hash function for a byte array. For convenience, a 64-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed);
+
+// Hash function for a byte array. For convenience, two seeds are also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64WithSeeds(const char* s, size_t len,
+ uint64_t seed0, uint64_t seed1);
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint128_t Hash128(const char* s, size_t len);
+
+// Hash function for a byte array. For convenience, a 128-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed);
+
+// BASIC NON-STRING HASHING
+
+// Hash 128 input bits down to 64 bits of output.
+// This is intended to be a reasonably good hash function.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+inline uint64_t Hash128to64(uint128_t x) {
+ // Murmur-inspired hashing.
+ const uint64_t kMul = 0x9ddfea08eb382d69ULL;
+ uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
+ a ^= (a >> 47);
+ uint64_t b = (Uint128High64(x) ^ a) * kMul;
+ b ^= (b >> 47);
+ b *= kMul;
+ return b;
+}
+
+// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
+
+// Fingerprint function for a byte array. Most useful in 32-bit binaries.
+uint32_t Fingerprint32(const char* s, size_t len);
+
+// Fingerprint function for a byte array.
+uint64_t Fingerprint64(const char* s, size_t len);
+
+// Fingerprint function for a byte array.
+uint128_t Fingerprint128(const char* s, size_t len);
+
+// This is intended to be a good fingerprinting primitive.
+// See below for more overloads.
+inline uint64_t Fingerprint(uint128_t x) {
+ // Murmur-inspired hashing.
+ const uint64_t kMul = 0x9ddfea08eb382d69ULL;
+ uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
+ a ^= (a >> 47);
+ uint64_t b = (Uint128High64(x) ^ a) * kMul;
+ b ^= (b >> 44);
+ b *= kMul;
+ b ^= (b >> 41);
+ b *= kMul;
+ return b;
+}
+
+// This is intended to be a good fingerprinting primitive.
+inline uint64_t Fingerprint(uint64_t x) {
+ // Murmur-inspired hashing.
+ const uint64_t kMul = 0x9ddfea08eb382d69ULL;
+ uint64_t b = x * kMul;
+ b ^= (b >> 44);
+ b *= kMul;
+ b ^= (b >> 41);
+ b *= kMul;
+ return b;
+}
+
+#ifndef FARMHASH_NO_CXX_STRING
+
+// Convenience functions to hash or fingerprint C++ strings.
+// These require that Str::data() return a pointer to the first char
+// (as a const char*) and that Str::length() return the string's length;
+// they work with std::string, for example.
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline size_t Hash(const Str& s) {
+ assert(sizeof(s[0]) == 1);
+ return Hash(s.data(), s.length());
+}
+
+// Hash function for a byte array. Most useful in 32-bit binaries.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline uint32_t Hash32(const Str& s) {
+ assert(sizeof(s[0]) == 1);
+ return Hash32(s.data(), s.length());
+}
+
+// Hash function for a byte array. For convenience, a 32-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline uint32_t Hash32WithSeed(const Str& s, uint32_t seed) {
+ assert(sizeof(s[0]) == 1);
+ return Hash32WithSeed(s.data(), s.length(), seed);
+}
+
+// Hash 128 input bits down to 64 bits of output.
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline uint64_t Hash64(const Str& s) {
+ assert(sizeof(s[0]) == 1);
+ return Hash64(s.data(), s.length());
+}
+
+// Hash function for a byte array. For convenience, a 64-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline uint64_t Hash64WithSeed(const Str& s, uint64_t seed) {
+ assert(sizeof(s[0]) == 1);
+ return Hash64WithSeed(s.data(), s.length(), seed);
+}
+
+// Hash function for a byte array. For convenience, two seeds are also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline uint64_t Hash64WithSeeds(const Str& s, uint64_t seed0, uint64_t seed1) {
+ assert(sizeof(s[0]) == 1);
+ return Hash64WithSeeds(s.data(), s.length(), seed0, seed1);
+}
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline uint128_t Hash128(const Str& s) {
+ assert(sizeof(s[0]) == 1);
+ return Hash128(s.data(), s.length());
+}
+
+// Hash function for a byte array. For convenience, a 128-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+template <typename Str>
+inline uint128_t Hash128WithSeed(const Str& s, uint128_t seed) {
+ assert(sizeof(s[0]) == 1);
+ return Hash128(s.data(), s.length(), seed);
+}
+
+// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
+
+// Fingerprint function for a byte array. Most useful in 32-bit binaries.
+template <typename Str>
+inline uint32_t Fingerprint32(const Str& s) {
+ assert(sizeof(s[0]) == 1);
+ return Fingerprint32(s.data(), s.length());
+}
+
+// Fingerprint 128 input bits down to 64 bits of output.
+// Fingerprint function for a byte array.
+template <typename Str>
+inline uint64_t Fingerprint64(const Str& s) {
+ assert(sizeof(s[0]) == 1);
+ return Fingerprint64(s.data(), s.length());
+}
+
+// Fingerprint function for a byte array.
+template <typename Str>
+inline uint128_t Fingerprint128(const Str& s) {
+ assert(sizeof(s[0]) == 1);
+ return Fingerprint128(s.data(), s.length());
+}
+
+#endif
+
+} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
+
+/* gently define FARMHASH_BIG_ENDIAN when detected big-endian machine */
+#if defined(__BIG_ENDIAN__)
+ #if !defined(FARMHASH_BIG_ENDIAN)
+ #define FARMHASH_BIG_ENDIAN
+ #endif
+#elif defined(__LITTLE_ENDIAN__)
+ // nothing for little-endian
+#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER == __ORDER_LITTLE_ENDIAN__)
+ // nothing for little-endian
+#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER == __ORDER_BIG_ENDIAN__)
+ #if !defined(FARMHASH_BIG_ENDIAN)
+ #define FARMHASH_BIG_ENDIAN
+ #endif
+#elif defined(__linux__) || defined(__CYGWIN__) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
+ #include <endian.h> // libc6-dev, GLIBC
+ #if BYTE_ORDER == BIG_ENDIAN
+ #if !defined(FARMHASH_BIG_ENDIAN)
+ #define FARMHASH_BIG_ENDIAN
+ #endif
+ #endif
+#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+ #include <sys/endian.h>
+ #if BYTE_ORDER == BIG_ENDIAN
+ #if !defined(FARMHASH_BIG_ENDIAN)
+ #define FARMHASH_BIG_ENDIAN
+ #endif
+ #endif
+#elif defined(_WIN32)
+ // Windows is (currently) little-endian
+#else
+ #error "Unable to determine endianness!"
+#endif /* __BIG_ENDIAN__ */
+
+#endif // FARM_HASH_H_
diff --git a/contrib/libs/farmhash/farmhash_iface.cc b/contrib/libs/farmhash/farmhash_iface.cc
index 0064662412..a9c3ca77f2 100644
--- a/contrib/libs/farmhash/farmhash_iface.cc
+++ b/contrib/libs/farmhash/farmhash_iface.cc
@@ -1,106 +1,106 @@
-#include "common.h"
-
-#include "farmhash_iface.h"
-
-#include <util/system/cpu_id.h>
-
-namespace NAMESPACE_FOR_HASH_FUNCTIONS {
-
-// BASIC STRING HASHING
-
-// Hash function for a byte array. See also Hash(), below.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint32_t Hash32(const char* s, size_t len) {
- return DebugTweak(
- (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32(s, len) :
- (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32(s, len) :
- NX86::CachedHaveSSE42() ? farmhashsa::Hash32(s, len) :
- farmhashmk::Hash32(s, len));
-}
-
-// Hash function for a byte array. For convenience, a 32-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
- return DebugTweak(
- (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
- (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32WithSeed(s, len, seed) :
- NX86::CachedHaveSSE42() ? farmhashsa::Hash32WithSeed(s, len, seed) :
- farmhashmk::Hash32WithSeed(s, len, seed));
-}
-
-// Hash function for a byte array. For convenience, a 64-bit seed is also
-// hashed into the result. See also Hash(), below.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64(const char* s, size_t len) {
- return DebugTweak(
- (NX86::CachedHaveSSE42() & x86_64) ?
- farmhashte::Hash64(s, len) :
- farmhashxo::Hash64(s, len));
-}
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-size_t Hash(const char* s, size_t len) {
- return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
-}
-
-// Hash function for a byte array. For convenience, a 64-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
- return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
-}
-
-// Hash function for a byte array. For convenience, two seeds are also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
- return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
-}
-
-// Hash function for a byte array.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint128_t Hash128(const char* s, size_t len) {
- return DebugTweak(farmhashcc::Fingerprint128(s, len));
-}
-
-// Hash function for a byte array. For convenience, a 128-bit seed is also
-// hashed into the result.
-// May change from time to time, may differ on different platforms, may differ
-// depending on NDEBUG.
-uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) {
- return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
-}
-
-// BASIC NON-STRING HASHING
-
-// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
-
-// Fingerprint function for a byte array. Most useful in 32-bit binaries.
-uint32_t Fingerprint32(const char* s, size_t len) {
- return farmhashmk::Hash32(s, len);
-}
-
-// Fingerprint function for a byte array.
-uint64_t Fingerprint64(const char* s, size_t len) {
- return farmhashna::Hash64(s, len);
-}
-
-// Fingerprint function for a byte array.
-uint128_t Fingerprint128(const char* s, size_t len) {
- return farmhashcc::Fingerprint128(s, len);
-}
-
-// Older and still available but perhaps not as fast as the above:
-// farmhashns::Hash32{,WithSeed}()
-
-} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-
+#include "common.h"
+
+#include "farmhash_iface.h"
+
+#include <util/system/cpu_id.h>
+
+namespace NAMESPACE_FOR_HASH_FUNCTIONS {
+
+// BASIC STRING HASHING
+
+// Hash function for a byte array. See also Hash(), below.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint32_t Hash32(const char* s, size_t len) {
+ return DebugTweak(
+ (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32(s, len) :
+ (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32(s, len) :
+ NX86::CachedHaveSSE42() ? farmhashsa::Hash32(s, len) :
+ farmhashmk::Hash32(s, len));
+}
+
+// Hash function for a byte array. For convenience, a 32-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
+ return DebugTweak(
+ (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
+ (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32WithSeed(s, len, seed) :
+ NX86::CachedHaveSSE42() ? farmhashsa::Hash32WithSeed(s, len, seed) :
+ farmhashmk::Hash32WithSeed(s, len, seed));
+}
+
+// Hash function for a byte array. For convenience, a 64-bit seed is also
+// hashed into the result. See also Hash(), below.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64(const char* s, size_t len) {
+ return DebugTweak(
+ (NX86::CachedHaveSSE42() & x86_64) ?
+ farmhashte::Hash64(s, len) :
+ farmhashxo::Hash64(s, len));
+}
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+size_t Hash(const char* s, size_t len) {
+ return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
+}
+
+// Hash function for a byte array. For convenience, a 64-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
+ return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
+}
+
+// Hash function for a byte array. For convenience, two seeds are also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
+}
+
+// Hash function for a byte array.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint128_t Hash128(const char* s, size_t len) {
+ return DebugTweak(farmhashcc::Fingerprint128(s, len));
+}
+
+// Hash function for a byte array. For convenience, a 128-bit seed is also
+// hashed into the result.
+// May change from time to time, may differ on different platforms, may differ
+// depending on NDEBUG.
+uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) {
+ return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
+}
+
+// BASIC NON-STRING HASHING
+
+// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
+
+// Fingerprint function for a byte array. Most useful in 32-bit binaries.
+uint32_t Fingerprint32(const char* s, size_t len) {
+ return farmhashmk::Hash32(s, len);
+}
+
+// Fingerprint function for a byte array.
+uint64_t Fingerprint64(const char* s, size_t len) {
+ return farmhashna::Hash64(s, len);
+}
+
+// Fingerprint function for a byte array.
+uint128_t Fingerprint128(const char* s, size_t len) {
+ return farmhashcc::Fingerprint128(s, len);
+}
+
+// Older and still available but perhaps not as fast as the above:
+// farmhashns::Hash32{,WithSeed}()
+
+} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
+
diff --git a/contrib/libs/farmhash/farmhash_iface.h b/contrib/libs/farmhash/farmhash_iface.h
index 9d5d0a5f9b..936aafd494 100644
--- a/contrib/libs/farmhash/farmhash_iface.h
+++ b/contrib/libs/farmhash/farmhash_iface.h
@@ -1,28 +1,28 @@
-#define FARMHASH_INTERFACE(name) namespace name { \
- uint32_t Hash32(const char* s, size_t len); \
- uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed); \
- uint64_t Hash64(const char* s, size_t len); \
- uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed); \
- uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1); \
- uint128_t Hash128(const char* s, size_t len); \
- uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed); \
-}
-
-namespace farmhashcc {
- uint32_t Fingerprint32(const char* s, size_t len);
- uint64_t Fingerprint64(const char* s, size_t len);
- uint128_t Fingerprint128(const char* s, size_t len);
- uint128_t CityHash128WithSeed(const char* s, size_t len, uint128_t seed);
-}
-
-FARMHASH_INTERFACE(farmhashcc)
-FARMHASH_INTERFACE(farmhashsa)
-FARMHASH_INTERFACE(farmhashsu)
-FARMHASH_INTERFACE(farmhashmk)
-FARMHASH_INTERFACE(farmhashnt)
-FARMHASH_INTERFACE(farmhashte)
-FARMHASH_INTERFACE(farmhashxo)
-FARMHASH_INTERFACE(farmhashuo)
-FARMHASH_INTERFACE(farmhashna)
-
-#undef FARMHASH_INTERFACE
+#define FARMHASH_INTERFACE(name) namespace name { \
+ uint32_t Hash32(const char* s, size_t len); \
+ uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed); \
+ uint64_t Hash64(const char* s, size_t len); \
+ uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed); \
+ uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1); \
+ uint128_t Hash128(const char* s, size_t len); \
+ uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed); \
+}
+
+namespace farmhashcc {
+ uint32_t Fingerprint32(const char* s, size_t len);
+ uint64_t Fingerprint64(const char* s, size_t len);
+ uint128_t Fingerprint128(const char* s, size_t len);
+ uint128_t CityHash128WithSeed(const char* s, size_t len, uint128_t seed);
+}
+
+FARMHASH_INTERFACE(farmhashcc)
+FARMHASH_INTERFACE(farmhashsa)
+FARMHASH_INTERFACE(farmhashsu)
+FARMHASH_INTERFACE(farmhashmk)
+FARMHASH_INTERFACE(farmhashnt)
+FARMHASH_INTERFACE(farmhashte)
+FARMHASH_INTERFACE(farmhashxo)
+FARMHASH_INTERFACE(farmhashuo)
+FARMHASH_INTERFACE(farmhashna)
+
+#undef FARMHASH_INTERFACE
diff --git a/contrib/libs/farmhash/farmhashcc.cc b/contrib/libs/farmhash/farmhashcc.cc
index 4fc2741048..d3e30af4c3 100644
--- a/contrib/libs/farmhash/farmhashcc.cc
+++ b/contrib/libs/farmhash/farmhashcc.cc
@@ -1,314 +1,314 @@
-#include "common.h"
-
-namespace {
- #include "farmhashsa.cc"
-}
-
-namespace farmhashcc {
-// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
-// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
-// a seeded 32-bit hash function similar to CityHash32.
-
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len) {
- uint32_t a = Fetch(s - 4 + (len >> 1));
- uint32_t b = Fetch(s + 4);
- uint32_t c = Fetch(s + len - 8);
- uint32_t d = Fetch(s + (len >> 1));
- uint32_t e = Fetch(s);
- uint32_t f = Fetch(s + len - 4);
- uint32_t h = len;
-
- return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
-}
-
-STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len) {
- uint32_t b = 0;
- uint32_t c = 9;
- for (size_t i = 0; i < len; i++) {
- signed char v = s[i];
- b = b * c1 + v;
- c ^= b;
- }
- return fmix(Mur(b, Mur(len, c)));
-}
-
-STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len) {
- uint32_t a = len, b = len * 5, c = 9, d = b;
- a += Fetch(s);
- b += Fetch(s + len - 4);
- c += Fetch(s + ((len >> 1) & 4));
- return fmix(Mur(c, Mur(b, Mur(a, d))));
-}
-
-uint32_t Hash32(const char *s, size_t len) {
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
- Hash32Len13to24(s, len);
- }
-
- // len > 24
- uint32_t h = len, g = c1 * len, f = g;
- uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
- uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
- uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
- uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
- uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
- h ^= a0;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- h ^= a2;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- g ^= a1;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- g ^= a3;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- f += a4;
- f = Rotate(f, 19);
- f = f * 5 + 0xe6546b64;
- size_t iters = (len - 1) / 20;
- do {
- uint32_t a0 = Rotate(Fetch(s) * c1, 17) * c2;
- uint32_t a1 = Fetch(s + 4);
- uint32_t a2 = Rotate(Fetch(s + 8) * c1, 17) * c2;
- uint32_t a3 = Rotate(Fetch(s + 12) * c1, 17) * c2;
- uint32_t a4 = Fetch(s + 16);
- h ^= a0;
- h = Rotate(h, 18);
- h = h * 5 + 0xe6546b64;
- f += a1;
- f = Rotate(f, 19);
- f = f * c1;
- g += a2;
- g = Rotate(g, 18);
- g = g * 5 + 0xe6546b64;
- h ^= a3 + a1;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- g ^= a4;
- g = Bswap(g) * 5;
- h += a4 * 5;
- h = Bswap(h);
- f += a0;
- PERMUTE3(f, h, g);
- s += 20;
- } while (--iters != 0);
- g = Rotate(g, 11) * c1;
- g = Rotate(g, 17) * c1;
- f = Rotate(f, 11) * c1;
- f = Rotate(f, 17) * c1;
- h = Rotate(h + g, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- h = Rotate(h + f, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- return h;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
- else return farmhashmk::Hash32Len0to4(s, len, seed);
- }
- uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
- return Mur(Hash32(s + 24, len - 24) + seed, h);
-}
-
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-#undef Bswap
-#define Bswap Bswap64
-
-STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
- return val ^ (val >> 47);
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
- return Hash128to64(Uint128(u, v));
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
- // Murmur-inspired hashing.
- uint64_t a = (u ^ v) * mul;
- a ^= (a >> 47);
- uint64_t b = (v ^ a) * mul;
- b ^= (b >> 47);
- b *= mul;
- return b;
-}
-
-STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
- if (len >= 8) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) + k2;
- uint64_t b = Fetch(s + len - 8);
- uint64_t c = Rotate(b, 37) * mul + a;
- uint64_t d = (Rotate(a, 25) + b) * mul;
- return HashLen16(c, d, mul);
- }
- if (len >= 4) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch32(s);
- return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
- }
- if (len > 0) {
- uint8_t a = s[0];
- uint8_t b = s[len >> 1];
- uint8_t c = s[len - 1];
- uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
- uint32_t z = len + (static_cast<uint32_t>(c) << 2);
- return ShiftMix(y * k2 ^ z * k0) * k2;
- }
- return k2;
-}
-
-// Return a 16-byte hash for 48 bytes. Quick and dirty.
-// Callers do best to use "random-looking" values for a and b.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
- a += w;
- b = Rotate(b + a + z, 21);
- uint64_t c = a;
- a += x;
- a += y;
- b += Rotate(a, 44);
- return make_pair(a + z, b + c);
-}
-
-// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- const char* s, uint64_t a, uint64_t b) {
- return WeakHashLen32WithSeeds(Fetch(s),
- Fetch(s + 8),
- Fetch(s + 16),
- Fetch(s + 24),
- a,
- b);
-}
-
-
-
-// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
-// of any length representable in signed long. Based on City and Murmur.
-STATIC_INLINE uint128_t CityMurmur(const char *s, size_t len, uint128_t seed) {
- uint64_t a = Uint128Low64(seed);
- uint64_t b = Uint128High64(seed);
- uint64_t c = 0;
- uint64_t d = 0;
- signed long l = len - 16;
- if (l <= 0) { // len <= 16
- a = ShiftMix(a * k1) * k1;
- c = b * k1 + HashLen0to16(s, len);
- d = ShiftMix(a + (len >= 8 ? Fetch(s) : c));
- } else { // len > 16
- c = HashLen16(Fetch(s + len - 8) + k1, a);
- d = HashLen16(b + len, c + Fetch(s + len - 16));
- a += d;
- do {
- a ^= ShiftMix(Fetch(s) * k1) * k1;
- a *= k1;
- b ^= a;
- c ^= ShiftMix(Fetch(s + 8) * k1) * k1;
- c *= k1;
- d ^= c;
- s += 16;
- l -= 16;
- } while (l > 0);
- }
- a = HashLen16(a, c);
- b = HashLen16(d, b);
- return Uint128(a ^ b, HashLen16(b, a));
-}
-
-uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) {
- if (len < 128) {
- return CityMurmur(s, len, seed);
- }
-
- // We expect len >= 128 to be the common case. Keep 56 bytes of state:
- // v, w, x, y, and z.
- pair<uint64_t, uint64_t> v, w;
- uint64_t x = Uint128Low64(seed);
- uint64_t y = Uint128High64(seed);
- uint64_t z = len * k1;
- v.first = Rotate(y ^ k1, 49) * k1 + Fetch(s);
- v.second = Rotate(v.first, 42) * k1 + Fetch(s + 8);
- w.first = Rotate(y + z, 35) * k1 + x;
- w.second = Rotate(x + Fetch(s + 88), 53) * k1;
-
- // This is the same inner loop as CityHash64(), manually unrolled.
- do {
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- s += 64;
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- s += 64;
- len -= 128;
- } while (LIKELY(len >= 128));
- x += Rotate(v.first + z, 49) * k0;
- y = y * k0 + Rotate(w.second, 37);
- z = z * k0 + Rotate(w.first, 27);
- w.first *= 9;
- v.first *= k0;
- // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
- for (size_t tail_done = 0; tail_done < len; ) {
- tail_done += 32;
- y = Rotate(x + y, 42) * k0 + v.second;
- w.first += Fetch(s + len - tail_done + 16);
- x = x * k0 + w.first;
- z += w.second + Fetch(s + len - tail_done);
- w.second += v.first;
- v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
- v.first *= k0;
- }
- // At this point our 56 bytes of state should contain more than
- // enough information for a strong 128-bit hash. We use two
- // different 56-byte-to-8-byte hashes to get a 16-byte final result.
- x = HashLen16(x, v.first);
- y = HashLen16(y + z, w.first);
- return Uint128(HashLen16(x + v.second, w.second) + y,
- HashLen16(x + w.second, y + v.second));
-}
-
-STATIC_INLINE uint128_t CityHash128(const char *s, size_t len) {
- return len >= 16 ?
- CityHash128WithSeed(s + 16, len - 16,
- Uint128(Fetch(s), Fetch(s + 8) + k0)) :
- CityHash128WithSeed(s, len, Uint128(k0, k1));
-}
-
-uint128_t Fingerprint128(const char* s, size_t len) {
- return CityHash128(s, len);
-}
-} // namespace farmhashcc
+#include "common.h"
+
+namespace {
+ #include "farmhashsa.cc"
+}
+
+namespace farmhashcc {
+// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
+// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
+// a seeded 32-bit hash function similar to CityHash32.
+
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len) {
+ uint32_t a = Fetch(s - 4 + (len >> 1));
+ uint32_t b = Fetch(s + 4);
+ uint32_t c = Fetch(s + len - 8);
+ uint32_t d = Fetch(s + (len >> 1));
+ uint32_t e = Fetch(s);
+ uint32_t f = Fetch(s + len - 4);
+ uint32_t h = len;
+
+ return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
+}
+
+STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len) {
+ uint32_t b = 0;
+ uint32_t c = 9;
+ for (size_t i = 0; i < len; i++) {
+ signed char v = s[i];
+ b = b * c1 + v;
+ c ^= b;
+ }
+ return fmix(Mur(b, Mur(len, c)));
+}
+
+STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len) {
+ uint32_t a = len, b = len * 5, c = 9, d = b;
+ a += Fetch(s);
+ b += Fetch(s + len - 4);
+ c += Fetch(s + ((len >> 1) & 4));
+ return fmix(Mur(c, Mur(b, Mur(a, d))));
+}
+
+uint32_t Hash32(const char *s, size_t len) {
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
+ Hash32Len13to24(s, len);
+ }
+
+ // len > 24
+ uint32_t h = len, g = c1 * len, f = g;
+ uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
+ uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
+ uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
+ uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
+ uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
+ h ^= a0;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ h ^= a2;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ g ^= a1;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ g ^= a3;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ f += a4;
+ f = Rotate(f, 19);
+ f = f * 5 + 0xe6546b64;
+ size_t iters = (len - 1) / 20;
+ do {
+ uint32_t a0 = Rotate(Fetch(s) * c1, 17) * c2;
+ uint32_t a1 = Fetch(s + 4);
+ uint32_t a2 = Rotate(Fetch(s + 8) * c1, 17) * c2;
+ uint32_t a3 = Rotate(Fetch(s + 12) * c1, 17) * c2;
+ uint32_t a4 = Fetch(s + 16);
+ h ^= a0;
+ h = Rotate(h, 18);
+ h = h * 5 + 0xe6546b64;
+ f += a1;
+ f = Rotate(f, 19);
+ f = f * c1;
+ g += a2;
+ g = Rotate(g, 18);
+ g = g * 5 + 0xe6546b64;
+ h ^= a3 + a1;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ g ^= a4;
+ g = Bswap(g) * 5;
+ h += a4 * 5;
+ h = Bswap(h);
+ f += a0;
+ PERMUTE3(f, h, g);
+ s += 20;
+ } while (--iters != 0);
+ g = Rotate(g, 11) * c1;
+ g = Rotate(g, 17) * c1;
+ f = Rotate(f, 11) * c1;
+ f = Rotate(f, 17) * c1;
+ h = Rotate(h + g, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ h = Rotate(h + f, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ return h;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
+ else return farmhashmk::Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
+ return Mur(Hash32(s + 24, len - 24) + seed, h);
+}
+
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+#undef Bswap
+#define Bswap Bswap64
+
+STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
+ return val ^ (val >> 47);
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
+ return Hash128to64(Uint128(u, v));
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
+ // Murmur-inspired hashing.
+ uint64_t a = (u ^ v) * mul;
+ a ^= (a >> 47);
+ uint64_t b = (v ^ a) * mul;
+ b ^= (b >> 47);
+ b *= mul;
+ return b;
+}
+
+STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
+ if (len >= 8) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) + k2;
+ uint64_t b = Fetch(s + len - 8);
+ uint64_t c = Rotate(b, 37) * mul + a;
+ uint64_t d = (Rotate(a, 25) + b) * mul;
+ return HashLen16(c, d, mul);
+ }
+ if (len >= 4) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch32(s);
+ return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
+ }
+ if (len > 0) {
+ uint8_t a = s[0];
+ uint8_t b = s[len >> 1];
+ uint8_t c = s[len - 1];
+ uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
+ uint32_t z = len + (static_cast<uint32_t>(c) << 2);
+ return ShiftMix(y * k2 ^ z * k0) * k2;
+ }
+ return k2;
+}
+
+// Return a 16-byte hash for 48 bytes. Quick and dirty.
+// Callers do best to use "random-looking" values for a and b.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
+ a += w;
+ b = Rotate(b + a + z, 21);
+ uint64_t c = a;
+ a += x;
+ a += y;
+ b += Rotate(a, 44);
+ return make_pair(a + z, b + c);
+}
+
+// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ const char* s, uint64_t a, uint64_t b) {
+ return WeakHashLen32WithSeeds(Fetch(s),
+ Fetch(s + 8),
+ Fetch(s + 16),
+ Fetch(s + 24),
+ a,
+ b);
+}
+
+
+
+// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
+// of any length representable in signed long. Based on City and Murmur.
+STATIC_INLINE uint128_t CityMurmur(const char *s, size_t len, uint128_t seed) {
+ uint64_t a = Uint128Low64(seed);
+ uint64_t b = Uint128High64(seed);
+ uint64_t c = 0;
+ uint64_t d = 0;
+ signed long l = len - 16;
+ if (l <= 0) { // len <= 16
+ a = ShiftMix(a * k1) * k1;
+ c = b * k1 + HashLen0to16(s, len);
+ d = ShiftMix(a + (len >= 8 ? Fetch(s) : c));
+ } else { // len > 16
+ c = HashLen16(Fetch(s + len - 8) + k1, a);
+ d = HashLen16(b + len, c + Fetch(s + len - 16));
+ a += d;
+ do {
+ a ^= ShiftMix(Fetch(s) * k1) * k1;
+ a *= k1;
+ b ^= a;
+ c ^= ShiftMix(Fetch(s + 8) * k1) * k1;
+ c *= k1;
+ d ^= c;
+ s += 16;
+ l -= 16;
+ } while (l > 0);
+ }
+ a = HashLen16(a, c);
+ b = HashLen16(d, b);
+ return Uint128(a ^ b, HashLen16(b, a));
+}
+
+uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) {
+ if (len < 128) {
+ return CityMurmur(s, len, seed);
+ }
+
+ // We expect len >= 128 to be the common case. Keep 56 bytes of state:
+ // v, w, x, y, and z.
+ pair<uint64_t, uint64_t> v, w;
+ uint64_t x = Uint128Low64(seed);
+ uint64_t y = Uint128High64(seed);
+ uint64_t z = len * k1;
+ v.first = Rotate(y ^ k1, 49) * k1 + Fetch(s);
+ v.second = Rotate(v.first, 42) * k1 + Fetch(s + 8);
+ w.first = Rotate(y + z, 35) * k1 + x;
+ w.second = Rotate(x + Fetch(s + 88), 53) * k1;
+
+ // This is the same inner loop as CityHash64(), manually unrolled.
+ do {
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ s += 64;
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ s += 64;
+ len -= 128;
+ } while (LIKELY(len >= 128));
+ x += Rotate(v.first + z, 49) * k0;
+ y = y * k0 + Rotate(w.second, 37);
+ z = z * k0 + Rotate(w.first, 27);
+ w.first *= 9;
+ v.first *= k0;
+ // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
+ for (size_t tail_done = 0; tail_done < len; ) {
+ tail_done += 32;
+ y = Rotate(x + y, 42) * k0 + v.second;
+ w.first += Fetch(s + len - tail_done + 16);
+ x = x * k0 + w.first;
+ z += w.second + Fetch(s + len - tail_done);
+ w.second += v.first;
+ v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
+ v.first *= k0;
+ }
+ // At this point our 56 bytes of state should contain more than
+ // enough information for a strong 128-bit hash. We use two
+ // different 56-byte-to-8-byte hashes to get a 16-byte final result.
+ x = HashLen16(x, v.first);
+ y = HashLen16(y + z, w.first);
+ return Uint128(HashLen16(x + v.second, w.second) + y,
+ HashLen16(x + w.second, y + v.second));
+}
+
+STATIC_INLINE uint128_t CityHash128(const char *s, size_t len) {
+ return len >= 16 ?
+ CityHash128WithSeed(s + 16, len - 16,
+ Uint128(Fetch(s), Fetch(s + 8) + k0)) :
+ CityHash128WithSeed(s, len, Uint128(k0, k1));
+}
+
+uint128_t Fingerprint128(const char* s, size_t len) {
+ return CityHash128(s, len);
+}
+} // namespace farmhashcc
diff --git a/contrib/libs/farmhash/farmhashmk.cc b/contrib/libs/farmhash/farmhashmk.cc
index 1f9072f495..2580400292 100644
--- a/contrib/libs/farmhash/farmhashmk.cc
+++ b/contrib/libs/farmhash/farmhashmk.cc
@@ -1,120 +1,120 @@
-#include "common.h"
-
-namespace {
- #include "farmhashnt.cc"
-}
-
-namespace farmhashmk {
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len, uint32_t seed = 0) {
- uint32_t a = Fetch(s - 4 + (len >> 1));
- uint32_t b = Fetch(s + 4);
- uint32_t c = Fetch(s + len - 8);
- uint32_t d = Fetch(s + (len >> 1));
- uint32_t e = Fetch(s);
- uint32_t f = Fetch(s + len - 4);
- uint32_t h = d * c1 + len + seed;
- a = Rotate(a, 12) + f;
- h = Mur(c, h) + a;
- a = Rotate(a, 3) + c;
- h = Mur(e, h) + a;
- a = Rotate(a + f, 12) + d;
- h = Mur(b ^ seed, h) + a;
- return fmix(h);
-}
-
-STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len, uint32_t seed = 0) {
- uint32_t b = seed;
- uint32_t c = 9;
- for (size_t i = 0; i < len; i++) {
- signed char v = s[i];
- b = b * c1 + v;
- c ^= b;
- }
- return fmix(Mur(b, Mur(len, c)));
-}
-
-STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len, uint32_t seed = 0) {
- uint32_t a = len, b = len * 5, c = 9, d = b + seed;
- a += Fetch(s);
- b += Fetch(s + len - 4);
- c += Fetch(s + ((len >> 1) & 4));
- return fmix(seed ^ Mur(c, Mur(b, Mur(a, d))));
-}
-
-uint32_t Hash32(const char *s, size_t len) {
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
- Hash32Len13to24(s, len);
- }
-
- // len > 24
- uint32_t h = len, g = c1 * len, f = g;
- uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
- uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
- uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
- uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
- uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
- h ^= a0;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- h ^= a2;
- h = Rotate(h, 19);
- h = h * 5 + 0xe6546b64;
- g ^= a1;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- g ^= a3;
- g = Rotate(g, 19);
- g = g * 5 + 0xe6546b64;
- f += a4;
- f = Rotate(f, 19) + 113;
- size_t iters = (len - 1) / 20;
- do {
- uint32_t a = Fetch(s);
- uint32_t b = Fetch(s + 4);
- uint32_t c = Fetch(s + 8);
- uint32_t d = Fetch(s + 12);
- uint32_t e = Fetch(s + 16);
- h += a;
- g += b;
- f += c;
- h = Mur(d, h) + e;
- g = Mur(c, g) + a;
- f = Mur(b + e * c1, f) + d;
- f += g;
- g += f;
- s += 20;
- } while (--iters != 0);
- g = Rotate(g, 11) * c1;
- g = Rotate(g, 17) * c1;
- f = Rotate(f, 11) * c1;
- f = Rotate(f, 17) * c1;
- h = Rotate(h + g, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- h = Rotate(h + f, 19);
- h = h * 5 + 0xe6546b64;
- h = Rotate(h, 17) * c1;
- return h;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return Hash32Len5to12(s, len, seed);
- else return Hash32Len0to4(s, len, seed);
- }
- uint32_t h = Hash32Len13to24(s, 24, seed ^ len);
- return Mur(Hash32(s + 24, len - 24) + seed, h);
-}
-} // namespace farmhashmk
+#include "common.h"
+
+namespace {
+ #include "farmhashnt.cc"
+}
+
+namespace farmhashmk {
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len, uint32_t seed = 0) {
+ uint32_t a = Fetch(s - 4 + (len >> 1));
+ uint32_t b = Fetch(s + 4);
+ uint32_t c = Fetch(s + len - 8);
+ uint32_t d = Fetch(s + (len >> 1));
+ uint32_t e = Fetch(s);
+ uint32_t f = Fetch(s + len - 4);
+ uint32_t h = d * c1 + len + seed;
+ a = Rotate(a, 12) + f;
+ h = Mur(c, h) + a;
+ a = Rotate(a, 3) + c;
+ h = Mur(e, h) + a;
+ a = Rotate(a + f, 12) + d;
+ h = Mur(b ^ seed, h) + a;
+ return fmix(h);
+}
+
+STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len, uint32_t seed = 0) {
+ uint32_t b = seed;
+ uint32_t c = 9;
+ for (size_t i = 0; i < len; i++) {
+ signed char v = s[i];
+ b = b * c1 + v;
+ c ^= b;
+ }
+ return fmix(Mur(b, Mur(len, c)));
+}
+
+STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len, uint32_t seed = 0) {
+ uint32_t a = len, b = len * 5, c = 9, d = b + seed;
+ a += Fetch(s);
+ b += Fetch(s + len - 4);
+ c += Fetch(s + ((len >> 1) & 4));
+ return fmix(seed ^ Mur(c, Mur(b, Mur(a, d))));
+}
+
+uint32_t Hash32(const char *s, size_t len) {
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
+ Hash32Len13to24(s, len);
+ }
+
+ // len > 24
+ uint32_t h = len, g = c1 * len, f = g;
+ uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
+ uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
+ uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
+ uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
+ uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
+ h ^= a0;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ h ^= a2;
+ h = Rotate(h, 19);
+ h = h * 5 + 0xe6546b64;
+ g ^= a1;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ g ^= a3;
+ g = Rotate(g, 19);
+ g = g * 5 + 0xe6546b64;
+ f += a4;
+ f = Rotate(f, 19) + 113;
+ size_t iters = (len - 1) / 20;
+ do {
+ uint32_t a = Fetch(s);
+ uint32_t b = Fetch(s + 4);
+ uint32_t c = Fetch(s + 8);
+ uint32_t d = Fetch(s + 12);
+ uint32_t e = Fetch(s + 16);
+ h += a;
+ g += b;
+ f += c;
+ h = Mur(d, h) + e;
+ g = Mur(c, g) + a;
+ f = Mur(b + e * c1, f) + d;
+ f += g;
+ g += f;
+ s += 20;
+ } while (--iters != 0);
+ g = Rotate(g, 11) * c1;
+ g = Rotate(g, 17) * c1;
+ f = Rotate(f, 11) * c1;
+ f = Rotate(f, 17) * c1;
+ h = Rotate(h + g, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ h = Rotate(h + f, 19);
+ h = h * 5 + 0xe6546b64;
+ h = Rotate(h, 17) * c1;
+ return h;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return Hash32Len5to12(s, len, seed);
+ else return Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = Hash32Len13to24(s, 24, seed ^ len);
+ return Mur(Hash32(s + 24, len - 24) + seed, h);
+}
+} // namespace farmhashmk
diff --git a/contrib/libs/farmhash/farmhashna.cc b/contrib/libs/farmhash/farmhashna.cc
index a2941aa535..76ef2a3168 100644
--- a/contrib/libs/farmhash/farmhashna.cc
+++ b/contrib/libs/farmhash/farmhashna.cc
@@ -1,173 +1,173 @@
-#include "common.h"
-
-namespace farmhashna {
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-#undef Bswap
-#define Bswap Bswap64
-
-STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
- return val ^ (val >> 47);
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
- return Hash128to64(Uint128(u, v));
-}
-
-STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
- // Murmur-inspired hashing.
- uint64_t a = (u ^ v) * mul;
- a ^= (a >> 47);
- uint64_t b = (v ^ a) * mul;
- b ^= (b >> 47);
- b *= mul;
- return b;
-}
-
-STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
- if (len >= 8) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) + k2;
- uint64_t b = Fetch(s + len - 8);
- uint64_t c = Rotate(b, 37) * mul + a;
- uint64_t d = (Rotate(a, 25) + b) * mul;
- return HashLen16(c, d, mul);
- }
- if (len >= 4) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch32(s);
- return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
- }
- if (len > 0) {
- uint8_t a = s[0];
- uint8_t b = s[len >> 1];
- uint8_t c = s[len - 1];
- uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
- uint32_t z = len + (static_cast<uint32_t>(c) << 2);
- return ShiftMix(y * k2 ^ z * k0) * k2;
- }
- return k2;
-}
-
-// This probably works well for 16-byte strings as well, but it may be overkill
-// in that case.
-STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) * k1;
- uint64_t b = Fetch(s + 8);
- uint64_t c = Fetch(s + len - 8) * mul;
- uint64_t d = Fetch(s + len - 16) * k2;
- return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
- a + Rotate(b + k2, 18) + c, mul);
-}
-
-// Return a 16-byte hash for 48 bytes. Quick and dirty.
-// Callers do best to use "random-looking" values for a and b.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
- a += w;
- b = Rotate(b + a + z, 21);
- uint64_t c = a;
- a += x;
- a += y;
- b += Rotate(a, 44);
- return make_pair(a + z, b + c);
-}
-
-// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
- const char* s, uint64_t a, uint64_t b) {
- return WeakHashLen32WithSeeds(Fetch(s),
- Fetch(s + 8),
- Fetch(s + 16),
- Fetch(s + 24),
- a,
- b);
-}
-
-// Return an 8-byte hash for 33 to 64 bytes.
-STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
- uint64_t mul = k2 + len * 2;
- uint64_t a = Fetch(s) * k2;
- uint64_t b = Fetch(s + 8);
- uint64_t c = Fetch(s + len - 8) * mul;
- uint64_t d = Fetch(s + len - 16) * k2;
- uint64_t y = Rotate(a + b, 43) + Rotate(c, 30) + d;
- uint64_t z = HashLen16(y, a + Rotate(b + k2, 18) + c, mul);
- uint64_t e = Fetch(s + 16) * mul;
- uint64_t f = Fetch(s + 24);
- uint64_t g = (y + Fetch(s + len - 32)) * mul;
- uint64_t h = (z + Fetch(s + len - 24)) * mul;
- return HashLen16(Rotate(e + f, 43) + Rotate(g, 30) + h,
- e + Rotate(f + a, 18) + g, mul);
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- const uint64_t seed = 81;
- if (len <= 32) {
- if (len <= 16) {
- return HashLen0to16(s, len);
- } else {
- return HashLen17to32(s, len);
- }
- } else if (len <= 64) {
- return HashLen33to64(s, len);
- }
-
- // For strings over 64 bytes we loop. Internal state consists of
- // 56 bytes: v, w, x, y, and z.
- uint64_t x = seed;
- uint64_t y = seed * k1 + 113;
- uint64_t z = ShiftMix(y * k2 + 113) * k2;
- pair<uint64_t, uint64_t> v = make_pair(0, 0);
- pair<uint64_t, uint64_t> w = make_pair(0, 0);
- x = x * k2 + Fetch(s);
-
- // Set end so that after the loop we have 1 to 64 bytes left to process.
- const char* end = s + ((len - 1) / 64) * 64;
- const char* last64 = end + ((len - 1) & 63) - 63;
- assert(s + len - 64 == last64);
- do {
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- s += 64;
- } while (s != end);
- uint64_t mul = k1 + ((z & 0xff) << 1);
- // Make s point to the last 64 bytes of input.
- s = last64;
- w.first += ((len - 1) & 63);
- v.first += w.first;
- w.first += v.first;
- x = Rotate(x + y + v.first + Fetch(s + 8), 37) * mul;
- y = Rotate(y + v.second + Fetch(s + 48), 42) * mul;
- x ^= w.second * 9;
- y += v.first * 9 + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * mul;
- v = WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
- w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- std::swap(z, x);
- return HashLen16(HashLen16(v.first, w.first, mul) + ShiftMix(y) * k0 + z,
- HashLen16(v.second, w.second, mul) + x,
- mul);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1);
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return Hash64WithSeeds(s, len, k2, seed);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
- return HashLen16(Hash64(s, len) - seed0, seed1);
-}
-} // namespace farmhashna
+#include "common.h"
+
+namespace farmhashna {
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+#undef Bswap
+#define Bswap Bswap64
+
+STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
+ return val ^ (val >> 47);
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
+ return Hash128to64(Uint128(u, v));
+}
+
+STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
+ // Murmur-inspired hashing.
+ uint64_t a = (u ^ v) * mul;
+ a ^= (a >> 47);
+ uint64_t b = (v ^ a) * mul;
+ b ^= (b >> 47);
+ b *= mul;
+ return b;
+}
+
+STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
+ if (len >= 8) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) + k2;
+ uint64_t b = Fetch(s + len - 8);
+ uint64_t c = Rotate(b, 37) * mul + a;
+ uint64_t d = (Rotate(a, 25) + b) * mul;
+ return HashLen16(c, d, mul);
+ }
+ if (len >= 4) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch32(s);
+ return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
+ }
+ if (len > 0) {
+ uint8_t a = s[0];
+ uint8_t b = s[len >> 1];
+ uint8_t c = s[len - 1];
+ uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
+ uint32_t z = len + (static_cast<uint32_t>(c) << 2);
+ return ShiftMix(y * k2 ^ z * k0) * k2;
+ }
+ return k2;
+}
+
+// This probably works well for 16-byte strings as well, but it may be overkill
+// in that case.
+STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) * k1;
+ uint64_t b = Fetch(s + 8);
+ uint64_t c = Fetch(s + len - 8) * mul;
+ uint64_t d = Fetch(s + len - 16) * k2;
+ return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
+ a + Rotate(b + k2, 18) + c, mul);
+}
+
+// Return a 16-byte hash for 48 bytes. Quick and dirty.
+// Callers do best to use "random-looking" values for a and b.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
+ a += w;
+ b = Rotate(b + a + z, 21);
+ uint64_t c = a;
+ a += x;
+ a += y;
+ b += Rotate(a, 44);
+ return make_pair(a + z, b + c);
+}
+
+// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
+STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+ const char* s, uint64_t a, uint64_t b) {
+ return WeakHashLen32WithSeeds(Fetch(s),
+ Fetch(s + 8),
+ Fetch(s + 16),
+ Fetch(s + 24),
+ a,
+ b);
+}
+
+// Return an 8-byte hash for 33 to 64 bytes.
+STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
+ uint64_t mul = k2 + len * 2;
+ uint64_t a = Fetch(s) * k2;
+ uint64_t b = Fetch(s + 8);
+ uint64_t c = Fetch(s + len - 8) * mul;
+ uint64_t d = Fetch(s + len - 16) * k2;
+ uint64_t y = Rotate(a + b, 43) + Rotate(c, 30) + d;
+ uint64_t z = HashLen16(y, a + Rotate(b + k2, 18) + c, mul);
+ uint64_t e = Fetch(s + 16) * mul;
+ uint64_t f = Fetch(s + 24);
+ uint64_t g = (y + Fetch(s + len - 32)) * mul;
+ uint64_t h = (z + Fetch(s + len - 24)) * mul;
+ return HashLen16(Rotate(e + f, 43) + Rotate(g, 30) + h,
+ e + Rotate(f + a, 18) + g, mul);
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ const uint64_t seed = 81;
+ if (len <= 32) {
+ if (len <= 16) {
+ return HashLen0to16(s, len);
+ } else {
+ return HashLen17to32(s, len);
+ }
+ } else if (len <= 64) {
+ return HashLen33to64(s, len);
+ }
+
+ // For strings over 64 bytes we loop. Internal state consists of
+ // 56 bytes: v, w, x, y, and z.
+ uint64_t x = seed;
+ uint64_t y = seed * k1 + 113;
+ uint64_t z = ShiftMix(y * k2 + 113) * k2;
+ pair<uint64_t, uint64_t> v = make_pair(0, 0);
+ pair<uint64_t, uint64_t> w = make_pair(0, 0);
+ x = x * k2 + Fetch(s);
+
+ // Set end so that after the loop we have 1 to 64 bytes left to process.
+ const char* end = s + ((len - 1) / 64) * 64;
+ const char* last64 = end + ((len - 1) & 63) - 63;
+ assert(s + len - 64 == last64);
+ do {
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ s += 64;
+ } while (s != end);
+ uint64_t mul = k1 + ((z & 0xff) << 1);
+ // Make s point to the last 64 bytes of input.
+ s = last64;
+ w.first += ((len - 1) & 63);
+ v.first += w.first;
+ w.first += v.first;
+ x = Rotate(x + y + v.first + Fetch(s + 8), 37) * mul;
+ y = Rotate(y + v.second + Fetch(s + 48), 42) * mul;
+ x ^= w.second * 9;
+ y += v.first * 9 + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * mul;
+ v = WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ std::swap(z, x);
+ return HashLen16(HashLen16(v.first, w.first, mul) + ShiftMix(y) * k0 + z,
+ HashLen16(v.second, w.second, mul) + x,
+ mul);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1);
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return Hash64WithSeeds(s, len, k2, seed);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return HashLen16(Hash64(s, len) - seed0, seed1);
+}
+} // namespace farmhashna
diff --git a/contrib/libs/farmhash/farmhashnt.cc b/contrib/libs/farmhash/farmhashnt.cc
index 836ccfcc85..d397ad38fb 100644
--- a/contrib/libs/farmhash/farmhashnt.cc
+++ b/contrib/libs/farmhash/farmhashnt.cc
@@ -1,31 +1,31 @@
-#include "common.h"
-
-namespace {
- #include "farmhashte.cc"
-}
-
-namespace farmhashnt {
-#if !can_use_sse41 || !x86_64
-
-uint32_t Hash32(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash32(s, len);
-}
-
-#else
-
-uint32_t Hash32(const char *s, size_t len) {
- return static_cast<uint32_t>(farmhashte::Hash64(s, len));
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- return static_cast<uint32_t>(farmhashte::Hash64WithSeed(s, len, seed));
-}
-
-#endif
-} // namespace farmhashnt
+#include "common.h"
+
+namespace {
+ #include "farmhashte.cc"
+}
+
+namespace farmhashnt {
+#if !can_use_sse41 || !x86_64
+
+uint32_t Hash32(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash32(s, len);
+}
+
+#else
+
+uint32_t Hash32(const char *s, size_t len) {
+ return static_cast<uint32_t>(farmhashte::Hash64(s, len));
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ return static_cast<uint32_t>(farmhashte::Hash64WithSeed(s, len, seed));
+}
+
+#endif
+} // namespace farmhashnt
diff --git a/contrib/libs/farmhash/farmhashsa.cc b/contrib/libs/farmhash/farmhashsa.cc
index aa1c24b55b..e6571cbb9a 100644
--- a/contrib/libs/farmhash/farmhashsa.cc
+++ b/contrib/libs/farmhash/farmhashsa.cc
@@ -1,216 +1,216 @@
-#include "common.h"
-
-namespace {
- #include "farmhashsu.cc"
-}
-
-namespace farmhashsa {
-#if !can_use_sse42
-
-uint32_t Hash32(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash32(s, len);
-}
-
-#else
-
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-// Helpers for data-parallel operations (4x 32-bits).
-STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
-STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
-STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
-STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
-STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
-STATIC_INLINE __m128i Rotate(__m128i x, int c) {
- return Or(_mm_slli_epi32(x, c),
- _mm_srli_epi32(x, 32 - c));
-}
-STATIC_INLINE __m128i Rot17(__m128i x) { return Rotate(x, 17); }
-STATIC_INLINE __m128i Rot19(__m128i x) { return Rotate(x, 19); }
-STATIC_INLINE __m128i Shuffle0321(__m128i x) {
- return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
-}
-
-uint32_t Hash32(const char *s, size_t len) {
- const uint32_t seed = 81;
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ?
- farmhashmk::Hash32Len0to4(s, len) :
- farmhashmk::Hash32Len5to12(s, len)) :
- farmhashmk::Hash32Len13to24(s, len);
- }
-
- if (len < 40) {
- uint32_t a = len, b = seed * c2, c = a + b;
- a += Fetch(s + len - 4);
- b += Fetch(s + len - 20);
- c += Fetch(s + len - 16);
- uint32_t d = a;
- a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
- a = Mur(a, Mur(b, Mur(c, d)));
- a += Fetch(s + len - 12);
- b += Fetch(s + len - 8);
- d += a;
- a += d;
- b = Mur(b, d) * c2;
- a = _mm_crc32_u32(a, b + c);
- return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
- }
-
-#undef Mulc1
-#define Mulc1(x) Mul((x), cc1)
-
-#undef Mulc2
-#define Mulc2(x) Mul((x), cc2)
-
-#undef Murk
-#define Murk(a, h) \
- Add(k, \
- Mul5( \
- Rot19( \
- Xor( \
- Mulc2( \
- Rot17( \
- Mulc1(a))), \
- (h)))))
-
- const __m128i cc1 = _mm_set1_epi32(c1);
- const __m128i cc2 = _mm_set1_epi32(c2);
- __m128i h = _mm_set1_epi32(seed);
- __m128i g = _mm_set1_epi32(c1 * seed);
- __m128i f = g;
- __m128i k = _mm_set1_epi32(0xe6546b64);
- if (len < 80) {
- __m128i a = Fetch128(s);
- __m128i b = Fetch128(s + 16);
- __m128i c = Fetch128(s + (len - 15) / 2);
- __m128i d = Fetch128(s + len - 32);
- __m128i e = Fetch128(s + len - 16);
- h = Add(h, a);
- g = Add(g, b);
- g = Shuffle0321(g);
- f = Add(f, c);
- __m128i be = Add(b, Mulc1(e));
- h = Add(h, f);
- f = Add(f, h);
- h = Add(Murk(d, h), e);
- k = Xor(k, _mm_shuffle_epi8(g, f));
- g = Add(Xor(c, g), a);
- f = Add(Xor(be, f), d);
- k = Add(k, be);
- k = Add(k, _mm_shuffle_epi8(f, h));
- f = Add(f, g);
- g = Add(g, f);
- g = Add(_mm_set1_epi32(len), Mulc1(g));
- } else {
- // len >= 80
- // The following is loosely modelled after farmhashmk::Hash32.
- size_t iters = (len - 1) / 80;
- len -= iters * 80;
-
-#undef Chunk
-#define Chunk() do { \
- __m128i a = Fetch128(s); \
- __m128i b = Fetch128(s + 16); \
- __m128i c = Fetch128(s + 32); \
- __m128i d = Fetch128(s + 48); \
- __m128i e = Fetch128(s + 64); \
- h = Add(h, a); \
- g = Add(g, b); \
- g = Shuffle0321(g); \
- f = Add(f, c); \
- __m128i be = Add(b, Mulc1(e)); \
- h = Add(h, f); \
- f = Add(f, h); \
- h = Add(Murk(d, h), e); \
- k = Xor(k, _mm_shuffle_epi8(g, f)); \
- g = Add(Xor(c, g), a); \
- f = Add(Xor(be, f), d); \
- k = Add(k, be); \
- k = Add(k, _mm_shuffle_epi8(f, h)); \
- f = Add(f, g); \
- g = Add(g, f); \
- f = Mulc1(f); \
-} while (0)
-
- while (iters-- != 0) {
- Chunk();
- s += 80;
- }
-
- if (len != 0) {
- h = Add(h, _mm_set1_epi32(len));
- s = s + len - 80;
- Chunk();
- }
- }
-
- g = Shuffle0321(g);
- k = Xor(k, g);
- f = Mulc1(f);
- k = Mulc2(k);
- g = Mulc1(g);
- h = Mulc2(h);
- k = Add(k, _mm_shuffle_epi8(g, f));
- h = Add(h, f);
- f = Add(f, h);
- g = Add(g, k);
- k = Add(k, g);
- k = Xor(k, _mm_shuffle_epi8(f, h));
- __m128i buf[4];
- buf[0] = f;
- buf[1] = g;
- buf[2] = k;
- buf[3] = h;
- s = reinterpret_cast<char*>(buf);
- uint32_t x = Fetch(s);
- uint32_t y = Fetch(s+4);
- uint32_t z = Fetch(s+8);
- x = _mm_crc32_u32(x, Fetch(s+12));
- y = _mm_crc32_u32(y, Fetch(s+16));
- z = _mm_crc32_u32(z * c1, Fetch(s+20));
- x = _mm_crc32_u32(x, Fetch(s+24));
- y = _mm_crc32_u32(y * c1, Fetch(s+28));
- uint32_t o = y;
- z = _mm_crc32_u32(z, Fetch(s+32));
- x = _mm_crc32_u32(x * c1, Fetch(s+36));
- y = _mm_crc32_u32(y, Fetch(s+40));
- z = _mm_crc32_u32(z * c1, Fetch(s+44));
- x = _mm_crc32_u32(x, Fetch(s+48));
- y = _mm_crc32_u32(y * c1, Fetch(s+52));
- z = _mm_crc32_u32(z, Fetch(s+56));
- x = _mm_crc32_u32(x, Fetch(s+60));
- return (o - x + y - z) * c1;
-}
-
-#undef Chunk
-#undef Murk
-#undef Mulc2
-#undef Mulc1
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
- else return farmhashmk::Hash32Len0to4(s, len, seed);
- }
- uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
- return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
-}
-
-#endif
-} // namespace farmhashsa
+#include "common.h"
+
+namespace {
+ #include "farmhashsu.cc"
+}
+
+namespace farmhashsa {
+#if !can_use_sse42
+
+uint32_t Hash32(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash32(s, len);
+}
+
+#else
+
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+// Helpers for data-parallel operations (4x 32-bits).
+STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
+STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
+STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
+STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
+STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
+STATIC_INLINE __m128i Rotate(__m128i x, int c) {
+ return Or(_mm_slli_epi32(x, c),
+ _mm_srli_epi32(x, 32 - c));
+}
+STATIC_INLINE __m128i Rot17(__m128i x) { return Rotate(x, 17); }
+STATIC_INLINE __m128i Rot19(__m128i x) { return Rotate(x, 19); }
+STATIC_INLINE __m128i Shuffle0321(__m128i x) {
+ return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
+}
+
+uint32_t Hash32(const char *s, size_t len) {
+ const uint32_t seed = 81;
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ?
+ farmhashmk::Hash32Len0to4(s, len) :
+ farmhashmk::Hash32Len5to12(s, len)) :
+ farmhashmk::Hash32Len13to24(s, len);
+ }
+
+ if (len < 40) {
+ uint32_t a = len, b = seed * c2, c = a + b;
+ a += Fetch(s + len - 4);
+ b += Fetch(s + len - 20);
+ c += Fetch(s + len - 16);
+ uint32_t d = a;
+ a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
+ a = Mur(a, Mur(b, Mur(c, d)));
+ a += Fetch(s + len - 12);
+ b += Fetch(s + len - 8);
+ d += a;
+ a += d;
+ b = Mur(b, d) * c2;
+ a = _mm_crc32_u32(a, b + c);
+ return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
+ }
+
+#undef Mulc1
+#define Mulc1(x) Mul((x), cc1)
+
+#undef Mulc2
+#define Mulc2(x) Mul((x), cc2)
+
+#undef Murk
+#define Murk(a, h) \
+ Add(k, \
+ Mul5( \
+ Rot19( \
+ Xor( \
+ Mulc2( \
+ Rot17( \
+ Mulc1(a))), \
+ (h)))))
+
+ const __m128i cc1 = _mm_set1_epi32(c1);
+ const __m128i cc2 = _mm_set1_epi32(c2);
+ __m128i h = _mm_set1_epi32(seed);
+ __m128i g = _mm_set1_epi32(c1 * seed);
+ __m128i f = g;
+ __m128i k = _mm_set1_epi32(0xe6546b64);
+ if (len < 80) {
+ __m128i a = Fetch128(s);
+ __m128i b = Fetch128(s + 16);
+ __m128i c = Fetch128(s + (len - 15) / 2);
+ __m128i d = Fetch128(s + len - 32);
+ __m128i e = Fetch128(s + len - 16);
+ h = Add(h, a);
+ g = Add(g, b);
+ g = Shuffle0321(g);
+ f = Add(f, c);
+ __m128i be = Add(b, Mulc1(e));
+ h = Add(h, f);
+ f = Add(f, h);
+ h = Add(Murk(d, h), e);
+ k = Xor(k, _mm_shuffle_epi8(g, f));
+ g = Add(Xor(c, g), a);
+ f = Add(Xor(be, f), d);
+ k = Add(k, be);
+ k = Add(k, _mm_shuffle_epi8(f, h));
+ f = Add(f, g);
+ g = Add(g, f);
+ g = Add(_mm_set1_epi32(len), Mulc1(g));
+ } else {
+ // len >= 80
+ // The following is loosely modelled after farmhashmk::Hash32.
+ size_t iters = (len - 1) / 80;
+ len -= iters * 80;
+
+#undef Chunk
+#define Chunk() do { \
+ __m128i a = Fetch128(s); \
+ __m128i b = Fetch128(s + 16); \
+ __m128i c = Fetch128(s + 32); \
+ __m128i d = Fetch128(s + 48); \
+ __m128i e = Fetch128(s + 64); \
+ h = Add(h, a); \
+ g = Add(g, b); \
+ g = Shuffle0321(g); \
+ f = Add(f, c); \
+ __m128i be = Add(b, Mulc1(e)); \
+ h = Add(h, f); \
+ f = Add(f, h); \
+ h = Add(Murk(d, h), e); \
+ k = Xor(k, _mm_shuffle_epi8(g, f)); \
+ g = Add(Xor(c, g), a); \
+ f = Add(Xor(be, f), d); \
+ k = Add(k, be); \
+ k = Add(k, _mm_shuffle_epi8(f, h)); \
+ f = Add(f, g); \
+ g = Add(g, f); \
+ f = Mulc1(f); \
+} while (0)
+
+ while (iters-- != 0) {
+ Chunk();
+ s += 80;
+ }
+
+ if (len != 0) {
+ h = Add(h, _mm_set1_epi32(len));
+ s = s + len - 80;
+ Chunk();
+ }
+ }
+
+ g = Shuffle0321(g);
+ k = Xor(k, g);
+ f = Mulc1(f);
+ k = Mulc2(k);
+ g = Mulc1(g);
+ h = Mulc2(h);
+ k = Add(k, _mm_shuffle_epi8(g, f));
+ h = Add(h, f);
+ f = Add(f, h);
+ g = Add(g, k);
+ k = Add(k, g);
+ k = Xor(k, _mm_shuffle_epi8(f, h));
+ __m128i buf[4];
+ buf[0] = f;
+ buf[1] = g;
+ buf[2] = k;
+ buf[3] = h;
+ s = reinterpret_cast<char*>(buf);
+ uint32_t x = Fetch(s);
+ uint32_t y = Fetch(s+4);
+ uint32_t z = Fetch(s+8);
+ x = _mm_crc32_u32(x, Fetch(s+12));
+ y = _mm_crc32_u32(y, Fetch(s+16));
+ z = _mm_crc32_u32(z * c1, Fetch(s+20));
+ x = _mm_crc32_u32(x, Fetch(s+24));
+ y = _mm_crc32_u32(y * c1, Fetch(s+28));
+ uint32_t o = y;
+ z = _mm_crc32_u32(z, Fetch(s+32));
+ x = _mm_crc32_u32(x * c1, Fetch(s+36));
+ y = _mm_crc32_u32(y, Fetch(s+40));
+ z = _mm_crc32_u32(z * c1, Fetch(s+44));
+ x = _mm_crc32_u32(x, Fetch(s+48));
+ y = _mm_crc32_u32(y * c1, Fetch(s+52));
+ z = _mm_crc32_u32(z, Fetch(s+56));
+ x = _mm_crc32_u32(x, Fetch(s+60));
+ return (o - x + y - z) * c1;
+}
+
+#undef Chunk
+#undef Murk
+#undef Mulc2
+#undef Mulc1
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
+ else return farmhashmk::Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
+ return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
+}
+
+#endif
+} // namespace farmhashsa
diff --git a/contrib/libs/farmhash/farmhashsu.cc b/contrib/libs/farmhash/farmhashsu.cc
index 49b48d5f3c..319ac35912 100644
--- a/contrib/libs/farmhash/farmhashsu.cc
+++ b/contrib/libs/farmhash/farmhashsu.cc
@@ -1,226 +1,226 @@
-#include "common.h"
-
-namespace {
- #include "farmhashmk.cc"
-}
-
-namespace farmhashsu {
-#if !can_use_sse42 || !can_use_aesni
-
-uint32_t Hash32(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash32(s, len);
-}
-
-#else
-
-#undef Fetch
-#define Fetch Fetch32
-
-#undef Rotate
-#define Rotate Rotate32
-
-#undef Bswap
-#define Bswap Bswap32
-
-// Helpers for data-parallel operations (4x 32-bits).
-STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
-STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
-STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
-STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
-STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
-STATIC_INLINE __m128i RotateLeft(__m128i x, int c) {
- return Or(_mm_slli_epi32(x, c),
- _mm_srli_epi32(x, 32 - c));
-}
-STATIC_INLINE __m128i Rol17(__m128i x) { return RotateLeft(x, 17); }
-STATIC_INLINE __m128i Rol19(__m128i x) { return RotateLeft(x, 19); }
-STATIC_INLINE __m128i Shuffle0321(__m128i x) {
- return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
-}
-
-uint32_t Hash32(const char *s, size_t len) {
- const uint32_t seed = 81;
- if (len <= 24) {
- return len <= 12 ?
- (len <= 4 ?
- farmhashmk::Hash32Len0to4(s, len) :
- farmhashmk::Hash32Len5to12(s, len)) :
- farmhashmk::Hash32Len13to24(s, len);
- }
-
- if (len < 40) {
- uint32_t a = len, b = seed * c2, c = a + b;
- a += Fetch(s + len - 4);
- b += Fetch(s + len - 20);
- c += Fetch(s + len - 16);
- uint32_t d = a;
- a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
- a = Mur(a, Mur(b, _mm_crc32_u32(c, d)));
- a += Fetch(s + len - 12);
- b += Fetch(s + len - 8);
- d += a;
- a += d;
- b = Mur(b, d) * c2;
- a = _mm_crc32_u32(a, b + c);
- return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
- }
-
-#undef Mulc1
-#define Mulc1(x) Mul((x), cc1)
-
-#undef Mulc2
-#define Mulc2(x) Mul((x), cc2)
-
-#undef Murk
-#define Murk(a, h) \
- Add(k, \
- Mul5( \
- Rol19( \
- Xor( \
- Mulc2( \
- Rol17( \
- Mulc1(a))), \
- (h)))))
-
- const __m128i cc1 = _mm_set1_epi32(c1);
- const __m128i cc2 = _mm_set1_epi32(c2);
- __m128i h = _mm_set1_epi32(seed);
- __m128i g = _mm_set1_epi32(c1 * seed);
- __m128i f = g;
- __m128i k = _mm_set1_epi32(0xe6546b64);
- __m128i q;
- if (len < 80) {
- __m128i a = Fetch128(s);
- __m128i b = Fetch128(s + 16);
- __m128i c = Fetch128(s + (len - 15) / 2);
- __m128i d = Fetch128(s + len - 32);
- __m128i e = Fetch128(s + len - 16);
- h = Add(h, a);
- g = Add(g, b);
- q = g;
- g = Shuffle0321(g);
- f = Add(f, c);
- __m128i be = Add(b, Mulc1(e));
- h = Add(h, f);
- f = Add(f, h);
- h = Add(Murk(d, h), e);
- k = Xor(k, _mm_shuffle_epi8(g, f));
- g = Add(Xor(c, g), a);
- f = Add(Xor(be, f), d);
- k = Add(k, be);
- k = Add(k, _mm_shuffle_epi8(f, h));
- f = Add(f, g);
- g = Add(g, f);
- g = Add(_mm_set1_epi32(len), Mulc1(g));
- } else {
- // len >= 80
- // The following is loosely modelled after farmhashmk::Hash32.
- size_t iters = (len - 1) / 80;
- len -= iters * 80;
-
-#undef Chunk
-#define Chunk() do { \
- __m128i a = Fetch128(s); \
- __m128i b = Fetch128(s + 16); \
- __m128i c = Fetch128(s + 32); \
- __m128i d = Fetch128(s + 48); \
- __m128i e = Fetch128(s + 64); \
- h = Add(h, a); \
- g = Add(g, b); \
- g = Shuffle0321(g); \
- f = Add(f, c); \
- __m128i be = Add(b, Mulc1(e)); \
- h = Add(h, f); \
- f = Add(f, h); \
- h = Add(h, d); \
- q = Add(q, e); \
- h = Rol17(h); \
- h = Mulc1(h); \
- k = Xor(k, _mm_shuffle_epi8(g, f)); \
- g = Add(Xor(c, g), a); \
- f = Add(Xor(be, f), d); \
- std::swap(f, q); \
- q = _mm_aesimc_si128(q); \
- k = Add(k, be); \
- k = Add(k, _mm_shuffle_epi8(f, h)); \
- f = Add(f, g); \
- g = Add(g, f); \
- f = Mulc1(f); \
-} while (0)
-
- q = g;
- while (iters-- != 0) {
- Chunk();
- s += 80;
- }
-
- if (len != 0) {
- h = Add(h, _mm_set1_epi32(len));
- s = s + len - 80;
- Chunk();
- }
- }
-
- g = Shuffle0321(g);
- k = Xor(k, g);
- k = Xor(k, q);
- h = Xor(h, q);
- f = Mulc1(f);
- k = Mulc2(k);
- g = Mulc1(g);
- h = Mulc2(h);
- k = Add(k, _mm_shuffle_epi8(g, f));
- h = Add(h, f);
- f = Add(f, h);
- g = Add(g, k);
- k = Add(k, g);
- k = Xor(k, _mm_shuffle_epi8(f, h));
- __m128i buf[4];
- buf[0] = f;
- buf[1] = g;
- buf[2] = k;
- buf[3] = h;
- s = reinterpret_cast<char*>(buf);
- uint32_t x = Fetch(s);
- uint32_t y = Fetch(s+4);
- uint32_t z = Fetch(s+8);
- x = _mm_crc32_u32(x, Fetch(s+12));
- y = _mm_crc32_u32(y, Fetch(s+16));
- z = _mm_crc32_u32(z * c1, Fetch(s+20));
- x = _mm_crc32_u32(x, Fetch(s+24));
- y = _mm_crc32_u32(y * c1, Fetch(s+28));
- uint32_t o = y;
- z = _mm_crc32_u32(z, Fetch(s+32));
- x = _mm_crc32_u32(x * c1, Fetch(s+36));
- y = _mm_crc32_u32(y, Fetch(s+40));
- z = _mm_crc32_u32(z * c1, Fetch(s+44));
- x = _mm_crc32_u32(x, Fetch(s+48));
- y = _mm_crc32_u32(y * c1, Fetch(s+52));
- z = _mm_crc32_u32(z, Fetch(s+56));
- x = _mm_crc32_u32(x, Fetch(s+60));
- return (o - x + y - z) * c1;
-}
-
-#undef Chunk
-#undef Murk
-#undef Mulc2
-#undef Mulc1
-
-uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
- if (len <= 24) {
- if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
- else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
- else return farmhashmk::Hash32Len0to4(s, len, seed);
- }
- uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
- return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
-}
-
-#endif
-} // namespace farmhashsu
+#include "common.h"
+
+namespace {
+ #include "farmhashmk.cc"
+}
+
+namespace farmhashsu {
+#if !can_use_sse42 || !can_use_aesni
+
+uint32_t Hash32(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash32(s, len);
+}
+
+#else
+
+#undef Fetch
+#define Fetch Fetch32
+
+#undef Rotate
+#define Rotate Rotate32
+
+#undef Bswap
+#define Bswap Bswap32
+
+// Helpers for data-parallel operations (4x 32-bits).
+STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
+STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
+STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
+STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
+STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
+STATIC_INLINE __m128i RotateLeft(__m128i x, int c) {
+ return Or(_mm_slli_epi32(x, c),
+ _mm_srli_epi32(x, 32 - c));
+}
+STATIC_INLINE __m128i Rol17(__m128i x) { return RotateLeft(x, 17); }
+STATIC_INLINE __m128i Rol19(__m128i x) { return RotateLeft(x, 19); }
+STATIC_INLINE __m128i Shuffle0321(__m128i x) {
+ return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
+}
+
+uint32_t Hash32(const char *s, size_t len) {
+ const uint32_t seed = 81;
+ if (len <= 24) {
+ return len <= 12 ?
+ (len <= 4 ?
+ farmhashmk::Hash32Len0to4(s, len) :
+ farmhashmk::Hash32Len5to12(s, len)) :
+ farmhashmk::Hash32Len13to24(s, len);
+ }
+
+ if (len < 40) {
+ uint32_t a = len, b = seed * c2, c = a + b;
+ a += Fetch(s + len - 4);
+ b += Fetch(s + len - 20);
+ c += Fetch(s + len - 16);
+ uint32_t d = a;
+ a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
+ a = Mur(a, Mur(b, _mm_crc32_u32(c, d)));
+ a += Fetch(s + len - 12);
+ b += Fetch(s + len - 8);
+ d += a;
+ a += d;
+ b = Mur(b, d) * c2;
+ a = _mm_crc32_u32(a, b + c);
+ return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
+ }
+
+#undef Mulc1
+#define Mulc1(x) Mul((x), cc1)
+
+#undef Mulc2
+#define Mulc2(x) Mul((x), cc2)
+
+#undef Murk
+#define Murk(a, h) \
+ Add(k, \
+ Mul5( \
+ Rol19( \
+ Xor( \
+ Mulc2( \
+ Rol17( \
+ Mulc1(a))), \
+ (h)))))
+
+ const __m128i cc1 = _mm_set1_epi32(c1);
+ const __m128i cc2 = _mm_set1_epi32(c2);
+ __m128i h = _mm_set1_epi32(seed);
+ __m128i g = _mm_set1_epi32(c1 * seed);
+ __m128i f = g;
+ __m128i k = _mm_set1_epi32(0xe6546b64);
+ __m128i q;
+ if (len < 80) {
+ __m128i a = Fetch128(s);
+ __m128i b = Fetch128(s + 16);
+ __m128i c = Fetch128(s + (len - 15) / 2);
+ __m128i d = Fetch128(s + len - 32);
+ __m128i e = Fetch128(s + len - 16);
+ h = Add(h, a);
+ g = Add(g, b);
+ q = g;
+ g = Shuffle0321(g);
+ f = Add(f, c);
+ __m128i be = Add(b, Mulc1(e));
+ h = Add(h, f);
+ f = Add(f, h);
+ h = Add(Murk(d, h), e);
+ k = Xor(k, _mm_shuffle_epi8(g, f));
+ g = Add(Xor(c, g), a);
+ f = Add(Xor(be, f), d);
+ k = Add(k, be);
+ k = Add(k, _mm_shuffle_epi8(f, h));
+ f = Add(f, g);
+ g = Add(g, f);
+ g = Add(_mm_set1_epi32(len), Mulc1(g));
+ } else {
+ // len >= 80
+ // The following is loosely modelled after farmhashmk::Hash32.
+ size_t iters = (len - 1) / 80;
+ len -= iters * 80;
+
+#undef Chunk
+#define Chunk() do { \
+ __m128i a = Fetch128(s); \
+ __m128i b = Fetch128(s + 16); \
+ __m128i c = Fetch128(s + 32); \
+ __m128i d = Fetch128(s + 48); \
+ __m128i e = Fetch128(s + 64); \
+ h = Add(h, a); \
+ g = Add(g, b); \
+ g = Shuffle0321(g); \
+ f = Add(f, c); \
+ __m128i be = Add(b, Mulc1(e)); \
+ h = Add(h, f); \
+ f = Add(f, h); \
+ h = Add(h, d); \
+ q = Add(q, e); \
+ h = Rol17(h); \
+ h = Mulc1(h); \
+ k = Xor(k, _mm_shuffle_epi8(g, f)); \
+ g = Add(Xor(c, g), a); \
+ f = Add(Xor(be, f), d); \
+ std::swap(f, q); \
+ q = _mm_aesimc_si128(q); \
+ k = Add(k, be); \
+ k = Add(k, _mm_shuffle_epi8(f, h)); \
+ f = Add(f, g); \
+ g = Add(g, f); \
+ f = Mulc1(f); \
+} while (0)
+
+ q = g;
+ while (iters-- != 0) {
+ Chunk();
+ s += 80;
+ }
+
+ if (len != 0) {
+ h = Add(h, _mm_set1_epi32(len));
+ s = s + len - 80;
+ Chunk();
+ }
+ }
+
+ g = Shuffle0321(g);
+ k = Xor(k, g);
+ k = Xor(k, q);
+ h = Xor(h, q);
+ f = Mulc1(f);
+ k = Mulc2(k);
+ g = Mulc1(g);
+ h = Mulc2(h);
+ k = Add(k, _mm_shuffle_epi8(g, f));
+ h = Add(h, f);
+ f = Add(f, h);
+ g = Add(g, k);
+ k = Add(k, g);
+ k = Xor(k, _mm_shuffle_epi8(f, h));
+ __m128i buf[4];
+ buf[0] = f;
+ buf[1] = g;
+ buf[2] = k;
+ buf[3] = h;
+ s = reinterpret_cast<char*>(buf);
+ uint32_t x = Fetch(s);
+ uint32_t y = Fetch(s+4);
+ uint32_t z = Fetch(s+8);
+ x = _mm_crc32_u32(x, Fetch(s+12));
+ y = _mm_crc32_u32(y, Fetch(s+16));
+ z = _mm_crc32_u32(z * c1, Fetch(s+20));
+ x = _mm_crc32_u32(x, Fetch(s+24));
+ y = _mm_crc32_u32(y * c1, Fetch(s+28));
+ uint32_t o = y;
+ z = _mm_crc32_u32(z, Fetch(s+32));
+ x = _mm_crc32_u32(x * c1, Fetch(s+36));
+ y = _mm_crc32_u32(y, Fetch(s+40));
+ z = _mm_crc32_u32(z * c1, Fetch(s+44));
+ x = _mm_crc32_u32(x, Fetch(s+48));
+ y = _mm_crc32_u32(y * c1, Fetch(s+52));
+ z = _mm_crc32_u32(z, Fetch(s+56));
+ x = _mm_crc32_u32(x, Fetch(s+60));
+ return (o - x + y - z) * c1;
+}
+
+#undef Chunk
+#undef Murk
+#undef Mulc2
+#undef Mulc1
+
+uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
+ if (len <= 24) {
+ if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
+ else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
+ else return farmhashmk::Hash32Len0to4(s, len, seed);
+ }
+ uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
+ return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
+}
+
+#endif
+} // namespace farmhashsu
diff --git a/contrib/libs/farmhash/farmhashte.cc b/contrib/libs/farmhash/farmhashte.cc
index c5df17f43a..709ba49898 100644
--- a/contrib/libs/farmhash/farmhashte.cc
+++ b/contrib/libs/farmhash/farmhashte.cc
@@ -1,238 +1,238 @@
-#include "common.h"
-
-namespace {
- #include "farmhashxo.cc"
-}
-
-namespace farmhashte {
-#if !can_use_sse41 || !x86_64
-
-uint64_t Hash64(const char *s, size_t len) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return s == NULL ? 0 : len;
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed + Hash64(s, len);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len,
- uint64_t seed0, uint64_t seed1) {
- FARMHASH_DIE_IF_MISCONFIGURED;
- return seed0 + seed1 + Hash64(s, len);
-}
-
-#else
-
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-#undef Bswap
-#define Bswap Bswap64
-
-// Helpers for data-parallel operations (1x 128 bits or 2x 64 or 4x 32).
-STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi64(x, y); }
-STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
-STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
-STATIC_INLINE __m128i Shuf(__m128i x, __m128i y) { return _mm_shuffle_epi8(y, x); }
-
-// Requires n >= 256. Requires SSE4.1. Should be slightly faster if the
-// compiler uses AVX instructions (e.g., use the -mavx flag with GCC).
-STATIC_INLINE uint64_t Hash64Long(const char* s, size_t n,
- uint64_t seed0, uint64_t seed1) {
- const __m128i kShuf =
- _mm_set_epi8(4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1);
- const __m128i kMult =
- _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03,
- 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51);
- uint64_t seed2 = (seed0 + 113) * (seed1 + 9);
- uint64_t seed3 = (Rotate(seed0, 23) + 27) * (Rotate(seed1, 30) + 111);
- __m128i d0 = _mm_cvtsi64_si128(seed0);
- __m128i d1 = _mm_cvtsi64_si128(seed1);
- __m128i d2 = Shuf(kShuf, d0);
- __m128i d3 = Shuf(kShuf, d1);
- __m128i d4 = Xor(d0, d1);
- __m128i d5 = Xor(d1, d2);
- __m128i d6 = Xor(d2, d4);
- __m128i d7 = _mm_set1_epi32(seed2 >> 32);
- __m128i d8 = Mul(kMult, d2);
- __m128i d9 = _mm_set1_epi32(seed3 >> 32);
- __m128i d10 = _mm_set1_epi32(seed3);
- __m128i d11 = Add(d2, _mm_set1_epi32(seed2));
- const char* end = s + (n & ~static_cast<size_t>(255));
- do {
- __m128i z;
- z = Fetch128(s);
- d0 = Add(d0, z);
- d1 = Shuf(kShuf, d1);
- d2 = Xor(d2, d0);
- d4 = Xor(d4, z);
- d4 = Xor(d4, d1);
- std::swap(d0, d6);
- z = Fetch128(s + 16);
- d5 = Add(d5, z);
- d6 = Shuf(kShuf, d6);
- d8 = Shuf(kShuf, d8);
- d7 = Xor(d7, d5);
- d0 = Xor(d0, z);
- d0 = Xor(d0, d6);
- std::swap(d5, d11);
- z = Fetch128(s + 32);
- d1 = Add(d1, z);
- d2 = Shuf(kShuf, d2);
- d4 = Shuf(kShuf, d4);
- d5 = Xor(d5, z);
- d5 = Xor(d5, d2);
- std::swap(d10, d4);
- z = Fetch128(s + 48);
- d6 = Add(d6, z);
- d7 = Shuf(kShuf, d7);
- d0 = Shuf(kShuf, d0);
- d8 = Xor(d8, d6);
- d1 = Xor(d1, z);
- d1 = Add(d1, d7);
- z = Fetch128(s + 64);
- d2 = Add(d2, z);
- d5 = Shuf(kShuf, d5);
- d4 = Add(d4, d2);
- d6 = Xor(d6, z);
- d6 = Xor(d6, d11);
- std::swap(d8, d2);
- z = Fetch128(s + 80);
- d7 = Xor(d7, z);
- d8 = Shuf(kShuf, d8);
- d1 = Shuf(kShuf, d1);
- d0 = Add(d0, d7);
- d2 = Add(d2, z);
- d2 = Add(d2, d8);
- std::swap(d1, d7);
- z = Fetch128(s + 96);
- d4 = Shuf(kShuf, d4);
- d6 = Shuf(kShuf, d6);
- d8 = Mul(kMult, d8);
- d5 = Xor(d5, d11);
- d7 = Xor(d7, z);
- d7 = Add(d7, d4);
- std::swap(d6, d0);
- z = Fetch128(s + 112);
- d8 = Add(d8, z);
- d0 = Shuf(kShuf, d0);
- d2 = Shuf(kShuf, d2);
- d1 = Xor(d1, d8);
- d10 = Xor(d10, z);
- d10 = Xor(d10, d0);
- std::swap(d11, d5);
- z = Fetch128(s + 128);
- d4 = Add(d4, z);
- d5 = Shuf(kShuf, d5);
- d7 = Shuf(kShuf, d7);
- d6 = Add(d6, d4);
- d8 = Xor(d8, z);
- d8 = Xor(d8, d5);
- std::swap(d4, d10);
- z = Fetch128(s + 144);
- d0 = Add(d0, z);
- d1 = Shuf(kShuf, d1);
- d2 = Add(d2, d0);
- d4 = Xor(d4, z);
- d4 = Xor(d4, d1);
- z = Fetch128(s + 160);
- d5 = Add(d5, z);
- d6 = Shuf(kShuf, d6);
- d8 = Shuf(kShuf, d8);
- d7 = Xor(d7, d5);
- d0 = Xor(d0, z);
- d0 = Xor(d0, d6);
- std::swap(d2, d8);
- z = Fetch128(s + 176);
- d1 = Add(d1, z);
- d2 = Shuf(kShuf, d2);
- d4 = Shuf(kShuf, d4);
- d5 = Mul(kMult, d5);
- d5 = Xor(d5, z);
- d5 = Xor(d5, d2);
- std::swap(d7, d1);
- z = Fetch128(s + 192);
- d6 = Add(d6, z);
- d7 = Shuf(kShuf, d7);
- d0 = Shuf(kShuf, d0);
- d8 = Add(d8, d6);
- d1 = Xor(d1, z);
- d1 = Xor(d1, d7);
- std::swap(d0, d6);
- z = Fetch128(s + 208);
- d2 = Add(d2, z);
- d5 = Shuf(kShuf, d5);
- d4 = Xor(d4, d2);
- d6 = Xor(d6, z);
- d6 = Xor(d6, d9);
- std::swap(d5, d11);
- z = Fetch128(s + 224);
- d7 = Add(d7, z);
- d8 = Shuf(kShuf, d8);
- d1 = Shuf(kShuf, d1);
- d0 = Xor(d0, d7);
- d2 = Xor(d2, z);
- d2 = Xor(d2, d8);
- std::swap(d10, d4);
- z = Fetch128(s + 240);
- d3 = Add(d3, z);
- d4 = Shuf(kShuf, d4);
- d6 = Shuf(kShuf, d6);
- d7 = Mul(kMult, d7);
- d5 = Add(d5, d3);
- d7 = Xor(d7, z);
- d7 = Xor(d7, d4);
- std::swap(d3, d9);
- s += 256;
- } while (s != end);
- d6 = Add(Mul(kMult, d6), _mm_cvtsi64_si128(n));
- if (n % 256 != 0) {
- d7 = Add(_mm_shuffle_epi32(d8, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0)), d7);
- d8 = Add(Mul(kMult, d8), _mm_cvtsi64_si128(farmhashxo::Hash64(s, n % 256)));
- }
- __m128i t[8];
- d0 = Mul(kMult, Shuf(kShuf, Mul(kMult, d0)));
- d3 = Mul(kMult, Shuf(kShuf, Mul(kMult, d3)));
- d9 = Mul(kMult, Shuf(kShuf, Mul(kMult, d9)));
- d1 = Mul(kMult, Shuf(kShuf, Mul(kMult, d1)));
- d0 = Add(d11, d0);
- d3 = Xor(d7, d3);
- d9 = Add(d8, d9);
- d1 = Add(d10, d1);
- d4 = Add(d3, d4);
- d5 = Add(d9, d5);
- d6 = Xor(d1, d6);
- d2 = Add(d0, d2);
- t[0] = d0;
- t[1] = d3;
- t[2] = d9;
- t[3] = d1;
- t[4] = d4;
- t[5] = d5;
- t[6] = d6;
- t[7] = d2;
- return farmhashxo::Hash64(reinterpret_cast<const char*>(t), sizeof(t));
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- // Empirically, farmhashxo seems faster until length 512.
- return len >= 512 ? Hash64Long(s, len, k2, k1) : farmhashxo::Hash64(s, len);
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return len >= 512 ? Hash64Long(s, len, k1, seed) :
- farmhashxo::Hash64WithSeed(s, len, seed);
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
- return len >= 512 ? Hash64Long(s, len, seed0, seed1) :
- farmhashxo::Hash64WithSeeds(s, len, seed0, seed1);
-}
-
-#endif
-} // namespace farmhashte
+#include "common.h"
+
+namespace {
+ #include "farmhashxo.cc"
+}
+
+namespace farmhashte {
+#if !can_use_sse41 || !x86_64
+
+uint64_t Hash64(const char *s, size_t len) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return s == NULL ? 0 : len;
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed + Hash64(s, len);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len,
+ uint64_t seed0, uint64_t seed1) {
+ FARMHASH_DIE_IF_MISCONFIGURED;
+ return seed0 + seed1 + Hash64(s, len);
+}
+
+#else
+
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+#undef Bswap
+#define Bswap Bswap64
+
+// Helpers for data-parallel operations (1x 128 bits or 2x 64 or 4x 32).
+STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi64(x, y); }
+STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
+STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
+STATIC_INLINE __m128i Shuf(__m128i x, __m128i y) { return _mm_shuffle_epi8(y, x); }
+
+// Requires n >= 256. Requires SSE4.1. Should be slightly faster if the
+// compiler uses AVX instructions (e.g., use the -mavx flag with GCC).
+STATIC_INLINE uint64_t Hash64Long(const char* s, size_t n,
+ uint64_t seed0, uint64_t seed1) {
+ const __m128i kShuf =
+ _mm_set_epi8(4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1);
+ const __m128i kMult =
+ _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03,
+ 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51);
+ uint64_t seed2 = (seed0 + 113) * (seed1 + 9);
+ uint64_t seed3 = (Rotate(seed0, 23) + 27) * (Rotate(seed1, 30) + 111);
+ __m128i d0 = _mm_cvtsi64_si128(seed0);
+ __m128i d1 = _mm_cvtsi64_si128(seed1);
+ __m128i d2 = Shuf(kShuf, d0);
+ __m128i d3 = Shuf(kShuf, d1);
+ __m128i d4 = Xor(d0, d1);
+ __m128i d5 = Xor(d1, d2);
+ __m128i d6 = Xor(d2, d4);
+ __m128i d7 = _mm_set1_epi32(seed2 >> 32);
+ __m128i d8 = Mul(kMult, d2);
+ __m128i d9 = _mm_set1_epi32(seed3 >> 32);
+ __m128i d10 = _mm_set1_epi32(seed3);
+ __m128i d11 = Add(d2, _mm_set1_epi32(seed2));
+ const char* end = s + (n & ~static_cast<size_t>(255));
+ do {
+ __m128i z;
+ z = Fetch128(s);
+ d0 = Add(d0, z);
+ d1 = Shuf(kShuf, d1);
+ d2 = Xor(d2, d0);
+ d4 = Xor(d4, z);
+ d4 = Xor(d4, d1);
+ std::swap(d0, d6);
+ z = Fetch128(s + 16);
+ d5 = Add(d5, z);
+ d6 = Shuf(kShuf, d6);
+ d8 = Shuf(kShuf, d8);
+ d7 = Xor(d7, d5);
+ d0 = Xor(d0, z);
+ d0 = Xor(d0, d6);
+ std::swap(d5, d11);
+ z = Fetch128(s + 32);
+ d1 = Add(d1, z);
+ d2 = Shuf(kShuf, d2);
+ d4 = Shuf(kShuf, d4);
+ d5 = Xor(d5, z);
+ d5 = Xor(d5, d2);
+ std::swap(d10, d4);
+ z = Fetch128(s + 48);
+ d6 = Add(d6, z);
+ d7 = Shuf(kShuf, d7);
+ d0 = Shuf(kShuf, d0);
+ d8 = Xor(d8, d6);
+ d1 = Xor(d1, z);
+ d1 = Add(d1, d7);
+ z = Fetch128(s + 64);
+ d2 = Add(d2, z);
+ d5 = Shuf(kShuf, d5);
+ d4 = Add(d4, d2);
+ d6 = Xor(d6, z);
+ d6 = Xor(d6, d11);
+ std::swap(d8, d2);
+ z = Fetch128(s + 80);
+ d7 = Xor(d7, z);
+ d8 = Shuf(kShuf, d8);
+ d1 = Shuf(kShuf, d1);
+ d0 = Add(d0, d7);
+ d2 = Add(d2, z);
+ d2 = Add(d2, d8);
+ std::swap(d1, d7);
+ z = Fetch128(s + 96);
+ d4 = Shuf(kShuf, d4);
+ d6 = Shuf(kShuf, d6);
+ d8 = Mul(kMult, d8);
+ d5 = Xor(d5, d11);
+ d7 = Xor(d7, z);
+ d7 = Add(d7, d4);
+ std::swap(d6, d0);
+ z = Fetch128(s + 112);
+ d8 = Add(d8, z);
+ d0 = Shuf(kShuf, d0);
+ d2 = Shuf(kShuf, d2);
+ d1 = Xor(d1, d8);
+ d10 = Xor(d10, z);
+ d10 = Xor(d10, d0);
+ std::swap(d11, d5);
+ z = Fetch128(s + 128);
+ d4 = Add(d4, z);
+ d5 = Shuf(kShuf, d5);
+ d7 = Shuf(kShuf, d7);
+ d6 = Add(d6, d4);
+ d8 = Xor(d8, z);
+ d8 = Xor(d8, d5);
+ std::swap(d4, d10);
+ z = Fetch128(s + 144);
+ d0 = Add(d0, z);
+ d1 = Shuf(kShuf, d1);
+ d2 = Add(d2, d0);
+ d4 = Xor(d4, z);
+ d4 = Xor(d4, d1);
+ z = Fetch128(s + 160);
+ d5 = Add(d5, z);
+ d6 = Shuf(kShuf, d6);
+ d8 = Shuf(kShuf, d8);
+ d7 = Xor(d7, d5);
+ d0 = Xor(d0, z);
+ d0 = Xor(d0, d6);
+ std::swap(d2, d8);
+ z = Fetch128(s + 176);
+ d1 = Add(d1, z);
+ d2 = Shuf(kShuf, d2);
+ d4 = Shuf(kShuf, d4);
+ d5 = Mul(kMult, d5);
+ d5 = Xor(d5, z);
+ d5 = Xor(d5, d2);
+ std::swap(d7, d1);
+ z = Fetch128(s + 192);
+ d6 = Add(d6, z);
+ d7 = Shuf(kShuf, d7);
+ d0 = Shuf(kShuf, d0);
+ d8 = Add(d8, d6);
+ d1 = Xor(d1, z);
+ d1 = Xor(d1, d7);
+ std::swap(d0, d6);
+ z = Fetch128(s + 208);
+ d2 = Add(d2, z);
+ d5 = Shuf(kShuf, d5);
+ d4 = Xor(d4, d2);
+ d6 = Xor(d6, z);
+ d6 = Xor(d6, d9);
+ std::swap(d5, d11);
+ z = Fetch128(s + 224);
+ d7 = Add(d7, z);
+ d8 = Shuf(kShuf, d8);
+ d1 = Shuf(kShuf, d1);
+ d0 = Xor(d0, d7);
+ d2 = Xor(d2, z);
+ d2 = Xor(d2, d8);
+ std::swap(d10, d4);
+ z = Fetch128(s + 240);
+ d3 = Add(d3, z);
+ d4 = Shuf(kShuf, d4);
+ d6 = Shuf(kShuf, d6);
+ d7 = Mul(kMult, d7);
+ d5 = Add(d5, d3);
+ d7 = Xor(d7, z);
+ d7 = Xor(d7, d4);
+ std::swap(d3, d9);
+ s += 256;
+ } while (s != end);
+ d6 = Add(Mul(kMult, d6), _mm_cvtsi64_si128(n));
+ if (n % 256 != 0) {
+ d7 = Add(_mm_shuffle_epi32(d8, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0)), d7);
+ d8 = Add(Mul(kMult, d8), _mm_cvtsi64_si128(farmhashxo::Hash64(s, n % 256)));
+ }
+ __m128i t[8];
+ d0 = Mul(kMult, Shuf(kShuf, Mul(kMult, d0)));
+ d3 = Mul(kMult, Shuf(kShuf, Mul(kMult, d3)));
+ d9 = Mul(kMult, Shuf(kShuf, Mul(kMult, d9)));
+ d1 = Mul(kMult, Shuf(kShuf, Mul(kMult, d1)));
+ d0 = Add(d11, d0);
+ d3 = Xor(d7, d3);
+ d9 = Add(d8, d9);
+ d1 = Add(d10, d1);
+ d4 = Add(d3, d4);
+ d5 = Add(d9, d5);
+ d6 = Xor(d1, d6);
+ d2 = Add(d0, d2);
+ t[0] = d0;
+ t[1] = d3;
+ t[2] = d9;
+ t[3] = d1;
+ t[4] = d4;
+ t[5] = d5;
+ t[6] = d6;
+ t[7] = d2;
+ return farmhashxo::Hash64(reinterpret_cast<const char*>(t), sizeof(t));
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ // Empirically, farmhashxo seems faster until length 512.
+ return len >= 512 ? Hash64Long(s, len, k2, k1) : farmhashxo::Hash64(s, len);
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return len >= 512 ? Hash64Long(s, len, k1, seed) :
+ farmhashxo::Hash64WithSeed(s, len, seed);
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return len >= 512 ? Hash64Long(s, len, seed0, seed1) :
+ farmhashxo::Hash64WithSeeds(s, len, seed0, seed1);
+}
+
+#endif
+} // namespace farmhashte
diff --git a/contrib/libs/farmhash/farmhashuo.cc b/contrib/libs/farmhash/farmhashuo.cc
index ed190a44d5..66e84e44d2 100644
--- a/contrib/libs/farmhash/farmhashuo.cc
+++ b/contrib/libs/farmhash/farmhashuo.cc
@@ -1,121 +1,121 @@
-#include "common.h"
-
-namespace {
- #include "farmhashna.cc"
-}
-
-namespace farmhashuo {
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r) {
- uint64_t a = (x ^ y) * mul;
- a ^= (a >> 47);
- uint64_t b = (y ^ a) * mul;
- return Rotate(b, r) * mul;
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len,
- uint64_t seed0, uint64_t seed1) {
- if (len <= 64) {
- return farmhashna::Hash64WithSeeds(s, len, seed0, seed1);
- }
-
- // For strings over 64 bytes we loop. Internal state consists of
- // 64 bytes: u, v, w, x, y, and z.
- uint64_t x = seed0;
- uint64_t y = seed1 * k2 + 113;
- uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
- pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
- pair<uint64_t, uint64_t> w = make_pair(0, 0);
- uint64_t u = x - z;
- x *= k2;
- uint64_t mul = k2 + (u & 0x82);
-
- // Set end so that after the loop we have 1 to 64 bytes left to process.
- const char* end = s + ((len - 1) / 64) * 64;
- const char* last64 = end + ((len - 1) & 63) - 63;
- assert(s + len - 64 == last64);
- do {
- uint64_t a0 = Fetch(s);
- uint64_t a1 = Fetch(s + 8);
- uint64_t a2 = Fetch(s + 16);
- uint64_t a3 = Fetch(s + 24);
- uint64_t a4 = Fetch(s + 32);
- uint64_t a5 = Fetch(s + 40);
- uint64_t a6 = Fetch(s + 48);
- uint64_t a7 = Fetch(s + 56);
- x += a0 + a1;
- y += a2;
- z += a3;
- v.first += a4;
- v.second += a5 + a1;
- w.first += a6;
- w.second += a7;
-
- x = Rotate(x, 26);
- x *= 9;
- y = Rotate(y, 29);
- z *= mul;
- v.first = Rotate(v.first, 33);
- v.second = Rotate(v.second, 30);
- w.first ^= x;
- w.first *= 9;
- z = Rotate(z, 32);
- z += w.second;
- w.second += z;
- z *= 9;
- std::swap(u, y);
-
- z += a0 + a6;
- v.first += a2;
- v.second += a3;
- w.first += a4;
- w.second += a5 + a6;
- x += a1;
- y += a7;
-
- y += v.first;
- v.first += x - y;
- v.second += w.first;
- w.first += v.second;
- w.second += x - y;
- x += w.second;
- w.second = Rotate(w.second, 34);
- std::swap(u, z);
- s += 64;
- } while (s != end);
- // Make s point to the last 64 bytes of input.
- s = last64;
- u *= 9;
- v.second = Rotate(v.second, 28);
- v.first = Rotate(v.first, 20);
- w.first += ((len - 1) & 63);
- u += y;
- y += u;
- x = Rotate(y - x + v.first + Fetch(s + 8), 37) * mul;
- y = Rotate(y ^ v.second ^ Fetch(s + 48), 42) * mul;
- x ^= w.second * 9;
- y += v.first + Fetch(s + 40);
- z = Rotate(z + w.first, 33) * mul;
- v = farmhashna::WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
- w = farmhashna::WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
- return H(farmhashna::HashLen16(v.first + x, w.first ^ y, mul) + z - u,
- H(v.second + y, w.second + z, k2, 30) ^ x,
- k2,
- 31);
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return len <= 64 ? farmhashna::Hash64WithSeed(s, len, seed) :
- Hash64WithSeeds(s, len, 0, seed);
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- return len <= 64 ? farmhashna::Hash64(s, len) :
- Hash64WithSeeds(s, len, 81, 0);
-}
-} // namespace farmhashuo
+#include "common.h"
+
+namespace {
+ #include "farmhashna.cc"
+}
+
+namespace farmhashuo {
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r) {
+ uint64_t a = (x ^ y) * mul;
+ a ^= (a >> 47);
+ uint64_t b = (y ^ a) * mul;
+ return Rotate(b, r) * mul;
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len,
+ uint64_t seed0, uint64_t seed1) {
+ if (len <= 64) {
+ return farmhashna::Hash64WithSeeds(s, len, seed0, seed1);
+ }
+
+ // For strings over 64 bytes we loop. Internal state consists of
+ // 64 bytes: u, v, w, x, y, and z.
+ uint64_t x = seed0;
+ uint64_t y = seed1 * k2 + 113;
+ uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
+ pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
+ pair<uint64_t, uint64_t> w = make_pair(0, 0);
+ uint64_t u = x - z;
+ x *= k2;
+ uint64_t mul = k2 + (u & 0x82);
+
+ // Set end so that after the loop we have 1 to 64 bytes left to process.
+ const char* end = s + ((len - 1) / 64) * 64;
+ const char* last64 = end + ((len - 1) & 63) - 63;
+ assert(s + len - 64 == last64);
+ do {
+ uint64_t a0 = Fetch(s);
+ uint64_t a1 = Fetch(s + 8);
+ uint64_t a2 = Fetch(s + 16);
+ uint64_t a3 = Fetch(s + 24);
+ uint64_t a4 = Fetch(s + 32);
+ uint64_t a5 = Fetch(s + 40);
+ uint64_t a6 = Fetch(s + 48);
+ uint64_t a7 = Fetch(s + 56);
+ x += a0 + a1;
+ y += a2;
+ z += a3;
+ v.first += a4;
+ v.second += a5 + a1;
+ w.first += a6;
+ w.second += a7;
+
+ x = Rotate(x, 26);
+ x *= 9;
+ y = Rotate(y, 29);
+ z *= mul;
+ v.first = Rotate(v.first, 33);
+ v.second = Rotate(v.second, 30);
+ w.first ^= x;
+ w.first *= 9;
+ z = Rotate(z, 32);
+ z += w.second;
+ w.second += z;
+ z *= 9;
+ std::swap(u, y);
+
+ z += a0 + a6;
+ v.first += a2;
+ v.second += a3;
+ w.first += a4;
+ w.second += a5 + a6;
+ x += a1;
+ y += a7;
+
+ y += v.first;
+ v.first += x - y;
+ v.second += w.first;
+ w.first += v.second;
+ w.second += x - y;
+ x += w.second;
+ w.second = Rotate(w.second, 34);
+ std::swap(u, z);
+ s += 64;
+ } while (s != end);
+ // Make s point to the last 64 bytes of input.
+ s = last64;
+ u *= 9;
+ v.second = Rotate(v.second, 28);
+ v.first = Rotate(v.first, 20);
+ w.first += ((len - 1) & 63);
+ u += y;
+ y += u;
+ x = Rotate(y - x + v.first + Fetch(s + 8), 37) * mul;
+ y = Rotate(y ^ v.second ^ Fetch(s + 48), 42) * mul;
+ x ^= w.second * 9;
+ y += v.first + Fetch(s + 40);
+ z = Rotate(z + w.first, 33) * mul;
+ v = farmhashna::WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
+ w = farmhashna::WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
+ return H(farmhashna::HashLen16(v.first + x, w.first ^ y, mul) + z - u,
+ H(v.second + y, w.second + z, k2, 30) ^ x,
+ k2,
+ 31);
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return len <= 64 ? farmhashna::Hash64WithSeed(s, len, seed) :
+ Hash64WithSeeds(s, len, 0, seed);
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ return len <= 64 ? farmhashna::Hash64(s, len) :
+ Hash64WithSeeds(s, len, 81, 0);
+}
+} // namespace farmhashuo
diff --git a/contrib/libs/farmhash/farmhashxo.cc b/contrib/libs/farmhash/farmhashxo.cc
index 96ec226687..e9bf1fd797 100644
--- a/contrib/libs/farmhash/farmhashxo.cc
+++ b/contrib/libs/farmhash/farmhashxo.cc
@@ -1,71 +1,71 @@
-#include "common.h"
-
-namespace {
- #include "farmhashuo.cc"
-}
-
-namespace farmhashxo {
-#undef Fetch
-#define Fetch Fetch64
-
-#undef Rotate
-#define Rotate Rotate64
-
-STATIC_INLINE uint64_t H32(const char *s, size_t len, uint64_t mul,
- uint64_t seed0 = 0, uint64_t seed1 = 0) {
- uint64_t a = Fetch(s) * k1;
- uint64_t b = Fetch(s + 8);
- uint64_t c = Fetch(s + len - 8) * mul;
- uint64_t d = Fetch(s + len - 16) * k2;
- uint64_t u = Rotate(a + b, 43) + Rotate(c, 30) + d + seed0;
- uint64_t v = a + Rotate(b + k2, 18) + c + seed1;
- a = farmhashna::ShiftMix((u ^ v) * mul);
- b = farmhashna::ShiftMix((v ^ a) * mul);
- return b;
-}
-
-// Return an 8-byte hash for 33 to 64 bytes.
-STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
- uint64_t mul0 = k2 - 30;
- uint64_t mul1 = k2 - 30 + 2 * len;
- uint64_t h0 = H32(s, 32, mul0);
- uint64_t h1 = H32(s + len - 32, 32, mul1);
- return ((h1 * mul1) + h0) * mul1;
-}
-
-// Return an 8-byte hash for 65 to 96 bytes.
-STATIC_INLINE uint64_t HashLen65to96(const char *s, size_t len) {
- uint64_t mul0 = k2 - 114;
- uint64_t mul1 = k2 - 114 + 2 * len;
- uint64_t h0 = H32(s, 32, mul0);
- uint64_t h1 = H32(s + 32, 32, mul1);
- uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1);
- return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1;
-}
-
-uint64_t Hash64(const char *s, size_t len) {
- if (len <= 32) {
- if (len <= 16) {
- return farmhashna::HashLen0to16(s, len);
- } else {
- return farmhashna::HashLen17to32(s, len);
- }
- } else if (len <= 64) {
- return HashLen33to64(s, len);
- } else if (len <= 96) {
- return HashLen65to96(s, len);
- } else if (len <= 256) {
- return farmhashna::Hash64(s, len);
- } else {
- return farmhashuo::Hash64(s, len);
- }
-}
-
-uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
- return farmhashuo::Hash64WithSeeds(s, len, seed0, seed1);
-}
-
-uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
- return farmhashuo::Hash64WithSeed(s, len, seed);
-}
-} // namespace farmhashxo
+#include "common.h"
+
+namespace {
+ #include "farmhashuo.cc"
+}
+
+namespace farmhashxo {
+#undef Fetch
+#define Fetch Fetch64
+
+#undef Rotate
+#define Rotate Rotate64
+
+STATIC_INLINE uint64_t H32(const char *s, size_t len, uint64_t mul,
+ uint64_t seed0 = 0, uint64_t seed1 = 0) {
+ uint64_t a = Fetch(s) * k1;
+ uint64_t b = Fetch(s + 8);
+ uint64_t c = Fetch(s + len - 8) * mul;
+ uint64_t d = Fetch(s + len - 16) * k2;
+ uint64_t u = Rotate(a + b, 43) + Rotate(c, 30) + d + seed0;
+ uint64_t v = a + Rotate(b + k2, 18) + c + seed1;
+ a = farmhashna::ShiftMix((u ^ v) * mul);
+ b = farmhashna::ShiftMix((v ^ a) * mul);
+ return b;
+}
+
+// Return an 8-byte hash for 33 to 64 bytes.
+STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
+ uint64_t mul0 = k2 - 30;
+ uint64_t mul1 = k2 - 30 + 2 * len;
+ uint64_t h0 = H32(s, 32, mul0);
+ uint64_t h1 = H32(s + len - 32, 32, mul1);
+ return ((h1 * mul1) + h0) * mul1;
+}
+
+// Return an 8-byte hash for 65 to 96 bytes.
+STATIC_INLINE uint64_t HashLen65to96(const char *s, size_t len) {
+ uint64_t mul0 = k2 - 114;
+ uint64_t mul1 = k2 - 114 + 2 * len;
+ uint64_t h0 = H32(s, 32, mul0);
+ uint64_t h1 = H32(s + 32, 32, mul1);
+ uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1);
+ return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1;
+}
+
+uint64_t Hash64(const char *s, size_t len) {
+ if (len <= 32) {
+ if (len <= 16) {
+ return farmhashna::HashLen0to16(s, len);
+ } else {
+ return farmhashna::HashLen17to32(s, len);
+ }
+ } else if (len <= 64) {
+ return HashLen33to64(s, len);
+ } else if (len <= 96) {
+ return HashLen65to96(s, len);
+ } else if (len <= 256) {
+ return farmhashna::Hash64(s, len);
+ } else {
+ return farmhashuo::Hash64(s, len);
+ }
+}
+
+uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
+ return farmhashuo::Hash64WithSeeds(s, len, seed0, seed1);
+}
+
+uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
+ return farmhashuo::Hash64WithSeed(s, len, seed);
+}
+} // namespace farmhashxo
diff --git a/contrib/libs/farmhash/split.py b/contrib/libs/farmhash/split.py
index 083eae63f6..2939c75651 100755
--- a/contrib/libs/farmhash/split.py
+++ b/contrib/libs/farmhash/split.py
@@ -1,74 +1,74 @@
-#!/usr/bin/env python
-
-
-END_PREFIX = '} // namespace '
-TEST_PREFIX = '#if FARMHASHSELFTEST'
-
-
-def main():
- with open('farmhash.cc', 'rb') as input_file:
- lines = input_file.readlines()
-
- namespace_out = None
-
- prev_name = None
-
- output = open('common.h', 'wb')
- output.write('#pragma once\n\n')
-
- def write_common():
- output.write('#include "common.h"\n\n')
-
- def write_include(include):
- if include:
- output.write('namespace {\n')
- output.write(' ' + '#include "{}"\n'.format(include))
- output.write('}\n\n')
-
- write_test = False
-
- for line in lines:
-
- if line.startswith(TEST_PREFIX):
- write_test = True
- output.close()
- output = open('test.cc', 'wb')
- write_common()
- write_include('farmhash_iface.h')
-
- if write_test:
- output.write(line)
- continue
-
- elif line.startswith('namespace '):
- namespace = line.split(' ')[1]
-
- if namespace.startswith('farmhash'):
- filename = namespace + '.cc'
-
- output.close()
- output = open(filename, 'wb')
- write_common()
- write_include(prev_name)
-
- output.write(line)
- prev_name = filename
-
- else:
- if prev_name is not None:
- output.close()
- output = open('farmhash_iface.cc', 'wb')
- write_common()
- write_include(prev_name)
- prev_name = None
-
- output.write(line)
-
- else:
- output.write(line)
-
- output.close()
-
-
-if __name__ == '__main__':
- main()
+#!/usr/bin/env python
+
+
+END_PREFIX = '} // namespace '
+TEST_PREFIX = '#if FARMHASHSELFTEST'
+
+
+def main():
+ with open('farmhash.cc', 'rb') as input_file:
+ lines = input_file.readlines()
+
+ namespace_out = None
+
+ prev_name = None
+
+ output = open('common.h', 'wb')
+ output.write('#pragma once\n\n')
+
+ def write_common():
+ output.write('#include "common.h"\n\n')
+
+ def write_include(include):
+ if include:
+ output.write('namespace {\n')
+ output.write(' ' + '#include "{}"\n'.format(include))
+ output.write('}\n\n')
+
+ write_test = False
+
+ for line in lines:
+
+ if line.startswith(TEST_PREFIX):
+ write_test = True
+ output.close()
+ output = open('test.cc', 'wb')
+ write_common()
+ write_include('farmhash_iface.h')
+
+ if write_test:
+ output.write(line)
+ continue
+
+ elif line.startswith('namespace '):
+ namespace = line.split(' ')[1]
+
+ if namespace.startswith('farmhash'):
+ filename = namespace + '.cc'
+
+ output.close()
+ output = open(filename, 'wb')
+ write_common()
+ write_include(prev_name)
+
+ output.write(line)
+ prev_name = filename
+
+ else:
+ if prev_name is not None:
+ output.close()
+ output = open('farmhash_iface.cc', 'wb')
+ write_common()
+ write_include(prev_name)
+ prev_name = None
+
+ output.write(line)
+
+ else:
+ output.write(line)
+
+ output.close()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/contrib/libs/farmhash/test.cc b/contrib/libs/farmhash/test.cc
index e36b992b66..08d191ae7c 100644
--- a/contrib/libs/farmhash/test.cc
+++ b/contrib/libs/farmhash/test.cc
@@ -1,9872 +1,9872 @@
#include <library/cpp/testing/unittest/registar.h>
-
-#include "common.h"
-
-#include "farmhash_iface.h"
-
-#if FARMHASHSELFTEST
-
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+
+#include "common.h"
+
+#include "farmhash_iface.h"
+
+#if FARMHASHSELFTEST
+
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- /* if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0); */
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashccTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-1039179260u, 1690343979u, 1018511555u, 2464489001u,
-20368522u, 2663783964u, 175201532u, 1619210592u,
-4081014168u,
-2576519988u,
-3285042206u, 502478099u, 739479538u, 1500332790u,
-13754768u, 3789353455u, 3473868058u, 1909255088u,
-2212771159u,
-1112731063u,
-826915357u, 2893489933u, 118369799u, 1848668220u,
-1308219822u, 249416982u, 64306364u, 4221800195u,
-1020067935u,
-3955445564u,
-563346294u, 550236731u, 2339016688u, 1826259714u,
-3872358639u, 2295981050u, 1870005390u, 4015628802u,
-1451961420u,
-653440099u,
-1292493871u, 164377749u, 1717712483u, 463414587u,
-3924343675u, 1050492084u, 3566618804u, 2046983362u,
-31917516u,
-2957164615u,
-230718965u, 999595115u, 3534822176u, 2175709186u,
-965707431u, 441796222u, 2481718051u, 1827777486u,
-2590087362u,
-3879448744u,
-3515079898u, 1601433082u, 982764532u, 254808716u,
-1293372530u, 4205605817u, 947001462u, 1138890052u,
-176305566u,
-2447367541u,
-2973802542u, 4123621138u, 3083865840u, 1706367795u,
-792114347u, 2880110657u, 440613768u, 195054868u,
-1359016305u,
-3363804638u,
-649488537u, 1624045597u, 1441938215u, 3147758996u,
-3199173578u, 2597283203u, 2191333609u, 3763129144u,
-1117290165u,
-1062549743u,
-2565615889u, 1046361554u, 1581968261u, 1058773671u,
-1123053168u, 3807622275u, 1486749916u, 3900816089u,
-2437877004u,
-1894455839u,
-1912520953u, 1914997013u, 561048608u, 1643267444u,
-3671572006u, 194811086u, 1468911468u, 2179206286u,
-673206794u,
-3486923651u,
-3741426466u, 3292160512u, 697001377u, 1900763774u,
-3726097344u, 629282039u, 3578723715u, 2868028489u,
-3269862919u,
-2303349487u,
-3643953525u, 2307255916u, 849996280u, 732080434u,
-909961480u, 3542445214u, 2628347095u, 4236856917u,
-1380660650u,
-2631821908u,
-2007289004u, 3509705198u, 3788541675u, 789457322u,
-3090670546u, 638977894u, 3503881773u, 947102987u,
-1525325287u,
-1816697045u,
-2706647405u, 288763142u, 3505438495u, 481308609u,
-2882636782u, 3745162621u, 3503467033u, 428247823u,
-176408838u,
-333551502u,
-1001068721u, 1681483651u, 75380831u, 4191469679u,
-3627361839u, 2736617386u, 3120737438u, 1297502456u,
-864896482u,
-85674920u,
-2886047255u, 4119881331u, 2496990525u, 3442502055u,
-1806582817u, 3186345024u, 4099591287u, 2560171465u,
-3489229104u,
-3065015872u,
-2755089808u, 3098442882u, 378524719u, 2664097023u,
-1771960725u, 2901182183u, 55258521u, 1266621443u,
-581644891u,
-37790450u,
-1800731704u, 3601350920u, 53428754u, 2759476837u,
-3391093099u, 1496510311u, 2511119507u, 2636877410u,
-631613207u,
-1573846064u,
-260484875u, 1088212603u, 2369525206u, 322522428u,
-3191396600u, 2076543340u, 1552496658u, 2739811558u,
-3867875546u,
-2051584261u,
-2126250818u, 901517871u, 3651631165u, 1323139145u,
-1521111765u, 477802997u, 3508559783u, 383954241u,
-3804516756u,
-4250206331u,
-2655954340u, 2484996477u, 1417544845u, 1520282298u,
-2745204366u, 2869345147u, 1872738335u, 2592877343u,
-1619744564u,
-1804962124u,
-3458679890u, 423948620u, 273645618u, 4187865426u,
-376057175u, 2943431463u, 3581950599u, 1035398331u,
-1088213445u,
-861988903u,
-1323370244u, 777069428u, 506235917u, 369720851u,
-2789995854u, 230915180u, 1505086948u, 940361236u,
-3727873235u,
-1159167499u,
-1860302871u, 3456858862u, 3923555152u, 2131072714u,
-2910461068u, 3671950363u, 2010742682u, 4088068851u,
-3616470388u,
-2087714788u,
-221675509u, 1230154072u, 3450704646u, 1463226695u,
-1998357699u, 266026801u, 619568740u, 3560427266u,
-4148162586u,
-3150417316u,
-1356375822u, 2056097622u, 627905802u, 3881675638u,
-2309738053u, 971916703u, 3447805361u, 1673575328u,
-673084328u,
-3317849401u,
-2836362782u, 2377208890u, 3275350588u, 158350552u,
-2553241779u, 2497264995u, 3262882649u, 3897937187u,
-1598963653u,
-3068514414u,
-601541505u, 374517071u, 3380795976u, 235752573u,
-284670003u, 2990192160u, 904937105u, 2306579150u,
-2117362589u,
-1635274830u,
-3355572906u, 170799903u, 1226685528u, 664567688u,
-413219134u, 878324258u, 4026159448u, 3620649295u,
-1823625377u,
-3175888439u,
-1759344347u, 2640637095u, 3549558u, 2192984935u,
-978623493u, 804017880u, 3877562323u, 3843116489u,
-1641748342u,
-1853539444u,
-3001178468u, 3443560727u, 2685426077u, 1653064722u,
-349231508u, 2726789654u, 3136215581u, 768402830u,
-269384321u,
-531936536u,
-2592883487u, 1343156334u, 3628619802u, 1477143570u,
-4269458419u, 3285611028u, 959104925u, 2712290710u,
-3480237248u,
-835796333u,
-2020636251u, 1191914589u, 126521603u, 4288023938u,
-3731699932u, 2136758855u, 985780142u, 193807575u,
-1850544433u,
-653947619u,
-3929316796u, 381871169u, 950486363u, 1787262279u,
-360480382u, 1800636585u, 1039258631u, 3682073259u,
-1262819303u,
-1786000319u,
-1570627191u, 893065837u, 301304916u, 1478469809u,
-623018819u, 2742232545u, 2058913014u, 1706060059u,
-2421125401u,
-1315829592u,
-3208766775u, 1805586156u, 575853086u, 3085025513u,
-4010908260u, 2344058256u, 3814407434u, 1458485673u,
-2474514786u,
-3581895658u,
-2710719679u, 190812706u, 2135454262u, 2620080728u,
-3400757986u, 1669914857u, 1559978393u, 1629811331u,
-3096616493u,
-1391424435u,
-4158376003u, 1015657076u, 794783832u, 479952178u,
-1150290207u, 2497437906u, 231815090u, 755078067u,
-3832053281u,
-63649475u,
-2415822606u, 4105027719u, 1706992318u, 1106598740u,
-3941945667u, 1271300761u, 505882259u, 760186809u,
-2657183368u,
-1925422058u,
-1039773764u, 880219458u, 4275949176u, 1556833823u,
-925882132u, 4216310340u, 757497522u, 461833914u,
-3884002070u,
-2790957660u,
-2100050089u, 651959176u, 1380301291u, 1289124125u,
-452314403u, 226156280u, 3306924715u, 1750807758u,
-2290180542u,
-1953760569u,
-2253069096u, 3960924806u, 1786291620u, 60736185u,
-2569018293u, 3870479674u, 2247005661u, 2239850953u,
-4261808536u,
-3282975782u,
-780945879u, 3349849383u, 1579362556u, 2265045884u,
-905088740u, 725212379u, 3156479246u, 2501620391u,
-3062836263u,
-4070422690u,
-996797869u, 4082582315u, 976105756u, 303983602u,
-1862104804u, 3864508254u, 3383979677u, 2835500286u,
-2798364010u,
-519359476u,
-3447342725u, 194373889u, 3313466630u, 232399983u,
-2841787856u, 1672751454u, 3345183154u, 1805381384u,
-2226129336u,
-2847829057u,
-2350774567u, 2838540121u, 2757948482u, 1017002062u,
-2329150951u, 2171488196u, 3668619047u, 3874977844u,
-3287966998u,
-262346753u,
-2493054715u, 2298644430u, 2926101182u, 1528457638u,
-598656233u, 2615845874u, 989110727u, 820441411u,
-253617372u,
-2201077208u,
-2047569338u, 3114356329u, 3335563734u, 2967673540u,
-768438341u, 1417708203u, 3873718246u, 1538441843u,
-1279167650u,
-3917966776u,
-2218481734u, 1015935150u, 1957845042u, 1318150213u,
-3146423971u, 4218994877u, 1162470863u, 1519718292u,
-2594658906u,
-665870414u,
-3430347817u, 3933868731u, 1597041394u, 3138684682u,
-3398212027u, 1064647658u, 1576321132u, 14792918u,
-224938029u,
-3706456050u,
-847274786u, 2645698692u, 1743374687u, 2343133224u,
-3066596790u, 2857270120u, 200596308u, 452055528u,
-2319312082u,
-3488655402u,
-4146865894u, 608206438u, 2699777051u, 3687240713u,
-327957508u, 3664730153u, 568134564u, 2993484554u,
-4159860363u,
-4274533921u,
-1079994063u, 2360220210u, 3609597760u, 3639708902u,
-2836180437u, 1069910270u, 1892427666u, 1874729790u,
-1267712826u,
-121886940u,
-3572289214u, 2475945610u, 783779452u, 588827737u,
-1531395014u, 2085084212u, 2219189792u, 3981444548u,
-2218885336u,
-1691622694u,
-2053232885u, 1386558530u, 2182946189u, 2365247285u,
-1871081313u, 2935751853u, 38413723u, 543465863u,
-900691890u,
-2899905665u,
-575120562u, 93133904u, 457154948u, 2983705792u,
-4232229200u, 2038565963u, 614693984u, 3405328302u,
-4083090010u,
-2088004171u,
-244031209u, 1861889294u, 2417109253u, 3299562328u,
-4158642443u, 4199064449u, 3161611046u, 885015950u,
-3677904099u,
-2969861785u,
-772348805u, 1712263832u, 3219357614u, 484271305u,
-3645706114u, 2059620251u, 409557488u, 2278896731u,
-224475749u,
-3523022952u,
-2057140088u, 449131785u, 1149879244u, 4255363996u,
-3602720135u, 1690010854u, 2503998822u, 2750828466u,
-3340671802u,
-1447583863u,
-2649684943u, 2764747249u, 3046070595u, 3441726138u,
-3840332559u, 3156747501u, 1288666680u, 1472744459u,
-3452391933u,
-1617542784u,
-217869690u, 3718469527u, 348639731u, 590532355u,
-43789787u, 22606314u, 1621559290u, 2231743261u,
-2234620879u,
-544748955u,
-3169387920u, 203343594u, 3272552527u, 1078282365u,
-809576321u, 854207584u, 3625491053u, 1193737267u,
-1628966807u,
-2661421060u,
-2433442061u, 3886639039u, 2149304418u, 303000565u,
-1432830882u, 137378235u, 1135974068u, 318705754u,
-2491227157u,
-2627534472u,
-3520352233u, 2488397682u, 3969194920u, 3843962181u,
-2135981459u, 2611933220u, 799460731u, 2300968851u,
-3412851628u,
-3070914013u,
-3555224260u, 4125937572u, 240359903u, 722496673u,
-2061023600u, 3843919221u, 2759960043u, 1191155322u,
-1504041490u,
-3735253656u,
-1773124736u, 101110011u, 1627699578u, 2645634551u,
-263603947u, 1388368439u, 677146538u, 1644201982u,
-2625699644u,
-2403862553u,
-2426069017u, 3613511705u, 915141802u, 2981654265u,
-3474818167u, 2611101773u, 627891434u, 762754924u,
-2143021902u,
-51067670u,
-4017746573u, 2269879853u, 3037857950u, 2388899692u,
-582729171u, 1886116725u, 2281219772u, 264704948u,
-3509984037u,
-4078683368u,
-2172959411u, 1807195632u, 3357092302u, 2253764928u,
-2320369390u, 3076335959u, 2623583210u, 168378015u,
-1435562650u,
-1100977467u,
-3160490319u, 2550328495u, 2396855930u, 1347823908u,
-1617990918u, 3849653099u, 3224111576u, 1681539821u,
-4171542880u,
-552200045u,
-3562947778u, 1676237880u, 3747732307u, 2453332913u,
-865530667u, 3566636849u, 3485502777u, 336779723u,
-2535942410u,
-1685000184u,
-820545711u, 1893670486u, 1273910461u, 1193758569u,
-970365241u, 381205962u, 3612810852u, 1160577445u,
-541488143u,
-4005031080u,
-2333965236u, 2419855455u, 3484533538u, 3073937876u,
-908466956u, 661391539u, 2342122412u, 1467049112u,
-1785800827u,
-135343033u,
-139643209u, 2438375667u, 974654058u, 3216478230u,
-3807620420u, 779043363u, 2812846449u, 333254784u,
-1025244024u,
-2242303095u,
-2476683742u, 350018683u, 174652916u, 933097576u,
-826905896u, 559603581u, 2777181260u, 164915169u,
-4070353203u,
-1459055748u,
-297303985u, 3103837241u, 3812514233u, 232265137u,
-2032819099u, 1523091376u, 3531238208u, 1403510182u,
-2886832080u,
-2599705941u,
-2789695716u, 68437968u, 3823813791u, 1040994569u,
-3024194990u, 2461740520u, 3735391266u, 2042207153u,
-2461678616u,
-3519231840u,
-1344224923u, 411442756u, 1179779351u, 7661528u,
-778352196u, 3288808867u, 589356197u, 2627504511u,
-3374744599u,
-3312172905u,
-357423007u, 3539567796u, 4044452215u, 1445118403u,
-2937983820u, 184089910u, 346201845u, 2427295202u,
-1345448010u,
-2884434843u,
-3085001879u, 2640105409u, 315310640u, 3530289798u,
-3362974764u, 963602652u, 75228477u, 3509381180u,
-4012777756u,
-2380345941u,
-1073137836u, 2083960378u, 1220315185u, 3628720934u,
-3508867818u, 67148343u, 3558085158u, 1753943368u,
-863309561u,
-2844713625u,
-441921850u, 854732254u, 816793316u, 2555428747u,
-3440623414u, 1707304366u, 3189874375u, 1623229221u,
-1220335976u,
-806745430u,
-3909262947u, 1680369031u, 2926179486u, 3410391660u,
-3991630434u, 2876458763u, 1179167079u, 536360759u,
-1592117159u,
-1514343977u,
-1032622306u, 2057494855u, 784938958u, 178402996u,
-1152907972u, 2326185495u, 2939973666u, 4181120253u,
-552831733u,
-664251856u,
-1297139539u, 1969357631u, 1474065957u, 3055419017u,
-3395829380u, 3316562752u, 2168409017u, 614624786u,
-3585854336u,
-668291094u,
-1162889217u, 3773171307u, 2263271126u, 355089668u,
-3195850578u, 3396793277u, 3519870267u, 527857605u,
-3972392320u,
-2224315010u,
-4047225561u, 3271434798u, 3192704713u, 2798505213u,
-3932215896u, 3792924012u, 3796843756u, 453872975u,
-4050552799u,
-1056432676u,
-928166947u, 121311642u, 930989547u, 2087070683u,
-1288978057u, 1556325239u, 1812435626u, 1682385724u,
-1214364933u,
-904760776u,
-3957045528u, 3949822847u, 2411065880u, 3716420732u,
-3424837835u, 3833550693u, 1799375326u, 2012368921u,
-2768764136u,
-1786111037u,
-4055479315u, 3751639533u, 2808224623u, 3492656387u,
-1306824780u, 2624000170u, 3134795218u, 1778409297u,
-3900821801u,
-593336325u,
-2772069220u, 2980873673u, 3574497158u, 3994780459u,
-4246519854u, 3482758570u, 4228015183u, 33101083u,
-1769887734u,
-4158035314u,
-3690638998u, 1119035482u, 4134969651u, 2483207353u,
-3932823321u, 285829887u, 3485140138u, 1304815138u,
-995608264u,
-3133997465u,
-1195477617u, 2147693728u, 3506673112u, 4234467492u,
-1183174337u, 1395340482u, 769199343u, 193262308u,
-2798920256u,
-3827889422u,
-3399695609u, 3036045724u, 2999477386u, 3567001759u,
-2682864314u, 1414023907u, 3699872975u, 3369870701u,
-2662284872u,
-2179640019u,
-2485080099u, 3234415609u, 3755915606u, 1339453220u,
-1567403399u, 2076272391u, 293946298u, 3861962750u,
-1291949822u,
-2916864995u,
-132642326u, 2215117062u, 2205863575u, 2488805750u,
-405632860u, 3248129390u, 2952606864u, 896734759u,
-2047417173u,
-3865951392u,
-657296855u, 1328547532u, 3966511825u, 3959682388u,
-4171801020u, 2981416957u, 1868896247u, 790081075u,
-3143666398u,
-2950766549u,
-2065854887u, 2737081890u, 995061774u, 1510712611u,
-2865954809u, 565044286u, 1565631102u, 1500654931u,
-494822108u,
-2803515503u,
-1058154996u, 3506280187u, 856885925u, 4204610546u,
-800905649u, 1130711562u, 558146282u, 2053400666u,
-449794061u,
-2643520245u,
-2101248725u, 3123292429u, 3583524041u, 983372394u,
-1587743780u, 672870813u, 444833475u, 100741452u,
-366232251u,
-1717951248u,
-524144122u, 1362432726u, 1304947719u, 674306020u,
-405665887u, 4081931036u, 1580408204u, 2343242778u,
-3901654006u,
-2627173567u,
-3015148205u, 814686701u, 1327920712u, 1346494176u,
-2468632605u, 2259795544u, 2519278184u, 2129281928u,
-2860266380u,
-4001619412u,
-1154910973u, 2841022216u, 1199925485u, 1372200293u,
-2713179055u, 3609776550u, 2896463880u, 1056406892u,
-177413841u,
-40180172u,
-3274788406u, 660921784u, 1686225028u, 4003382965u,
-2532691887u, 4256809101u, 1186018983u, 667359096u,
-2375266493u,
-2760222015u,
-745187078u, 312264012u, 396822261u, 2588536966u,
-2026998998u, 1766454365u, 3218807676u, 3915487497u,
-2630550356u,
-4130063378u,
-4231937074u, 752212123u, 3085144349u, 3267186363u,
-4103872100u, 4193207863u, 1306401710u, 3014853131u,
-1067760598u,
-2306188342u,
-2437881506u, 4258185052u, 2506507580u, 130876929u,
-1076894205u, 4106981702u, 2799540844u, 945747327u,
-1436722291u,
-2499772225u,
-2571537041u, 2038830635u, 2066826058u, 2892892912u,
-524875858u, 3392572161u, 2869992096u, 1308273341u,
-923668994u,
-1980407857u,
-2275009652u, 240598096u, 2658376530u, 3505603048u,
-1022603789u, 582423424u, 846379327u, 4092636095u,
-4177298326u,
-1004173023u,
-2154027018u, 2993634669u, 1098364089u, 3035642175u,
-1335688126u, 1376393415u, 1252369770u, 3815033328u,
-1999309358u,
-1234054757u,
-1388595255u, 2859334775u, 366532860u, 3453410395u,
-4226967708u, 1321729870u, 2078463405u, 156766592u,
-3157683394u,
-3549293384u,
-3348214547u, 2879648344u, 1144813399u, 2758966254u,
-647753581u, 813615926u, 2035441590u, 1961053117u,
-600168686u,
-2192833387u,
-3156481401u, 3627320321u, 383550248u, 81209584u,
-2339331745u, 1284116690u, 1980144976u, 2955724163u,
-789301728u,
-3842040415u,
-1115881490u, 965249078u, 4098663322u, 1870257033u,
-2923150701u, 4217108433u, 183816559u, 2104089285u,
-2640095343u,
-3173757052u,
-927847464u, 2383114981u, 4287174363u, 1886129652u,
-70635161u, 1182924521u, 1121440038u, 4246220730u,
-3890583049u,
-975913757u,
-2436253031u, 1074894869u, 1301280627u, 992471939u,
-735658128u, 244441856u, 1541612456u, 3457776165u,
-3503534059u,
-1931651133u,
-349142786u, 3669028584u, 1828812038u, 99128389u,
-1364272849u, 1963678455u, 3971963311u, 2316950886u,
-1308901796u,
-2789591580u,
-1460494965u, 2380227479u, 1577190651u, 1755822080u,
-2911014607u, 859387544u, 13023113u, 2319243370u,
-2522582211u,
-2299110490u,
-3342378874u, 2589323490u, 1884430765u, 3739058655u,
-2419330954u, 355389916u, 273950915u, 3670136553u,
-410946824u,
-3174041420u,
-2609010298u, 3059091350u, 2300275014u, 725729828u,
-2548380995u, 1738849964u, 1257081412u, 79430455u,
-810321297u,
-3246190593u,
-1007937684u, 912115394u, 40880059u, 3450073327u,
-4289832174u, 2253485111u, 1065639151u, 2953189309u,
-124779113u,
-654299738u,
-115760833u, 1250932069u, 884995826u, 3998908281u,
-1382882981u, 1134187162u, 3202324501u, 487502928u,
-3032756345u,
-4057517628u,
-933197381u, 2319223127u, 2044528655u, 2554572663u,
-4049450620u, 1620812836u, 2832905391u, 2273005481u,
-1913090121u,
-1055456023u,
-510593296u, 3285343192u, 2912822536u, 1645225063u,
-638418430u, 452701300u, 1025483165u, 1639370512u,
-167948643u,
-2809842730u,
-2983135664u, 407521332u, 1543756616u, 3949773145u,
-4283462892u, 659962275u, 3878013463u, 1000748756u,
-4053212051u,
-4099239406u,
-3467581965u, 354635541u, 21301844u, 3831212473u,
-3189450571u, 2264401966u, 4096484849u, 1736448515u,
-3976926096u,
-3727194724u,
-2243487039u, 585209095u, 3143046007u, 969558123u,
-3037113502u, 3594170243u, 2835860223u, 3775493975u,
-2787220812u,
-2274252217u,
-2915380701u, 3077533278u, 1252871826u, 1519790952u,
-205297661u, 2950557658u, 3956882191u, 2724439401u,
-3694608025u,
-124028038u,
-216019153u, 1533010676u, 2259986336u, 2014061617u,
-2068617849u, 3078123052u, 2692046098u, 1582812948u,
-396916232u,
-1470894001u,
-1694309312u, 300268215u, 1553892743u, 671176040u,
-1544988994u, 2793402821u, 4194972569u, 2296476154u,
-748354332u,
-3491325898u,
-4261053291u, 1104998242u, 797816835u, 243564059u,
-2197717393u, 299029458u, 1675252188u, 3139770041u,
-583018574u,
-2532106100u,
-2099391658u, 3760526730u, 3422719327u, 3556917689u,
-2374009285u, 2130865894u, 3710563151u, 1437538307u,
-3938030842u,
-2006930694u,
-2151243336u, 1939741287u, 1957068175u, 2135147479u,
-649553342u, 1713643042u, 4188696599u, 1698739939u,
-3549427584u,
-1016382174u,
-322644378u, 2476164549u, 2037263020u, 88036019u,
-2548960923u, 539867919u, 2871157727u, 4031659929u,
-754087252u,
-972656559u,
-4246379429u, 3877308578u, 2059459630u, 3614934323u,
-1410565271u, 2102980459u, 215395636u, 1083393481u,
-3775523015u,
-2062750105u,
-2475645882u, 3041186774u, 3534315423u, 758607219u,
-1686100614u, 180500983u, 1155581185u, 1476664671u,
-2918661695u,
-3812731350u,
-4003853737u, 4148884881u, 1468469436u, 3278880418u,
-1045838071u, 1049161262u, 360450415u, 3158065524u,
-814443735u,
-3391401707u,
-729968410u, 738771593u, 3662738792u, 1672830580u,
-4199496163u, 188487238u, 219098233u, 2141731267u,
-3890250614u,
-2988780375u,
-4026279523u, 3489429375u, 2468433807u, 1178270701u,
-2685094218u, 2716621497u, 3718335529u, 2273344755u,
-701110882u,
-1925717409u,
-1515176562u, 2325460593u, 3954798930u, 784566105u,
-3769422266u, 1641530321u, 2703876862u, 2907480267u,
-1828076455u,
-1805635221u,
-3883381245u, 1476756210u, 2072514392u, 3658557081u,
-2003610746u, 2556845550u, 729594004u, 3303898266u,
-1968227254u,
-423204951u,
-231828688u, 4223697811u, 698619045u, 3636824418u,
-2738779239u, 2333529003u, 2833158642u, 580285428u,
-3038148234u,
-1012378004u,
-1113647298u, 1424593483u, 4053247723u, 1167152941u,
-2677383578u, 3419485379u, 2135673840u, 440478166u,
-1682229112u,
-3226724137u,
-1217439806u, 3828726923u, 3636576271u, 3467643156u,
-2005614908u, 2655346461u, 2345488441u, 1027557096u,
-3594084220u,
-1372306343u,
-2342583762u, 4291342905u, 4094931814u, 3254771759u,
-821978248u, 2404930117u, 1143937655u, 3156949255u,
-3460606610u,
-449701786u,
-3474906110u, 1932585294u, 2283357584u, 1808481478u,
-3522851029u, 3040164731u, 1530172182u, 2950426149u,
-1402416557u,
-756419859u,
-4132576145u, 724994790u, 2852015871u, 2177908339u,
-899914731u, 139675671u, 1423281870u, 3198458070u,
-807581308u,
-2021611521u,
-1801452575u, 1425984297u, 2833835949u, 1536827865u,
-3902351840u, 164546042u, 1872840974u, 3986194780u,
-792156290u,
-3378681896u,
-941547959u, 3931328334u, 3661060482u, 2386420777u,
-3920146272u, 3458621279u, 3348500844u, 2269586542u,
-797371473u,
-3188953649u,
-80514771u, 2913333490u, 1246325623u, 3253846094u,
-1723906239u, 1606413555u, 587500718u, 1412413859u,
-2310046829u,
-2113313263u,
-3855635608u, 47271944u, 1112281934u, 3440228404u,
-2633519166u, 425094457u, 307659635u, 67338587u,
-2412987939u,
-2363930989u,
-2853008596u, 2844637339u, 922568813u, 130379293u,
-2825204405u, 2904442145u, 1176875333u, 1511685505u,
-599177514u,
-1872681372u,
-682394826u, 1888849790u, 3635304282u, 1761257265u,
-1571292431u, 355247075u, 1177210823u, 1691529530u,
-3629531121u,
-3760474006u,
-1129340625u, 868116266u, 3908237785u, 1942124366u,
-1266630014u, 3214841995u, 334023850u, 1110037019u,
-369650727u,
-1288666741u,
-70535706u, 20230114u, 4284225520u, 727856157u,
-293696779u, 1244943770u, 3976592462u, 560421917u,
-4171688499u,
-2438786950u,
-1218144639u, 3809125983u, 1302395746u, 534542359u,
-2121993015u, 2899519374u, 3192177626u, 1761707794u,
-3101683464u,
-1555403906u,
-3225675390u, 1875263768u, 4278894569u, 651707603u,
-2111591484u, 3802716028u, 2900262228u, 1181469202u,
-3254743797u,
-1822684466u,
-860641829u, 3046128268u, 1284833012u, 1125261608u,
-461384524u, 2331344566u, 1274400010u, 990498321u,
-3462536298u,
-3796842585u,
-2346607194u, 279495949u, 3951194590u, 3522664971u,
-3169688303u, 726831706u, 1123875117u, 1816166599u,
-3759808754u,
-2918558151u,
-3713203220u, 3369939267u, 466047109u, 384042536u,
-587271104u, 2191634696u, 2449929095u, 1157932232u,
-2084466674u,
-841370485u,
-3241372562u, 4277738486u, 2150836793u, 1173569449u,
-778768930u, 2594706485u, 3065269405u, 3019263663u,
-2660146610u,
-2789946230u,
-77056913u, 728174395u, 3647185904u, 804562358u,
-2697276483u, 881311175u, 1178696435u, 2059173891u,
-2308303791u,
-221481230u,
-50241451u, 3689414100u, 1969074761u, 2732071529u,
-1900890356u, 840789500u, 2100609300u, 985565597u,
-1220850414u,
-2456636259u,
-223607678u, 1016310244u, 1937434395u, 85717256u,
-275058190u, 3712011133u, 171916016u, 2389569096u,
-3679765802u,
-3575358777u,
-3481108261u, 3178286380u, 2489642395u, 2931039055u,
-3086601621u, 3079518902u, 3027718495u, 2506894644u,
-2976869602u,
-2134336365u,
-2420172217u, 918054427u, 661522682u, 1403791357u,
-3587174388u, 2623673551u, 1355661457u, 4159477684u,
-1109013587u,
-3112183488u,
-2217849279u, 3500291996u, 2419603731u, 2929886201u,
-3854470013u, 1358382103u, 1357666555u, 21053566u,
-2716621233u,
-3094836862u,
-3309729704u, 57086558u, 839187419u, 2757944838u,
-3651040558u, 3607536716u, 3691257732u, 2312878285u,
-1202511724u,
-183479927u,
-2509829803u, 109313218u, 478173887u, 2072044014u,
-190631406u, 2495604975u, 1010416260u, 3679857586u,
-726566957u,
-258500881u,
-1805873908u, 3081447051u, 2352101327u, 534922207u,
-1584552873u, 813470716u, 255914637u, 249169434u,
-3193498057u,
-1038802706u,
-2590158653u, 3147907290u, 663060128u, 1156177857u,
-634616100u, 312879189u, 1545020368u, 2054634247u,
-3271451914u,
-3438291534u,
-2181454946u, 3864535432u, 2398586877u, 896491075u,
-2810631478u, 2770357487u, 3372930052u, 898070638u,
-2051007323u,
-392959778u,
-36645539u, 3743556044u, 4134529680u, 4124451188u,
-566806297u, 2936523982u, 1304761965u, 537399498u,
-1940818842u,
-40862381u,
-36288410u, 3063605629u, 2826611650u, 3961972098u,
-1871578006u, 2392095486u, 1136931591u, 513864488u,
-173276451u,
-3039055682u,
-3543322032u, 1943592006u, 657217094u, 1751698246u,
-2969618445u, 456616022u, 900309519u, 113892716u,
-1126392103u,
-1235651045u,
-1882073852u, 2136610853u, 2353639710u, 2819956700u,
-3980083530u, 828773559u, 224069850u, 902434120u,
-2802008036u,
-94358995u,
-2777723394u, 2812641403u, 2525832595u, 4157388110u,
-4235563782u, 937800324u, 141690749u, 568062536u,
-550123849u,
-1330316521u,
-1949488696u, 2296431366u, 1958465262u, 3564751729u,
-3748252207u, 120455129u, 1607318832u, 2525729790u,
-2640987481u,
-2332096657u,
-1775969159u, 1555085077u, 2913525137u, 1347085183u,
-2376253113u, 3194050574u, 1806090610u, 678641356u,
-1499146713u,
-383849715u,
-3299835823u, 2284860330u, 2614269636u, 3913628844u,
-2761334210u, 1959484587u, 529797021u, 239966995u,
-3102194829u,
-3602307804u,
-1122192627u, 3577510006u, 164486066u, 1680137310u,
-1473396395u, 1467801424u, 903493660u, 1185943071u,
-2798556505u,
-2306744492u,
-3167201310u, 3577947177u, 3067592134u, 2905506289u,
-1210366329u, 204484056u, 2347778932u, 3862374472u,
-3277439508u,
-4187414621u,
-1646699310u, 621385800u, 3934869089u, 3975491588u,
-3580085916u, 1925674500u, 2436305348u, 3983301539u,
-2739439523u,
-3291507446u,
-3395637920u, 3753389171u, 2955202032u, 2654255623u,
-3771089254u, 2140443405u, 2779834738u, 3261942805u,
-3526889244u,
-1842009139u,
-4048484340u, 2106218403u, 2161244271u, 772152700u,
-1158647659u, 3776791619u, 3882186721u, 699525237u,
-2954670460u,
-1007105869u,
-3359152025u, 1146388699u, 1401550303u, 2326582541u,
-4181783540u, 1085644043u, 1942143795u, 1038368308u,
-1526153809u,
-4042547244u,
-1891441000u, 2573991874u, 1281441253u, 3635098284u,
-1980545715u, 825985487u, 3934748116u, 4228386979u,
-1480870944u,
-1042194545u,
-2397771642u, 2248490001u, 3817869868u, 878654626u,
-3785629484u, 1672470870u, 3229367873u, 1894538933u,
-1010692731u,
-1733824268u,
-656620328u, 3048283803u, 3353340056u, 2324965120u,
-4192585951u, 2284524675u, 3483884368u, 1510168293u,
-1554942691u,
-1309709396u,
-1241133168u, 3162179280u, 4046378054u, 3171681593u,
-1165297136u, 3496703563u, 150437903u, 1948622072u,
-1076332463u,
-2292479143u,
-1464229958u, 3479738093u, 2328067598u, 2334503110u,
-833324834u, 3981605747u, 3002629155u, 2854644186u,
-2832201336u,
-95796957u,
-3269249397u, 2358313329u, 3411860910u, 4283292480u,
-2802208697u, 1305947955u, 2156803420u, 1991340283u,
-189678024u,
-447602599u,
-1055411517u, 1531748363u, 1555852656u, 412402681u,
-3774988152u, 20597551u, 2925024131u, 1423989620u,
-3749428061u,
-1541439448u,
-112270416u, 1936224776u, 132162941u, 3772011507u,
-3814102518u, 1908807815u, 444154079u, 823765347u,
-3362275567u,
-3419047430u,
-2108287005u, 2315102125u, 658593738u, 3195094029u,
-3721937534u, 3176229204u, 3398835373u, 1271898712u,
-1142546577u,
-3185986817u,
-3562705803u, 2046119567u, 912990621u, 1829977672u,
-3459576979u, 1118045834u, 1369529376u, 3320601076u,
-3954988953u,
-4002467635u,
-3359456351u, 1314849568u, 1766750942u, 2998874853u,
-1181800239u, 707328036u, 3314954697u, 2066721120u,
-598194215u,
-1124451278u,
-3156679616u, 3742684743u, 2960199690u, 2683497915u,
-2566077529u, 937014607u, 102095219u, 4262922475u,
-3132264275u,
-1262099830u,
-862722905u, 2717653494u, 3245583534u, 3427209989u,
-3220278124u, 85457091u, 2222333500u, 3513997967u,
-3522324951u,
-2830855552u,
-2215004781u, 3482411840u, 4227160614u, 2030964411u,
-1741393851u, 2643723748u, 942813508u, 403442675u,
-3112048748u,
-530556423u,
-3817755244u, 3543286628u, 2247276090u, 1532920842u,
-4101962711u, 1446540991u, 3297821473u, 1861255389u,
-1984398u,
-2366525138u,
-377589481u, 3549193828u, 1427765914u, 506831657u,
-277278988u, 1447652775u, 3214362239u, 3142198690u,
-2843087541u,
-468915015u,
-807895062u, 2198723907u, 4031145069u, 2417156212u,
-4027298697u, 637175947u, 1229254212u, 1773257887u,
-1659444818u,
-451148891u,
-2099741368u, 735351990u, 2534775713u, 3261804619u,
-712519954u, 3527962772u, 3758642738u, 4245823575u,
-1281314264u,
-1167866160u,
-1489546151u, 1197354389u, 1043278102u, 2563326586u,
-371937794u, 2320164817u, 3189512691u, 573685198u,
-4108603513u,
-3758899588u,
-3507030163u, 2947201212u, 2529492585u, 578234375u,
-3362349842u, 3318878925u, 3611203517u, 3059253190u,
-4270755916u,
-4291274625u,
-4237586791u, 4137422245u, 2927218651u, 2444687041u,
-797128811u, 2043057612u, 396533859u, 2665256178u,
-3346510674u,
-1779586176u,
-3076562062u, 1882746214u, 921095362u, 2026988397u,
-514514911u, 3886379478u, 4218272420u, 1480386793u,
-3900160816u,
-2292273451u,
-1276138356u, 1125461821u, 1912885715u, 3365266013u,
-1333211627u, 4085009861u, 1390530102u, 3347984752u,
-2721771301u,
-1419492325u,
-4066766256u, 3250852311u, 820111852u, 1382201318u,
-2366036798u, 938032241u, 3100979439u, 487048687u,
-2292851045u,
-3241399180u,
-3912670510u, 2416437067u, 2973194517u, 3507707986u,
-1935099406u, 2533441488u, 104616731u, 2892622820u,
-3801190339u,
-4239188808u,
-807238241u, 3300121546u, 2249406147u, 4032114017u,
-3713738189u, 3324425575u, 4275607376u, 3663120298u,
-4173658372u,
-3984289690u,
-1827636846u, 3264588778u, 3297165529u, 558623533u,
-2728945672u, 1566297318u, 3447249966u, 481719551u,
-1596842050u,
-1838185946u,
-265271620u, 1050246315u, 4046655705u, 1844193138u,
-3807563245u, 1075384804u, 1292554949u, 1506525927u,
-2921816148u,
-2051885269u,
-1930534041u, 3872721086u, 1564489377u, 2272482181u,
-2849358683u, 589618304u, 2262072443u, 290363051u,
-299168363u,
-3867603931u,
-2868688756u, 2545263115u, 1092098533u, 3885725603u,
-2352430409u, 1981595469u, 2047946646u, 1332642839u,
-793806516u,
-214858837u,
-1061484659u, 3192394476u, 1115054785u, 3690637234u,
-996792368u, 2023479706u, 3046498231u, 4205835102u,
-3870714754u,
-257472875u,
-3549864599u, 2040276129u, 2414778670u, 812235477u,
-2674248196u, 1864096101u, 2257492689u, 1332556794u,
-1079540713u,
-465530720u,
-2304763972u, 830724724u, 3354588920u, 2510713652u,
-3103749409u, 468835585u, 1707620787u, 3038024846u,
-1000303198u,
-3462270146u,
-2748698899u, 2100348093u, 511537258u, 1237187486u,
-102049383u, 2268226698u, 3162251739u, 4219404629u,
-838822407u,
-1481440623u,
-2989224077u, 2676681975u, 3246551821u, 3812079906u,
-370572963u, 2283154352u, 3084789986u, 1961085583u,
-1955640586u,
-2409348147u,
-2284780581u, 1634818716u, 4018221729u, 2320761377u,
-3566831899u, 1799560520u, 91431959u, 1754113747u,
-1459430477u,
-3613658517u,
-924489906u, 3406317699u, 866289774u, 3924821603u,
-1265394945u, 1870668109u, 151949856u, 2747006534u,
-3111906201u,
-64039467u,
-2314447545u, 2600195638u, 4095795204u, 4162096026u,
-1026756826u, 2460047982u, 52686887u, 823198739u,
-1518045160u,
-2867527376u,
-566410761u, 2200433819u, 2114146405u, 2893790965u,
-881504901u, 974783212u, 490815659u, 937300283u,
-1523735309u,
-2511976468u,
-2634644947u, 355119367u, 1373773092u, 309232995u,
-3088671051u, 787126032u, 3442836843u, 4289194567u,
-2177850062u,
-1174136430u,
-3248982914u, 3129039732u, 1166851580u, 2196451882u,
-469595580u, 2130837700u, 3783349021u, 3745262548u,
-1236930515u,
-3032131496u,
-1525591437u, 1823628217u, 1939019255u, 1950270463u,
-3659899927u, 3688643445u, 3004399289u, 1155199552u,
-357547234u,
-2213110526u,
-3122658210u, 2667800490u, 2718690333u, 3512372076u,
-1098611683u, 2657518392u, 4248458835u, 3109874532u,
-1592908438u,
-2864927516u,
-3635248840u, 1251777186u, 3797340158u, 3508496870u,
-303354834u, 1482394062u, 2087100120u, 1595931912u,
-608574156u,
-723367884u,
-907938402u, 3357047807u, 1619629851u, 3092082995u,
-89030300u, 916336992u, 1861180168u, 3436334155u,
-1375000544u,
-3472936241u,
-1321217853u, 791356402u, 2872410224u, 2326250297u,
-2657644088u, 1748314108u, 4146771421u, 2913114440u,
-2924821844u,
-2101101496u,
-3268017251u, 2109603066u, 690665520u, 1830067573u,
-951427661u, 2982533150u, 3884512506u, 2358657479u,
-2833210784u,
-3419798214u,
-3785893994u, 2103940206u, 86759766u, 4031230616u,
-3745237192u, 2739453927u, 497038072u, 3303159408u,
-1251537249u,
-1993408196u,
-3185905715u, 2885948408u, 3154277110u, 2444150313u,
-2505582079u, 2120610195u, 3266465773u, 1814611964u,
-3080050407u,
-1079915522u,
-1819346505u, 2529946763u, 892097374u, 3740257161u,
-3618100441u, 1079900094u, 3607172225u, 737863389u,
-360704560u,
-3341993089u,
-1139047381u, 3132219631u, 1248981859u, 1109338159u,
-2004908615u, 4022302594u, 4166640860u, 2959140950u,
-3949235962u,
-2832278473u,
-2200524012u, 2634933043u, 2495844522u, 2613799818u,
-4034096813u, 683271795u, 1673546817u, 1363163726u,
-1805395136u,
-511749501u,
-1231032599u, 2305979751u, 345737783u, 3339868854u,
-2931857933u, 2323251738u, 1332068477u, 51846558u,
-3927238177u,
-1387182179u,
-1701238601u, 1419275173u, 2580882268u, 3357874599u,
-1726558907u, 1292901039u, 1371322339u, 1311713044u,
-3526735232u,
-4017884184u,
-3366093428u, 77140994u, 2128996229u, 1357915765u,
-4019691901u, 483989024u, 2390311750u, 2766065288u,
-3938587520u,
-3064810344u,
-1054589198u, 1274997019u, 4040589616u, 1277751144u,
-2274907047u, 4170399945u, 2886368209u, 4168922115u,
-3901237033u,
-3252972311u,
-2205185840u, 3403097556u, 3385493699u, 2809751370u,
-555319628u, 399539034u, 2998971454u, 1521596214u,
-178870216u,
-1471733541u,
-519629198u, 514159209u, 1500582242u, 1928616587u,
-2686427928u, 4133138798u, 1225914083u, 1432713584u,
-3559310915u,
-3925489366u,
-1055613123u, 4126676029u, 2723867653u, 3290604111u,
-1377022957u, 2373608155u, 3615237379u, 594338683u,
-2645257602u,
-2408427260u,
-917033274u, 750455097u, 625657657u, 121713200u,
-2191273413u, 4043949724u, 3293146785u, 3809297972u,
-3947296919u,
-115456894u,
-1529576616u, 1459278275u, 2157117997u, 1747859293u,
-4106665903u, 996939232u, 2007976332u, 4274649009u,
-1017725787u,
-4244666096u,
-1219631331u, 3072426253u, 3547691720u, 1620822012u,
-1397717508u, 2031597325u, 3345983430u, 2459068000u,
-3645130467u,
-2308642742u,
-359955852u, 1348467968u, 1133123059u, 2435919062u,
-2800365907u, 4213217210u, 4056565603u, 2811666556u,
-2318007236u,
-3823652401u,
-3654086429u, 1273260424u, 1591610446u, 943349350u,
-3441227678u, 3779964757u, 233818224u, 3469971032u,
-3764095096u,
-4009204587u,
-678472092u, 1990559652u, 2583121088u, 2978143652u,
-2496370864u, 2139539656u, 4287972050u, 295832576u,
-3536742861u,
-2257466133u,
-2738052161u, 1988611898u, 2466189642u, 3294419573u,
-2311186273u, 474374532u, 3081964174u, 2515138278u,
-835731677u,
-1178182694u,
-3352119543u, 2884763225u, 3462399574u, 2900817210u,
-1993698511u, 2868445043u, 2746444849u, 1205258179u,
-2353442946u,
-4079040070u,
-3624133102u, 2907136076u, 2902521697u, 426813211u,
-1418185512u, 3711189488u, 1351506552u, 1934749519u,
-46595543u,
-401688809u,
-3514602124u, 1396852607u, 1951477943u, 2502249173u,
-3199695820u, 2890250638u, 4205072507u, 1715623846u,
-3266686789u,
-3218688128u,
-1697759742u, 851227671u, 2358709645u, 4174233268u,
-500583683u, 3805940955u, 736234120u, 2710563712u,
-1949664540u,
-3139414003u,
-4293073253u, 1284406972u, 1785182449u, 1051548274u,
-2994248357u, 2499882522u, 717208669u, 2039517285u,
-518424929u,
-143136433u,
-2303774671u, 1272930860u, 2286410920u, 788459311u,
-273225293u, 2439291703u, 2254505236u, 3446287701u,
-3655156558u,
-1546628787u,
-340081500u, 3285722006u, 1324810435u, 1053980860u,
-1779472859u, 2700355724u, 686005017u, 3762376315u,
-3963193100u,
-1370881135u,
-661300087u, 1152753704u, 2349891598u, 3910051187u,
-2109444785u, 1311123870u, 2639837565u, 1896770931u,
-1081414128u,
-869877586u,
-4284220400u, 63045374u, 235968615u, 184451062u,
-1271099822u, 1319179857u, 3274963209u, 4172272710u,
-3388797445u,
-2965973320u,
-3793110097u, 3327241723u, 2991804005u, 1199544355u,
-771553759u, 2031749842u, 2596517372u, 1199888213u,
-858347951u,
-3340178832u,
-2903875412u, 763490382u, 76949161u, 2056544406u,
-1145227689u, 998233136u, 2354530024u, 427713587u,
-3537837347u,
-604661755u,
-923986833u, 1023730418u, 798294227u, 432557449u,
-801802449u, 1861313429u, 3899128441u, 4068407979u,
-2352677083u,
-3783539925u,
-10731973u, 3390767975u, 3949540249u, 1920121661u,
-3248580201u, 641956426u, 2104847395u, 604835744u,
-1491663404u,
-4255204651u,
-1520970746u, 2845653368u, 3247412938u, 3730629005u,
-855569514u, 3073294700u, 2429691698u, 3818342476u,
-3938869985u,
-2731201328u,
-2335202643u, 778117742u, 13298408u, 228780590u,
-2871715314u, 3253688653u, 4150999702u, 3846220408u,
-930808u,
-1397128726u,
-1964216488u, 2781092828u, 116285375u, 2271239476u,
-3724347554u, 2931203895u, 3893169206u, 1883912528u,
-2093892660u,
-3658787024u,
-3095016046u, 1094059199u, 3640239610u, 558564267u,
-2102812456u, 464734873u, 925262247u, 1609838036u,
-588364741u,
-1731409233u,
-1576165139u, 3933979268u, 375316394u, 4247099643u,
-3670508019u, 4080496835u, 2371248533u, 183762693u,
-2078935389u,
-2699810414u,
-1491815683u, 2999180789u, 1831158425u, 1603373553u,
-2006136905u, 3210230591u, 416748595u, 1536971415u,
-3271869367u,
-1266062739u,
-2138414557u, 3337114778u, 1634586826u, 36472629u,
-4482244u, 568009609u, 2721216780u, 4037289545u,
-2235138807u,
-1789351460u,
-4067539527u, 1323062829u, 3864620647u, 4192026301u,
-4278901241u, 1399025382u, 2826652805u, 1363860382u,
-1801770651u,
-1613381526u,
-1165249276u, 4046576622u, 2535596946u, 3260388176u,
-1078898578u, 2259750862u, 643387587u, 237144235u,
-4199571427u,
-3440917581u,
-3067939258u, 2018625455u, 1460528353u, 3138629939u,
-1666223528u, 3841139376u, 2528281125u, 885565193u,
-2609492686u,
-2517257479u,
-560864620u, 2261471820u, 3491559165u, 1329620416u,
-622383582u, 1759597655u, 2877873893u, 584692817u,
-1901728399u,
-2599000260u,
-3169771644u, 296332336u, 774719455u, 4175920823u,
-2287316070u, 4115615023u, 1073335619u, 4240292725u,
-1359158837u,
-1960974237u,
-3173724597u, 1619084286u, 2876340752u, 4065675347u,
-480741335u, 1237329941u, 701055566u, 3729009837u,
-1314736422u,
-4003180069u,
-3118519317u, 3035354420u, 3380357671u, 4020909015u,
-253958714u, 3545798863u, 3008185002u, 2624719888u,
-3219955575u,
-3060719376u,
-573101682u, 1580316843u, 2610493412u, 3490983536u,
-3601975611u, 851470366u, 635384901u, 3427048824u,
-1470002757u,
-3592460087u,
-2265226856u, 4124282457u, 2106385486u, 3334305617u,
-4208282753u, 3798749815u, 225396466u, 118791182u,
-2523395972u,
-194595464u,
-2563824631u, 2521301383u, 4224409406u, 468670274u,
-1761966400u, 1300908277u, 2570709228u, 1847901526u,
-1470099163u,
-2690466752u,
-1472536718u, 2399279735u, 4150607803u, 1775080054u,
-2082537685u, 4080034578u, 1256001880u, 392967725u,
-2055838940u,
-3349115816u,
-1745947263u, 2213925887u, 1836572741u, 2417722792u,
-636223705u, 2423329294u, 3960951311u, 1543591052u,
-1547914361u,
-2760945653u,
-3519014111u, 313543871u, 4119598884u, 1071003714u,
-2192556597u, 1526995535u, 3929839778u, 536388591u,
-3040873792u,
-3752682932u,
-1640614237u, 2432794021u, 385337403u, 2794410617u,
-2386128075u, 1055206708u, 1422747714u, 3759330929u,
-2533597496u,
-30440955u,
-1482899460u, 3350385050u, 616259409u, 3980103795u,
-1211364140u, 1040071544u, 594746920u, 1645973936u,
-2547331531u,
-1097726368u,
-700666526u, 2976247482u, 1144906608u, 996506677u,
-1997130756u, 800321417u, 1392942823u, 1601662248u,
-2079778663u,
-529512908u,
-2925120134u, 4106433085u, 630221833u, 2423086156u,
-1119859778u, 1726827981u, 1870859181u, 2559832707u,
-1792284257u,
-2059356387u,
-3572353364u, 3229407475u, 575621095u, 3221893291u,
-2372428048u, 2020123035u, 961449593u, 2243824063u,
-3803906611u,
-3735348189u,
-2981620804u, 4180681078u, 1555330629u, 230736535u,
-2075526640u, 749652975u, 713664372u, 2152096659u,
-2142067223u,
-3322302242u,
-1421646830u, 2092832615u, 1213735101u, 3192136753u,
-1106723940u, 3455398230u, 2541685524u, 2529956739u,
-3789430647u,
-1950084508u,
-2157395621u, 850457360u, 2758902426u, 2848030169u,
-6506379u, 1162213157u, 2981459221u, 272690871u,
-3059420255u,
-4242691285u,
-588065598u, 1206949936u, 3968214184u, 566348532u,
-126142880u, 1480567086u, 2959621988u, 2050218418u,
-2242731195u,
-3833514449u,
-1898070331u, 3687399477u, 3891859374u, 868185955u,
-2335308774u, 3676335246u, 3871121805u, 2189032743u,
-3275728647u,
-860492892u,
-1590764344u, 4130384758u, 262871548u, 3004764525u,
-2685542071u, 991231482u, 435122019u, 3031116998u,
-2898921700u,
-2917932604u,
-4238665148u, 2459072654u, 3444612545u, 4207731740u,
-1808564313u, 2798532269u, 3944553556u, 3926395409u,
-1633200670u,
-4138335224u,
-2524878605u, 4184292650u, 3563398268u, 4288943552u,
-3802121210u, 957502058u, 2410820887u, 4227117506u,
-4018625153u,
-4284329158u,
-530216712u, 2978986531u, 863452221u, 1910162118u,
-4088211378u, 4091971261u, 3150811451u, 4200871487u,
-3794038652u,
-3041564310u,
-2045287082u, 887805614u, 2889167251u, 4120352181u,
-1699912580u, 3478922097u, 3211994687u, 3136177842u,
-1500806861u,
-3211881347u,
-2147976385u, 3342722260u, 3359650541u, 4197378460u,
-781354073u, 1533623029u, 2204677828u, 3228172832u,
-3248592437u,
-3355841359u,
-560815159u, 1144951236u, 4027015711u, 2882625391u,
-339363613u, 2354572719u, 1769831876u, 4238589331u,
-1519732871u,
-2185834614u,
-1601096831u, 129709881u, 39655633u, 367604993u,
-1737681770u, 3259114599u, 2767070452u, 872365177u,
-1574125529u,
-3405020189u,
-4181346685u, 1134030380u, 403769171u, 2193351164u,
-1426232618u, 2885309450u, 3033612627u, 924948363u,
-935514094u,
-3202053329u,
-912294839u, 1618472324u, 4159158431u, 3744999487u,
-777064358u, 3974213124u, 1990246048u, 309725290u,
-2449849392u,
-1943692420u,
-2288635750u, 2433793635u, 2168904061u, 683315308u,
-3081493019u, 3477759434u, 3815496269u, 2823504699u,
-586945121u,
-3088963200u,
-3492287335u, 636875049u, 1111206944u, 2037346120u,
-1282050044u, 1409681512u, 1786128584u, 755810950u,
-2332676758u,
-2178142310u,
-957827166u, 1014983590u, 1888800725u, 3608595803u,
-3200072714u, 2534008478u, 659336139u, 1281728287u,
-4060560529u,
-2915575125u,
-3521503774u, 2926487340u, 1096297674u, 653489861u,
-2352326980u, 2561136777u, 1224141198u, 1250479629u,
-1297625391u,
-2409997371u,
-1942483722u, 2481835750u, 1394715707u, 1673070941u,
-2456039704u, 3980558014u, 3547934764u, 1882038812u,
-1078160498u,
-2488279087u,
-1848235245u, 1211914722u, 2264928765u, 2807773070u,
-270145554u, 583747883u, 3826009010u, 2996618216u,
-425727157u,
-992726957u,
-3384462280u, 726650661u, 1955043265u, 1923879512u,
-1854693773u, 2987614542u, 2660044993u, 2457260810u,
-426299370u,
-2671892900u,
-1827308087u, 3083953443u, 1791749638u, 3265087416u,
-2119752201u, 2547122538u, 3990783236u, 1912713468u,
-3688865211u,
-1815780016u,
-303699291u, 2416763742u, 2690891610u, 1535193548u,
-1107803989u, 1504143133u, 2235270371u, 2545884083u,
-2276278682u,
-411724404u,
-3416925704u, 2565792091u, 3383911757u, 546058824u,
-3374654444u, 2364630415u, 2693473470u, 2622125691u,
-261864817u,
-55682470u,
-857617568u, 141304067u, 1885488541u, 155368182u,
-1281949051u, 3384522408u, 3254816901u, 1959816782u,
-1452224057u,
-2830267691u,
-3709231247u, 58988202u, 4218130458u, 2984061349u,
-1888707848u, 4223605071u, 4241442486u, 375269213u,
-3208327038u,
-2199916493u,
-550337252u, 2855061437u, 276088636u, 114362204u,
-2321163647u, 2127813633u, 3289403024u, 2686973202u,
-2717376797u,
-3593428039u,
-3648831666u, 890925902u, 3289404818u, 3289516821u,
-4248913260u, 1858916580u, 3303932308u, 1752797086u,
-1628149686u,
-3245893605u,
-1568537311u, 2844194502u, 1593855770u, 2408174109u,
-124797514u, 2085649512u, 3188565660u, 2264996276u,
-1926696513u,
-3053957740u,
-2238806881u, 2189050973u, 203685243u, 379855590u,
-3920271562u, 1058600179u, 3698061923u, 4255106849u,
-608401664u,
-1598041932u,
-3318266418u, 2535016555u, 852760884u, 1918098822u,
-2200437599u, 1532285043u, 3425662132u, 3561293706u,
-2231633206u,
-4108785088u,
-3359152801u, 173534780u, 208383607u, 2862988169u,
-2406642243u, 426814583u, 2777335795u, 3322703596u,
-954190623u,
-615093090u,
-4179102978u, 2452847930u, 100239619u, 42471741u,
-818352432u, 2190624654u, 504379960u, 3631619975u,
-633412456u,
-1018421783u,
-842645419u, 711808707u, 3424580813u, 2132457941u,
-1158335882u, 3567952480u, 2302183699u, 1145788151u,
-3474264138u,
-3105085243u,
-3115506027u, 2783713015u, 3871785309u, 539583269u,
-1400252405u, 3857849984u, 4231186588u, 1278653799u,
-1760227022u,
-761044088u,
-3838185417u, 2439542532u, 585283357u, 2055995220u,
-937117124u, 3831944855u, 1823586038u, 3287917855u,
-485082427u,
-3209172809u,
-1984570176u, 2818337297u, 2691869057u, 3790476953u,
-839035557u, 3203129010u, 669981176u, 4121157385u,
-3519870450u,
-3792633352u,
-3017650322u, 1603459507u, 4225677666u, 376555451u,
-473780127u, 2018786277u, 3299822439u, 1010254499u,
-2383887565u,
-3155009499u,
-3108110655u, 2641738274u, 3684908622u, 1606463047u,
-3311068174u, 52708046u, 754181455u, 1018079176u,
-3915670272u,
-3366999425u,
-1012880204u, 1339439715u, 466437962u, 1402662350u,
-2504046911u, 736323938u, 2037800124u, 1725908589u,
-716341840u,
-1750123474u,
-3366342464u, 1743666195u, 2975303189u, 3821364027u,
-3253707772u, 3635548377u, 3840413796u, 1955642085u,
-1018315169u,
-1258092848u,
-2095540656u, 1076256607u, 117289557u, 1311658655u,
-2118301000u, 68721550u, 2886814107u, 2712432819u,
-4201862886u,
-753807148u,
-1940229047u, 731347296u, 1068901393u, 3873155894u,
-2852787666u, 1973464853u, 79735652u, 3966380587u,
-3245740712u,
-2525773438u,
-734938109u, 3045656416u, 3335746354u, 4099732691u,
-1911896517u, 1697006473u, 1145487066u, 1605663299u,
-3053606724u,
-2386289465u,
-3821211369u, 1006215345u, 1256304829u, 1053001668u,
-1289194958u, 118761054u, 1853688730u, 2803418011u,
-188650809u,
-3763686458u,
-1006829556u, 2961984133u, 3390525025u, 2061199893u,
-141792681u, 2439893463u, 2652982650u, 1804942682u,
-1546510005u,
-1246961405u,
-2407577046u, 565772575u, 3751844810u, 2943166103u,
-3750052451u, 3022527280u, 25162928u, 397381043u,
-1818337632u,
-3447363730u,
-3936437150u, 2569420703u, 2215592390u, 2171555672u,
-3665571006u, 4021712412u, 2939158353u, 4057813172u,
-1823237318u,
-103999245u,
-3251978010u, 3591914940u, 3582495283u, 2519035265u,
-3905726135u, 3180393349u, 2743117123u, 55247368u,
-3325286701u,
-705195946u,
-1857526853u, 1480518550u, 3809990433u, 1398189338u,
-3126362926u, 3959531492u, 1503658285u, 1977847740u,
-3043964489u,
-2613086143u,
-1518119282u, 4238434900u, 3905746486u, 3064949667u,
-1028122931u, 3309119457u, 4071194920u, 3096098907u,
-4137180520u,
-494467959u,
-1231408687u, 1691606157u, 1793452569u, 2722196118u,
-3478603952u, 1059665738u, 2282032278u, 3990268388u,
-1719514651u,
-4248311578u,
-3799146721u, 898026304u, 3367808954u, 4162472815u,
-170495870u, 1308116609u, 3428285344u, 1714716475u,
-395576794u,
-4153638621u,
-2999745812u, 3483315953u, 304980828u, 595337120u,
-3486516729u, 2331563143u, 2583609459u, 1885928417u,
-3834283777u,
-979337825u,
-932057378u, 3124081189u, 1930356777u, 3865887996u,
-4178282217u, 4214219408u, 3669465884u, 1472413856u,
-3356866587u,
-1012769806u,
-3043639963u, 996996396u, 207308216u, 982967331u,
-2991319933u, 318066902u, 721489670u, 1249967713u,
-749240921u,
-591392325u,
-2379365192u, 2250868849u, 2163259329u, 143191325u,
-3778285606u, 982149096u, 3536906200u, 2244353244u,
-1443862317u,
-3161549210u,
-2183127464u, 2015409516u, 547003700u, 2032484282u,
-523677821u, 4275663308u, 3827205526u, 3903778273u,
-2444530525u,
-2543645801u,
-1173958423u, 784740616u, 2878693675u, 3127696736u,
-3832037316u, 3161002398u, 4084166400u, 4213346853u,
-223390424u,
-4273380883u,
-2130315482u, 3429606032u, 3367732613u, 1912357694u,
-422632590u, 1266957023u, 3437535648u, 736404240u,
-2281709372u,
-415859912u,
-212948797u, 351612650u, 3920561440u, 112963586u,
-2230727543u, 2851076612u, 1990662634u, 2264296857u,
-3131463650u,
-2704034623u,
-3541637839u, 2954232792u, 533986918u, 4158757533u,
-65174248u, 4232639593u, 865906667u, 1948225652u,
-779656112u,
-3873989249u,
-2372984749u, 2346988193u, 1104345713u, 1165654138u,
-4045762610u, 3588205178u, 461363991u, 1111215752u,
-1389675192u,
-2404325151u,
-2152228101u, 3808973622u, 1901235912u, 3458690696u,
-314513238u, 2539459143u, 2847998873u, 952026138u,
-2325705328u,
-407844712u,
-3727960715u, 2996448351u, 2374336760u, 3138756390u,
-2600015243u, 539980418u, 1876285352u, 1670330799u,
-1709360377u,
-2868531654u,
-494777964u, 2773053597u, 599486162u, 3962209577u,
-1871328846u, 2171933018u, 110279472u, 384074780u,
-4147021936u,
-2333589647u,
-4251778066u, 40493468u, 3099342316u, 4108779767u,
-2812424588u, 954542332u, 2040682331u, 2251152306u,
-45915516u,
-259525626u,
-1045384743u, 4134656562u, 749389261u, 874399445u,
-616549904u, 2200447504u, 436024539u, 78972290u,
-3210485762u,
-1907985531u,
-3013721395u, 4214533685u, 4198804243u, 534879265u,
-1517190881u, 3756787754u, 1152563554u, 1718750948u,
-777737463u,
-1402478860u,
-1824562784u, 1879401449u, 3515818786u, 513165201u,
-1423491227u, 2103067918u, 2291777410u, 1097943000u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ /* if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0); */
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashccTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+1039179260u, 1690343979u, 1018511555u, 2464489001u,
+20368522u, 2663783964u, 175201532u, 1619210592u,
+4081014168u,
+2576519988u,
+3285042206u, 502478099u, 739479538u, 1500332790u,
+13754768u, 3789353455u, 3473868058u, 1909255088u,
+2212771159u,
+1112731063u,
+826915357u, 2893489933u, 118369799u, 1848668220u,
+1308219822u, 249416982u, 64306364u, 4221800195u,
+1020067935u,
+3955445564u,
+563346294u, 550236731u, 2339016688u, 1826259714u,
+3872358639u, 2295981050u, 1870005390u, 4015628802u,
+1451961420u,
+653440099u,
+1292493871u, 164377749u, 1717712483u, 463414587u,
+3924343675u, 1050492084u, 3566618804u, 2046983362u,
+31917516u,
+2957164615u,
+230718965u, 999595115u, 3534822176u, 2175709186u,
+965707431u, 441796222u, 2481718051u, 1827777486u,
+2590087362u,
+3879448744u,
+3515079898u, 1601433082u, 982764532u, 254808716u,
+1293372530u, 4205605817u, 947001462u, 1138890052u,
+176305566u,
+2447367541u,
+2973802542u, 4123621138u, 3083865840u, 1706367795u,
+792114347u, 2880110657u, 440613768u, 195054868u,
+1359016305u,
+3363804638u,
+649488537u, 1624045597u, 1441938215u, 3147758996u,
+3199173578u, 2597283203u, 2191333609u, 3763129144u,
+1117290165u,
+1062549743u,
+2565615889u, 1046361554u, 1581968261u, 1058773671u,
+1123053168u, 3807622275u, 1486749916u, 3900816089u,
+2437877004u,
+1894455839u,
+1912520953u, 1914997013u, 561048608u, 1643267444u,
+3671572006u, 194811086u, 1468911468u, 2179206286u,
+673206794u,
+3486923651u,
+3741426466u, 3292160512u, 697001377u, 1900763774u,
+3726097344u, 629282039u, 3578723715u, 2868028489u,
+3269862919u,
+2303349487u,
+3643953525u, 2307255916u, 849996280u, 732080434u,
+909961480u, 3542445214u, 2628347095u, 4236856917u,
+1380660650u,
+2631821908u,
+2007289004u, 3509705198u, 3788541675u, 789457322u,
+3090670546u, 638977894u, 3503881773u, 947102987u,
+1525325287u,
+1816697045u,
+2706647405u, 288763142u, 3505438495u, 481308609u,
+2882636782u, 3745162621u, 3503467033u, 428247823u,
+176408838u,
+333551502u,
+1001068721u, 1681483651u, 75380831u, 4191469679u,
+3627361839u, 2736617386u, 3120737438u, 1297502456u,
+864896482u,
+85674920u,
+2886047255u, 4119881331u, 2496990525u, 3442502055u,
+1806582817u, 3186345024u, 4099591287u, 2560171465u,
+3489229104u,
+3065015872u,
+2755089808u, 3098442882u, 378524719u, 2664097023u,
+1771960725u, 2901182183u, 55258521u, 1266621443u,
+581644891u,
+37790450u,
+1800731704u, 3601350920u, 53428754u, 2759476837u,
+3391093099u, 1496510311u, 2511119507u, 2636877410u,
+631613207u,
+1573846064u,
+260484875u, 1088212603u, 2369525206u, 322522428u,
+3191396600u, 2076543340u, 1552496658u, 2739811558u,
+3867875546u,
+2051584261u,
+2126250818u, 901517871u, 3651631165u, 1323139145u,
+1521111765u, 477802997u, 3508559783u, 383954241u,
+3804516756u,
+4250206331u,
+2655954340u, 2484996477u, 1417544845u, 1520282298u,
+2745204366u, 2869345147u, 1872738335u, 2592877343u,
+1619744564u,
+1804962124u,
+3458679890u, 423948620u, 273645618u, 4187865426u,
+376057175u, 2943431463u, 3581950599u, 1035398331u,
+1088213445u,
+861988903u,
+1323370244u, 777069428u, 506235917u, 369720851u,
+2789995854u, 230915180u, 1505086948u, 940361236u,
+3727873235u,
+1159167499u,
+1860302871u, 3456858862u, 3923555152u, 2131072714u,
+2910461068u, 3671950363u, 2010742682u, 4088068851u,
+3616470388u,
+2087714788u,
+221675509u, 1230154072u, 3450704646u, 1463226695u,
+1998357699u, 266026801u, 619568740u, 3560427266u,
+4148162586u,
+3150417316u,
+1356375822u, 2056097622u, 627905802u, 3881675638u,
+2309738053u, 971916703u, 3447805361u, 1673575328u,
+673084328u,
+3317849401u,
+2836362782u, 2377208890u, 3275350588u, 158350552u,
+2553241779u, 2497264995u, 3262882649u, 3897937187u,
+1598963653u,
+3068514414u,
+601541505u, 374517071u, 3380795976u, 235752573u,
+284670003u, 2990192160u, 904937105u, 2306579150u,
+2117362589u,
+1635274830u,
+3355572906u, 170799903u, 1226685528u, 664567688u,
+413219134u, 878324258u, 4026159448u, 3620649295u,
+1823625377u,
+3175888439u,
+1759344347u, 2640637095u, 3549558u, 2192984935u,
+978623493u, 804017880u, 3877562323u, 3843116489u,
+1641748342u,
+1853539444u,
+3001178468u, 3443560727u, 2685426077u, 1653064722u,
+349231508u, 2726789654u, 3136215581u, 768402830u,
+269384321u,
+531936536u,
+2592883487u, 1343156334u, 3628619802u, 1477143570u,
+4269458419u, 3285611028u, 959104925u, 2712290710u,
+3480237248u,
+835796333u,
+2020636251u, 1191914589u, 126521603u, 4288023938u,
+3731699932u, 2136758855u, 985780142u, 193807575u,
+1850544433u,
+653947619u,
+3929316796u, 381871169u, 950486363u, 1787262279u,
+360480382u, 1800636585u, 1039258631u, 3682073259u,
+1262819303u,
+1786000319u,
+1570627191u, 893065837u, 301304916u, 1478469809u,
+623018819u, 2742232545u, 2058913014u, 1706060059u,
+2421125401u,
+1315829592u,
+3208766775u, 1805586156u, 575853086u, 3085025513u,
+4010908260u, 2344058256u, 3814407434u, 1458485673u,
+2474514786u,
+3581895658u,
+2710719679u, 190812706u, 2135454262u, 2620080728u,
+3400757986u, 1669914857u, 1559978393u, 1629811331u,
+3096616493u,
+1391424435u,
+4158376003u, 1015657076u, 794783832u, 479952178u,
+1150290207u, 2497437906u, 231815090u, 755078067u,
+3832053281u,
+63649475u,
+2415822606u, 4105027719u, 1706992318u, 1106598740u,
+3941945667u, 1271300761u, 505882259u, 760186809u,
+2657183368u,
+1925422058u,
+1039773764u, 880219458u, 4275949176u, 1556833823u,
+925882132u, 4216310340u, 757497522u, 461833914u,
+3884002070u,
+2790957660u,
+2100050089u, 651959176u, 1380301291u, 1289124125u,
+452314403u, 226156280u, 3306924715u, 1750807758u,
+2290180542u,
+1953760569u,
+2253069096u, 3960924806u, 1786291620u, 60736185u,
+2569018293u, 3870479674u, 2247005661u, 2239850953u,
+4261808536u,
+3282975782u,
+780945879u, 3349849383u, 1579362556u, 2265045884u,
+905088740u, 725212379u, 3156479246u, 2501620391u,
+3062836263u,
+4070422690u,
+996797869u, 4082582315u, 976105756u, 303983602u,
+1862104804u, 3864508254u, 3383979677u, 2835500286u,
+2798364010u,
+519359476u,
+3447342725u, 194373889u, 3313466630u, 232399983u,
+2841787856u, 1672751454u, 3345183154u, 1805381384u,
+2226129336u,
+2847829057u,
+2350774567u, 2838540121u, 2757948482u, 1017002062u,
+2329150951u, 2171488196u, 3668619047u, 3874977844u,
+3287966998u,
+262346753u,
+2493054715u, 2298644430u, 2926101182u, 1528457638u,
+598656233u, 2615845874u, 989110727u, 820441411u,
+253617372u,
+2201077208u,
+2047569338u, 3114356329u, 3335563734u, 2967673540u,
+768438341u, 1417708203u, 3873718246u, 1538441843u,
+1279167650u,
+3917966776u,
+2218481734u, 1015935150u, 1957845042u, 1318150213u,
+3146423971u, 4218994877u, 1162470863u, 1519718292u,
+2594658906u,
+665870414u,
+3430347817u, 3933868731u, 1597041394u, 3138684682u,
+3398212027u, 1064647658u, 1576321132u, 14792918u,
+224938029u,
+3706456050u,
+847274786u, 2645698692u, 1743374687u, 2343133224u,
+3066596790u, 2857270120u, 200596308u, 452055528u,
+2319312082u,
+3488655402u,
+4146865894u, 608206438u, 2699777051u, 3687240713u,
+327957508u, 3664730153u, 568134564u, 2993484554u,
+4159860363u,
+4274533921u,
+1079994063u, 2360220210u, 3609597760u, 3639708902u,
+2836180437u, 1069910270u, 1892427666u, 1874729790u,
+1267712826u,
+121886940u,
+3572289214u, 2475945610u, 783779452u, 588827737u,
+1531395014u, 2085084212u, 2219189792u, 3981444548u,
+2218885336u,
+1691622694u,
+2053232885u, 1386558530u, 2182946189u, 2365247285u,
+1871081313u, 2935751853u, 38413723u, 543465863u,
+900691890u,
+2899905665u,
+575120562u, 93133904u, 457154948u, 2983705792u,
+4232229200u, 2038565963u, 614693984u, 3405328302u,
+4083090010u,
+2088004171u,
+244031209u, 1861889294u, 2417109253u, 3299562328u,
+4158642443u, 4199064449u, 3161611046u, 885015950u,
+3677904099u,
+2969861785u,
+772348805u, 1712263832u, 3219357614u, 484271305u,
+3645706114u, 2059620251u, 409557488u, 2278896731u,
+224475749u,
+3523022952u,
+2057140088u, 449131785u, 1149879244u, 4255363996u,
+3602720135u, 1690010854u, 2503998822u, 2750828466u,
+3340671802u,
+1447583863u,
+2649684943u, 2764747249u, 3046070595u, 3441726138u,
+3840332559u, 3156747501u, 1288666680u, 1472744459u,
+3452391933u,
+1617542784u,
+217869690u, 3718469527u, 348639731u, 590532355u,
+43789787u, 22606314u, 1621559290u, 2231743261u,
+2234620879u,
+544748955u,
+3169387920u, 203343594u, 3272552527u, 1078282365u,
+809576321u, 854207584u, 3625491053u, 1193737267u,
+1628966807u,
+2661421060u,
+2433442061u, 3886639039u, 2149304418u, 303000565u,
+1432830882u, 137378235u, 1135974068u, 318705754u,
+2491227157u,
+2627534472u,
+3520352233u, 2488397682u, 3969194920u, 3843962181u,
+2135981459u, 2611933220u, 799460731u, 2300968851u,
+3412851628u,
+3070914013u,
+3555224260u, 4125937572u, 240359903u, 722496673u,
+2061023600u, 3843919221u, 2759960043u, 1191155322u,
+1504041490u,
+3735253656u,
+1773124736u, 101110011u, 1627699578u, 2645634551u,
+263603947u, 1388368439u, 677146538u, 1644201982u,
+2625699644u,
+2403862553u,
+2426069017u, 3613511705u, 915141802u, 2981654265u,
+3474818167u, 2611101773u, 627891434u, 762754924u,
+2143021902u,
+51067670u,
+4017746573u, 2269879853u, 3037857950u, 2388899692u,
+582729171u, 1886116725u, 2281219772u, 264704948u,
+3509984037u,
+4078683368u,
+2172959411u, 1807195632u, 3357092302u, 2253764928u,
+2320369390u, 3076335959u, 2623583210u, 168378015u,
+1435562650u,
+1100977467u,
+3160490319u, 2550328495u, 2396855930u, 1347823908u,
+1617990918u, 3849653099u, 3224111576u, 1681539821u,
+4171542880u,
+552200045u,
+3562947778u, 1676237880u, 3747732307u, 2453332913u,
+865530667u, 3566636849u, 3485502777u, 336779723u,
+2535942410u,
+1685000184u,
+820545711u, 1893670486u, 1273910461u, 1193758569u,
+970365241u, 381205962u, 3612810852u, 1160577445u,
+541488143u,
+4005031080u,
+2333965236u, 2419855455u, 3484533538u, 3073937876u,
+908466956u, 661391539u, 2342122412u, 1467049112u,
+1785800827u,
+135343033u,
+139643209u, 2438375667u, 974654058u, 3216478230u,
+3807620420u, 779043363u, 2812846449u, 333254784u,
+1025244024u,
+2242303095u,
+2476683742u, 350018683u, 174652916u, 933097576u,
+826905896u, 559603581u, 2777181260u, 164915169u,
+4070353203u,
+1459055748u,
+297303985u, 3103837241u, 3812514233u, 232265137u,
+2032819099u, 1523091376u, 3531238208u, 1403510182u,
+2886832080u,
+2599705941u,
+2789695716u, 68437968u, 3823813791u, 1040994569u,
+3024194990u, 2461740520u, 3735391266u, 2042207153u,
+2461678616u,
+3519231840u,
+1344224923u, 411442756u, 1179779351u, 7661528u,
+778352196u, 3288808867u, 589356197u, 2627504511u,
+3374744599u,
+3312172905u,
+357423007u, 3539567796u, 4044452215u, 1445118403u,
+2937983820u, 184089910u, 346201845u, 2427295202u,
+1345448010u,
+2884434843u,
+3085001879u, 2640105409u, 315310640u, 3530289798u,
+3362974764u, 963602652u, 75228477u, 3509381180u,
+4012777756u,
+2380345941u,
+1073137836u, 2083960378u, 1220315185u, 3628720934u,
+3508867818u, 67148343u, 3558085158u, 1753943368u,
+863309561u,
+2844713625u,
+441921850u, 854732254u, 816793316u, 2555428747u,
+3440623414u, 1707304366u, 3189874375u, 1623229221u,
+1220335976u,
+806745430u,
+3909262947u, 1680369031u, 2926179486u, 3410391660u,
+3991630434u, 2876458763u, 1179167079u, 536360759u,
+1592117159u,
+1514343977u,
+1032622306u, 2057494855u, 784938958u, 178402996u,
+1152907972u, 2326185495u, 2939973666u, 4181120253u,
+552831733u,
+664251856u,
+1297139539u, 1969357631u, 1474065957u, 3055419017u,
+3395829380u, 3316562752u, 2168409017u, 614624786u,
+3585854336u,
+668291094u,
+1162889217u, 3773171307u, 2263271126u, 355089668u,
+3195850578u, 3396793277u, 3519870267u, 527857605u,
+3972392320u,
+2224315010u,
+4047225561u, 3271434798u, 3192704713u, 2798505213u,
+3932215896u, 3792924012u, 3796843756u, 453872975u,
+4050552799u,
+1056432676u,
+928166947u, 121311642u, 930989547u, 2087070683u,
+1288978057u, 1556325239u, 1812435626u, 1682385724u,
+1214364933u,
+904760776u,
+3957045528u, 3949822847u, 2411065880u, 3716420732u,
+3424837835u, 3833550693u, 1799375326u, 2012368921u,
+2768764136u,
+1786111037u,
+4055479315u, 3751639533u, 2808224623u, 3492656387u,
+1306824780u, 2624000170u, 3134795218u, 1778409297u,
+3900821801u,
+593336325u,
+2772069220u, 2980873673u, 3574497158u, 3994780459u,
+4246519854u, 3482758570u, 4228015183u, 33101083u,
+1769887734u,
+4158035314u,
+3690638998u, 1119035482u, 4134969651u, 2483207353u,
+3932823321u, 285829887u, 3485140138u, 1304815138u,
+995608264u,
+3133997465u,
+1195477617u, 2147693728u, 3506673112u, 4234467492u,
+1183174337u, 1395340482u, 769199343u, 193262308u,
+2798920256u,
+3827889422u,
+3399695609u, 3036045724u, 2999477386u, 3567001759u,
+2682864314u, 1414023907u, 3699872975u, 3369870701u,
+2662284872u,
+2179640019u,
+2485080099u, 3234415609u, 3755915606u, 1339453220u,
+1567403399u, 2076272391u, 293946298u, 3861962750u,
+1291949822u,
+2916864995u,
+132642326u, 2215117062u, 2205863575u, 2488805750u,
+405632860u, 3248129390u, 2952606864u, 896734759u,
+2047417173u,
+3865951392u,
+657296855u, 1328547532u, 3966511825u, 3959682388u,
+4171801020u, 2981416957u, 1868896247u, 790081075u,
+3143666398u,
+2950766549u,
+2065854887u, 2737081890u, 995061774u, 1510712611u,
+2865954809u, 565044286u, 1565631102u, 1500654931u,
+494822108u,
+2803515503u,
+1058154996u, 3506280187u, 856885925u, 4204610546u,
+800905649u, 1130711562u, 558146282u, 2053400666u,
+449794061u,
+2643520245u,
+2101248725u, 3123292429u, 3583524041u, 983372394u,
+1587743780u, 672870813u, 444833475u, 100741452u,
+366232251u,
+1717951248u,
+524144122u, 1362432726u, 1304947719u, 674306020u,
+405665887u, 4081931036u, 1580408204u, 2343242778u,
+3901654006u,
+2627173567u,
+3015148205u, 814686701u, 1327920712u, 1346494176u,
+2468632605u, 2259795544u, 2519278184u, 2129281928u,
+2860266380u,
+4001619412u,
+1154910973u, 2841022216u, 1199925485u, 1372200293u,
+2713179055u, 3609776550u, 2896463880u, 1056406892u,
+177413841u,
+40180172u,
+3274788406u, 660921784u, 1686225028u, 4003382965u,
+2532691887u, 4256809101u, 1186018983u, 667359096u,
+2375266493u,
+2760222015u,
+745187078u, 312264012u, 396822261u, 2588536966u,
+2026998998u, 1766454365u, 3218807676u, 3915487497u,
+2630550356u,
+4130063378u,
+4231937074u, 752212123u, 3085144349u, 3267186363u,
+4103872100u, 4193207863u, 1306401710u, 3014853131u,
+1067760598u,
+2306188342u,
+2437881506u, 4258185052u, 2506507580u, 130876929u,
+1076894205u, 4106981702u, 2799540844u, 945747327u,
+1436722291u,
+2499772225u,
+2571537041u, 2038830635u, 2066826058u, 2892892912u,
+524875858u, 3392572161u, 2869992096u, 1308273341u,
+923668994u,
+1980407857u,
+2275009652u, 240598096u, 2658376530u, 3505603048u,
+1022603789u, 582423424u, 846379327u, 4092636095u,
+4177298326u,
+1004173023u,
+2154027018u, 2993634669u, 1098364089u, 3035642175u,
+1335688126u, 1376393415u, 1252369770u, 3815033328u,
+1999309358u,
+1234054757u,
+1388595255u, 2859334775u, 366532860u, 3453410395u,
+4226967708u, 1321729870u, 2078463405u, 156766592u,
+3157683394u,
+3549293384u,
+3348214547u, 2879648344u, 1144813399u, 2758966254u,
+647753581u, 813615926u, 2035441590u, 1961053117u,
+600168686u,
+2192833387u,
+3156481401u, 3627320321u, 383550248u, 81209584u,
+2339331745u, 1284116690u, 1980144976u, 2955724163u,
+789301728u,
+3842040415u,
+1115881490u, 965249078u, 4098663322u, 1870257033u,
+2923150701u, 4217108433u, 183816559u, 2104089285u,
+2640095343u,
+3173757052u,
+927847464u, 2383114981u, 4287174363u, 1886129652u,
+70635161u, 1182924521u, 1121440038u, 4246220730u,
+3890583049u,
+975913757u,
+2436253031u, 1074894869u, 1301280627u, 992471939u,
+735658128u, 244441856u, 1541612456u, 3457776165u,
+3503534059u,
+1931651133u,
+349142786u, 3669028584u, 1828812038u, 99128389u,
+1364272849u, 1963678455u, 3971963311u, 2316950886u,
+1308901796u,
+2789591580u,
+1460494965u, 2380227479u, 1577190651u, 1755822080u,
+2911014607u, 859387544u, 13023113u, 2319243370u,
+2522582211u,
+2299110490u,
+3342378874u, 2589323490u, 1884430765u, 3739058655u,
+2419330954u, 355389916u, 273950915u, 3670136553u,
+410946824u,
+3174041420u,
+2609010298u, 3059091350u, 2300275014u, 725729828u,
+2548380995u, 1738849964u, 1257081412u, 79430455u,
+810321297u,
+3246190593u,
+1007937684u, 912115394u, 40880059u, 3450073327u,
+4289832174u, 2253485111u, 1065639151u, 2953189309u,
+124779113u,
+654299738u,
+115760833u, 1250932069u, 884995826u, 3998908281u,
+1382882981u, 1134187162u, 3202324501u, 487502928u,
+3032756345u,
+4057517628u,
+933197381u, 2319223127u, 2044528655u, 2554572663u,
+4049450620u, 1620812836u, 2832905391u, 2273005481u,
+1913090121u,
+1055456023u,
+510593296u, 3285343192u, 2912822536u, 1645225063u,
+638418430u, 452701300u, 1025483165u, 1639370512u,
+167948643u,
+2809842730u,
+2983135664u, 407521332u, 1543756616u, 3949773145u,
+4283462892u, 659962275u, 3878013463u, 1000748756u,
+4053212051u,
+4099239406u,
+3467581965u, 354635541u, 21301844u, 3831212473u,
+3189450571u, 2264401966u, 4096484849u, 1736448515u,
+3976926096u,
+3727194724u,
+2243487039u, 585209095u, 3143046007u, 969558123u,
+3037113502u, 3594170243u, 2835860223u, 3775493975u,
+2787220812u,
+2274252217u,
+2915380701u, 3077533278u, 1252871826u, 1519790952u,
+205297661u, 2950557658u, 3956882191u, 2724439401u,
+3694608025u,
+124028038u,
+216019153u, 1533010676u, 2259986336u, 2014061617u,
+2068617849u, 3078123052u, 2692046098u, 1582812948u,
+396916232u,
+1470894001u,
+1694309312u, 300268215u, 1553892743u, 671176040u,
+1544988994u, 2793402821u, 4194972569u, 2296476154u,
+748354332u,
+3491325898u,
+4261053291u, 1104998242u, 797816835u, 243564059u,
+2197717393u, 299029458u, 1675252188u, 3139770041u,
+583018574u,
+2532106100u,
+2099391658u, 3760526730u, 3422719327u, 3556917689u,
+2374009285u, 2130865894u, 3710563151u, 1437538307u,
+3938030842u,
+2006930694u,
+2151243336u, 1939741287u, 1957068175u, 2135147479u,
+649553342u, 1713643042u, 4188696599u, 1698739939u,
+3549427584u,
+1016382174u,
+322644378u, 2476164549u, 2037263020u, 88036019u,
+2548960923u, 539867919u, 2871157727u, 4031659929u,
+754087252u,
+972656559u,
+4246379429u, 3877308578u, 2059459630u, 3614934323u,
+1410565271u, 2102980459u, 215395636u, 1083393481u,
+3775523015u,
+2062750105u,
+2475645882u, 3041186774u, 3534315423u, 758607219u,
+1686100614u, 180500983u, 1155581185u, 1476664671u,
+2918661695u,
+3812731350u,
+4003853737u, 4148884881u, 1468469436u, 3278880418u,
+1045838071u, 1049161262u, 360450415u, 3158065524u,
+814443735u,
+3391401707u,
+729968410u, 738771593u, 3662738792u, 1672830580u,
+4199496163u, 188487238u, 219098233u, 2141731267u,
+3890250614u,
+2988780375u,
+4026279523u, 3489429375u, 2468433807u, 1178270701u,
+2685094218u, 2716621497u, 3718335529u, 2273344755u,
+701110882u,
+1925717409u,
+1515176562u, 2325460593u, 3954798930u, 784566105u,
+3769422266u, 1641530321u, 2703876862u, 2907480267u,
+1828076455u,
+1805635221u,
+3883381245u, 1476756210u, 2072514392u, 3658557081u,
+2003610746u, 2556845550u, 729594004u, 3303898266u,
+1968227254u,
+423204951u,
+231828688u, 4223697811u, 698619045u, 3636824418u,
+2738779239u, 2333529003u, 2833158642u, 580285428u,
+3038148234u,
+1012378004u,
+1113647298u, 1424593483u, 4053247723u, 1167152941u,
+2677383578u, 3419485379u, 2135673840u, 440478166u,
+1682229112u,
+3226724137u,
+1217439806u, 3828726923u, 3636576271u, 3467643156u,
+2005614908u, 2655346461u, 2345488441u, 1027557096u,
+3594084220u,
+1372306343u,
+2342583762u, 4291342905u, 4094931814u, 3254771759u,
+821978248u, 2404930117u, 1143937655u, 3156949255u,
+3460606610u,
+449701786u,
+3474906110u, 1932585294u, 2283357584u, 1808481478u,
+3522851029u, 3040164731u, 1530172182u, 2950426149u,
+1402416557u,
+756419859u,
+4132576145u, 724994790u, 2852015871u, 2177908339u,
+899914731u, 139675671u, 1423281870u, 3198458070u,
+807581308u,
+2021611521u,
+1801452575u, 1425984297u, 2833835949u, 1536827865u,
+3902351840u, 164546042u, 1872840974u, 3986194780u,
+792156290u,
+3378681896u,
+941547959u, 3931328334u, 3661060482u, 2386420777u,
+3920146272u, 3458621279u, 3348500844u, 2269586542u,
+797371473u,
+3188953649u,
+80514771u, 2913333490u, 1246325623u, 3253846094u,
+1723906239u, 1606413555u, 587500718u, 1412413859u,
+2310046829u,
+2113313263u,
+3855635608u, 47271944u, 1112281934u, 3440228404u,
+2633519166u, 425094457u, 307659635u, 67338587u,
+2412987939u,
+2363930989u,
+2853008596u, 2844637339u, 922568813u, 130379293u,
+2825204405u, 2904442145u, 1176875333u, 1511685505u,
+599177514u,
+1872681372u,
+682394826u, 1888849790u, 3635304282u, 1761257265u,
+1571292431u, 355247075u, 1177210823u, 1691529530u,
+3629531121u,
+3760474006u,
+1129340625u, 868116266u, 3908237785u, 1942124366u,
+1266630014u, 3214841995u, 334023850u, 1110037019u,
+369650727u,
+1288666741u,
+70535706u, 20230114u, 4284225520u, 727856157u,
+293696779u, 1244943770u, 3976592462u, 560421917u,
+4171688499u,
+2438786950u,
+1218144639u, 3809125983u, 1302395746u, 534542359u,
+2121993015u, 2899519374u, 3192177626u, 1761707794u,
+3101683464u,
+1555403906u,
+3225675390u, 1875263768u, 4278894569u, 651707603u,
+2111591484u, 3802716028u, 2900262228u, 1181469202u,
+3254743797u,
+1822684466u,
+860641829u, 3046128268u, 1284833012u, 1125261608u,
+461384524u, 2331344566u, 1274400010u, 990498321u,
+3462536298u,
+3796842585u,
+2346607194u, 279495949u, 3951194590u, 3522664971u,
+3169688303u, 726831706u, 1123875117u, 1816166599u,
+3759808754u,
+2918558151u,
+3713203220u, 3369939267u, 466047109u, 384042536u,
+587271104u, 2191634696u, 2449929095u, 1157932232u,
+2084466674u,
+841370485u,
+3241372562u, 4277738486u, 2150836793u, 1173569449u,
+778768930u, 2594706485u, 3065269405u, 3019263663u,
+2660146610u,
+2789946230u,
+77056913u, 728174395u, 3647185904u, 804562358u,
+2697276483u, 881311175u, 1178696435u, 2059173891u,
+2308303791u,
+221481230u,
+50241451u, 3689414100u, 1969074761u, 2732071529u,
+1900890356u, 840789500u, 2100609300u, 985565597u,
+1220850414u,
+2456636259u,
+223607678u, 1016310244u, 1937434395u, 85717256u,
+275058190u, 3712011133u, 171916016u, 2389569096u,
+3679765802u,
+3575358777u,
+3481108261u, 3178286380u, 2489642395u, 2931039055u,
+3086601621u, 3079518902u, 3027718495u, 2506894644u,
+2976869602u,
+2134336365u,
+2420172217u, 918054427u, 661522682u, 1403791357u,
+3587174388u, 2623673551u, 1355661457u, 4159477684u,
+1109013587u,
+3112183488u,
+2217849279u, 3500291996u, 2419603731u, 2929886201u,
+3854470013u, 1358382103u, 1357666555u, 21053566u,
+2716621233u,
+3094836862u,
+3309729704u, 57086558u, 839187419u, 2757944838u,
+3651040558u, 3607536716u, 3691257732u, 2312878285u,
+1202511724u,
+183479927u,
+2509829803u, 109313218u, 478173887u, 2072044014u,
+190631406u, 2495604975u, 1010416260u, 3679857586u,
+726566957u,
+258500881u,
+1805873908u, 3081447051u, 2352101327u, 534922207u,
+1584552873u, 813470716u, 255914637u, 249169434u,
+3193498057u,
+1038802706u,
+2590158653u, 3147907290u, 663060128u, 1156177857u,
+634616100u, 312879189u, 1545020368u, 2054634247u,
+3271451914u,
+3438291534u,
+2181454946u, 3864535432u, 2398586877u, 896491075u,
+2810631478u, 2770357487u, 3372930052u, 898070638u,
+2051007323u,
+392959778u,
+36645539u, 3743556044u, 4134529680u, 4124451188u,
+566806297u, 2936523982u, 1304761965u, 537399498u,
+1940818842u,
+40862381u,
+36288410u, 3063605629u, 2826611650u, 3961972098u,
+1871578006u, 2392095486u, 1136931591u, 513864488u,
+173276451u,
+3039055682u,
+3543322032u, 1943592006u, 657217094u, 1751698246u,
+2969618445u, 456616022u, 900309519u, 113892716u,
+1126392103u,
+1235651045u,
+1882073852u, 2136610853u, 2353639710u, 2819956700u,
+3980083530u, 828773559u, 224069850u, 902434120u,
+2802008036u,
+94358995u,
+2777723394u, 2812641403u, 2525832595u, 4157388110u,
+4235563782u, 937800324u, 141690749u, 568062536u,
+550123849u,
+1330316521u,
+1949488696u, 2296431366u, 1958465262u, 3564751729u,
+3748252207u, 120455129u, 1607318832u, 2525729790u,
+2640987481u,
+2332096657u,
+1775969159u, 1555085077u, 2913525137u, 1347085183u,
+2376253113u, 3194050574u, 1806090610u, 678641356u,
+1499146713u,
+383849715u,
+3299835823u, 2284860330u, 2614269636u, 3913628844u,
+2761334210u, 1959484587u, 529797021u, 239966995u,
+3102194829u,
+3602307804u,
+1122192627u, 3577510006u, 164486066u, 1680137310u,
+1473396395u, 1467801424u, 903493660u, 1185943071u,
+2798556505u,
+2306744492u,
+3167201310u, 3577947177u, 3067592134u, 2905506289u,
+1210366329u, 204484056u, 2347778932u, 3862374472u,
+3277439508u,
+4187414621u,
+1646699310u, 621385800u, 3934869089u, 3975491588u,
+3580085916u, 1925674500u, 2436305348u, 3983301539u,
+2739439523u,
+3291507446u,
+3395637920u, 3753389171u, 2955202032u, 2654255623u,
+3771089254u, 2140443405u, 2779834738u, 3261942805u,
+3526889244u,
+1842009139u,
+4048484340u, 2106218403u, 2161244271u, 772152700u,
+1158647659u, 3776791619u, 3882186721u, 699525237u,
+2954670460u,
+1007105869u,
+3359152025u, 1146388699u, 1401550303u, 2326582541u,
+4181783540u, 1085644043u, 1942143795u, 1038368308u,
+1526153809u,
+4042547244u,
+1891441000u, 2573991874u, 1281441253u, 3635098284u,
+1980545715u, 825985487u, 3934748116u, 4228386979u,
+1480870944u,
+1042194545u,
+2397771642u, 2248490001u, 3817869868u, 878654626u,
+3785629484u, 1672470870u, 3229367873u, 1894538933u,
+1010692731u,
+1733824268u,
+656620328u, 3048283803u, 3353340056u, 2324965120u,
+4192585951u, 2284524675u, 3483884368u, 1510168293u,
+1554942691u,
+1309709396u,
+1241133168u, 3162179280u, 4046378054u, 3171681593u,
+1165297136u, 3496703563u, 150437903u, 1948622072u,
+1076332463u,
+2292479143u,
+1464229958u, 3479738093u, 2328067598u, 2334503110u,
+833324834u, 3981605747u, 3002629155u, 2854644186u,
+2832201336u,
+95796957u,
+3269249397u, 2358313329u, 3411860910u, 4283292480u,
+2802208697u, 1305947955u, 2156803420u, 1991340283u,
+189678024u,
+447602599u,
+1055411517u, 1531748363u, 1555852656u, 412402681u,
+3774988152u, 20597551u, 2925024131u, 1423989620u,
+3749428061u,
+1541439448u,
+112270416u, 1936224776u, 132162941u, 3772011507u,
+3814102518u, 1908807815u, 444154079u, 823765347u,
+3362275567u,
+3419047430u,
+2108287005u, 2315102125u, 658593738u, 3195094029u,
+3721937534u, 3176229204u, 3398835373u, 1271898712u,
+1142546577u,
+3185986817u,
+3562705803u, 2046119567u, 912990621u, 1829977672u,
+3459576979u, 1118045834u, 1369529376u, 3320601076u,
+3954988953u,
+4002467635u,
+3359456351u, 1314849568u, 1766750942u, 2998874853u,
+1181800239u, 707328036u, 3314954697u, 2066721120u,
+598194215u,
+1124451278u,
+3156679616u, 3742684743u, 2960199690u, 2683497915u,
+2566077529u, 937014607u, 102095219u, 4262922475u,
+3132264275u,
+1262099830u,
+862722905u, 2717653494u, 3245583534u, 3427209989u,
+3220278124u, 85457091u, 2222333500u, 3513997967u,
+3522324951u,
+2830855552u,
+2215004781u, 3482411840u, 4227160614u, 2030964411u,
+1741393851u, 2643723748u, 942813508u, 403442675u,
+3112048748u,
+530556423u,
+3817755244u, 3543286628u, 2247276090u, 1532920842u,
+4101962711u, 1446540991u, 3297821473u, 1861255389u,
+1984398u,
+2366525138u,
+377589481u, 3549193828u, 1427765914u, 506831657u,
+277278988u, 1447652775u, 3214362239u, 3142198690u,
+2843087541u,
+468915015u,
+807895062u, 2198723907u, 4031145069u, 2417156212u,
+4027298697u, 637175947u, 1229254212u, 1773257887u,
+1659444818u,
+451148891u,
+2099741368u, 735351990u, 2534775713u, 3261804619u,
+712519954u, 3527962772u, 3758642738u, 4245823575u,
+1281314264u,
+1167866160u,
+1489546151u, 1197354389u, 1043278102u, 2563326586u,
+371937794u, 2320164817u, 3189512691u, 573685198u,
+4108603513u,
+3758899588u,
+3507030163u, 2947201212u, 2529492585u, 578234375u,
+3362349842u, 3318878925u, 3611203517u, 3059253190u,
+4270755916u,
+4291274625u,
+4237586791u, 4137422245u, 2927218651u, 2444687041u,
+797128811u, 2043057612u, 396533859u, 2665256178u,
+3346510674u,
+1779586176u,
+3076562062u, 1882746214u, 921095362u, 2026988397u,
+514514911u, 3886379478u, 4218272420u, 1480386793u,
+3900160816u,
+2292273451u,
+1276138356u, 1125461821u, 1912885715u, 3365266013u,
+1333211627u, 4085009861u, 1390530102u, 3347984752u,
+2721771301u,
+1419492325u,
+4066766256u, 3250852311u, 820111852u, 1382201318u,
+2366036798u, 938032241u, 3100979439u, 487048687u,
+2292851045u,
+3241399180u,
+3912670510u, 2416437067u, 2973194517u, 3507707986u,
+1935099406u, 2533441488u, 104616731u, 2892622820u,
+3801190339u,
+4239188808u,
+807238241u, 3300121546u, 2249406147u, 4032114017u,
+3713738189u, 3324425575u, 4275607376u, 3663120298u,
+4173658372u,
+3984289690u,
+1827636846u, 3264588778u, 3297165529u, 558623533u,
+2728945672u, 1566297318u, 3447249966u, 481719551u,
+1596842050u,
+1838185946u,
+265271620u, 1050246315u, 4046655705u, 1844193138u,
+3807563245u, 1075384804u, 1292554949u, 1506525927u,
+2921816148u,
+2051885269u,
+1930534041u, 3872721086u, 1564489377u, 2272482181u,
+2849358683u, 589618304u, 2262072443u, 290363051u,
+299168363u,
+3867603931u,
+2868688756u, 2545263115u, 1092098533u, 3885725603u,
+2352430409u, 1981595469u, 2047946646u, 1332642839u,
+793806516u,
+214858837u,
+1061484659u, 3192394476u, 1115054785u, 3690637234u,
+996792368u, 2023479706u, 3046498231u, 4205835102u,
+3870714754u,
+257472875u,
+3549864599u, 2040276129u, 2414778670u, 812235477u,
+2674248196u, 1864096101u, 2257492689u, 1332556794u,
+1079540713u,
+465530720u,
+2304763972u, 830724724u, 3354588920u, 2510713652u,
+3103749409u, 468835585u, 1707620787u, 3038024846u,
+1000303198u,
+3462270146u,
+2748698899u, 2100348093u, 511537258u, 1237187486u,
+102049383u, 2268226698u, 3162251739u, 4219404629u,
+838822407u,
+1481440623u,
+2989224077u, 2676681975u, 3246551821u, 3812079906u,
+370572963u, 2283154352u, 3084789986u, 1961085583u,
+1955640586u,
+2409348147u,
+2284780581u, 1634818716u, 4018221729u, 2320761377u,
+3566831899u, 1799560520u, 91431959u, 1754113747u,
+1459430477u,
+3613658517u,
+924489906u, 3406317699u, 866289774u, 3924821603u,
+1265394945u, 1870668109u, 151949856u, 2747006534u,
+3111906201u,
+64039467u,
+2314447545u, 2600195638u, 4095795204u, 4162096026u,
+1026756826u, 2460047982u, 52686887u, 823198739u,
+1518045160u,
+2867527376u,
+566410761u, 2200433819u, 2114146405u, 2893790965u,
+881504901u, 974783212u, 490815659u, 937300283u,
+1523735309u,
+2511976468u,
+2634644947u, 355119367u, 1373773092u, 309232995u,
+3088671051u, 787126032u, 3442836843u, 4289194567u,
+2177850062u,
+1174136430u,
+3248982914u, 3129039732u, 1166851580u, 2196451882u,
+469595580u, 2130837700u, 3783349021u, 3745262548u,
+1236930515u,
+3032131496u,
+1525591437u, 1823628217u, 1939019255u, 1950270463u,
+3659899927u, 3688643445u, 3004399289u, 1155199552u,
+357547234u,
+2213110526u,
+3122658210u, 2667800490u, 2718690333u, 3512372076u,
+1098611683u, 2657518392u, 4248458835u, 3109874532u,
+1592908438u,
+2864927516u,
+3635248840u, 1251777186u, 3797340158u, 3508496870u,
+303354834u, 1482394062u, 2087100120u, 1595931912u,
+608574156u,
+723367884u,
+907938402u, 3357047807u, 1619629851u, 3092082995u,
+89030300u, 916336992u, 1861180168u, 3436334155u,
+1375000544u,
+3472936241u,
+1321217853u, 791356402u, 2872410224u, 2326250297u,
+2657644088u, 1748314108u, 4146771421u, 2913114440u,
+2924821844u,
+2101101496u,
+3268017251u, 2109603066u, 690665520u, 1830067573u,
+951427661u, 2982533150u, 3884512506u, 2358657479u,
+2833210784u,
+3419798214u,
+3785893994u, 2103940206u, 86759766u, 4031230616u,
+3745237192u, 2739453927u, 497038072u, 3303159408u,
+1251537249u,
+1993408196u,
+3185905715u, 2885948408u, 3154277110u, 2444150313u,
+2505582079u, 2120610195u, 3266465773u, 1814611964u,
+3080050407u,
+1079915522u,
+1819346505u, 2529946763u, 892097374u, 3740257161u,
+3618100441u, 1079900094u, 3607172225u, 737863389u,
+360704560u,
+3341993089u,
+1139047381u, 3132219631u, 1248981859u, 1109338159u,
+2004908615u, 4022302594u, 4166640860u, 2959140950u,
+3949235962u,
+2832278473u,
+2200524012u, 2634933043u, 2495844522u, 2613799818u,
+4034096813u, 683271795u, 1673546817u, 1363163726u,
+1805395136u,
+511749501u,
+1231032599u, 2305979751u, 345737783u, 3339868854u,
+2931857933u, 2323251738u, 1332068477u, 51846558u,
+3927238177u,
+1387182179u,
+1701238601u, 1419275173u, 2580882268u, 3357874599u,
+1726558907u, 1292901039u, 1371322339u, 1311713044u,
+3526735232u,
+4017884184u,
+3366093428u, 77140994u, 2128996229u, 1357915765u,
+4019691901u, 483989024u, 2390311750u, 2766065288u,
+3938587520u,
+3064810344u,
+1054589198u, 1274997019u, 4040589616u, 1277751144u,
+2274907047u, 4170399945u, 2886368209u, 4168922115u,
+3901237033u,
+3252972311u,
+2205185840u, 3403097556u, 3385493699u, 2809751370u,
+555319628u, 399539034u, 2998971454u, 1521596214u,
+178870216u,
+1471733541u,
+519629198u, 514159209u, 1500582242u, 1928616587u,
+2686427928u, 4133138798u, 1225914083u, 1432713584u,
+3559310915u,
+3925489366u,
+1055613123u, 4126676029u, 2723867653u, 3290604111u,
+1377022957u, 2373608155u, 3615237379u, 594338683u,
+2645257602u,
+2408427260u,
+917033274u, 750455097u, 625657657u, 121713200u,
+2191273413u, 4043949724u, 3293146785u, 3809297972u,
+3947296919u,
+115456894u,
+1529576616u, 1459278275u, 2157117997u, 1747859293u,
+4106665903u, 996939232u, 2007976332u, 4274649009u,
+1017725787u,
+4244666096u,
+1219631331u, 3072426253u, 3547691720u, 1620822012u,
+1397717508u, 2031597325u, 3345983430u, 2459068000u,
+3645130467u,
+2308642742u,
+359955852u, 1348467968u, 1133123059u, 2435919062u,
+2800365907u, 4213217210u, 4056565603u, 2811666556u,
+2318007236u,
+3823652401u,
+3654086429u, 1273260424u, 1591610446u, 943349350u,
+3441227678u, 3779964757u, 233818224u, 3469971032u,
+3764095096u,
+4009204587u,
+678472092u, 1990559652u, 2583121088u, 2978143652u,
+2496370864u, 2139539656u, 4287972050u, 295832576u,
+3536742861u,
+2257466133u,
+2738052161u, 1988611898u, 2466189642u, 3294419573u,
+2311186273u, 474374532u, 3081964174u, 2515138278u,
+835731677u,
+1178182694u,
+3352119543u, 2884763225u, 3462399574u, 2900817210u,
+1993698511u, 2868445043u, 2746444849u, 1205258179u,
+2353442946u,
+4079040070u,
+3624133102u, 2907136076u, 2902521697u, 426813211u,
+1418185512u, 3711189488u, 1351506552u, 1934749519u,
+46595543u,
+401688809u,
+3514602124u, 1396852607u, 1951477943u, 2502249173u,
+3199695820u, 2890250638u, 4205072507u, 1715623846u,
+3266686789u,
+3218688128u,
+1697759742u, 851227671u, 2358709645u, 4174233268u,
+500583683u, 3805940955u, 736234120u, 2710563712u,
+1949664540u,
+3139414003u,
+4293073253u, 1284406972u, 1785182449u, 1051548274u,
+2994248357u, 2499882522u, 717208669u, 2039517285u,
+518424929u,
+143136433u,
+2303774671u, 1272930860u, 2286410920u, 788459311u,
+273225293u, 2439291703u, 2254505236u, 3446287701u,
+3655156558u,
+1546628787u,
+340081500u, 3285722006u, 1324810435u, 1053980860u,
+1779472859u, 2700355724u, 686005017u, 3762376315u,
+3963193100u,
+1370881135u,
+661300087u, 1152753704u, 2349891598u, 3910051187u,
+2109444785u, 1311123870u, 2639837565u, 1896770931u,
+1081414128u,
+869877586u,
+4284220400u, 63045374u, 235968615u, 184451062u,
+1271099822u, 1319179857u, 3274963209u, 4172272710u,
+3388797445u,
+2965973320u,
+3793110097u, 3327241723u, 2991804005u, 1199544355u,
+771553759u, 2031749842u, 2596517372u, 1199888213u,
+858347951u,
+3340178832u,
+2903875412u, 763490382u, 76949161u, 2056544406u,
+1145227689u, 998233136u, 2354530024u, 427713587u,
+3537837347u,
+604661755u,
+923986833u, 1023730418u, 798294227u, 432557449u,
+801802449u, 1861313429u, 3899128441u, 4068407979u,
+2352677083u,
+3783539925u,
+10731973u, 3390767975u, 3949540249u, 1920121661u,
+3248580201u, 641956426u, 2104847395u, 604835744u,
+1491663404u,
+4255204651u,
+1520970746u, 2845653368u, 3247412938u, 3730629005u,
+855569514u, 3073294700u, 2429691698u, 3818342476u,
+3938869985u,
+2731201328u,
+2335202643u, 778117742u, 13298408u, 228780590u,
+2871715314u, 3253688653u, 4150999702u, 3846220408u,
+930808u,
+1397128726u,
+1964216488u, 2781092828u, 116285375u, 2271239476u,
+3724347554u, 2931203895u, 3893169206u, 1883912528u,
+2093892660u,
+3658787024u,
+3095016046u, 1094059199u, 3640239610u, 558564267u,
+2102812456u, 464734873u, 925262247u, 1609838036u,
+588364741u,
+1731409233u,
+1576165139u, 3933979268u, 375316394u, 4247099643u,
+3670508019u, 4080496835u, 2371248533u, 183762693u,
+2078935389u,
+2699810414u,
+1491815683u, 2999180789u, 1831158425u, 1603373553u,
+2006136905u, 3210230591u, 416748595u, 1536971415u,
+3271869367u,
+1266062739u,
+2138414557u, 3337114778u, 1634586826u, 36472629u,
+4482244u, 568009609u, 2721216780u, 4037289545u,
+2235138807u,
+1789351460u,
+4067539527u, 1323062829u, 3864620647u, 4192026301u,
+4278901241u, 1399025382u, 2826652805u, 1363860382u,
+1801770651u,
+1613381526u,
+1165249276u, 4046576622u, 2535596946u, 3260388176u,
+1078898578u, 2259750862u, 643387587u, 237144235u,
+4199571427u,
+3440917581u,
+3067939258u, 2018625455u, 1460528353u, 3138629939u,
+1666223528u, 3841139376u, 2528281125u, 885565193u,
+2609492686u,
+2517257479u,
+560864620u, 2261471820u, 3491559165u, 1329620416u,
+622383582u, 1759597655u, 2877873893u, 584692817u,
+1901728399u,
+2599000260u,
+3169771644u, 296332336u, 774719455u, 4175920823u,
+2287316070u, 4115615023u, 1073335619u, 4240292725u,
+1359158837u,
+1960974237u,
+3173724597u, 1619084286u, 2876340752u, 4065675347u,
+480741335u, 1237329941u, 701055566u, 3729009837u,
+1314736422u,
+4003180069u,
+3118519317u, 3035354420u, 3380357671u, 4020909015u,
+253958714u, 3545798863u, 3008185002u, 2624719888u,
+3219955575u,
+3060719376u,
+573101682u, 1580316843u, 2610493412u, 3490983536u,
+3601975611u, 851470366u, 635384901u, 3427048824u,
+1470002757u,
+3592460087u,
+2265226856u, 4124282457u, 2106385486u, 3334305617u,
+4208282753u, 3798749815u, 225396466u, 118791182u,
+2523395972u,
+194595464u,
+2563824631u, 2521301383u, 4224409406u, 468670274u,
+1761966400u, 1300908277u, 2570709228u, 1847901526u,
+1470099163u,
+2690466752u,
+1472536718u, 2399279735u, 4150607803u, 1775080054u,
+2082537685u, 4080034578u, 1256001880u, 392967725u,
+2055838940u,
+3349115816u,
+1745947263u, 2213925887u, 1836572741u, 2417722792u,
+636223705u, 2423329294u, 3960951311u, 1543591052u,
+1547914361u,
+2760945653u,
+3519014111u, 313543871u, 4119598884u, 1071003714u,
+2192556597u, 1526995535u, 3929839778u, 536388591u,
+3040873792u,
+3752682932u,
+1640614237u, 2432794021u, 385337403u, 2794410617u,
+2386128075u, 1055206708u, 1422747714u, 3759330929u,
+2533597496u,
+30440955u,
+1482899460u, 3350385050u, 616259409u, 3980103795u,
+1211364140u, 1040071544u, 594746920u, 1645973936u,
+2547331531u,
+1097726368u,
+700666526u, 2976247482u, 1144906608u, 996506677u,
+1997130756u, 800321417u, 1392942823u, 1601662248u,
+2079778663u,
+529512908u,
+2925120134u, 4106433085u, 630221833u, 2423086156u,
+1119859778u, 1726827981u, 1870859181u, 2559832707u,
+1792284257u,
+2059356387u,
+3572353364u, 3229407475u, 575621095u, 3221893291u,
+2372428048u, 2020123035u, 961449593u, 2243824063u,
+3803906611u,
+3735348189u,
+2981620804u, 4180681078u, 1555330629u, 230736535u,
+2075526640u, 749652975u, 713664372u, 2152096659u,
+2142067223u,
+3322302242u,
+1421646830u, 2092832615u, 1213735101u, 3192136753u,
+1106723940u, 3455398230u, 2541685524u, 2529956739u,
+3789430647u,
+1950084508u,
+2157395621u, 850457360u, 2758902426u, 2848030169u,
+6506379u, 1162213157u, 2981459221u, 272690871u,
+3059420255u,
+4242691285u,
+588065598u, 1206949936u, 3968214184u, 566348532u,
+126142880u, 1480567086u, 2959621988u, 2050218418u,
+2242731195u,
+3833514449u,
+1898070331u, 3687399477u, 3891859374u, 868185955u,
+2335308774u, 3676335246u, 3871121805u, 2189032743u,
+3275728647u,
+860492892u,
+1590764344u, 4130384758u, 262871548u, 3004764525u,
+2685542071u, 991231482u, 435122019u, 3031116998u,
+2898921700u,
+2917932604u,
+4238665148u, 2459072654u, 3444612545u, 4207731740u,
+1808564313u, 2798532269u, 3944553556u, 3926395409u,
+1633200670u,
+4138335224u,
+2524878605u, 4184292650u, 3563398268u, 4288943552u,
+3802121210u, 957502058u, 2410820887u, 4227117506u,
+4018625153u,
+4284329158u,
+530216712u, 2978986531u, 863452221u, 1910162118u,
+4088211378u, 4091971261u, 3150811451u, 4200871487u,
+3794038652u,
+3041564310u,
+2045287082u, 887805614u, 2889167251u, 4120352181u,
+1699912580u, 3478922097u, 3211994687u, 3136177842u,
+1500806861u,
+3211881347u,
+2147976385u, 3342722260u, 3359650541u, 4197378460u,
+781354073u, 1533623029u, 2204677828u, 3228172832u,
+3248592437u,
+3355841359u,
+560815159u, 1144951236u, 4027015711u, 2882625391u,
+339363613u, 2354572719u, 1769831876u, 4238589331u,
+1519732871u,
+2185834614u,
+1601096831u, 129709881u, 39655633u, 367604993u,
+1737681770u, 3259114599u, 2767070452u, 872365177u,
+1574125529u,
+3405020189u,
+4181346685u, 1134030380u, 403769171u, 2193351164u,
+1426232618u, 2885309450u, 3033612627u, 924948363u,
+935514094u,
+3202053329u,
+912294839u, 1618472324u, 4159158431u, 3744999487u,
+777064358u, 3974213124u, 1990246048u, 309725290u,
+2449849392u,
+1943692420u,
+2288635750u, 2433793635u, 2168904061u, 683315308u,
+3081493019u, 3477759434u, 3815496269u, 2823504699u,
+586945121u,
+3088963200u,
+3492287335u, 636875049u, 1111206944u, 2037346120u,
+1282050044u, 1409681512u, 1786128584u, 755810950u,
+2332676758u,
+2178142310u,
+957827166u, 1014983590u, 1888800725u, 3608595803u,
+3200072714u, 2534008478u, 659336139u, 1281728287u,
+4060560529u,
+2915575125u,
+3521503774u, 2926487340u, 1096297674u, 653489861u,
+2352326980u, 2561136777u, 1224141198u, 1250479629u,
+1297625391u,
+2409997371u,
+1942483722u, 2481835750u, 1394715707u, 1673070941u,
+2456039704u, 3980558014u, 3547934764u, 1882038812u,
+1078160498u,
+2488279087u,
+1848235245u, 1211914722u, 2264928765u, 2807773070u,
+270145554u, 583747883u, 3826009010u, 2996618216u,
+425727157u,
+992726957u,
+3384462280u, 726650661u, 1955043265u, 1923879512u,
+1854693773u, 2987614542u, 2660044993u, 2457260810u,
+426299370u,
+2671892900u,
+1827308087u, 3083953443u, 1791749638u, 3265087416u,
+2119752201u, 2547122538u, 3990783236u, 1912713468u,
+3688865211u,
+1815780016u,
+303699291u, 2416763742u, 2690891610u, 1535193548u,
+1107803989u, 1504143133u, 2235270371u, 2545884083u,
+2276278682u,
+411724404u,
+3416925704u, 2565792091u, 3383911757u, 546058824u,
+3374654444u, 2364630415u, 2693473470u, 2622125691u,
+261864817u,
+55682470u,
+857617568u, 141304067u, 1885488541u, 155368182u,
+1281949051u, 3384522408u, 3254816901u, 1959816782u,
+1452224057u,
+2830267691u,
+3709231247u, 58988202u, 4218130458u, 2984061349u,
+1888707848u, 4223605071u, 4241442486u, 375269213u,
+3208327038u,
+2199916493u,
+550337252u, 2855061437u, 276088636u, 114362204u,
+2321163647u, 2127813633u, 3289403024u, 2686973202u,
+2717376797u,
+3593428039u,
+3648831666u, 890925902u, 3289404818u, 3289516821u,
+4248913260u, 1858916580u, 3303932308u, 1752797086u,
+1628149686u,
+3245893605u,
+1568537311u, 2844194502u, 1593855770u, 2408174109u,
+124797514u, 2085649512u, 3188565660u, 2264996276u,
+1926696513u,
+3053957740u,
+2238806881u, 2189050973u, 203685243u, 379855590u,
+3920271562u, 1058600179u, 3698061923u, 4255106849u,
+608401664u,
+1598041932u,
+3318266418u, 2535016555u, 852760884u, 1918098822u,
+2200437599u, 1532285043u, 3425662132u, 3561293706u,
+2231633206u,
+4108785088u,
+3359152801u, 173534780u, 208383607u, 2862988169u,
+2406642243u, 426814583u, 2777335795u, 3322703596u,
+954190623u,
+615093090u,
+4179102978u, 2452847930u, 100239619u, 42471741u,
+818352432u, 2190624654u, 504379960u, 3631619975u,
+633412456u,
+1018421783u,
+842645419u, 711808707u, 3424580813u, 2132457941u,
+1158335882u, 3567952480u, 2302183699u, 1145788151u,
+3474264138u,
+3105085243u,
+3115506027u, 2783713015u, 3871785309u, 539583269u,
+1400252405u, 3857849984u, 4231186588u, 1278653799u,
+1760227022u,
+761044088u,
+3838185417u, 2439542532u, 585283357u, 2055995220u,
+937117124u, 3831944855u, 1823586038u, 3287917855u,
+485082427u,
+3209172809u,
+1984570176u, 2818337297u, 2691869057u, 3790476953u,
+839035557u, 3203129010u, 669981176u, 4121157385u,
+3519870450u,
+3792633352u,
+3017650322u, 1603459507u, 4225677666u, 376555451u,
+473780127u, 2018786277u, 3299822439u, 1010254499u,
+2383887565u,
+3155009499u,
+3108110655u, 2641738274u, 3684908622u, 1606463047u,
+3311068174u, 52708046u, 754181455u, 1018079176u,
+3915670272u,
+3366999425u,
+1012880204u, 1339439715u, 466437962u, 1402662350u,
+2504046911u, 736323938u, 2037800124u, 1725908589u,
+716341840u,
+1750123474u,
+3366342464u, 1743666195u, 2975303189u, 3821364027u,
+3253707772u, 3635548377u, 3840413796u, 1955642085u,
+1018315169u,
+1258092848u,
+2095540656u, 1076256607u, 117289557u, 1311658655u,
+2118301000u, 68721550u, 2886814107u, 2712432819u,
+4201862886u,
+753807148u,
+1940229047u, 731347296u, 1068901393u, 3873155894u,
+2852787666u, 1973464853u, 79735652u, 3966380587u,
+3245740712u,
+2525773438u,
+734938109u, 3045656416u, 3335746354u, 4099732691u,
+1911896517u, 1697006473u, 1145487066u, 1605663299u,
+3053606724u,
+2386289465u,
+3821211369u, 1006215345u, 1256304829u, 1053001668u,
+1289194958u, 118761054u, 1853688730u, 2803418011u,
+188650809u,
+3763686458u,
+1006829556u, 2961984133u, 3390525025u, 2061199893u,
+141792681u, 2439893463u, 2652982650u, 1804942682u,
+1546510005u,
+1246961405u,
+2407577046u, 565772575u, 3751844810u, 2943166103u,
+3750052451u, 3022527280u, 25162928u, 397381043u,
+1818337632u,
+3447363730u,
+3936437150u, 2569420703u, 2215592390u, 2171555672u,
+3665571006u, 4021712412u, 2939158353u, 4057813172u,
+1823237318u,
+103999245u,
+3251978010u, 3591914940u, 3582495283u, 2519035265u,
+3905726135u, 3180393349u, 2743117123u, 55247368u,
+3325286701u,
+705195946u,
+1857526853u, 1480518550u, 3809990433u, 1398189338u,
+3126362926u, 3959531492u, 1503658285u, 1977847740u,
+3043964489u,
+2613086143u,
+1518119282u, 4238434900u, 3905746486u, 3064949667u,
+1028122931u, 3309119457u, 4071194920u, 3096098907u,
+4137180520u,
+494467959u,
+1231408687u, 1691606157u, 1793452569u, 2722196118u,
+3478603952u, 1059665738u, 2282032278u, 3990268388u,
+1719514651u,
+4248311578u,
+3799146721u, 898026304u, 3367808954u, 4162472815u,
+170495870u, 1308116609u, 3428285344u, 1714716475u,
+395576794u,
+4153638621u,
+2999745812u, 3483315953u, 304980828u, 595337120u,
+3486516729u, 2331563143u, 2583609459u, 1885928417u,
+3834283777u,
+979337825u,
+932057378u, 3124081189u, 1930356777u, 3865887996u,
+4178282217u, 4214219408u, 3669465884u, 1472413856u,
+3356866587u,
+1012769806u,
+3043639963u, 996996396u, 207308216u, 982967331u,
+2991319933u, 318066902u, 721489670u, 1249967713u,
+749240921u,
+591392325u,
+2379365192u, 2250868849u, 2163259329u, 143191325u,
+3778285606u, 982149096u, 3536906200u, 2244353244u,
+1443862317u,
+3161549210u,
+2183127464u, 2015409516u, 547003700u, 2032484282u,
+523677821u, 4275663308u, 3827205526u, 3903778273u,
+2444530525u,
+2543645801u,
+1173958423u, 784740616u, 2878693675u, 3127696736u,
+3832037316u, 3161002398u, 4084166400u, 4213346853u,
+223390424u,
+4273380883u,
+2130315482u, 3429606032u, 3367732613u, 1912357694u,
+422632590u, 1266957023u, 3437535648u, 736404240u,
+2281709372u,
+415859912u,
+212948797u, 351612650u, 3920561440u, 112963586u,
+2230727543u, 2851076612u, 1990662634u, 2264296857u,
+3131463650u,
+2704034623u,
+3541637839u, 2954232792u, 533986918u, 4158757533u,
+65174248u, 4232639593u, 865906667u, 1948225652u,
+779656112u,
+3873989249u,
+2372984749u, 2346988193u, 1104345713u, 1165654138u,
+4045762610u, 3588205178u, 461363991u, 1111215752u,
+1389675192u,
+2404325151u,
+2152228101u, 3808973622u, 1901235912u, 3458690696u,
+314513238u, 2539459143u, 2847998873u, 952026138u,
+2325705328u,
+407844712u,
+3727960715u, 2996448351u, 2374336760u, 3138756390u,
+2600015243u, 539980418u, 1876285352u, 1670330799u,
+1709360377u,
+2868531654u,
+494777964u, 2773053597u, 599486162u, 3962209577u,
+1871328846u, 2171933018u, 110279472u, 384074780u,
+4147021936u,
+2333589647u,
+4251778066u, 40493468u, 3099342316u, 4108779767u,
+2812424588u, 954542332u, 2040682331u, 2251152306u,
+45915516u,
+259525626u,
+1045384743u, 4134656562u, 749389261u, 874399445u,
+616549904u, 2200447504u, 436024539u, 78972290u,
+3210485762u,
+1907985531u,
+3013721395u, 4214533685u, 4198804243u, 534879265u,
+1517190881u, 3756787754u, 1152563554u, 1718750948u,
+777737463u,
+1402478860u,
+1824562784u, 1879401449u, 3515818786u, 513165201u,
+1423491227u, 2103067918u, 2291777410u, 1097943000u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; IsAlive(farmhashcc::Hash32WithSeed(farm_hash_data, len++, SEED)); IsAlive(farmhashcc::Hash32(farm_hash_data, len++)); { uint128_t u = farmhashcc::Fingerprint128(farm_hash_data, len++); uint64_t h = Uint128Low64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); h = Uint128High64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
Check(farmhashcc::Hash32WithSeed(farm_hash_data + offset, len, SEED));
Check(farmhashcc::Hash32(farm_hash_data + offset, len));
{ uint128_t u = farmhashcc::Fingerprint128(farm_hash_data + offset, len); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
{ uint128_t u = farmhashcc::CityHash128WithSeed(farm_hash_data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashccTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashccTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
cout << farmhashcc::Hash32WithSeed(farm_hash_data + offset, len, SEED) << "u," << endl;
cout << farmhashcc::Hash32(farm_hash_data + offset, len) << "u," << endl;
{ uint128_t u = farmhashcc::Fingerprint128(farm_hash_data + offset, len); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint128_t u = farmhashcc::CityHash128WithSeed(farm_hash_data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashccTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashccTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashccTest::Dump(0, i);
- }
- farmhashccTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashccTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashccTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashccTest::Dump(0, i);
+ }
+ farmhashccTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashmkTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-4081014168u,
-2576519988u,
-2212771159u,
-1112731063u,
-1020067935u,
-3955445564u,
-1451961420u,
-653440099u,
-31917516u,
-2957164615u,
-2590087362u,
-3879448744u,
-176305566u,
-2447367541u,
-1359016305u,
-3363804638u,
-1117290165u,
-1062549743u,
-2437877004u,
-1894455839u,
-673206794u,
-3486923651u,
-3269862919u,
-2303349487u,
-1380660650u,
-595525107u,
-1525325287u,
-2025609358u,
-176408838u,
-1592885012u,
-864896482u,
-2101378090u,
-3489229104u,
-2118965695u,
-581644891u,
-2718789079u,
-631613207u,
-4228658372u,
-3867875546u,
-3531368319u,
-3804516756u,
-3317755099u,
-1619744564u,
-2884717286u,
-1088213445u,
-2667691076u,
-3727873235u,
-2330406762u,
-3616470388u,
-967660719u,
-4148162586u,
-315219121u,
-673084328u,
-3047602355u,
-1598963653u,
-1267826661u,
-2117362589u,
-2861192253u,
-1823625377u,
-1380350078u,
-1641748342u,
-1176094482u,
-269384321u,
-2178982315u,
-3480237248u,
-2660755208u,
-1850544433u,
-3429699438u,
-1262819303u,
-640556464u,
-2421125401u,
-2188368608u,
-2612932825u,
-1474432581u,
-173790449u,
-2124882189u,
-831272654u,
-622960146u,
-4238751051u,
-3250317967u,
-2120810248u,
-1948231495u,
-1389029321u,
-2200398357u,
-2134232963u,
-2948072329u,
-617717625u,
-681164587u,
-114859387u,
-430545646u,
-57239089u,
-3163338012u,
-3482496399u,
-557662576u,
-1102441413u,
-2670159360u,
-991116729u,
-846014240u,
-4233741566u,
-1802317242u,
-3129528802u,
-1459456375u,
-1305643039u,
-3258671612u,
-1578285833u,
-868590079u,
-1631034517u,
-1695432937u,
-561078856u,
-1004115553u,
-3086090507u,
-3818348650u,
-731596645u,
-780926790u,
-2544205955u,
-158479164u,
-3983514188u,
-2004735250u,
-3436218400u,
-673684751u,
-1463431419u,
-2880490219u,
-3223748024u,
-2218318859u,
-1474466194u,
-2636437533u,
-2206794961u,
-140995728u,
-1186394086u,
-1805716888u,
-1640037724u,
-3942729099u,
-1944727013u,
-918951560u,
-498666871u,
-3486974657u,
-2967205462u,
-1167253804u,
-1884281041u,
-2866015002u,
-4158319270u,
-2627220079u,
-3733319624u,
-3317092271u,
-438323662u,
-3195868065u,
-3426606709u,
-360708338u,
-1905491012u,
-650004803u,
-1351266252u,
-3133279000u,
-3722811115u,
-2722412434u,
-918432408u,
-3678271248u,
-269599647u,
-621514057u,
-3117077855u,
-1545425390u,
-2597567410u,
-1221437820u,
-3493254589u,
-102787342u,
-918861168u,
-348795089u,
-3439883229u,
-2353641807u,
-2209585469u,
-4035884492u,
-2686995435u,
-1649888022u,
-3852893848u,
-3042700028u,
-314103172u,
-726977769u,
-2489830276u,
-2872753660u,
-1316214989u,
-1488801501u,
-1811420390u,
-639581627u,
-2362837215u,
-3634581834u,
-3648576802u,
-1257314182u,
-762118371u,
-4268447045u,
-730167096u,
-755561509u,
-882614845u,
-3696972894u,
-228263661u,
-1478636142u,
-2767751651u,
-1532617116u,
-3838657661u,
-1944359935u,
-1401102137u,
-3772933173u,
-1050098254u,
-1658079354u,
-1846025728u,
-2204244794u,
-2017217424u,
-1275162853u,
-1429816745u,
-2175565479u,
-1716109139u,
-1187506761u,
-2434641075u,
-2725597783u,
-1795687662u,
-1393312782u,
-3511565397u,
-627885430u,
-4145733164u,
-2519005353u,
-231414775u,
-1242015635u,
-2760723497u,
-2185540568u,
-727314436u,
-2358790354u,
-1186393454u,
-4234795645u,
-350567813u,
-866773875u,
-3145590392u,
-1158374055u,
-3903123687u,
-1862119793u,
-2204587556u,
-4266276976u,
-4151548555u,
-915250402u,
-2874695320u,
-2360311410u,
-1099212769u,
-1271542714u,
-3473148363u,
-1637325418u,
-1807795989u,
-2493819794u,
-3800917924u,
-4001205856u,
-2582153621u,
-3365872040u,
-2890146216u,
-2626363824u,
-3133351295u,
-4046827296u,
-3053118771u,
-4113026751u,
-884356716u,
-3828347401u,
-10608262u,
-830987972u,
-1841080500u,
-3202717763u,
-3561778749u,
-1906000052u,
-3058284660u,
-1432904514u,
-2567431677u,
-2550162530u,
-665557986u,
-936887821u,
-2101205308u,
-4253535847u,
-1662043545u,
-1253611611u,
-2091370094u,
-2635077370u,
-2602176041u,
-3624115809u,
-748442714u,
-2709749154u,
-1023493343u,
-860291012u,
-3924715584u,
-1536436740u,
-2551145800u,
-2391782865u,
-1467705048u,
-2583909796u,
-3616666170u,
-1162857372u,
-4228631071u,
-1510132376u,
-2739165009u,
-2656606142u,
-3454996358u,
-3155038853u,
-1022087316u,
-100044110u,
-494208296u,
-2746186477u,
-4216782431u,
-225448834u,
-3728320521u,
-335282866u,
-3148194874u,
-953503703u,
-1293353960u,
-202372387u,
-1326119870u,
-4045123735u,
-3819994846u,
-1629004186u,
-1081099186u,
-3591584153u,
-1670825804u,
-3404257979u,
-3262192301u,
-2572846095u,
-3714992543u,
-4264142572u,
-529616678u,
-2882154574u,
-3006354178u,
-3865969421u,
-2007174907u,
-308283107u,
-2629833703u,
-3159124075u,
-1146492131u,
-494104332u,
-493149727u,
-1342910585u,
-521642387u,
-2201695937u,
-2517980959u,
-2426821287u,
-777374655u,
-2228189792u,
-4027055486u,
-228976000u,
-3842083468u,
-1723920223u,
-1192126094u,
-787744493u,
-2740368380u,
-2284153001u,
-2773829458u,
-442000614u,
-387830783u,
-2169780670u,
-2253144627u,
-3532502484u,
-1969684059u,
-1165351416u,
-3055056536u,
-3582324253u,
-231419363u,
-770979865u,
-3213983597u,
-3690452836u,
-935794639u,
-3230602762u,
-2841762457u,
-407598927u,
-1164479891u,
-3721799696u,
-354738136u,
-1801566618u,
-3206038542u,
-2621379981u,
-1943487262u,
-3534745636u,
-1074424589u,
-1304517521u,
-4133400969u,
-2339317978u,
-2135116860u,
-4180643791u,
-2415309340u,
-1855926417u,
-3418648630u,
-1968113037u,
-597304222u,
-3668824865u,
-3810008716u,
-3014702569u,
-3151212026u,
-156057449u,
-373134533u,
-2068234004u,
-191580563u,
-3832754488u,
-2924104199u,
-2026044494u,
-4065780435u,
-122565840u,
-4194985167u,
-2744823717u,
-2494098735u,
-3753793370u,
-1885739217u,
-2488161225u,
-3643797615u,
-2653367310u,
-2494061477u,
-189968132u,
-899646597u,
-392100396u,
-4012318310u,
-3855777086u,
-3566860954u,
-2698574996u,
-2414249905u,
-1330623339u,
-1263222732u,
-1277741760u,
-2194959402u,
-1629656136u,
-120494320u,
-1072368005u,
-1084245077u,
-4011372748u,
-1366613353u,
-3108643228u,
-3332219532u,
-2114746095u,
-3964007334u,
-371687128u,
-1084813876u,
-126459896u,
-4292782331u,
-321283184u,
-398168499u,
-3604983506u,
-560701543u,
-2073961354u,
-4240841868u,
-4151211362u,
-1338986875u,
-4093476832u,
-2269279497u,
-3500846299u,
-2510225147u,
-598000444u,
-1330391422u,
-1432533385u,
-4171226231u,
-426821154u,
-2932270996u,
-3378981077u,
-2217871549u,
-1619647984u,
-4051608043u,
-3180237819u,
-12919578u,
-1375401767u,
-371320427u,
-2986640571u,
-2336669859u,
-3796464715u,
-1892383284u,
-306814912u,
-2125823211u,
-1863678891u,
-3249703818u,
-3840225752u,
-281579900u,
-264680257u,
-4266359110u,
-4182229890u,
-2239659703u,
-3627947372u,
-2373929191u,
-224082765u,
-4053639058u,
-1862360303u,
-3187739624u,
-3392706679u,
-948039509u,
-817505760u,
-1215842393u,
-3462222651u,
-536021853u,
-182346832u,
-2731944883u,
-2346674384u,
-2640961678u,
-3446695687u,
-2271722179u,
-1301069656u,
-2803881468u,
-2832614405u,
-1691544398u,
-698756814u,
-3980620906u,
-3565421410u,
-754769376u,
-4115923404u,
-3909962218u,
-2747614077u,
-2888289845u,
-1016920862u,
-2790946178u,
-3067070960u,
-3173251481u,
-1572132982u,
-255048203u,
-2996538818u,
-3405398987u,
-136106013u,
-3581605228u,
-4277437977u,
-2147300534u,
-3728426265u,
-3483629996u,
-1478452694u,
-20756076u,
-2774992067u,
-432987927u,
-1516771026u,
-3511588664u,
-2130994978u,
-509385406u,
-873090347u,
-2163904107u,
-4192239086u,
-2532489989u,
-1090772651u,
-3910797408u,
-3710882132u,
-155010959u,
-1369823531u,
-1599664937u,
-4035593587u,
-1212746925u,
-795822552u,
-116689518u,
-3674240941u,
-1135576664u,
-756750261u,
-1027431362u,
-390555140u,
-2228460216u,
-1506940482u,
-3733857700u,
-3048762971u,
-2511703196u,
-548609887u,
-1607354252u,
-659053982u,
-259884450u,
-1793130460u,
-4083364495u,
-3148555881u,
-1764350138u,
-2436485683u,
-4031563025u,
-3261860724u,
-2475833430u,
-2101726086u,
-3191176464u,
-2646658847u,
-2127042126u,
-771316100u,
-2115922959u,
-3208515045u,
-2355437783u,
-3621147793u,
-1580163615u,
-3211555675u,
-3299188490u,
-191613920u,
-466733956u,
-2939029038u,
-1509152039u,
-130591314u,
-1892874677u,
-1646908044u,
-3452406523u,
-3998376606u,
-1199243832u,
-2187108812u,
-3189230066u,
-4161151481u,
-3371454980u,
-3681788646u,
-180842187u,
-3685022399u,
-3058749895u,
-3250165163u,
-2895367943u,
-2627101723u,
-771755098u,
-1332921024u,
-3638871848u,
-514215135u,
-3591227378u,
-2300310870u,
-3689533503u,
-851607114u,
-114330368u,
-2709027386u,
-1743034877u,
-1013693860u,
-288169008u,
-3545190686u,
-1052165084u,
-3995862307u,
-96902755u,
-1097819851u,
-2645431442u,
-2184148618u,
-2151206566u,
-350979797u,
-3467920900u,
-421116779u,
-1246252u,
-4057835428u,
-329324407u,
-4104482417u,
-844624570u,
-3306265806u,
-3787625025u,
-4263241191u,
-3251413927u,
-2921204431u,
-2931915325u,
-992134330u,
-3986338354u,
-1327895216u,
-1458363596u,
-1480608532u,
-728594368u,
-3804366693u,
-794404223u,
-1643240863u,
-793417255u,
-4167916443u,
-2683488959u,
-3124925324u,
-4184843652u,
-3750971752u,
-308509829u,
-1054550805u,
-2797511972u,
-4043123412u,
-1587158240u,
-4050518606u,
-3030062190u,
-2589912753u,
-603440067u,
-937013191u,
-1071662315u,
-2100661456u,
-2602005741u,
-435516078u,
-2260470147u,
-1256268350u,
-3612035u,
-3368856141u,
-151516099u,
-3081868591u,
-3363755681u,
-2049963149u,
-2885320434u,
-84682005u,
-2411758308u,
-2695174275u,
-3099904644u,
-1787308684u,
-1132379308u,
-564634346u,
-510236510u,
-2804443681u,
-3931864252u,
-2064427949u,
-1893979229u,
-2916544974u,
-1885887717u,
-2978018250u,
-494192125u,
-2642662373u,
-901112508u,
-636035003u,
-1658643797u,
-172746975u,
-517504890u,
-3440019372u,
-4144498044u,
-1854755456u,
-3672653905u,
-4176892856u,
-382159097u,
-282871690u,
-3629300472u,
-2500754041u,
-1677659759u,
-1067175061u,
-161654075u,
-1672575536u,
-346120493u,
-2730229631u,
-203466442u,
-1244549529u,
-199761971u,
-2744895408u,
-3195315331u,
-2124618519u,
-3261045496u,
-985339699u,
-3385585455u,
-1545740710u,
-3636652160u,
-2167020081u,
-1207897204u,
-28752417u,
-2895834146u,
-3640845375u,
-3750293073u,
-548997850u,
-4207814196u,
-4183030708u,
-2462810989u,
-3929965401u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashmkTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+4081014168u,
+2576519988u,
+2212771159u,
+1112731063u,
+1020067935u,
+3955445564u,
+1451961420u,
+653440099u,
+31917516u,
+2957164615u,
+2590087362u,
+3879448744u,
+176305566u,
+2447367541u,
+1359016305u,
+3363804638u,
+1117290165u,
+1062549743u,
+2437877004u,
+1894455839u,
+673206794u,
+3486923651u,
+3269862919u,
+2303349487u,
+1380660650u,
+595525107u,
+1525325287u,
+2025609358u,
+176408838u,
+1592885012u,
+864896482u,
+2101378090u,
+3489229104u,
+2118965695u,
+581644891u,
+2718789079u,
+631613207u,
+4228658372u,
+3867875546u,
+3531368319u,
+3804516756u,
+3317755099u,
+1619744564u,
+2884717286u,
+1088213445u,
+2667691076u,
+3727873235u,
+2330406762u,
+3616470388u,
+967660719u,
+4148162586u,
+315219121u,
+673084328u,
+3047602355u,
+1598963653u,
+1267826661u,
+2117362589u,
+2861192253u,
+1823625377u,
+1380350078u,
+1641748342u,
+1176094482u,
+269384321u,
+2178982315u,
+3480237248u,
+2660755208u,
+1850544433u,
+3429699438u,
+1262819303u,
+640556464u,
+2421125401u,
+2188368608u,
+2612932825u,
+1474432581u,
+173790449u,
+2124882189u,
+831272654u,
+622960146u,
+4238751051u,
+3250317967u,
+2120810248u,
+1948231495u,
+1389029321u,
+2200398357u,
+2134232963u,
+2948072329u,
+617717625u,
+681164587u,
+114859387u,
+430545646u,
+57239089u,
+3163338012u,
+3482496399u,
+557662576u,
+1102441413u,
+2670159360u,
+991116729u,
+846014240u,
+4233741566u,
+1802317242u,
+3129528802u,
+1459456375u,
+1305643039u,
+3258671612u,
+1578285833u,
+868590079u,
+1631034517u,
+1695432937u,
+561078856u,
+1004115553u,
+3086090507u,
+3818348650u,
+731596645u,
+780926790u,
+2544205955u,
+158479164u,
+3983514188u,
+2004735250u,
+3436218400u,
+673684751u,
+1463431419u,
+2880490219u,
+3223748024u,
+2218318859u,
+1474466194u,
+2636437533u,
+2206794961u,
+140995728u,
+1186394086u,
+1805716888u,
+1640037724u,
+3942729099u,
+1944727013u,
+918951560u,
+498666871u,
+3486974657u,
+2967205462u,
+1167253804u,
+1884281041u,
+2866015002u,
+4158319270u,
+2627220079u,
+3733319624u,
+3317092271u,
+438323662u,
+3195868065u,
+3426606709u,
+360708338u,
+1905491012u,
+650004803u,
+1351266252u,
+3133279000u,
+3722811115u,
+2722412434u,
+918432408u,
+3678271248u,
+269599647u,
+621514057u,
+3117077855u,
+1545425390u,
+2597567410u,
+1221437820u,
+3493254589u,
+102787342u,
+918861168u,
+348795089u,
+3439883229u,
+2353641807u,
+2209585469u,
+4035884492u,
+2686995435u,
+1649888022u,
+3852893848u,
+3042700028u,
+314103172u,
+726977769u,
+2489830276u,
+2872753660u,
+1316214989u,
+1488801501u,
+1811420390u,
+639581627u,
+2362837215u,
+3634581834u,
+3648576802u,
+1257314182u,
+762118371u,
+4268447045u,
+730167096u,
+755561509u,
+882614845u,
+3696972894u,
+228263661u,
+1478636142u,
+2767751651u,
+1532617116u,
+3838657661u,
+1944359935u,
+1401102137u,
+3772933173u,
+1050098254u,
+1658079354u,
+1846025728u,
+2204244794u,
+2017217424u,
+1275162853u,
+1429816745u,
+2175565479u,
+1716109139u,
+1187506761u,
+2434641075u,
+2725597783u,
+1795687662u,
+1393312782u,
+3511565397u,
+627885430u,
+4145733164u,
+2519005353u,
+231414775u,
+1242015635u,
+2760723497u,
+2185540568u,
+727314436u,
+2358790354u,
+1186393454u,
+4234795645u,
+350567813u,
+866773875u,
+3145590392u,
+1158374055u,
+3903123687u,
+1862119793u,
+2204587556u,
+4266276976u,
+4151548555u,
+915250402u,
+2874695320u,
+2360311410u,
+1099212769u,
+1271542714u,
+3473148363u,
+1637325418u,
+1807795989u,
+2493819794u,
+3800917924u,
+4001205856u,
+2582153621u,
+3365872040u,
+2890146216u,
+2626363824u,
+3133351295u,
+4046827296u,
+3053118771u,
+4113026751u,
+884356716u,
+3828347401u,
+10608262u,
+830987972u,
+1841080500u,
+3202717763u,
+3561778749u,
+1906000052u,
+3058284660u,
+1432904514u,
+2567431677u,
+2550162530u,
+665557986u,
+936887821u,
+2101205308u,
+4253535847u,
+1662043545u,
+1253611611u,
+2091370094u,
+2635077370u,
+2602176041u,
+3624115809u,
+748442714u,
+2709749154u,
+1023493343u,
+860291012u,
+3924715584u,
+1536436740u,
+2551145800u,
+2391782865u,
+1467705048u,
+2583909796u,
+3616666170u,
+1162857372u,
+4228631071u,
+1510132376u,
+2739165009u,
+2656606142u,
+3454996358u,
+3155038853u,
+1022087316u,
+100044110u,
+494208296u,
+2746186477u,
+4216782431u,
+225448834u,
+3728320521u,
+335282866u,
+3148194874u,
+953503703u,
+1293353960u,
+202372387u,
+1326119870u,
+4045123735u,
+3819994846u,
+1629004186u,
+1081099186u,
+3591584153u,
+1670825804u,
+3404257979u,
+3262192301u,
+2572846095u,
+3714992543u,
+4264142572u,
+529616678u,
+2882154574u,
+3006354178u,
+3865969421u,
+2007174907u,
+308283107u,
+2629833703u,
+3159124075u,
+1146492131u,
+494104332u,
+493149727u,
+1342910585u,
+521642387u,
+2201695937u,
+2517980959u,
+2426821287u,
+777374655u,
+2228189792u,
+4027055486u,
+228976000u,
+3842083468u,
+1723920223u,
+1192126094u,
+787744493u,
+2740368380u,
+2284153001u,
+2773829458u,
+442000614u,
+387830783u,
+2169780670u,
+2253144627u,
+3532502484u,
+1969684059u,
+1165351416u,
+3055056536u,
+3582324253u,
+231419363u,
+770979865u,
+3213983597u,
+3690452836u,
+935794639u,
+3230602762u,
+2841762457u,
+407598927u,
+1164479891u,
+3721799696u,
+354738136u,
+1801566618u,
+3206038542u,
+2621379981u,
+1943487262u,
+3534745636u,
+1074424589u,
+1304517521u,
+4133400969u,
+2339317978u,
+2135116860u,
+4180643791u,
+2415309340u,
+1855926417u,
+3418648630u,
+1968113037u,
+597304222u,
+3668824865u,
+3810008716u,
+3014702569u,
+3151212026u,
+156057449u,
+373134533u,
+2068234004u,
+191580563u,
+3832754488u,
+2924104199u,
+2026044494u,
+4065780435u,
+122565840u,
+4194985167u,
+2744823717u,
+2494098735u,
+3753793370u,
+1885739217u,
+2488161225u,
+3643797615u,
+2653367310u,
+2494061477u,
+189968132u,
+899646597u,
+392100396u,
+4012318310u,
+3855777086u,
+3566860954u,
+2698574996u,
+2414249905u,
+1330623339u,
+1263222732u,
+1277741760u,
+2194959402u,
+1629656136u,
+120494320u,
+1072368005u,
+1084245077u,
+4011372748u,
+1366613353u,
+3108643228u,
+3332219532u,
+2114746095u,
+3964007334u,
+371687128u,
+1084813876u,
+126459896u,
+4292782331u,
+321283184u,
+398168499u,
+3604983506u,
+560701543u,
+2073961354u,
+4240841868u,
+4151211362u,
+1338986875u,
+4093476832u,
+2269279497u,
+3500846299u,
+2510225147u,
+598000444u,
+1330391422u,
+1432533385u,
+4171226231u,
+426821154u,
+2932270996u,
+3378981077u,
+2217871549u,
+1619647984u,
+4051608043u,
+3180237819u,
+12919578u,
+1375401767u,
+371320427u,
+2986640571u,
+2336669859u,
+3796464715u,
+1892383284u,
+306814912u,
+2125823211u,
+1863678891u,
+3249703818u,
+3840225752u,
+281579900u,
+264680257u,
+4266359110u,
+4182229890u,
+2239659703u,
+3627947372u,
+2373929191u,
+224082765u,
+4053639058u,
+1862360303u,
+3187739624u,
+3392706679u,
+948039509u,
+817505760u,
+1215842393u,
+3462222651u,
+536021853u,
+182346832u,
+2731944883u,
+2346674384u,
+2640961678u,
+3446695687u,
+2271722179u,
+1301069656u,
+2803881468u,
+2832614405u,
+1691544398u,
+698756814u,
+3980620906u,
+3565421410u,
+754769376u,
+4115923404u,
+3909962218u,
+2747614077u,
+2888289845u,
+1016920862u,
+2790946178u,
+3067070960u,
+3173251481u,
+1572132982u,
+255048203u,
+2996538818u,
+3405398987u,
+136106013u,
+3581605228u,
+4277437977u,
+2147300534u,
+3728426265u,
+3483629996u,
+1478452694u,
+20756076u,
+2774992067u,
+432987927u,
+1516771026u,
+3511588664u,
+2130994978u,
+509385406u,
+873090347u,
+2163904107u,
+4192239086u,
+2532489989u,
+1090772651u,
+3910797408u,
+3710882132u,
+155010959u,
+1369823531u,
+1599664937u,
+4035593587u,
+1212746925u,
+795822552u,
+116689518u,
+3674240941u,
+1135576664u,
+756750261u,
+1027431362u,
+390555140u,
+2228460216u,
+1506940482u,
+3733857700u,
+3048762971u,
+2511703196u,
+548609887u,
+1607354252u,
+659053982u,
+259884450u,
+1793130460u,
+4083364495u,
+3148555881u,
+1764350138u,
+2436485683u,
+4031563025u,
+3261860724u,
+2475833430u,
+2101726086u,
+3191176464u,
+2646658847u,
+2127042126u,
+771316100u,
+2115922959u,
+3208515045u,
+2355437783u,
+3621147793u,
+1580163615u,
+3211555675u,
+3299188490u,
+191613920u,
+466733956u,
+2939029038u,
+1509152039u,
+130591314u,
+1892874677u,
+1646908044u,
+3452406523u,
+3998376606u,
+1199243832u,
+2187108812u,
+3189230066u,
+4161151481u,
+3371454980u,
+3681788646u,
+180842187u,
+3685022399u,
+3058749895u,
+3250165163u,
+2895367943u,
+2627101723u,
+771755098u,
+1332921024u,
+3638871848u,
+514215135u,
+3591227378u,
+2300310870u,
+3689533503u,
+851607114u,
+114330368u,
+2709027386u,
+1743034877u,
+1013693860u,
+288169008u,
+3545190686u,
+1052165084u,
+3995862307u,
+96902755u,
+1097819851u,
+2645431442u,
+2184148618u,
+2151206566u,
+350979797u,
+3467920900u,
+421116779u,
+1246252u,
+4057835428u,
+329324407u,
+4104482417u,
+844624570u,
+3306265806u,
+3787625025u,
+4263241191u,
+3251413927u,
+2921204431u,
+2931915325u,
+992134330u,
+3986338354u,
+1327895216u,
+1458363596u,
+1480608532u,
+728594368u,
+3804366693u,
+794404223u,
+1643240863u,
+793417255u,
+4167916443u,
+2683488959u,
+3124925324u,
+4184843652u,
+3750971752u,
+308509829u,
+1054550805u,
+2797511972u,
+4043123412u,
+1587158240u,
+4050518606u,
+3030062190u,
+2589912753u,
+603440067u,
+937013191u,
+1071662315u,
+2100661456u,
+2602005741u,
+435516078u,
+2260470147u,
+1256268350u,
+3612035u,
+3368856141u,
+151516099u,
+3081868591u,
+3363755681u,
+2049963149u,
+2885320434u,
+84682005u,
+2411758308u,
+2695174275u,
+3099904644u,
+1787308684u,
+1132379308u,
+564634346u,
+510236510u,
+2804443681u,
+3931864252u,
+2064427949u,
+1893979229u,
+2916544974u,
+1885887717u,
+2978018250u,
+494192125u,
+2642662373u,
+901112508u,
+636035003u,
+1658643797u,
+172746975u,
+517504890u,
+3440019372u,
+4144498044u,
+1854755456u,
+3672653905u,
+4176892856u,
+382159097u,
+282871690u,
+3629300472u,
+2500754041u,
+1677659759u,
+1067175061u,
+161654075u,
+1672575536u,
+346120493u,
+2730229631u,
+203466442u,
+1244549529u,
+199761971u,
+2744895408u,
+3195315331u,
+2124618519u,
+3261045496u,
+985339699u,
+3385585455u,
+1545740710u,
+3636652160u,
+2167020081u,
+1207897204u,
+28752417u,
+2895834146u,
+3640845375u,
+3750293073u,
+548997850u,
+4207814196u,
+4183030708u,
+2462810989u,
+3929965401u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; IsAlive(farmhashmk::Hash32WithSeed(farm_hash_data, len++, SEED)); IsAlive(farmhashmk::Hash32(farm_hash_data, len++)); IsAlive(farmhashmk::Hash32(farm_hash_data, len++)); len -= 3; return alive > 0; }
Check(farmhashmk::Hash32WithSeed(farm_hash_data + offset, len, SEED));
Check(farmhashmk::Hash32(farm_hash_data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashmkTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashmkTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
cout << farmhashmk::Hash32WithSeed(farm_hash_data + offset, len, SEED) << "u," << endl;
cout << farmhashmk::Hash32(farm_hash_data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashmkTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashmkTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashmkTest::Dump(0, i);
- }
- farmhashmkTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashmkTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashmkTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashmkTest::Dump(0, i);
+ }
+ farmhashmkTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashnaTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-1140953930u, 861465670u,
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-890626835u, 800175912u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-3283896453u, 1867689945u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-1110588164u, 4186314283u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-283198166u, 2741341286u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-452473466u, 1706958772u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-236935126u, 2976578695u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-2305012065u, 2169731866u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-3058973506u, 2379411653u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-147814787u, 720739346u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-3425469811u, 3690733394u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-1635026870u, 192883107u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-3969463346u, 1436364519u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-2859809759u, 3808705738u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-4023053163u, 2650381482u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-3476440786u, 3829307897u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-2902102606u, 3600725550u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1448662590u, 397635823u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-180854224u, 2604346966u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-1669465176u, 1341975128u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-1043692997u, 1454396064u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-703505868u, 678706990u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-1933894405u, 3043213226u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-3828089804u, 3632594520u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-3729087873u, 1303930448u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3103338579u, 3064290191u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2295806711u, 1781190011u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-1968445277u, 315203929u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-440398219u, 1891630171u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-4204318635u, 441430649u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-3010839769u, 2837339569u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-4139181436u, 2993479124u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-667183474u, 2084369203u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-1016656857u, 3022024459u,
-3254014218u, 429095991u,
-165589978u, 1578546616u,
-985653208u, 1718653828u,
-623071693u, 366414107u,
-249776086u, 1207522198u,
-3047342438u, 2991127487u,
-3120876698u, 1684583131u,
-46987739u, 1157614300u,
-863214540u, 1087193030u,
-199124911u, 520792961u,
-3614377032u, 586863115u,
-3331828431u, 1013201099u,
-1716848157u, 4033596884u,
-1164298657u, 4140791139u,
-1146169032u, 1434258493u,
-3824360466u, 3242407770u,
-3725511003u, 232064808u,
-872586426u, 762243036u,
-2736953692u, 816692935u,
-512845449u, 3748861010u,
-2266795890u, 3781899767u,
-4290630595u, 517646945u,
-22638523u, 648000590u,
-959214578u, 558910384u,
-1283799121u, 3047062993u,
-1024246061u, 4027776454u,
-3544509313u, 622325861u,
-834785312u, 382936554u,
-411505255u, 1973395102u,
-1825135056u, 2725923798u,
-580988377u, 2826990641u,
-3474970689u, 1029055034u,
-812546227u, 2506885666u,
-2584372201u, 1758123094u,
-589567754u, 325737734u,
-345313518u, 2022370576u,
-3886113119u, 3338548567u,
-257578986u, 3698087965u,
-1776047957u, 1771384107u,
-3604937815u, 3198590202u,
-2305332220u, 191910725u,
-4232136669u, 427759438u,
-4244322689u, 542201663u,
-3315355162u, 2135941665u,
-556609672u, 45845311u,
-1175961330u, 3948351189u,
-23075771u, 3252374102u,
-1634635545u, 4151937410u,
-713127376u, 1467786451u,
-663013031u, 3444053918u,
-2638154051u, 810082938u,
-3077742128u, 1062268187u,
-2115441882u, 4081398201u,
-3735739145u, 2794294783u,
-2335576331u, 2560479831u,
-1379288194u, 4225182569u,
-2442302747u, 3948961926u,
-3958366652u, 3067277639u,
-3667516477u, 1709989541u,
-1516711748u, 2339636583u,
-4188504038u, 59581167u,
-2725013602u, 3639843023u,
-2658147000u, 2643979752u,
-3758739543u, 4189944477u,
-2470483982u, 877580602u,
-2995362413u, 118817200u,
-3252925478u, 2062343506u,
-3981838403u, 3762572073u,
-1231633714u, 4168280671u,
-2931588131u, 3284356565u,
-1129162571u, 732225574u,
-4173605289u, 1407328702u,
-1677744031u, 3532596884u,
-3232041815u, 1652884780u,
-2256541290u, 3459463480u,
-3740979556u, 259034107u,
-2227121257u, 1426140634u,
-3606709555u, 3424793077u,
-315836068u, 3200749877u,
-1386256573u, 24035717u,
-2982018998u, 1811050648u,
-234531934u, 1115203611u,
-1598686658u, 3146815575u,
-1603559457u, 323296368u,
-2632963283u, 1778459926u,
-739944537u, 579625482u,
-3486330348u, 492621815u,
-1231665285u, 2457048126u,
-3903349120u, 389846205u,
-3355404249u, 3275550588u,
-1052645068u, 862072556u,
-2834153464u, 1481069623u,
-2657392572u, 4279236653u,
-1688445808u, 701920051u,
-3740748788u, 3388062747u,
-1873358321u, 2152785640u,
-883382081u, 1005815394u,
-1020177209u, 734239551u,
-2371453141u, 100326520u,
-3488500412u, 1279682138u,
-2610427744u, 49703572u,
-3026361211u, 605900428u,
-302392721u, 2509302188u,
-1416453607u, 2815915291u,
-1862819968u, 519710058u,
-2450888314u, 4017598378u,
-937074653u, 3035635454u,
-1590230729u, 3268013438u,
-2710029305u, 12886044u,
-3711259084u, 2627383582u,
-3895772404u, 648534979u,
-260307902u, 855990313u,
-3669691805u, 263366740u,
-2938543471u, 414331688u,
-3080542944u, 3405007814u,
-3565059103u, 1190977418u,
-390836981u, 1606450012u,
-2649808239u, 2514169310u,
-2747519432u, 4129538640u,
-1721522849u, 492099164u,
-792990594u, 3625507637u,
-2271095827u, 2993032712u,
-2302363854u, 4013112951u,
-1111617969u, 2183845740u,
-795918276u, 1116991810u,
-3110898804u, 3963062126u,
-2737064702u, 462795667u,
-937372240u, 1343017609u,
-1091041189u, 2790555455u,
-277024217u, 25485284u,
-1166522068u, 1623631848u,
-241727183u, 2836158787u,
-3112996740u, 573836428u,
-2721658101u, 1937681565u,
-4175169209u, 3190765433u,
-1970000788u, 1668258120u,
-114616703u, 954762543u,
-199237753u, 4094644498u,
-2522281978u, 732086117u,
-1756889687u, 2936126607u,
-2437031370u, 4103143808u,
-3883389541u, 3171090854u,
-2483004780u, 1927385370u,
-2360538162u, 2740855009u,
-4241185118u, 1492209542u,
-1672737098u, 2148675559u,
-1789864670u, 2434313103u,
-2319172611u, 2760941207u,
-2636210123u, 1338083267u,
-1128080590u, 822806371u,
-1199583556u, 314727461u,
-1335160250u, 2084630531u,
-1156261526u, 316766066u,
-112090465u, 3129033323u,
-2746885618u, 636616055u,
-2582210744u, 1721064910u,
-3468394263u, 470463518u,
-2076016059u, 408721884u,
-2121041886u, 378460278u,
-1915948002u, 357324860u,
-2301682622u, 2691859523u,
-1869756364u, 2429314418u,
-2193146527u, 1185564327u,
-2614088922u, 1975527044u,
-919067651u, 2855948894u,
-3662539576u, 1943802836u,
-3529473373u, 1490330107u,
-366036094u, 3384241033u,
-4276268604u, 448403661u,
-4271796078u, 1910401882u,
-3077107698u, 299427366u,
-2035665349u, 3201262636u,
-3738454258u, 2554452696u,
-3588997135u, 3363895827u,
-1267505995u, 1852004679u,
-2237827073u, 2803250686u,
-3468044908u, 2143572850u,
-1728158656u, 1022551180u,
-1996680960u, 839529273u,
-2400647871u, 2201096054u,
-3606433628u, 2597259793u,
-3544595875u, 3909443124u,
-819278607u, 3447346709u,
-806136613u, 2711436388u,
-3656063205u, 837475154u,
-694525336u, 4070212073u,
-4011303412u, 1068395209u,
-438095290u, 484603494u,
-2673730227u, 737767009u,
-642310823u, 3914002299u,
-308425103u, 268427550u,
-1334387085u, 4069797497u,
-4280783219u, 2914011058u,
-4243643405u, 2849988118u,
-2504230175u, 1817156623u,
-2804200483u, 3406991497u,
-2948254999u, 2102063419u,
-1071272117u, 514889942u,
-571972433u, 1246595599u,
-1735616066u, 1539151988u,
-1230831543u, 277987182u,
-4269526481u, 991511607u,
-95237878u, 2005032160u,
-1291113144u, 626619670u,
-3560835907u, 164940926u,
-1433635018u, 116647396u,
-3039097112u, 2868163232u,
-1141645918u, 1764165478u,
-881378302u, 2159170082u,
-2953647681u, 1011320066u,
-184856151u, 1723308975u,
-336034862u, 2017579106u,
-1476681709u, 147523618u,
-3896252223u, 2264728166u,
-944743644u, 1694443528u,
-2690700128u, 1947321519u,
-735478508u, 4058183171u,
-260177668u, 505662155u,
-2391691262u, 1920739747u,
-3216960415u, 1898176786u,
-3722741628u, 1511077569u,
-449636564u, 983350414u,
-2580237367u, 2055059789u,
-1103819072u, 2089123665u,
-3873755579u, 2718467458u,
-3124338704u, 3204250304u,
-2475035432u, 1120017626u,
-3873758287u, 1982999824u,
-2950794582u, 780634378u,
-2842141483u, 4029205195u,
-1656892865u, 3330993377u,
-80890710u, 1953796601u,
-3873078673u, 136118734u,
-2317676604u, 4199091610u,
-1864448181u, 3063437608u,
-1699452298u, 1403506686u,
-1513069466u, 2348491299u,
-4273657745u, 4055855649u,
-1805475756u, 2562064338u,
-973124563u, 4197091358u,
-172861513u, 2858726767u,
-4271866024u, 3071338162u,
-3590386266u, 2328277259u,
-1096050703u, 1189614342u,
-459509140u, 771592405u,
-817999971u, 3740825152u,
-520400189u, 1941874618u,
-185232757u, 4032960199u,
-3928245258u, 3527721294u,
-1301118856u, 752188080u,
-3512945009u, 308584855u,
-2105373972u, 752872278u,
-3823368815u, 3760952096u,
-4250142168u, 2565680167u,
-3646354146u, 1259957455u,
-1085857127u, 3471066607u,
-38924274u, 3770488806u,
-1083869477u, 3312508103u,
-71956383u, 3738784936u,
-3099963860u, 1255084262u,
-4286969992u, 3621849251u,
-1190908967u, 1831557743u,
-2363435042u, 54945052u,
-4059585566u, 4023974274u,
-1788578453u, 3442180039u,
-2534883189u, 2432427547u,
-3909757989u, 731996369u,
-4168347425u, 1356028512u,
-2741583197u, 1280920000u,
-312887059u, 3259015297u,
-3946278527u, 4135481831u,
-1281043691u, 1121403845u,
-3312292477u, 1819941269u,
-1741932545u, 3293015483u,
-2127558730u, 713121337u,
-2635469238u, 486003418u,
-4015067527u, 2976737859u,
-2108187161u, 927011680u,
-1970188338u, 4177613234u,
-1799789551u, 2118505126u,
-4134691985u, 1958963937u,
-1929210029u, 2555835851u,
-2768832862u, 910892050u,
-2567532373u, 4075249328u,
-86689814u, 3726640307u,
-1392137718u, 1240000030u,
-4104757832u, 3026358429u,
-313797689u, 1435798509u,
-3101500919u, 1241665335u,
-3573008472u, 3615577014u,
-3767659003u, 3134294021u,
-4063565523u, 2296824134u,
-1541946015u, 3087190425u,
-2693152531u, 2199672572u,
-2123763822u, 1034244398u,
-857839960u, 2515339233u,
-2228007483u, 1628096047u,
-2116502287u, 2502657424u,
-2809830736u, 460237542u,
-450205998u, 3646921704u,
-3818199357u, 1808504491u,
-1950698961u, 2069753399u,
-3657033172u, 3734547671u,
-4067859590u, 3292597295u,
-1106466069u, 356742959u,
-2469567432u, 3495418823u,
-183440071u, 3248055817u,
-3662626864u, 1750561299u,
-3926138664u, 4088592524u,
-567122118u, 3810297651u,
-992181339u, 3384018814u,
-3272124369u, 3177596743u,
-320086295u, 2316548367u,
-100741310u, 451656820u,
-4086604273u, 3759628395u,
-2553391092u, 1745659881u,
-3650357479u, 2390172694u,
-330172533u, 767377322u,
-526742034u, 4102497288u,
-2088767754u, 164402616u,
-2482632320u, 2352347393u,
-1873658044u, 3861555476u,
-2751052984u, 1767810825u,
-20037241u, 545143220u,
-2594532522u, 472304191u,
-3441135892u, 3323383489u,
-258785117u, 2977745165u,
-2781737565u, 2963590112u,
-2756998822u, 207428029u,
-2581558559u, 3824717027u,
-1258619503u, 3472047571u,
-2648427775u, 2360400900u,
-2393763818u, 2332399088u,
-3932701729u, 884421165u,
-1396468647u, 1377764574u,
-4061795938u, 1559119087u,
-3343596838u, 3604258095u,
-1435134775u, 1099809675u,
-908163739u, 1418405656u,
-368446627u, 3741651161u,
-3374512975u, 3542220540u,
-3244772570u, 200009340u,
-3198975081u, 2521038253u,
-4081637863u, 337070226u,
-3235259030u, 3897262827u,
-736956644u, 641040550u,
-644850146u, 1306761320u,
-4219448634u, 193750500u,
-3293278106u, 1383997679u,
-1242645122u, 4109252858u,
-450747727u, 3716617561u,
-362725793u, 2252520167u,
-3377483696u, 1788337208u,
-8130777u, 3226734120u,
-759239140u, 1012411364u,
-1658628529u, 2911512007u,
-1002580201u, 1681898320u,
-3039016929u, 4294520281u,
-367022558u, 3071359622u,
-3205848570u, 152989999u,
-3839042136u, 2357687350u,
-4273132307u, 3898950547u,
-1176841812u, 1314157485u,
-75443951u, 1027027239u,
-1858986613u, 2040551642u,
-36574105u, 2603059541u,
-3456147251u, 2137668425u,
-4077477194u, 3565689036u,
-491832241u, 363703593u,
-2579177168u, 3589545214u,
-265993036u, 1864569342u,
-4149035573u, 3189253455u,
-1072259310u, 3153745937u,
-923017956u, 490608221u,
-855846773u, 845706553u,
-1018226240u, 1604548872u,
-3833372385u, 3287246572u,
-2757959551u, 2452872151u,
-1553870564u, 1713154780u,
-2649450292u, 500120236u,
-84251717u, 661869670u,
-1444911517u, 2489716881u,
-2810524030u, 1561519055u,
-3884088359u, 2509890699u,
-4247155916u, 1005636939u,
-3224066062u, 2774151984u,
-2035978240u, 2514910366u,
-1478837908u, 3144450144u,
-2107011431u, 96459446u,
-3587732908u, 2389230590u,
-3287635953u, 250533792u,
-1235983679u, 4237425634u,
-3704645833u, 3882376657u,
-2976369049u, 1187061987u,
-276949224u, 4100839753u,
-1698347543u, 1629662314u,
-1556151829u, 3784939568u,
-427484362u, 4246879223u,
-3155311770u, 4285163791u,
-1693376813u, 124492786u,
-1858777639u, 3476334357u,
-1941442701u, 1121980173u,
-3485932087u, 820852908u,
-358032121u, 2511026735u,
-1873607283u, 2556067450u,
-2248275536u, 1528632094u,
-1535473864u, 556796152u,
-1499201704u, 1472623890u,
-1526518503u, 3692729434u,
-1476438092u, 2913077464u,
-335109599u, 2167614601u,
-4121131078u, 3158127917u,
-3051522276u, 4046477658u,
-2857717851u, 1863977403u,
-1341023343u, 692059110u,
-1802040304u, 990407433u,
-3285847572u, 319814144u,
-561105582u, 1540183799u,
-4052924496u, 2926590471u,
-2244539806u, 439121871u,
-3317903224u, 3178387550u,
-4265214507u, 82077489u,
-1978918971u, 4279668976u,
-128732476u, 2853224222u,
-464407878u, 4190838199u,
-997819001u, 3250520802u,
-2330081301u, 4095846095u,
-733509243u, 1583801700u,
-722314527u, 3552883023u,
-1403784280u, 432327540u,
-1877837196u, 3912423882u,
-505219998u, 696031431u,
-908238873u, 4189387259u,
-8759461u, 2540185277u,
-3385159748u, 381355877u,
-2519951681u, 1679786240u,
-2019419351u, 4051584612u,
-1933923923u, 3768201861u,
-1670133081u, 3454981037u,
-700836153u, 1675560450u,
-371560700u, 338262316u,
-847351840u, 2222395828u,
-3130433948u, 405251683u,
-3037574880u, 184098830u,
-453340528u, 1385561439u,
-2224044848u, 4071581802u,
-1431235296u, 5570097u,
-570114376u, 2287305551u,
-2272418128u, 803575837u,
-3943113491u, 414959787u,
-708083137u, 2452657767u,
-4019147902u, 3841480082u,
-3791794715u, 2965956183u,
-2763690963u, 2350937598u,
-3424361375u, 779434428u,
-1274947212u, 686105485u,
-3426668051u, 3692865672u,
-3057021940u, 2285701422u,
-349809124u, 1379278508u,
-3623750518u, 215970497u,
-1783152480u, 823305654u,
-216118434u, 1787189830u,
-3692048450u, 2272612521u,
-3032187389u, 4159715581u,
-1388133148u, 1611772864u,
-2544383526u, 552925303u,
-3420960112u, 3198900547u,
-3503230228u, 2603352423u,
-2318375898u, 4064071435u,
-3006227299u, 4194096960u,
-1283392422u, 1510460996u,
-174272138u, 3671038966u,
-1775955687u, 1719108984u,
-1763892006u, 1385029063u,
-4083790740u, 406757708u,
-684087286u, 531310503u,
-3329923157u, 3492083607u,
-1059031410u, 3037314475u,
-3105682208u, 3382290593u,
-2292208503u, 426380557u,
-97373678u, 3842309471u,
-777173623u, 3241407531u,
-303065016u, 1477104583u,
-4234905200u, 2512514774u,
-2649684057u, 1397502982u,
-1802596032u, 3973022223u,
-2543566442u, 3139578968u,
-3193669211u, 811750340u,
-4013496209u, 567361887u,
-4169410406u, 3622282782u,
-3403136990u, 2540585554u,
-895210040u, 3862229802u,
-1145435213u, 4146963980u,
-784952939u, 943914610u,
-573034522u, 464420660u,
-2356867109u, 3054347639u,
-3985088434u, 1911188923u,
-583391304u, 176468511u,
-2990150068u, 2338031599u,
-519948041u, 3181425568u,
-496106033u, 4110294665u,
-2736756930u, 1196757691u,
-1089679033u, 240953857u,
-3399092928u, 4040779538u,
-2843673626u, 240495962u,
-3017658263u, 3828377737u,
-4243717901u, 2448373688u,
-2759616657u, 2246245780u,
-308018483u, 4262383425u,
-2731780771u, 328023017u,
-2884443148u, 841480070u,
-3188015819u, 4051263539u,
-2298178908u, 2944209234u,
-1372958390u, 4164532914u,
-4074952232u, 1683612329u,
-2155036654u, 1872815858u,
-2041174279u, 2368092311u,
-206775997u, 2283918569u,
-645945606u, 115406202u,
-4206471368u, 3923500892u,
-2217060665u, 350160869u,
-706531239u, 2824302286u,
-509981657u, 1469342315u,
-140980u, 1891558063u,
-164887091u, 3094962711u,
-3437115622u, 13327420u,
-422986366u, 330624974u,
-3630863408u, 2425505046u,
-824008515u, 3543885677u,
-918718096u, 376390582u,
-3224043675u, 3724791476u,
-1837192976u, 2968738516u,
-3424344721u, 3187805406u,
-1550978788u, 1743089918u,
-4251270061u, 645016762u,
-3855037968u, 1928519266u,
-1373803416u, 2289007286u,
-1889218686u, 1610271373u,
-3059200728u, 2108753646u,
-582042641u, 812347242u,
-3188172418u, 191994904u,
-1343511943u, 2247006571u,
-463291708u, 2697254095u,
-1534175504u, 1106275740u,
-622521957u, 917121602u,
-4095777215u, 3955972648u,
-3852234638u, 2845309942u,
-3299763344u, 2864033668u,
-2554947496u, 799569078u,
-2551629074u, 1102873346u,
-2661022773u, 2006922227u,
-2900438444u, 1448194126u,
-1321567432u, 1983773590u,
-1237256330u, 3449066284u,
-1691553115u, 3274671549u,
-4271625619u, 2741371614u,
-3285899651u, 786322314u,
-1586632825u, 564385522u,
-2530557509u, 2974240289u,
-1244759631u, 3263135197u,
-3592389776u, 3570296884u,
-2749873561u, 521432811u,
-987586766u, 3206261120u,
-1327840078u, 4078716491u,
-1753812954u, 976892272u,
-1827135136u, 1781944746u,
-1328622957u, 1015377974u,
-3439601008u, 2209584557u,
-2482286699u, 1109175923u,
-874877499u, 2036083451u,
-483570344u, 1091877599u,
-4190721328u, 1129462471u,
-640035849u, 1867372700u,
-920761165u, 3273688770u,
-1623777358u, 3389003793u,
-3241132743u, 2734783008u,
-696674661u, 2502161880u,
-1646071378u, 1164309901u,
-350411888u, 1978005963u,
-2253937037u, 7371540u,
-989577914u, 3626554867u,
-3214796883u, 531343826u,
-398899695u, 1145247203u,
-1516846461u, 3656006011u,
-529303412u, 3318455811u,
-3062828129u, 1696355359u,
-3698796465u, 3155218919u,
-1457595996u, 3191404246u,
-1395609912u, 2917345728u,
-1237411891u, 1854985978u,
-1091884675u, 3504488111u,
-3109924189u, 1628881950u,
-3939149151u, 878608872u,
-778235395u, 1052990614u,
-903730231u, 2069566979u,
-2437686324u, 3163786257u,
-2257884264u, 2123173186u,
-939764916u, 2933010098u,
-1235300371u, 1256485167u,
-1950274665u, 2180372319u,
-2648400302u, 122035049u,
-1883344352u, 2083771672u,
-3712110541u, 321199441u,
-1896357377u, 508560958u,
-3066325351u, 2770847216u,
-3177982504u, 296902736u,
-1486926688u, 456842861u,
-601221482u, 3992583643u,
-2794121515u, 1533934172u,
-1706465470u, 4281971893u,
-2557027816u, 900741486u,
-227175484u, 550595824u,
-690918144u, 2825943628u,
-90375300u, 300318232u,
-1985329734u, 1440763373u,
-3670603707u, 2533900859u,
-3253901179u, 542270815u,
-3677388841u, 307706478u,
-2570910669u, 3320103693u,
-1273768482u, 1216399252u,
-1652924805u, 1043647584u,
-1120323676u, 639941430u,
-325675502u, 3652676161u,
-4241680335u, 1545838362u,
-1991398008u, 4100211814u,
-1097584090u, 3262252593u,
-2254324292u, 1765019121u,
-4060211241u, 2315856188u,
-3704419305u, 411263051u,
-238929055u, 3540688404u,
-3094544537u, 3250435765u,
-3460621305u, 1967599860u,
-2016157366u, 847389916u,
-1659615591u, 4020453639u,
-901109753u, 2682611693u,
-1661364280u, 177155177u,
-3210561911u, 3802058181u,
-797089608u, 3286110054u,
-2110358240u, 1353279028u,
-2479975820u, 471725410u,
-2219863904u, 3623364733u,
-3167128228u, 1052188336u,
-3656587111u, 721788662u,
-3061255808u, 1615375832u,
-924941453u, 2547780700u,
-3328169224u, 1310964134u,
-2701956286u, 4145497671u,
-1421461094u, 1221397398u,
-1589183618u, 1492533854u,
-449740816u, 2686506989u,
-3035198924u, 1682886232u,
-2529760244u, 3342031659u,
-1235084019u, 2151665147u,
-2315686577u, 3282027660u,
-1140138691u, 2754346599u,
-2091754612u, 1178454681u,
-4226896579u, 2942520471u,
-2122168506u, 3751680858u,
-3213794286u, 2601416506u,
-4142747914u, 3951404257u,
-4243249649u, 748595836u,
-4004834921u, 238887261u,
-1927321047u, 2217148444u,
-205977665u, 1885975275u,
-186020771u, 2367569534u,
-2941662631u, 2608559272u,
-3342096731u, 741809437u,
-1962659444u, 3539886328u,
-3036596491u, 2282550094u,
-2366462727u, 2748286642u,
-2144472852u, 1390394371u,
-1257385924u, 2205425874u,
-2119055686u, 46865323u,
-3597555910u, 3188438773u,
-2372320753u, 3641116924u,
-3116286108u, 2680722658u,
-3371014971u, 2058751609u,
-2966943726u, 2345078707u,
-2330535244u, 4013841927u,
-1169588594u, 857915866u,
-1875260989u, 3175831309u,
-3193475664u, 1955181430u,
-923161569u, 4068653043u,
-776445899u, 954196929u,
-61509556u, 4248237857u,
-3808667664u, 581227317u,
-2893240187u, 4159497403u,
-4212264930u, 3973886195u,
-2077539039u, 851579036u,
-2957587591u, 772351886u,
-1173659554u, 946748363u,
-2794103714u, 2094375930u,
-4234750213u, 3671645488u,
-2614250782u, 2620465358u,
-3122317317u, 2365436865u,
-3393973390u, 523513960u,
-3645735309u, 2766686992u,
-2023960931u, 2312244996u,
-1875932218u, 3253711056u,
-3622416881u, 3274929205u,
-612094988u, 1555465129u,
-2114270406u, 3553762793u,
-1832633644u, 1087551556u,
-3306195841u, 1702313921u,
-3675066046u, 1735998785u,
-1690923980u, 1482649756u,
-1171351291u, 2043136409u,
-1962596992u, 461214626u,
-3278253346u, 1392428048u,
-3744621107u, 1028502697u,
-3991171462u, 1014064003u,
-3642345425u, 3186995039u,
-6114625u, 3359104346u,
-414856965u, 2814387514u,
-3583605071u, 2497896367u,
-1024572712u, 1927582962u,
-2892797583u, 845302635u,
-328548052u, 1523379748u,
-3392622118u, 1347167673u,
-1012316581u, 37767602u,
-2647726017u, 1070326065u,
-2075035198u, 4202817168u,
-2502924707u, 2612406822u,
-2187115553u, 1180137213u,
-701024148u, 1481965992u,
-3223787553u, 2083541843u,
-203230202u, 3876887380u,
-1334816273u, 2870251538u,
-2186205850u, 3985213979u,
-333533378u, 806507642u,
-1010064531u, 713520765u,
-3084131515u, 2637421459u,
-1703168933u, 1517562266u,
-4089081247u, 3231042924u,
-3079916123u, 3154574447u,
-2253948262u, 1725190035u,
-2452539325u, 1343734533u,
-213706059u, 2519409656u,
-108055211u, 2916327746u,
-587001593u, 1917607088u,
-4202913084u, 926304016u,
-469255411u, 4042080256u,
-3498936874u, 246692543u,
-495780578u, 438717281u,
-2259272650u, 4011324645u,
-2836854664u, 2317249321u,
-946828752u, 1280403658u,
-1905648354u, 2034241661u,
-774652981u, 1285694082u,
-2200307766u, 2158671727u,
-1135162148u, 232040752u,
-397012087u, 1717527689u,
-1720414106u, 918797022u,
-2580119304u, 3568069742u,
-2904461070u, 3893453420u,
-973817938u, 667499332u,
-3785870412u, 2088861715u,
-1565179401u, 600903026u,
-591806775u, 3512242245u,
-997964515u, 2339605347u,
-1134342772u, 3234226304u,
-4084179455u, 302315791u,
-2445626811u, 2590372496u,
-345572299u, 2274770442u,
-3600587867u, 3706939009u,
-1430507980u, 2656330434u,
-1079209397u, 2122849632u,
-1423705223u, 3826321888u,
-3683385276u, 1057038163u,
-1242840526u, 3987000643u,
-2398253089u, 1538190921u,
-1295898647u, 3570196893u,
-3065138774u, 3111336863u,
-2524949549u, 4203895425u,
-3025864372u, 968800353u,
-1023721001u, 3763083325u,
-526350786u, 635552097u,
-2308118370u, 2166472723u,
-2196937373u, 2643841788u,
-3040011470u, 4010301879u,
-2782379560u, 3474682856u,
-4201389782u, 4223278891u,
-1457302296u, 2251842132u,
-1090062008u, 3188219189u,
-292733931u, 1424229089u,
-1590782640u, 1365212370u,
-3975957073u, 3982969588u,
-2927147928u, 1048291071u,
-2766680094u, 884908196u,
-35237839u, 2221180633u,
-2490333812u, 4098360768u,
-4029081103u, 3490831871u,
-2392516272u, 3455379186u,
-3948800722u, 335456628u,
-2105117968u, 4181629008u,
-1044201772u, 3335754111u,
-540133451u, 3313113759u,
-3786107905u, 2627207327u,
-3540337875u, 3473113388u,
-3430536378u, 2514123129u,
-2124531276u, 3872633376u,
-3272957388u, 3501994650u,
-2418881542u, 487365389u,
-3877672368u, 1512866656u,
-3486531087u, 2102955203u,
-1136054817u, 3004241477u,
-1549075351u, 1302002008u,
-3936430045u, 2258587644u,
-4109233936u, 3679809321u,
-3467083076u, 2484463221u,
-1594979755u, 529218470u,
-3527024461u, 1147434678u,
-106799023u, 1823161970u,
-1704656738u, 1675883700u,
-3308746763u, 1875093248u,
-1352868568u, 1898561846u,
-2508994984u, 3177750780u,
-4217929592u, 400784472u,
-80090315u, 3564414786u,
-3841585648u, 3379293868u,
-160353261u, 2413172925u,
-2378499279u, 673436726u,
-1505702418u, 1330977363u,
-1853298225u, 3201741245u,
-2135714208u, 4069554166u,
-3715612384u, 3692488887u,
-3680311316u, 4274382900u,
-914186796u, 2264886523u,
-3869634032u, 1254199592u,
-1131020455u, 194781179u,
-429923922u, 2763792336u,
-2052895198u, 3997373194u,
-3440090658u, 2165746386u,
-1575500242u, 3463310191u,
-2064974716u, 3779513671u,
-3106421434u, 880320527u,
-3281914119u, 286569042u,
-3909096631u, 122359727u,
-1429837716u, 252230074u,
-4111461225u, 762273136u,
-93658514u, 2766407143u,
-3623657004u, 3869801679u,
-3925695921u, 2390397316u,
-2499025338u, 2741806539u,
-2507199021u, 1659221866u,
-361292116u, 4048761557u,
-3797133396u, 1517903247u,
-3121647246u, 3884308578u,
-1697201500u, 1558800262u,
-4150812360u, 3161302278u,
-2610217849u, 641564641u,
-183814518u, 2075245419u,
-611996508u, 2223461433u,
-329123979u, 121860586u,
-860985829u, 1137889144u,
-4018949439u, 2904348960u,
-947795261u, 1992594155u,
-4255427501u, 2281583851u,
-2892637604u, 1478186924u,
-3050771207u, 2767035539u,
-373510582u, 1963520320u,
-3763848370u, 3756817798u,
-627269409u, 1806905031u,
-1814444610u, 3646665053u,
-1822693920u, 278515794u,
-584050483u, 4142579188u,
-2149745808u, 3193071606u,
-1179706341u, 2693495182u,
-3259749808u, 644172091u,
-880509048u, 3340630542u,
-3365160815u, 2384445068u,
-3053081915u, 2840648309u,
-1986990122u, 1084703471u,
-2370410550u, 1627743573u,
-2244943480u, 4057483496u,
-2611595995u, 2470013639u,
-4024732359u, 3987190386u,
-873421687u, 2447660175u,
-3226583022u, 767655877u,
-2528024413u, 1962070688u,
-1233635843u, 2163464207u,
-659054446u, 854207134u,
-258410943u, 4197831420u,
-2515400215u, 3100476924u,
-1961549594u, 2219491151u,
-3997658851u, 163850514u,
-470325051u, 2598261204u,
-3052145580u, 59836528u,
-1376188597u, 966733415u,
-850667549u, 3622479237u,
-1083731990u, 1525777459u,
-4005126532u, 1428155540u,
-2781907007u, 943739431u,
-1493961005u, 2839096988u,
-2000057832u, 1941829603u,
-1901484772u, 939810041u,
-3377407371u, 3090115837u,
-3310840540u, 2068409688u,
-3261383939u, 2212130277u,
-2594774045u, 2912652418u,
-4179816101u, 3534504531u,
-3349254805u, 2796552902u,
-1385421283u, 4259908631u,
-3714780837u, 3070073945u,
-3372846298u, 3835884044u,
-3047965714u, 3009018735u,
-744091167u, 1861124263u,
-2764936304u, 1338171648u,
-4222019554u, 1395200692u,
-1371426007u, 3338031581u,
-2525665319u, 4196233786u,
-2332743921u, 1474702008u,
-2274266301u, 4255175517u,
-2290169528u, 1793910997u,
-2188254024u, 354202001u,
-3864458796u, 4280290498u,
-1554419340u, 1733094688u,
-2010552302u, 1561807039u,
-664313606u, 2548990879u,
-1084699349u, 3233936866u,
-973895284u, 2386881969u,
-1831995860u, 2961465052u,
-1428704144u, 3269904970u,
-231648253u, 2602483763u,
-4125013173u, 3319187387u,
-3347011944u, 1892898231u,
-4019114049u, 868879116u,
-4085937045u, 2378411019u,
-1072588531u, 3547435717u,
-2208070766u, 1069899078u,
-3142980597u, 2337088907u,
-1593338562u, 919414554u,
-688077849u, 3625708135u,
-1472447348u, 1947711896u,
-3953006207u, 877438080u,
-845995820u, 3150361443u,
-3053496713u, 2484577841u,
-224271045u, 2914958001u,
-2682612949u, 806655563u,
-2436224507u, 1907729235u,
-2920583824u, 1251814062u,
-2070814520u, 4034325578u,
-497847539u, 2714317144u,
-385182008u, 640855184u,
-1327075087u, 1062468773u,
-1757405994u, 1374270191u,
-4263183176u, 3041193150u,
-1037871524u, 3633173991u,
-4231821821u, 2830131945u,
-3505072908u, 2830570613u,
-4195208715u, 575398021u,
-3992840257u, 3691788221u,
-1949847968u, 2999344380u,
-3183782163u, 3723754342u,
-759716128u, 3284107364u,
-1714496583u, 15918244u,
-820509475u, 2553936299u,
-2201876606u, 4237151697u,
-2605688266u, 3253705097u,
-1008333207u, 712158730u,
-1722280252u, 1933868287u,
-4152736859u, 2097020806u,
-584426382u, 2836501956u,
-2522777566u, 1996172430u,
-2122199776u, 1069285218u,
-1474209360u, 690831894u,
-107482532u, 3695525410u,
-670591796u, 768977505u,
-2412057331u, 3647886687u,
-3110327607u, 1072658422u,
-379861934u, 1557579480u,
-4124127129u, 2271365865u,
-3880613089u, 739218494u,
-547346027u, 388559045u,
-3147335977u, 176230425u,
-3094853730u, 2554321205u,
-1495176194u, 4093461535u,
-3521297827u, 4108148413u,
-1913727929u, 1177947623u,
-1911655402u, 1053371241u,
-3265708874u, 1266515850u,
-1045540427u, 3194420196u,
-3717104621u, 1144474110u,
-1464392345u, 52070157u,
-4144237690u, 3350490823u,
-4166253320u, 2747410691u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashnaTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+1140953930u, 861465670u,
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+890626835u, 800175912u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+3283896453u, 1867689945u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+1110588164u, 4186314283u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+283198166u, 2741341286u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+452473466u, 1706958772u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+236935126u, 2976578695u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+2305012065u, 2169731866u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+3058973506u, 2379411653u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+147814787u, 720739346u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+3425469811u, 3690733394u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+1635026870u, 192883107u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+3969463346u, 1436364519u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+2859809759u, 3808705738u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+4023053163u, 2650381482u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+3476440786u, 3829307897u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+2902102606u, 3600725550u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1448662590u, 397635823u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+180854224u, 2604346966u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+1669465176u, 1341975128u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+1043692997u, 1454396064u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+703505868u, 678706990u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+1933894405u, 3043213226u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+3828089804u, 3632594520u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+3729087873u, 1303930448u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3103338579u, 3064290191u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2295806711u, 1781190011u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+1968445277u, 315203929u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+440398219u, 1891630171u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+4204318635u, 441430649u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+3010839769u, 2837339569u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+4139181436u, 2993479124u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+667183474u, 2084369203u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+1016656857u, 3022024459u,
+3254014218u, 429095991u,
+165589978u, 1578546616u,
+985653208u, 1718653828u,
+623071693u, 366414107u,
+249776086u, 1207522198u,
+3047342438u, 2991127487u,
+3120876698u, 1684583131u,
+46987739u, 1157614300u,
+863214540u, 1087193030u,
+199124911u, 520792961u,
+3614377032u, 586863115u,
+3331828431u, 1013201099u,
+1716848157u, 4033596884u,
+1164298657u, 4140791139u,
+1146169032u, 1434258493u,
+3824360466u, 3242407770u,
+3725511003u, 232064808u,
+872586426u, 762243036u,
+2736953692u, 816692935u,
+512845449u, 3748861010u,
+2266795890u, 3781899767u,
+4290630595u, 517646945u,
+22638523u, 648000590u,
+959214578u, 558910384u,
+1283799121u, 3047062993u,
+1024246061u, 4027776454u,
+3544509313u, 622325861u,
+834785312u, 382936554u,
+411505255u, 1973395102u,
+1825135056u, 2725923798u,
+580988377u, 2826990641u,
+3474970689u, 1029055034u,
+812546227u, 2506885666u,
+2584372201u, 1758123094u,
+589567754u, 325737734u,
+345313518u, 2022370576u,
+3886113119u, 3338548567u,
+257578986u, 3698087965u,
+1776047957u, 1771384107u,
+3604937815u, 3198590202u,
+2305332220u, 191910725u,
+4232136669u, 427759438u,
+4244322689u, 542201663u,
+3315355162u, 2135941665u,
+556609672u, 45845311u,
+1175961330u, 3948351189u,
+23075771u, 3252374102u,
+1634635545u, 4151937410u,
+713127376u, 1467786451u,
+663013031u, 3444053918u,
+2638154051u, 810082938u,
+3077742128u, 1062268187u,
+2115441882u, 4081398201u,
+3735739145u, 2794294783u,
+2335576331u, 2560479831u,
+1379288194u, 4225182569u,
+2442302747u, 3948961926u,
+3958366652u, 3067277639u,
+3667516477u, 1709989541u,
+1516711748u, 2339636583u,
+4188504038u, 59581167u,
+2725013602u, 3639843023u,
+2658147000u, 2643979752u,
+3758739543u, 4189944477u,
+2470483982u, 877580602u,
+2995362413u, 118817200u,
+3252925478u, 2062343506u,
+3981838403u, 3762572073u,
+1231633714u, 4168280671u,
+2931588131u, 3284356565u,
+1129162571u, 732225574u,
+4173605289u, 1407328702u,
+1677744031u, 3532596884u,
+3232041815u, 1652884780u,
+2256541290u, 3459463480u,
+3740979556u, 259034107u,
+2227121257u, 1426140634u,
+3606709555u, 3424793077u,
+315836068u, 3200749877u,
+1386256573u, 24035717u,
+2982018998u, 1811050648u,
+234531934u, 1115203611u,
+1598686658u, 3146815575u,
+1603559457u, 323296368u,
+2632963283u, 1778459926u,
+739944537u, 579625482u,
+3486330348u, 492621815u,
+1231665285u, 2457048126u,
+3903349120u, 389846205u,
+3355404249u, 3275550588u,
+1052645068u, 862072556u,
+2834153464u, 1481069623u,
+2657392572u, 4279236653u,
+1688445808u, 701920051u,
+3740748788u, 3388062747u,
+1873358321u, 2152785640u,
+883382081u, 1005815394u,
+1020177209u, 734239551u,
+2371453141u, 100326520u,
+3488500412u, 1279682138u,
+2610427744u, 49703572u,
+3026361211u, 605900428u,
+302392721u, 2509302188u,
+1416453607u, 2815915291u,
+1862819968u, 519710058u,
+2450888314u, 4017598378u,
+937074653u, 3035635454u,
+1590230729u, 3268013438u,
+2710029305u, 12886044u,
+3711259084u, 2627383582u,
+3895772404u, 648534979u,
+260307902u, 855990313u,
+3669691805u, 263366740u,
+2938543471u, 414331688u,
+3080542944u, 3405007814u,
+3565059103u, 1190977418u,
+390836981u, 1606450012u,
+2649808239u, 2514169310u,
+2747519432u, 4129538640u,
+1721522849u, 492099164u,
+792990594u, 3625507637u,
+2271095827u, 2993032712u,
+2302363854u, 4013112951u,
+1111617969u, 2183845740u,
+795918276u, 1116991810u,
+3110898804u, 3963062126u,
+2737064702u, 462795667u,
+937372240u, 1343017609u,
+1091041189u, 2790555455u,
+277024217u, 25485284u,
+1166522068u, 1623631848u,
+241727183u, 2836158787u,
+3112996740u, 573836428u,
+2721658101u, 1937681565u,
+4175169209u, 3190765433u,
+1970000788u, 1668258120u,
+114616703u, 954762543u,
+199237753u, 4094644498u,
+2522281978u, 732086117u,
+1756889687u, 2936126607u,
+2437031370u, 4103143808u,
+3883389541u, 3171090854u,
+2483004780u, 1927385370u,
+2360538162u, 2740855009u,
+4241185118u, 1492209542u,
+1672737098u, 2148675559u,
+1789864670u, 2434313103u,
+2319172611u, 2760941207u,
+2636210123u, 1338083267u,
+1128080590u, 822806371u,
+1199583556u, 314727461u,
+1335160250u, 2084630531u,
+1156261526u, 316766066u,
+112090465u, 3129033323u,
+2746885618u, 636616055u,
+2582210744u, 1721064910u,
+3468394263u, 470463518u,
+2076016059u, 408721884u,
+2121041886u, 378460278u,
+1915948002u, 357324860u,
+2301682622u, 2691859523u,
+1869756364u, 2429314418u,
+2193146527u, 1185564327u,
+2614088922u, 1975527044u,
+919067651u, 2855948894u,
+3662539576u, 1943802836u,
+3529473373u, 1490330107u,
+366036094u, 3384241033u,
+4276268604u, 448403661u,
+4271796078u, 1910401882u,
+3077107698u, 299427366u,
+2035665349u, 3201262636u,
+3738454258u, 2554452696u,
+3588997135u, 3363895827u,
+1267505995u, 1852004679u,
+2237827073u, 2803250686u,
+3468044908u, 2143572850u,
+1728158656u, 1022551180u,
+1996680960u, 839529273u,
+2400647871u, 2201096054u,
+3606433628u, 2597259793u,
+3544595875u, 3909443124u,
+819278607u, 3447346709u,
+806136613u, 2711436388u,
+3656063205u, 837475154u,
+694525336u, 4070212073u,
+4011303412u, 1068395209u,
+438095290u, 484603494u,
+2673730227u, 737767009u,
+642310823u, 3914002299u,
+308425103u, 268427550u,
+1334387085u, 4069797497u,
+4280783219u, 2914011058u,
+4243643405u, 2849988118u,
+2504230175u, 1817156623u,
+2804200483u, 3406991497u,
+2948254999u, 2102063419u,
+1071272117u, 514889942u,
+571972433u, 1246595599u,
+1735616066u, 1539151988u,
+1230831543u, 277987182u,
+4269526481u, 991511607u,
+95237878u, 2005032160u,
+1291113144u, 626619670u,
+3560835907u, 164940926u,
+1433635018u, 116647396u,
+3039097112u, 2868163232u,
+1141645918u, 1764165478u,
+881378302u, 2159170082u,
+2953647681u, 1011320066u,
+184856151u, 1723308975u,
+336034862u, 2017579106u,
+1476681709u, 147523618u,
+3896252223u, 2264728166u,
+944743644u, 1694443528u,
+2690700128u, 1947321519u,
+735478508u, 4058183171u,
+260177668u, 505662155u,
+2391691262u, 1920739747u,
+3216960415u, 1898176786u,
+3722741628u, 1511077569u,
+449636564u, 983350414u,
+2580237367u, 2055059789u,
+1103819072u, 2089123665u,
+3873755579u, 2718467458u,
+3124338704u, 3204250304u,
+2475035432u, 1120017626u,
+3873758287u, 1982999824u,
+2950794582u, 780634378u,
+2842141483u, 4029205195u,
+1656892865u, 3330993377u,
+80890710u, 1953796601u,
+3873078673u, 136118734u,
+2317676604u, 4199091610u,
+1864448181u, 3063437608u,
+1699452298u, 1403506686u,
+1513069466u, 2348491299u,
+4273657745u, 4055855649u,
+1805475756u, 2562064338u,
+973124563u, 4197091358u,
+172861513u, 2858726767u,
+4271866024u, 3071338162u,
+3590386266u, 2328277259u,
+1096050703u, 1189614342u,
+459509140u, 771592405u,
+817999971u, 3740825152u,
+520400189u, 1941874618u,
+185232757u, 4032960199u,
+3928245258u, 3527721294u,
+1301118856u, 752188080u,
+3512945009u, 308584855u,
+2105373972u, 752872278u,
+3823368815u, 3760952096u,
+4250142168u, 2565680167u,
+3646354146u, 1259957455u,
+1085857127u, 3471066607u,
+38924274u, 3770488806u,
+1083869477u, 3312508103u,
+71956383u, 3738784936u,
+3099963860u, 1255084262u,
+4286969992u, 3621849251u,
+1190908967u, 1831557743u,
+2363435042u, 54945052u,
+4059585566u, 4023974274u,
+1788578453u, 3442180039u,
+2534883189u, 2432427547u,
+3909757989u, 731996369u,
+4168347425u, 1356028512u,
+2741583197u, 1280920000u,
+312887059u, 3259015297u,
+3946278527u, 4135481831u,
+1281043691u, 1121403845u,
+3312292477u, 1819941269u,
+1741932545u, 3293015483u,
+2127558730u, 713121337u,
+2635469238u, 486003418u,
+4015067527u, 2976737859u,
+2108187161u, 927011680u,
+1970188338u, 4177613234u,
+1799789551u, 2118505126u,
+4134691985u, 1958963937u,
+1929210029u, 2555835851u,
+2768832862u, 910892050u,
+2567532373u, 4075249328u,
+86689814u, 3726640307u,
+1392137718u, 1240000030u,
+4104757832u, 3026358429u,
+313797689u, 1435798509u,
+3101500919u, 1241665335u,
+3573008472u, 3615577014u,
+3767659003u, 3134294021u,
+4063565523u, 2296824134u,
+1541946015u, 3087190425u,
+2693152531u, 2199672572u,
+2123763822u, 1034244398u,
+857839960u, 2515339233u,
+2228007483u, 1628096047u,
+2116502287u, 2502657424u,
+2809830736u, 460237542u,
+450205998u, 3646921704u,
+3818199357u, 1808504491u,
+1950698961u, 2069753399u,
+3657033172u, 3734547671u,
+4067859590u, 3292597295u,
+1106466069u, 356742959u,
+2469567432u, 3495418823u,
+183440071u, 3248055817u,
+3662626864u, 1750561299u,
+3926138664u, 4088592524u,
+567122118u, 3810297651u,
+992181339u, 3384018814u,
+3272124369u, 3177596743u,
+320086295u, 2316548367u,
+100741310u, 451656820u,
+4086604273u, 3759628395u,
+2553391092u, 1745659881u,
+3650357479u, 2390172694u,
+330172533u, 767377322u,
+526742034u, 4102497288u,
+2088767754u, 164402616u,
+2482632320u, 2352347393u,
+1873658044u, 3861555476u,
+2751052984u, 1767810825u,
+20037241u, 545143220u,
+2594532522u, 472304191u,
+3441135892u, 3323383489u,
+258785117u, 2977745165u,
+2781737565u, 2963590112u,
+2756998822u, 207428029u,
+2581558559u, 3824717027u,
+1258619503u, 3472047571u,
+2648427775u, 2360400900u,
+2393763818u, 2332399088u,
+3932701729u, 884421165u,
+1396468647u, 1377764574u,
+4061795938u, 1559119087u,
+3343596838u, 3604258095u,
+1435134775u, 1099809675u,
+908163739u, 1418405656u,
+368446627u, 3741651161u,
+3374512975u, 3542220540u,
+3244772570u, 200009340u,
+3198975081u, 2521038253u,
+4081637863u, 337070226u,
+3235259030u, 3897262827u,
+736956644u, 641040550u,
+644850146u, 1306761320u,
+4219448634u, 193750500u,
+3293278106u, 1383997679u,
+1242645122u, 4109252858u,
+450747727u, 3716617561u,
+362725793u, 2252520167u,
+3377483696u, 1788337208u,
+8130777u, 3226734120u,
+759239140u, 1012411364u,
+1658628529u, 2911512007u,
+1002580201u, 1681898320u,
+3039016929u, 4294520281u,
+367022558u, 3071359622u,
+3205848570u, 152989999u,
+3839042136u, 2357687350u,
+4273132307u, 3898950547u,
+1176841812u, 1314157485u,
+75443951u, 1027027239u,
+1858986613u, 2040551642u,
+36574105u, 2603059541u,
+3456147251u, 2137668425u,
+4077477194u, 3565689036u,
+491832241u, 363703593u,
+2579177168u, 3589545214u,
+265993036u, 1864569342u,
+4149035573u, 3189253455u,
+1072259310u, 3153745937u,
+923017956u, 490608221u,
+855846773u, 845706553u,
+1018226240u, 1604548872u,
+3833372385u, 3287246572u,
+2757959551u, 2452872151u,
+1553870564u, 1713154780u,
+2649450292u, 500120236u,
+84251717u, 661869670u,
+1444911517u, 2489716881u,
+2810524030u, 1561519055u,
+3884088359u, 2509890699u,
+4247155916u, 1005636939u,
+3224066062u, 2774151984u,
+2035978240u, 2514910366u,
+1478837908u, 3144450144u,
+2107011431u, 96459446u,
+3587732908u, 2389230590u,
+3287635953u, 250533792u,
+1235983679u, 4237425634u,
+3704645833u, 3882376657u,
+2976369049u, 1187061987u,
+276949224u, 4100839753u,
+1698347543u, 1629662314u,
+1556151829u, 3784939568u,
+427484362u, 4246879223u,
+3155311770u, 4285163791u,
+1693376813u, 124492786u,
+1858777639u, 3476334357u,
+1941442701u, 1121980173u,
+3485932087u, 820852908u,
+358032121u, 2511026735u,
+1873607283u, 2556067450u,
+2248275536u, 1528632094u,
+1535473864u, 556796152u,
+1499201704u, 1472623890u,
+1526518503u, 3692729434u,
+1476438092u, 2913077464u,
+335109599u, 2167614601u,
+4121131078u, 3158127917u,
+3051522276u, 4046477658u,
+2857717851u, 1863977403u,
+1341023343u, 692059110u,
+1802040304u, 990407433u,
+3285847572u, 319814144u,
+561105582u, 1540183799u,
+4052924496u, 2926590471u,
+2244539806u, 439121871u,
+3317903224u, 3178387550u,
+4265214507u, 82077489u,
+1978918971u, 4279668976u,
+128732476u, 2853224222u,
+464407878u, 4190838199u,
+997819001u, 3250520802u,
+2330081301u, 4095846095u,
+733509243u, 1583801700u,
+722314527u, 3552883023u,
+1403784280u, 432327540u,
+1877837196u, 3912423882u,
+505219998u, 696031431u,
+908238873u, 4189387259u,
+8759461u, 2540185277u,
+3385159748u, 381355877u,
+2519951681u, 1679786240u,
+2019419351u, 4051584612u,
+1933923923u, 3768201861u,
+1670133081u, 3454981037u,
+700836153u, 1675560450u,
+371560700u, 338262316u,
+847351840u, 2222395828u,
+3130433948u, 405251683u,
+3037574880u, 184098830u,
+453340528u, 1385561439u,
+2224044848u, 4071581802u,
+1431235296u, 5570097u,
+570114376u, 2287305551u,
+2272418128u, 803575837u,
+3943113491u, 414959787u,
+708083137u, 2452657767u,
+4019147902u, 3841480082u,
+3791794715u, 2965956183u,
+2763690963u, 2350937598u,
+3424361375u, 779434428u,
+1274947212u, 686105485u,
+3426668051u, 3692865672u,
+3057021940u, 2285701422u,
+349809124u, 1379278508u,
+3623750518u, 215970497u,
+1783152480u, 823305654u,
+216118434u, 1787189830u,
+3692048450u, 2272612521u,
+3032187389u, 4159715581u,
+1388133148u, 1611772864u,
+2544383526u, 552925303u,
+3420960112u, 3198900547u,
+3503230228u, 2603352423u,
+2318375898u, 4064071435u,
+3006227299u, 4194096960u,
+1283392422u, 1510460996u,
+174272138u, 3671038966u,
+1775955687u, 1719108984u,
+1763892006u, 1385029063u,
+4083790740u, 406757708u,
+684087286u, 531310503u,
+3329923157u, 3492083607u,
+1059031410u, 3037314475u,
+3105682208u, 3382290593u,
+2292208503u, 426380557u,
+97373678u, 3842309471u,
+777173623u, 3241407531u,
+303065016u, 1477104583u,
+4234905200u, 2512514774u,
+2649684057u, 1397502982u,
+1802596032u, 3973022223u,
+2543566442u, 3139578968u,
+3193669211u, 811750340u,
+4013496209u, 567361887u,
+4169410406u, 3622282782u,
+3403136990u, 2540585554u,
+895210040u, 3862229802u,
+1145435213u, 4146963980u,
+784952939u, 943914610u,
+573034522u, 464420660u,
+2356867109u, 3054347639u,
+3985088434u, 1911188923u,
+583391304u, 176468511u,
+2990150068u, 2338031599u,
+519948041u, 3181425568u,
+496106033u, 4110294665u,
+2736756930u, 1196757691u,
+1089679033u, 240953857u,
+3399092928u, 4040779538u,
+2843673626u, 240495962u,
+3017658263u, 3828377737u,
+4243717901u, 2448373688u,
+2759616657u, 2246245780u,
+308018483u, 4262383425u,
+2731780771u, 328023017u,
+2884443148u, 841480070u,
+3188015819u, 4051263539u,
+2298178908u, 2944209234u,
+1372958390u, 4164532914u,
+4074952232u, 1683612329u,
+2155036654u, 1872815858u,
+2041174279u, 2368092311u,
+206775997u, 2283918569u,
+645945606u, 115406202u,
+4206471368u, 3923500892u,
+2217060665u, 350160869u,
+706531239u, 2824302286u,
+509981657u, 1469342315u,
+140980u, 1891558063u,
+164887091u, 3094962711u,
+3437115622u, 13327420u,
+422986366u, 330624974u,
+3630863408u, 2425505046u,
+824008515u, 3543885677u,
+918718096u, 376390582u,
+3224043675u, 3724791476u,
+1837192976u, 2968738516u,
+3424344721u, 3187805406u,
+1550978788u, 1743089918u,
+4251270061u, 645016762u,
+3855037968u, 1928519266u,
+1373803416u, 2289007286u,
+1889218686u, 1610271373u,
+3059200728u, 2108753646u,
+582042641u, 812347242u,
+3188172418u, 191994904u,
+1343511943u, 2247006571u,
+463291708u, 2697254095u,
+1534175504u, 1106275740u,
+622521957u, 917121602u,
+4095777215u, 3955972648u,
+3852234638u, 2845309942u,
+3299763344u, 2864033668u,
+2554947496u, 799569078u,
+2551629074u, 1102873346u,
+2661022773u, 2006922227u,
+2900438444u, 1448194126u,
+1321567432u, 1983773590u,
+1237256330u, 3449066284u,
+1691553115u, 3274671549u,
+4271625619u, 2741371614u,
+3285899651u, 786322314u,
+1586632825u, 564385522u,
+2530557509u, 2974240289u,
+1244759631u, 3263135197u,
+3592389776u, 3570296884u,
+2749873561u, 521432811u,
+987586766u, 3206261120u,
+1327840078u, 4078716491u,
+1753812954u, 976892272u,
+1827135136u, 1781944746u,
+1328622957u, 1015377974u,
+3439601008u, 2209584557u,
+2482286699u, 1109175923u,
+874877499u, 2036083451u,
+483570344u, 1091877599u,
+4190721328u, 1129462471u,
+640035849u, 1867372700u,
+920761165u, 3273688770u,
+1623777358u, 3389003793u,
+3241132743u, 2734783008u,
+696674661u, 2502161880u,
+1646071378u, 1164309901u,
+350411888u, 1978005963u,
+2253937037u, 7371540u,
+989577914u, 3626554867u,
+3214796883u, 531343826u,
+398899695u, 1145247203u,
+1516846461u, 3656006011u,
+529303412u, 3318455811u,
+3062828129u, 1696355359u,
+3698796465u, 3155218919u,
+1457595996u, 3191404246u,
+1395609912u, 2917345728u,
+1237411891u, 1854985978u,
+1091884675u, 3504488111u,
+3109924189u, 1628881950u,
+3939149151u, 878608872u,
+778235395u, 1052990614u,
+903730231u, 2069566979u,
+2437686324u, 3163786257u,
+2257884264u, 2123173186u,
+939764916u, 2933010098u,
+1235300371u, 1256485167u,
+1950274665u, 2180372319u,
+2648400302u, 122035049u,
+1883344352u, 2083771672u,
+3712110541u, 321199441u,
+1896357377u, 508560958u,
+3066325351u, 2770847216u,
+3177982504u, 296902736u,
+1486926688u, 456842861u,
+601221482u, 3992583643u,
+2794121515u, 1533934172u,
+1706465470u, 4281971893u,
+2557027816u, 900741486u,
+227175484u, 550595824u,
+690918144u, 2825943628u,
+90375300u, 300318232u,
+1985329734u, 1440763373u,
+3670603707u, 2533900859u,
+3253901179u, 542270815u,
+3677388841u, 307706478u,
+2570910669u, 3320103693u,
+1273768482u, 1216399252u,
+1652924805u, 1043647584u,
+1120323676u, 639941430u,
+325675502u, 3652676161u,
+4241680335u, 1545838362u,
+1991398008u, 4100211814u,
+1097584090u, 3262252593u,
+2254324292u, 1765019121u,
+4060211241u, 2315856188u,
+3704419305u, 411263051u,
+238929055u, 3540688404u,
+3094544537u, 3250435765u,
+3460621305u, 1967599860u,
+2016157366u, 847389916u,
+1659615591u, 4020453639u,
+901109753u, 2682611693u,
+1661364280u, 177155177u,
+3210561911u, 3802058181u,
+797089608u, 3286110054u,
+2110358240u, 1353279028u,
+2479975820u, 471725410u,
+2219863904u, 3623364733u,
+3167128228u, 1052188336u,
+3656587111u, 721788662u,
+3061255808u, 1615375832u,
+924941453u, 2547780700u,
+3328169224u, 1310964134u,
+2701956286u, 4145497671u,
+1421461094u, 1221397398u,
+1589183618u, 1492533854u,
+449740816u, 2686506989u,
+3035198924u, 1682886232u,
+2529760244u, 3342031659u,
+1235084019u, 2151665147u,
+2315686577u, 3282027660u,
+1140138691u, 2754346599u,
+2091754612u, 1178454681u,
+4226896579u, 2942520471u,
+2122168506u, 3751680858u,
+3213794286u, 2601416506u,
+4142747914u, 3951404257u,
+4243249649u, 748595836u,
+4004834921u, 238887261u,
+1927321047u, 2217148444u,
+205977665u, 1885975275u,
+186020771u, 2367569534u,
+2941662631u, 2608559272u,
+3342096731u, 741809437u,
+1962659444u, 3539886328u,
+3036596491u, 2282550094u,
+2366462727u, 2748286642u,
+2144472852u, 1390394371u,
+1257385924u, 2205425874u,
+2119055686u, 46865323u,
+3597555910u, 3188438773u,
+2372320753u, 3641116924u,
+3116286108u, 2680722658u,
+3371014971u, 2058751609u,
+2966943726u, 2345078707u,
+2330535244u, 4013841927u,
+1169588594u, 857915866u,
+1875260989u, 3175831309u,
+3193475664u, 1955181430u,
+923161569u, 4068653043u,
+776445899u, 954196929u,
+61509556u, 4248237857u,
+3808667664u, 581227317u,
+2893240187u, 4159497403u,
+4212264930u, 3973886195u,
+2077539039u, 851579036u,
+2957587591u, 772351886u,
+1173659554u, 946748363u,
+2794103714u, 2094375930u,
+4234750213u, 3671645488u,
+2614250782u, 2620465358u,
+3122317317u, 2365436865u,
+3393973390u, 523513960u,
+3645735309u, 2766686992u,
+2023960931u, 2312244996u,
+1875932218u, 3253711056u,
+3622416881u, 3274929205u,
+612094988u, 1555465129u,
+2114270406u, 3553762793u,
+1832633644u, 1087551556u,
+3306195841u, 1702313921u,
+3675066046u, 1735998785u,
+1690923980u, 1482649756u,
+1171351291u, 2043136409u,
+1962596992u, 461214626u,
+3278253346u, 1392428048u,
+3744621107u, 1028502697u,
+3991171462u, 1014064003u,
+3642345425u, 3186995039u,
+6114625u, 3359104346u,
+414856965u, 2814387514u,
+3583605071u, 2497896367u,
+1024572712u, 1927582962u,
+2892797583u, 845302635u,
+328548052u, 1523379748u,
+3392622118u, 1347167673u,
+1012316581u, 37767602u,
+2647726017u, 1070326065u,
+2075035198u, 4202817168u,
+2502924707u, 2612406822u,
+2187115553u, 1180137213u,
+701024148u, 1481965992u,
+3223787553u, 2083541843u,
+203230202u, 3876887380u,
+1334816273u, 2870251538u,
+2186205850u, 3985213979u,
+333533378u, 806507642u,
+1010064531u, 713520765u,
+3084131515u, 2637421459u,
+1703168933u, 1517562266u,
+4089081247u, 3231042924u,
+3079916123u, 3154574447u,
+2253948262u, 1725190035u,
+2452539325u, 1343734533u,
+213706059u, 2519409656u,
+108055211u, 2916327746u,
+587001593u, 1917607088u,
+4202913084u, 926304016u,
+469255411u, 4042080256u,
+3498936874u, 246692543u,
+495780578u, 438717281u,
+2259272650u, 4011324645u,
+2836854664u, 2317249321u,
+946828752u, 1280403658u,
+1905648354u, 2034241661u,
+774652981u, 1285694082u,
+2200307766u, 2158671727u,
+1135162148u, 232040752u,
+397012087u, 1717527689u,
+1720414106u, 918797022u,
+2580119304u, 3568069742u,
+2904461070u, 3893453420u,
+973817938u, 667499332u,
+3785870412u, 2088861715u,
+1565179401u, 600903026u,
+591806775u, 3512242245u,
+997964515u, 2339605347u,
+1134342772u, 3234226304u,
+4084179455u, 302315791u,
+2445626811u, 2590372496u,
+345572299u, 2274770442u,
+3600587867u, 3706939009u,
+1430507980u, 2656330434u,
+1079209397u, 2122849632u,
+1423705223u, 3826321888u,
+3683385276u, 1057038163u,
+1242840526u, 3987000643u,
+2398253089u, 1538190921u,
+1295898647u, 3570196893u,
+3065138774u, 3111336863u,
+2524949549u, 4203895425u,
+3025864372u, 968800353u,
+1023721001u, 3763083325u,
+526350786u, 635552097u,
+2308118370u, 2166472723u,
+2196937373u, 2643841788u,
+3040011470u, 4010301879u,
+2782379560u, 3474682856u,
+4201389782u, 4223278891u,
+1457302296u, 2251842132u,
+1090062008u, 3188219189u,
+292733931u, 1424229089u,
+1590782640u, 1365212370u,
+3975957073u, 3982969588u,
+2927147928u, 1048291071u,
+2766680094u, 884908196u,
+35237839u, 2221180633u,
+2490333812u, 4098360768u,
+4029081103u, 3490831871u,
+2392516272u, 3455379186u,
+3948800722u, 335456628u,
+2105117968u, 4181629008u,
+1044201772u, 3335754111u,
+540133451u, 3313113759u,
+3786107905u, 2627207327u,
+3540337875u, 3473113388u,
+3430536378u, 2514123129u,
+2124531276u, 3872633376u,
+3272957388u, 3501994650u,
+2418881542u, 487365389u,
+3877672368u, 1512866656u,
+3486531087u, 2102955203u,
+1136054817u, 3004241477u,
+1549075351u, 1302002008u,
+3936430045u, 2258587644u,
+4109233936u, 3679809321u,
+3467083076u, 2484463221u,
+1594979755u, 529218470u,
+3527024461u, 1147434678u,
+106799023u, 1823161970u,
+1704656738u, 1675883700u,
+3308746763u, 1875093248u,
+1352868568u, 1898561846u,
+2508994984u, 3177750780u,
+4217929592u, 400784472u,
+80090315u, 3564414786u,
+3841585648u, 3379293868u,
+160353261u, 2413172925u,
+2378499279u, 673436726u,
+1505702418u, 1330977363u,
+1853298225u, 3201741245u,
+2135714208u, 4069554166u,
+3715612384u, 3692488887u,
+3680311316u, 4274382900u,
+914186796u, 2264886523u,
+3869634032u, 1254199592u,
+1131020455u, 194781179u,
+429923922u, 2763792336u,
+2052895198u, 3997373194u,
+3440090658u, 2165746386u,
+1575500242u, 3463310191u,
+2064974716u, 3779513671u,
+3106421434u, 880320527u,
+3281914119u, 286569042u,
+3909096631u, 122359727u,
+1429837716u, 252230074u,
+4111461225u, 762273136u,
+93658514u, 2766407143u,
+3623657004u, 3869801679u,
+3925695921u, 2390397316u,
+2499025338u, 2741806539u,
+2507199021u, 1659221866u,
+361292116u, 4048761557u,
+3797133396u, 1517903247u,
+3121647246u, 3884308578u,
+1697201500u, 1558800262u,
+4150812360u, 3161302278u,
+2610217849u, 641564641u,
+183814518u, 2075245419u,
+611996508u, 2223461433u,
+329123979u, 121860586u,
+860985829u, 1137889144u,
+4018949439u, 2904348960u,
+947795261u, 1992594155u,
+4255427501u, 2281583851u,
+2892637604u, 1478186924u,
+3050771207u, 2767035539u,
+373510582u, 1963520320u,
+3763848370u, 3756817798u,
+627269409u, 1806905031u,
+1814444610u, 3646665053u,
+1822693920u, 278515794u,
+584050483u, 4142579188u,
+2149745808u, 3193071606u,
+1179706341u, 2693495182u,
+3259749808u, 644172091u,
+880509048u, 3340630542u,
+3365160815u, 2384445068u,
+3053081915u, 2840648309u,
+1986990122u, 1084703471u,
+2370410550u, 1627743573u,
+2244943480u, 4057483496u,
+2611595995u, 2470013639u,
+4024732359u, 3987190386u,
+873421687u, 2447660175u,
+3226583022u, 767655877u,
+2528024413u, 1962070688u,
+1233635843u, 2163464207u,
+659054446u, 854207134u,
+258410943u, 4197831420u,
+2515400215u, 3100476924u,
+1961549594u, 2219491151u,
+3997658851u, 163850514u,
+470325051u, 2598261204u,
+3052145580u, 59836528u,
+1376188597u, 966733415u,
+850667549u, 3622479237u,
+1083731990u, 1525777459u,
+4005126532u, 1428155540u,
+2781907007u, 943739431u,
+1493961005u, 2839096988u,
+2000057832u, 1941829603u,
+1901484772u, 939810041u,
+3377407371u, 3090115837u,
+3310840540u, 2068409688u,
+3261383939u, 2212130277u,
+2594774045u, 2912652418u,
+4179816101u, 3534504531u,
+3349254805u, 2796552902u,
+1385421283u, 4259908631u,
+3714780837u, 3070073945u,
+3372846298u, 3835884044u,
+3047965714u, 3009018735u,
+744091167u, 1861124263u,
+2764936304u, 1338171648u,
+4222019554u, 1395200692u,
+1371426007u, 3338031581u,
+2525665319u, 4196233786u,
+2332743921u, 1474702008u,
+2274266301u, 4255175517u,
+2290169528u, 1793910997u,
+2188254024u, 354202001u,
+3864458796u, 4280290498u,
+1554419340u, 1733094688u,
+2010552302u, 1561807039u,
+664313606u, 2548990879u,
+1084699349u, 3233936866u,
+973895284u, 2386881969u,
+1831995860u, 2961465052u,
+1428704144u, 3269904970u,
+231648253u, 2602483763u,
+4125013173u, 3319187387u,
+3347011944u, 1892898231u,
+4019114049u, 868879116u,
+4085937045u, 2378411019u,
+1072588531u, 3547435717u,
+2208070766u, 1069899078u,
+3142980597u, 2337088907u,
+1593338562u, 919414554u,
+688077849u, 3625708135u,
+1472447348u, 1947711896u,
+3953006207u, 877438080u,
+845995820u, 3150361443u,
+3053496713u, 2484577841u,
+224271045u, 2914958001u,
+2682612949u, 806655563u,
+2436224507u, 1907729235u,
+2920583824u, 1251814062u,
+2070814520u, 4034325578u,
+497847539u, 2714317144u,
+385182008u, 640855184u,
+1327075087u, 1062468773u,
+1757405994u, 1374270191u,
+4263183176u, 3041193150u,
+1037871524u, 3633173991u,
+4231821821u, 2830131945u,
+3505072908u, 2830570613u,
+4195208715u, 575398021u,
+3992840257u, 3691788221u,
+1949847968u, 2999344380u,
+3183782163u, 3723754342u,
+759716128u, 3284107364u,
+1714496583u, 15918244u,
+820509475u, 2553936299u,
+2201876606u, 4237151697u,
+2605688266u, 3253705097u,
+1008333207u, 712158730u,
+1722280252u, 1933868287u,
+4152736859u, 2097020806u,
+584426382u, 2836501956u,
+2522777566u, 1996172430u,
+2122199776u, 1069285218u,
+1474209360u, 690831894u,
+107482532u, 3695525410u,
+670591796u, 768977505u,
+2412057331u, 3647886687u,
+3110327607u, 1072658422u,
+379861934u, 1557579480u,
+4124127129u, 2271365865u,
+3880613089u, 739218494u,
+547346027u, 388559045u,
+3147335977u, 176230425u,
+3094853730u, 2554321205u,
+1495176194u, 4093461535u,
+3521297827u, 4108148413u,
+1913727929u, 1177947623u,
+1911655402u, 1053371241u,
+3265708874u, 1266515850u,
+1045540427u, 3194420196u,
+3717104621u, 1144474110u,
+1464392345u, 52070157u,
+4144237690u, 3350490823u,
+4166253320u, 2747410691u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; { uint64_t h = farmhashna::Hash64WithSeeds(farm_hash_data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64WithSeed(farm_hash_data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64(farm_hash_data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
{ uint64_t h = farmhashna::Hash64WithSeeds(farm_hash_data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
{ uint64_t h = farmhashna::Hash64WithSeed(farm_hash_data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
{ uint64_t h = farmhashna::Hash64(farm_hash_data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashnaTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashnaTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
{ uint64_t h = farmhashna::Hash64WithSeeds(farm_hash_data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint64_t h = farmhashna::Hash64WithSeed(farm_hash_data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint64_t h = farmhashna::Hash64(farm_hash_data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashnaTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashnaTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashnaTest::Dump(0, i);
- }
- farmhashnaTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashnaTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashnaTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashnaTest::Dump(0, i);
+ }
+ farmhashnaTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashntTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-2681724312u,
-797982799u,
-921001710u,
-2134990486u,
-2244477846u,
-2992121793u,
-3943596029u,
-452431531u,
-2557197665u,
-2532580744u,
-3099673830u,
-3696623795u,
-3281581178u,
-1882212500u,
-275903667u,
-3033004529u,
-1402319660u,
-2699376854u,
-4222949502u,
-1712034059u,
-1330324210u,
-2921867846u,
-1728752234u,
-326029180u,
-3349570000u,
-1612122221u,
-1646032583u,
-1432476832u,
-3552092450u,
-1499109081u,
-1554038301u,
-3190844552u,
-540224401u,
-489963606u,
-1562872448u,
-2128624475u,
-1262831810u,
-1672724608u,
-2077310004u,
-1911523866u,
-294527927u,
-1389770549u,
-2026137563u,
-629449419u,
-2489287368u,
-645684964u,
-230403464u,
-3272648435u,
-165370827u,
-1230085527u,
-3628174014u,
-851743255u,
-1554380634u,
-3667013118u,
-2290487377u,
-1909203251u,
-1498556724u,
-4165088768u,
-197618179u,
-914413116u,
-1913303225u,
-3117299654u,
-1357272220u,
-507436733u,
-1413396341u,
-146044391u,
-429095991u,
-3056862311u,
-366414107u,
-2293458109u,
-1684583131u,
-1170404994u,
-520792961u,
-1577421232u,
-4033596884u,
-4229339322u,
-3242407770u,
-2649785113u,
-816692935u,
-3555213933u,
-517646945u,
-2180594090u,
-3047062993u,
-2391606125u,
-382936554u,
-788479970u,
-2826990641u,
-3167748333u,
-1758123094u,
-389974094u,
-3338548567u,
-2583576230u,
-3198590202u,
-4155628142u,
-542201663u,
-2856634168u,
-3948351189u,
-4194218315u,
-1467786451u,
-2743592929u,
-1062268187u,
-3810665822u,
-2560479831u,
-997658837u,
-3067277639u,
-1211737169u,
-59581167u,
-1389679610u,
-4189944477u,
-100876854u,
-2062343506u,
-3088828656u,
-3284356565u,
-3130054947u,
-3532596884u,
-3887208531u,
-259034107u,
-3233195759u,
-3200749877u,
-760633989u,
-1115203611u,
-1516407838u,
-1778459926u,
-2146672889u,
-2457048126u,
-2217471853u,
-862072556u,
-3745267835u,
-701920051u,
-581695350u,
-1410111809u,
-3326135446u,
-2187968410u,
-4267859263u,
-479241367u,
-2868987960u,
-704325635u,
-1418509533u,
-735688735u,
-3283299459u,
-813690332u,
-1439630796u,
-3195309868u,
-1616408198u,
-3254795114u,
-2799925823u,
-3929484338u,
-1798536177u,
-4205965408u,
-1499475160u,
-4247675634u,
-3779953975u,
-785893184u,
-2778575413u,
-1160134629u,
-823113169u,
-4116162021u,
-4167766971u,
-2487440590u,
-4004655503u,
-4044418876u,
-1462554406u,
-2011102035u,
-4265993528u,
-576405853u,
-4038839101u,
-2425317635u,
-1401013391u,
-3062418115u,
-3167030094u,
-2602636307u,
-4264167741u,
-4017058800u,
-1029665228u,
-4036354071u,
-2670703363u,
-688472265u,
-1054670286u,
-338058159u,
-1539305024u,
-146827036u,
-4060134777u,
-2502815838u,
-1603444633u,
-2448966429u,
-3891353218u,
-1082330589u,
-201837927u,
-2848283092u,
-883849006u,
-1982110346u,
-541496720u,
-133643215u,
-3847827123u,
-4015671361u,
-2849988118u,
-3452457457u,
-2102063419u,
-3281002516u,
-1539151988u,
-1147951686u,
-2005032160u,
-2415262714u,
-116647396u,
-1029284767u,
-2159170082u,
-1919171906u,
-2017579106u,
-2473524405u,
-1694443528u,
-3671562289u,
-505662155u,
-1019936943u,
-1511077569u,
-773792826u,
-2089123665u,
-484732447u,
-1120017626u,
-2809286837u,
-4029205195u,
-1097806406u,
-136118734u,
-4017075736u,
-1403506686u,
-1516736273u,
-2562064338u,
-2984955003u,
-3071338162u,
-1923531348u,
-771592405u,
-2586632018u,
-4032960199u,
-2687561076u,
-308584855u,
-1692079268u,
-2565680167u,
-3674576684u,
-3770488806u,
-69201295u,
-1255084262u,
-3593730713u,
-54945052u,
-1939595371u,
-2432427547u,
-2295501078u,
-1280920000u,
-82177963u,
-1121403845u,
-2889101923u,
-713121337u,
-1747052377u,
-927011680u,
-4142246789u,
-1958963937u,
-1636932722u,
-4075249328u,
-2025886508u,
-3026358429u,
-1845587644u,
-3615577014u,
-1363253259u,
-3087190425u,
-341851980u,
-2515339233u,
-1276595523u,
-460237542u,
-4198897105u,
-2069753399u,
-4278599955u,
-356742959u,
-3735275001u,
-1750561299u,
-668829411u,
-3384018814u,
-4233785523u,
-451656820u,
-107312677u,
-2390172694u,
-1216645846u,
-164402616u,
-1689811113u,
-1767810825u,
-1397772514u,
-3323383489u,
-2986430557u,
-207428029u,
-2260498180u,
-2360400900u,
-1263709570u,
-1377764574u,
-4252610345u,
-1099809675u,
-2776960536u,
-3542220540u,
-3752806924u,
-337070226u,
-3267551635u,
-1306761320u,
-2220373824u,
-4109252858u,
-896322512u,
-1788337208u,
-1336556841u,
-2911512007u,
-3712582785u,
-3071359622u,
-2561488770u,
-3898950547u,
-536047554u,
-2040551642u,
-3528794619u,
-3565689036u,
-1197100813u,
-1864569342u,
-3329594980u,
-490608221u,
-1174785921u,
-3287246572u,
-2163330264u,
-500120236u,
-2520062970u,
-1561519055u,
-4042710240u,
-2774151984u,
-3160666939u,
-96459446u,
-1878067032u,
-4237425634u,
-2952135524u,
-4100839753u,
-1265237690u,
-4246879223u,
-834830418u,
-3476334357u,
-4277111759u,
-2511026735u,
-3065234219u,
-556796152u,
-198182691u,
-2913077464u,
-1535115487u,
-4046477658u,
-140762681u,
-990407433u,
-2198985327u,
-2926590471u,
-559702706u,
-82077489u,
-1096697687u,
-4190838199u,
-3046872820u,
-1583801700u,
-2185339100u,
-3912423882u,
-3703603898u,
-2540185277u,
-1446869792u,
-4051584612u,
-2719373510u,
-1675560450u,
-1996164093u,
-405251683u,
-2864244470u,
-4071581802u,
-2028708916u,
-803575837u,
-557660441u,
-3841480082u,
-255451671u,
-779434428u,
-3452203069u,
-2285701422u,
-1568745354u,
-823305654u,
-3184047862u,
-4159715581u,
-3160134214u,
-3198900547u,
-1566527339u,
-4194096960u,
-1496132623u,
-1719108984u,
-2584236470u,
-531310503u,
-3456882941u,
-3382290593u,
-467441309u,
-3241407531u,
-2540270567u,
-1397502982u,
-3348545480u,
-811750340u,
-1017047954u,
-2540585554u,
-3531646869u,
-943914610u,
-1903578924u,
-1911188923u,
-241574049u,
-3181425568u,
-3529565564u,
-240953857u,
-2964595704u,
-3828377737u,
-4260564140u,
-4262383425u,
-383233885u,
-4051263539u,
-919677938u,
-1683612329u,
-4204155962u,
-2283918569u,
-4153726847u,
-350160869u,
-1387233546u,
-1891558063u,
-740563169u,
-330624974u,
-2948665536u,
-376390582u,
-3799363969u,
-3187805406u,
-2263421398u,
-1928519266u,
-2746577402u,
-2108753646u,
-768287270u,
-2247006571u,
-212490675u,
-917121602u,
-2549835613u,
-2864033668u,
-3738062408u,
-2006922227u,
-2616619070u,
-3449066284u,
-431292293u,
-786322314u,
-1415970351u,
-3263135197u,
-2954777083u,
-3206261120u,
-2287507921u,
-1781944746u,
-4081586725u,
-1109175923u,
-1813855658u,
-1129462471u,
-1037031473u,
-3389003793u,
-3122687303u,
-1164309901u,
-3193251135u,
-3626554867u,
-3071568023u,
-3656006011u,
-1167681812u,
-3155218919u,
-2704165015u,
-1854985978u,
-1712976649u,
-878608872u,
-4155949943u,
-3163786257u,
-1626463554u,
-1256485167u,
-582664250u,
-2083771672u,
-804336148u,
-2770847216u,
-1674051445u,
-3992583643u,
-2966108111u,
-900741486u,
-4014551783u,
-300318232u,
-3517585534u,
-542270815u,
-760762191u,
-1216399252u,
-643179562u,
-3652676161u,
-2990167340u,
-3262252593u,
-2134299399u,
-411263051u,
-1342880802u,
-1967599860u,
-853593042u,
-2682611693u,
-850464484u,
-3286110054u,
-3842907484u,
-3623364733u,
-3693536939u,
-1615375832u,
-2318423400u,
-4145497671u,
-1728968857u,
-2686506989u,
-1502282913u,
-2151665147u,
-3651607391u,
-1178454681u,
-4146839064u,
-2601416506u,
-1448097974u,
-238887261u,
-4093725287u,
-2367569534u,
-679517009u,
-3539886328u,
-3086277222u,
-1390394371u,
-119173722u,
-1766260771u,
-751439914u,
-215917713u,
-2656990891u,
-1570750352u,
-3533987737u,
-3576119563u,
-963183826u,
-3796810515u,
-136547246u,
-2592925324u,
-427154472u,
-1228758574u,
-1464255968u,
-2984611177u,
-2001585786u,
-1525438381u,
-1348536411u,
-2861338018u,
-764077711u,
-3785343245u,
-457568934u,
-4104954272u,
-2381948487u,
-3148473363u,
-2180270337u,
-1387729170u,
-951677556u,
-2721005055u,
-66786703u,
-1149351924u,
-1895026827u,
-3711056516u,
-3638638708u,
-2263003308u,
-3448840877u,
-225333538u,
-3797521928u,
-3262952567u,
-2078619498u,
-1178073973u,
-3288261538u,
-1496966875u,
-2481012988u,
-114945840u,
-1632780103u,
-2087949619u,
-3787017905u,
-2575395164u,
-2971726178u,
-3642087909u,
-3894199764u,
-203853421u,
-425935223u,
-3565833278u,
-1748785729u,
-580966986u,
-2124704694u,
-1107045577u,
-1067532701u,
-1406028344u,
-18613994u,
-3476683808u,
-3762914298u,
-1844996900u,
-904215228u,
-1118521573u,
-3657647605u,
-3136157065u,
-2287683323u,
-126005630u,
-3555092974u,
-49515858u,
-1010661841u,
-1902040126u,
-1400735275u,
-2771676666u,
-2225229957u,
-3454177594u,
-2883475137u,
-4144472319u,
-1051332394u,
-542648229u,
-1669710469u,
-553041029u,
-584127807u,
-2993670925u,
-3587959456u,
-1745399498u,
-1404723176u,
-1334333531u,
-3239516985u,
-1275954779u,
-367320647u,
-3684418197u,
-4030809053u,
-484559105u,
-4255931645u,
-4271715616u,
-3171911678u,
-928543347u,
-2159512867u,
-313902234u,
-647086234u,
-577214736u,
-1130129573u,
-995791646u,
-1645086060u,
-4122335794u,
-1064648931u,
-2752145076u,
-3312498873u,
-4238535494u,
-1471227427u,
-633688562u,
-1959779970u,
-766642813u,
-1380896111u,
-3647601207u,
-1733961041u,
-521947915u,
-189164145u,
-486382294u,
-3770038872u,
-3235740744u,
-1912506671u,
-2276864677u,
-1588060152u,
-2504457929u,
-1471020554u,
-3623212998u,
-3026631806u,
-2342164722u,
-1674890530u,
-3011542850u,
-3549160092u,
-4290680005u,
-3943068002u,
-2273781461u,
-2127663659u,
-1646681121u,
-447810651u,
-2366308558u,
-970504950u,
-2008155560u,
-2695940969u,
-3444688454u,
-1739318893u,
-2683090634u,
-2774816580u,
-437560100u,
-512012738u,
-3305170944u,
-665292744u,
-3580039116u,
-1579404983u,
-3397891494u,
-710590371u,
-2514565805u,
-3624609754u,
-3516075816u,
-1314000850u,
-1935166880u,
-3257747610u,
-3776931214u,
-3183054185u,
-675129307u,
-3333261712u,
-1154611403u,
-2759854023u,
-1963228038u,
-505138315u,
-1803966773u,
-4032705384u,
-798395739u,
-3473799845u,
-476400898u,
-602972493u,
-3289878097u,
-2520311409u,
-3214794876u,
-748160407u,
-1326769504u,
-902775872u,
-1372805534u,
-1213925114u,
-3009384989u,
-3781981134u,
-2835608783u,
-2716786748u,
-1669490957u,
-1089334066u,
-250756920u,
-4041016629u,
-2495807367u,
-2008251381u,
-106212622u,
-1927268995u,
-2251978818u,
-3788056262u,
-3678660147u,
-2656772270u,
-1997584981u,
-2668998785u,
-2954162084u,
-845687881u,
-776018378u,
-2066910012u,
-918315064u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashntTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+2681724312u,
+797982799u,
+921001710u,
+2134990486u,
+2244477846u,
+2992121793u,
+3943596029u,
+452431531u,
+2557197665u,
+2532580744u,
+3099673830u,
+3696623795u,
+3281581178u,
+1882212500u,
+275903667u,
+3033004529u,
+1402319660u,
+2699376854u,
+4222949502u,
+1712034059u,
+1330324210u,
+2921867846u,
+1728752234u,
+326029180u,
+3349570000u,
+1612122221u,
+1646032583u,
+1432476832u,
+3552092450u,
+1499109081u,
+1554038301u,
+3190844552u,
+540224401u,
+489963606u,
+1562872448u,
+2128624475u,
+1262831810u,
+1672724608u,
+2077310004u,
+1911523866u,
+294527927u,
+1389770549u,
+2026137563u,
+629449419u,
+2489287368u,
+645684964u,
+230403464u,
+3272648435u,
+165370827u,
+1230085527u,
+3628174014u,
+851743255u,
+1554380634u,
+3667013118u,
+2290487377u,
+1909203251u,
+1498556724u,
+4165088768u,
+197618179u,
+914413116u,
+1913303225u,
+3117299654u,
+1357272220u,
+507436733u,
+1413396341u,
+146044391u,
+429095991u,
+3056862311u,
+366414107u,
+2293458109u,
+1684583131u,
+1170404994u,
+520792961u,
+1577421232u,
+4033596884u,
+4229339322u,
+3242407770u,
+2649785113u,
+816692935u,
+3555213933u,
+517646945u,
+2180594090u,
+3047062993u,
+2391606125u,
+382936554u,
+788479970u,
+2826990641u,
+3167748333u,
+1758123094u,
+389974094u,
+3338548567u,
+2583576230u,
+3198590202u,
+4155628142u,
+542201663u,
+2856634168u,
+3948351189u,
+4194218315u,
+1467786451u,
+2743592929u,
+1062268187u,
+3810665822u,
+2560479831u,
+997658837u,
+3067277639u,
+1211737169u,
+59581167u,
+1389679610u,
+4189944477u,
+100876854u,
+2062343506u,
+3088828656u,
+3284356565u,
+3130054947u,
+3532596884u,
+3887208531u,
+259034107u,
+3233195759u,
+3200749877u,
+760633989u,
+1115203611u,
+1516407838u,
+1778459926u,
+2146672889u,
+2457048126u,
+2217471853u,
+862072556u,
+3745267835u,
+701920051u,
+581695350u,
+1410111809u,
+3326135446u,
+2187968410u,
+4267859263u,
+479241367u,
+2868987960u,
+704325635u,
+1418509533u,
+735688735u,
+3283299459u,
+813690332u,
+1439630796u,
+3195309868u,
+1616408198u,
+3254795114u,
+2799925823u,
+3929484338u,
+1798536177u,
+4205965408u,
+1499475160u,
+4247675634u,
+3779953975u,
+785893184u,
+2778575413u,
+1160134629u,
+823113169u,
+4116162021u,
+4167766971u,
+2487440590u,
+4004655503u,
+4044418876u,
+1462554406u,
+2011102035u,
+4265993528u,
+576405853u,
+4038839101u,
+2425317635u,
+1401013391u,
+3062418115u,
+3167030094u,
+2602636307u,
+4264167741u,
+4017058800u,
+1029665228u,
+4036354071u,
+2670703363u,
+688472265u,
+1054670286u,
+338058159u,
+1539305024u,
+146827036u,
+4060134777u,
+2502815838u,
+1603444633u,
+2448966429u,
+3891353218u,
+1082330589u,
+201837927u,
+2848283092u,
+883849006u,
+1982110346u,
+541496720u,
+133643215u,
+3847827123u,
+4015671361u,
+2849988118u,
+3452457457u,
+2102063419u,
+3281002516u,
+1539151988u,
+1147951686u,
+2005032160u,
+2415262714u,
+116647396u,
+1029284767u,
+2159170082u,
+1919171906u,
+2017579106u,
+2473524405u,
+1694443528u,
+3671562289u,
+505662155u,
+1019936943u,
+1511077569u,
+773792826u,
+2089123665u,
+484732447u,
+1120017626u,
+2809286837u,
+4029205195u,
+1097806406u,
+136118734u,
+4017075736u,
+1403506686u,
+1516736273u,
+2562064338u,
+2984955003u,
+3071338162u,
+1923531348u,
+771592405u,
+2586632018u,
+4032960199u,
+2687561076u,
+308584855u,
+1692079268u,
+2565680167u,
+3674576684u,
+3770488806u,
+69201295u,
+1255084262u,
+3593730713u,
+54945052u,
+1939595371u,
+2432427547u,
+2295501078u,
+1280920000u,
+82177963u,
+1121403845u,
+2889101923u,
+713121337u,
+1747052377u,
+927011680u,
+4142246789u,
+1958963937u,
+1636932722u,
+4075249328u,
+2025886508u,
+3026358429u,
+1845587644u,
+3615577014u,
+1363253259u,
+3087190425u,
+341851980u,
+2515339233u,
+1276595523u,
+460237542u,
+4198897105u,
+2069753399u,
+4278599955u,
+356742959u,
+3735275001u,
+1750561299u,
+668829411u,
+3384018814u,
+4233785523u,
+451656820u,
+107312677u,
+2390172694u,
+1216645846u,
+164402616u,
+1689811113u,
+1767810825u,
+1397772514u,
+3323383489u,
+2986430557u,
+207428029u,
+2260498180u,
+2360400900u,
+1263709570u,
+1377764574u,
+4252610345u,
+1099809675u,
+2776960536u,
+3542220540u,
+3752806924u,
+337070226u,
+3267551635u,
+1306761320u,
+2220373824u,
+4109252858u,
+896322512u,
+1788337208u,
+1336556841u,
+2911512007u,
+3712582785u,
+3071359622u,
+2561488770u,
+3898950547u,
+536047554u,
+2040551642u,
+3528794619u,
+3565689036u,
+1197100813u,
+1864569342u,
+3329594980u,
+490608221u,
+1174785921u,
+3287246572u,
+2163330264u,
+500120236u,
+2520062970u,
+1561519055u,
+4042710240u,
+2774151984u,
+3160666939u,
+96459446u,
+1878067032u,
+4237425634u,
+2952135524u,
+4100839753u,
+1265237690u,
+4246879223u,
+834830418u,
+3476334357u,
+4277111759u,
+2511026735u,
+3065234219u,
+556796152u,
+198182691u,
+2913077464u,
+1535115487u,
+4046477658u,
+140762681u,
+990407433u,
+2198985327u,
+2926590471u,
+559702706u,
+82077489u,
+1096697687u,
+4190838199u,
+3046872820u,
+1583801700u,
+2185339100u,
+3912423882u,
+3703603898u,
+2540185277u,
+1446869792u,
+4051584612u,
+2719373510u,
+1675560450u,
+1996164093u,
+405251683u,
+2864244470u,
+4071581802u,
+2028708916u,
+803575837u,
+557660441u,
+3841480082u,
+255451671u,
+779434428u,
+3452203069u,
+2285701422u,
+1568745354u,
+823305654u,
+3184047862u,
+4159715581u,
+3160134214u,
+3198900547u,
+1566527339u,
+4194096960u,
+1496132623u,
+1719108984u,
+2584236470u,
+531310503u,
+3456882941u,
+3382290593u,
+467441309u,
+3241407531u,
+2540270567u,
+1397502982u,
+3348545480u,
+811750340u,
+1017047954u,
+2540585554u,
+3531646869u,
+943914610u,
+1903578924u,
+1911188923u,
+241574049u,
+3181425568u,
+3529565564u,
+240953857u,
+2964595704u,
+3828377737u,
+4260564140u,
+4262383425u,
+383233885u,
+4051263539u,
+919677938u,
+1683612329u,
+4204155962u,
+2283918569u,
+4153726847u,
+350160869u,
+1387233546u,
+1891558063u,
+740563169u,
+330624974u,
+2948665536u,
+376390582u,
+3799363969u,
+3187805406u,
+2263421398u,
+1928519266u,
+2746577402u,
+2108753646u,
+768287270u,
+2247006571u,
+212490675u,
+917121602u,
+2549835613u,
+2864033668u,
+3738062408u,
+2006922227u,
+2616619070u,
+3449066284u,
+431292293u,
+786322314u,
+1415970351u,
+3263135197u,
+2954777083u,
+3206261120u,
+2287507921u,
+1781944746u,
+4081586725u,
+1109175923u,
+1813855658u,
+1129462471u,
+1037031473u,
+3389003793u,
+3122687303u,
+1164309901u,
+3193251135u,
+3626554867u,
+3071568023u,
+3656006011u,
+1167681812u,
+3155218919u,
+2704165015u,
+1854985978u,
+1712976649u,
+878608872u,
+4155949943u,
+3163786257u,
+1626463554u,
+1256485167u,
+582664250u,
+2083771672u,
+804336148u,
+2770847216u,
+1674051445u,
+3992583643u,
+2966108111u,
+900741486u,
+4014551783u,
+300318232u,
+3517585534u,
+542270815u,
+760762191u,
+1216399252u,
+643179562u,
+3652676161u,
+2990167340u,
+3262252593u,
+2134299399u,
+411263051u,
+1342880802u,
+1967599860u,
+853593042u,
+2682611693u,
+850464484u,
+3286110054u,
+3842907484u,
+3623364733u,
+3693536939u,
+1615375832u,
+2318423400u,
+4145497671u,
+1728968857u,
+2686506989u,
+1502282913u,
+2151665147u,
+3651607391u,
+1178454681u,
+4146839064u,
+2601416506u,
+1448097974u,
+238887261u,
+4093725287u,
+2367569534u,
+679517009u,
+3539886328u,
+3086277222u,
+1390394371u,
+119173722u,
+1766260771u,
+751439914u,
+215917713u,
+2656990891u,
+1570750352u,
+3533987737u,
+3576119563u,
+963183826u,
+3796810515u,
+136547246u,
+2592925324u,
+427154472u,
+1228758574u,
+1464255968u,
+2984611177u,
+2001585786u,
+1525438381u,
+1348536411u,
+2861338018u,
+764077711u,
+3785343245u,
+457568934u,
+4104954272u,
+2381948487u,
+3148473363u,
+2180270337u,
+1387729170u,
+951677556u,
+2721005055u,
+66786703u,
+1149351924u,
+1895026827u,
+3711056516u,
+3638638708u,
+2263003308u,
+3448840877u,
+225333538u,
+3797521928u,
+3262952567u,
+2078619498u,
+1178073973u,
+3288261538u,
+1496966875u,
+2481012988u,
+114945840u,
+1632780103u,
+2087949619u,
+3787017905u,
+2575395164u,
+2971726178u,
+3642087909u,
+3894199764u,
+203853421u,
+425935223u,
+3565833278u,
+1748785729u,
+580966986u,
+2124704694u,
+1107045577u,
+1067532701u,
+1406028344u,
+18613994u,
+3476683808u,
+3762914298u,
+1844996900u,
+904215228u,
+1118521573u,
+3657647605u,
+3136157065u,
+2287683323u,
+126005630u,
+3555092974u,
+49515858u,
+1010661841u,
+1902040126u,
+1400735275u,
+2771676666u,
+2225229957u,
+3454177594u,
+2883475137u,
+4144472319u,
+1051332394u,
+542648229u,
+1669710469u,
+553041029u,
+584127807u,
+2993670925u,
+3587959456u,
+1745399498u,
+1404723176u,
+1334333531u,
+3239516985u,
+1275954779u,
+367320647u,
+3684418197u,
+4030809053u,
+484559105u,
+4255931645u,
+4271715616u,
+3171911678u,
+928543347u,
+2159512867u,
+313902234u,
+647086234u,
+577214736u,
+1130129573u,
+995791646u,
+1645086060u,
+4122335794u,
+1064648931u,
+2752145076u,
+3312498873u,
+4238535494u,
+1471227427u,
+633688562u,
+1959779970u,
+766642813u,
+1380896111u,
+3647601207u,
+1733961041u,
+521947915u,
+189164145u,
+486382294u,
+3770038872u,
+3235740744u,
+1912506671u,
+2276864677u,
+1588060152u,
+2504457929u,
+1471020554u,
+3623212998u,
+3026631806u,
+2342164722u,
+1674890530u,
+3011542850u,
+3549160092u,
+4290680005u,
+3943068002u,
+2273781461u,
+2127663659u,
+1646681121u,
+447810651u,
+2366308558u,
+970504950u,
+2008155560u,
+2695940969u,
+3444688454u,
+1739318893u,
+2683090634u,
+2774816580u,
+437560100u,
+512012738u,
+3305170944u,
+665292744u,
+3580039116u,
+1579404983u,
+3397891494u,
+710590371u,
+2514565805u,
+3624609754u,
+3516075816u,
+1314000850u,
+1935166880u,
+3257747610u,
+3776931214u,
+3183054185u,
+675129307u,
+3333261712u,
+1154611403u,
+2759854023u,
+1963228038u,
+505138315u,
+1803966773u,
+4032705384u,
+798395739u,
+3473799845u,
+476400898u,
+602972493u,
+3289878097u,
+2520311409u,
+3214794876u,
+748160407u,
+1326769504u,
+902775872u,
+1372805534u,
+1213925114u,
+3009384989u,
+3781981134u,
+2835608783u,
+2716786748u,
+1669490957u,
+1089334066u,
+250756920u,
+4041016629u,
+2495807367u,
+2008251381u,
+106212622u,
+1927268995u,
+2251978818u,
+3788056262u,
+3678660147u,
+2656772270u,
+1997584981u,
+2668998785u,
+2954162084u,
+845687881u,
+776018378u,
+2066910012u,
+918315064u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; IsAlive(farmhashnt::Hash32WithSeed(farm_hash_data, len++, SEED)); IsAlive(farmhashnt::Hash32(farm_hash_data, len++)); IsAlive(farmhashnt::Hash32(farm_hash_data, len++)); len -= 3; return alive > 0; }
Check(farmhashnt::Hash32WithSeed(farm_hash_data + offset, len, SEED));
Check(farmhashnt::Hash32(farm_hash_data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashntTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashntTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
cout << farmhashnt::Hash32WithSeed(farm_hash_data + offset, len, SEED) << "u," << endl;
cout << farmhashnt::Hash32(farm_hash_data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashntTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashntTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashntTest::Dump(0, i);
- }
- farmhashntTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashntTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashntTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashntTest::Dump(0, i);
+ }
+ farmhashntTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashsaTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-4081014168u,
-2576519988u,
-2212771159u,
-1112731063u,
-1020067935u,
-3955445564u,
-1451961420u,
-653440099u,
-31917516u,
-2957164615u,
-2590087362u,
-3879448744u,
-176305566u,
-2447367541u,
-1359016305u,
-3363804638u,
-1117290165u,
-1062549743u,
-2437877004u,
-1894455839u,
-673206794u,
-3486923651u,
-3269862919u,
-2303349487u,
-1380660650u,
-595525107u,
-1525325287u,
-2025609358u,
-176408838u,
-1592885012u,
-864896482u,
-2101378090u,
-3489229104u,
-2118965695u,
-581644891u,
-2718789079u,
-631613207u,
-4228658372u,
-3867875546u,
-3531368319u,
-3804516756u,
-3317755099u,
-1619744564u,
-2884717286u,
-1088213445u,
-2667691076u,
-3727873235u,
-2330406762u,
-858590707u,
-123802208u,
-4150036245u,
-182283099u,
-1478882570u,
-3282617403u,
-819171187u,
-1172627392u,
-4254302102u,
-2957028020u,
-437030323u,
-2452147680u,
-2868246750u,
-3530169402u,
-3154852132u,
-215019192u,
-357580983u,
-1354454461u,
-1108813287u,
-2324008118u,
-2315997713u,
-4181601562u,
-1360882441u,
-92423273u,
-3048866755u,
-3369188505u,
-3664371439u,
-2920710428u,
-1027891570u,
-2653166430u,
-3461888315u,
-1475780447u,
-292769636u,
-1737473313u,
-4064110516u,
-4170160075u,
-762850927u,
-3630603695u,
-2803307356u,
-844987665u,
-460980967u,
-3005635467u,
-2802568977u,
-588668033u,
-2148940781u,
-3239099984u,
-1266953698u,
-3197808789u,
-3519942533u,
-2511995334u,
-2553810188u,
-871667697u,
-1358675720u,
-1499319171u,
-2044931270u,
-1210355103u,
-807152540u,
-3262320756u,
-2810214575u,
-1813386141u,
-4089465863u,
-903928165u,
-1388899322u,
-3209183659u,
-834536144u,
-2733354550u,
-2742289921u,
-3689042563u,
-2655593281u,
-4169686303u,
-415985561u,
-138892376u,
-516115393u,
-65683883u,
-4162865100u,
-889944635u,
-313566528u,
-3346420907u,
-1504303591u,
-2256809275u,
-742243229u,
-779775302u,
-3140940172u,
-2312556111u,
-2304095772u,
-1151741606u,
-2194712422u,
-1714084652u,
-3272736835u,
-1311540658u,
-191179665u,
-3996605106u,
-1657345233u,
-4205442903u,
-1553339212u,
-2351843044u,
-1647502006u,
-2525516233u,
-292202846u,
-1498646290u,
-1429323381u,
-974274898u,
-3759331561u,
-2881238887u,
-826787221u,
-1069622448u,
-221991032u,
-1462969082u,
-2799661508u,
-364022781u,
-2594244377u,
-797773898u,
-4097839290u,
-1529150125u,
-2456805570u,
-541503425u,
-3936326142u,
-3112719954u,
-775223581u,
-3074018423u,
-3198488875u,
-1772191849u,
-2456535211u,
-3154686028u,
-1520862019u,
-4005829426u,
-1306433767u,
-1943028506u,
-2246000782u,
-1057766454u,
-3761996982u,
-3441075333u,
-898641979u,
-3450209088u,
-3941329307u,
-3289922449u,
-3085075827u,
-1814193220u,
-690422997u,
-2627846676u,
-2653520704u,
-3739145533u,
-3996776010u,
-2287072592u,
-1346671698u,
-3082629900u,
-2298811274u,
-3639722036u,
-1729419228u,
-1836765953u,
-3708118742u,
-213436u,
-950223749u,
-3734247682u,
-2924575678u,
-1382024841u,
-2431637732u,
-3448846682u,
-1341301397u,
-4206956590u,
-1730650902u,
-2581075456u,
-1542359141u,
-707222542u,
-2925350541u,
-3846303536u,
-3579103295u,
-3932175763u,
-1339615732u,
-848825750u,
-1070170828u,
-1964973818u,
-577060344u,
-607721296u,
-4031023048u,
-406883794u,
-3991905552u,
-1198544082u,
-872468460u,
-1044847096u,
-3159976313u,
-3020028266u,
-2108700400u,
-3373767922u,
-264431841u,
-2817097007u,
-3700061048u,
-1733731531u,
-3459415893u,
-80378591u,
-1479875104u,
-19735612u,
-1382658977u,
-3416562245u,
-1959852842u,
-2384002344u,
-124683828u,
-3725782174u,
-2300301222u,
-393852269u,
-1302492002u,
-3623776492u,
-3787086417u,
-1730024749u,
-1710531361u,
-443700716u,
-1461987482u,
-671998131u,
-3018380746u,
-2592292305u,
-3390799372u,
-3945101155u,
-3743494852u,
-3716045582u,
-996005166u,
-320698449u,
-3420221765u,
-1518157951u,
-2555810666u,
-3381929684u,
-2019638523u,
-3088262796u,
-2072178906u,
-3433649364u,
-203906916u,
-34663784u,
-290301305u,
-1188021504u,
-3754681145u,
-3920313139u,
-2840496520u,
-1656802962u,
-2288475489u,
-3399185138u,
-1296000826u,
-2362384746u,
-309633360u,
-2719851778u,
-776035930u,
-3200733043u,
-365690832u,
-3326378243u,
-1500331457u,
-1625708592u,
-4230903462u,
-715344888u,
-3363777768u,
-2243620288u,
-2890765789u,
-553154234u,
-4044100108u,
-4056887320u,
-1185656496u,
-3671476744u,
-1064586897u,
-1154949698u,
-3493481974u,
-1294573722u,
-1869224012u,
-2530084956u,
-995321553u,
-833419249u,
-563815282u,
-250258043u,
-2970801822u,
-441007535u,
-42246961u,
-2820426655u,
-2878882436u,
-2363245780u,
-2138489282u,
-2972360481u,
-2312619393u,
-3598664848u,
-3071556076u,
-776990325u,
-3220427357u,
-2257939577u,
-3817305903u,
-1502979698u,
-3159755934u,
-3955997276u,
-2423850008u,
-1959927572u,
-1219782288u,
-4119776679u,
-1124253854u,
-3678052422u,
-2620644947u,
-1262408666u,
-3480072280u,
-2627137665u,
-807538749u,
-3276646337u,
-518510128u,
-1137828655u,
-1498449110u,
-3031692317u,
-1125635969u,
-1130096111u,
-780007336u,
-3111856399u,
-1014917264u,
-780877352u,
-2909458336u,
-4235949214u,
-2423879289u,
-275888892u,
-3891926795u,
-3538163953u,
-54815161u,
-162228302u,
-258154068u,
-3554455591u,
-1801469029u,
-2801563220u,
-726560058u,
-2450221940u,
-3677582978u,
-440993800u,
-424762443u,
-2624525253u,
-2587715329u,
-2292264424u,
-1074856749u,
-3294752007u,
-3164112672u,
-2399146799u,
-1920182465u,
-3858835361u,
-193755240u,
-3333610311u,
-1757504059u,
-2576027039u,
-2775253365u,
-2939191561u,
-1046147275u,
-235149906u,
-4262218222u,
-2900542726u,
-2260154702u,
-1019551635u,
-1194720570u,
-3519118691u,
-3039483153u,
-84918216u,
-3053381097u,
-2572396843u,
-3849763371u,
-2782686780u,
-3710049554u,
-3403430713u,
-2346080784u,
-2496307442u,
-1597281872u,
-696018239u,
-704625714u,
-623026921u,
-3182413559u,
-3794540330u,
-305497722u,
-1592680199u,
-2377854072u,
-3060601746u,
-3953057908u,
-3941551588u,
-1033716182u,
-2765716854u,
-1309699058u,
-3519400181u,
-3073370877u,
-115583008u,
-4032909296u,
-2944563574u,
-3762753718u,
-192842727u,
-1711348701u,
-3086147235u,
-1658229443u,
-1479783872u,
-3839977157u,
-225619117u,
-1349684817u,
-1964813173u,
-565753187u,
-2530252046u,
-840014353u,
-1645183704u,
-3668429078u,
-3438418557u,
-639704059u,
-360837811u,
-2531807958u,
-1572353913u,
-2116037299u,
-1948437512u,
-744553393u,
-2380697034u,
-3775234105u,
-3816065157u,
-301868653u,
-2960939561u,
-3306528247u,
-2389296549u,
-805918610u,
-1759358265u,
-1760876328u,
-2827601706u,
-2944594708u,
-3313666458u,
-2022601495u,
-730938791u,
-193539397u,
-2026103244u,
-802928398u,
-2630934308u,
-782805818u,
-3499326016u,
-293509489u,
-3646131514u,
-3182478647u,
-854800333u,
-2284531628u,
-438528022u,
-2339298129u,
-1692289216u,
-2427728723u,
-46501288u,
-350652353u,
-1355971222u,
-889682372u,
-944799254u,
-2763906061u,
-2807550612u,
-2683762637u,
-100870317u,
-2449357318u,
-2638348436u,
-4206088869u,
-1788948473u,
-3537588549u,
-2782490204u,
-134406470u,
-2409190528u,
-2362439849u,
-1861661528u,
-2101513194u,
-1424834765u,
-3581765745u,
-3185999525u,
-2057487100u,
-2303941176u,
-3639628788u,
-1180265315u,
-230437935u,
-2108319366u,
-1131685143u,
-1055685292u,
-1509007009u,
-1258485140u,
-560525005u,
-3598799040u,
-3835680585u,
-1851859628u,
-332858996u,
-641769248u,
-4252450037u,
-865386707u,
-720719117u,
-3133612164u,
-3833045874u,
-3492515435u,
-2465970289u,
-4234420011u,
-573859916u,
-252532886u,
-870392318u,
-4051320920u,
-894929092u,
-3748361688u,
-699355960u,
-1885212350u,
-1609756949u,
-461896870u,
-1337065461u,
-1775211059u,
-1786193749u,
-2815154643u,
-2128729882u,
-969639529u,
-3960427545u,
-859416958u,
-2739758802u,
-2698032197u,
-2813292418u,
-1985467524u,
-396604317u,
-4122172759u,
-1201259789u,
-4282051702u,
-3270018895u,
-961215209u,
-961075860u,
-4211926998u,
-4088374597u,
-577510509u,
-3058349487u,
-4025377754u,
-2815478438u,
-471023164u,
-3947959608u,
-4161486934u,
-2299888461u,
-1103571511u,
-2450153872u,
-1839939275u,
-108299608u,
-858086440u,
-1030152945u,
-3895328530u,
-3009080718u,
-3690840454u,
-3847025277u,
-152331362u,
-161365689u,
-831319961u,
-2166017294u,
-3945322722u,
-4059970216u,
-1420824131u,
-2770648308u,
-1567250186u,
-2181067149u,
-1939743488u,
-3080158120u,
-3435218248u,
-2495237495u,
-3814085102u,
-3180983013u,
-3199054292u,
-2204745908u,
-1140337267u,
-2213569784u,
-1941879842u,
-2105562605u,
-3618835614u,
-2247103645u,
-2492473487u,
-856414299u,
-166022030u,
-4080104712u,
-3218935344u,
-3284220561u,
-4261581452u,
-1206944836u,
-3496705432u,
-2215996876u,
-3154627465u,
-3384005496u,
-742170556u,
-1333047620u,
-802680366u,
-156833431u,
-2682100354u,
-2493654830u,
-584848366u,
-1691693131u,
-2169934170u,
-779968026u,
-2099545800u,
-1423039695u,
-4292110968u,
-4266576788u,
-149142597u,
-748501873u,
-3865014822u,
-1913588198u,
-130285614u,
-3500768879u,
-915458923u,
-3071792750u,
-1339986633u,
-4143929149u,
-4048379479u,
-725193827u,
-1375113643u,
-2425277412u,
-4144659274u,
-465714768u,
-226991589u,
-2212127704u,
-3936145258u,
-2891024846u,
-3816000225u,
-979331165u,
-1749907536u,
-53847318u,
-1462525833u,
-2961425455u,
-368859113u,
-3572721452u,
-453048644u,
-1628629918u,
-3497673923u,
-3619079585u,
-139870565u,
-1518176798u,
-3933074281u,
-1878623729u,
-2074035641u,
-3016759257u,
-1313053591u,
-2557706970u,
-2348296582u,
-962370022u,
-2337285014u,
-1618936717u,
-1915877085u,
-2743743122u,
-3250783882u,
-1346652536u,
-143311109u,
-2443788461u,
-1048248964u,
-2806619339u,
-3263266976u,
-1668146349u,
-3397428868u,
-3276188862u,
-1774196343u,
-1993847813u,
-2771079610u,
-476672419u,
-2119050359u,
-2918326659u,
-2245402721u,
-2692910474u,
-2374383269u,
-342400227u,
-2961437795u,
-3899230368u,
-337787132u,
-3664444935u,
-1269451153u,
-2971526729u,
-1486511182u,
-791070133u,
-2570319890u,
-3482497490u,
-2134230518u,
-4273391202u,
-1825511330u,
-3947753714u,
-1389755724u,
-3995075516u,
-2081052615u,
-3626343470u,
-4213603435u,
-2137917278u,
-2898987303u,
-3059215715u,
-3383237881u,
-3003674434u,
-409174425u,
-1911915604u,
-2087728055u,
-2942005882u,
-3386522440u,
-714936074u,
-261924004u,
-3268784033u,
-1141188757u,
-2413217552u,
-1515163433u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashsaTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+4081014168u,
+2576519988u,
+2212771159u,
+1112731063u,
+1020067935u,
+3955445564u,
+1451961420u,
+653440099u,
+31917516u,
+2957164615u,
+2590087362u,
+3879448744u,
+176305566u,
+2447367541u,
+1359016305u,
+3363804638u,
+1117290165u,
+1062549743u,
+2437877004u,
+1894455839u,
+673206794u,
+3486923651u,
+3269862919u,
+2303349487u,
+1380660650u,
+595525107u,
+1525325287u,
+2025609358u,
+176408838u,
+1592885012u,
+864896482u,
+2101378090u,
+3489229104u,
+2118965695u,
+581644891u,
+2718789079u,
+631613207u,
+4228658372u,
+3867875546u,
+3531368319u,
+3804516756u,
+3317755099u,
+1619744564u,
+2884717286u,
+1088213445u,
+2667691076u,
+3727873235u,
+2330406762u,
+858590707u,
+123802208u,
+4150036245u,
+182283099u,
+1478882570u,
+3282617403u,
+819171187u,
+1172627392u,
+4254302102u,
+2957028020u,
+437030323u,
+2452147680u,
+2868246750u,
+3530169402u,
+3154852132u,
+215019192u,
+357580983u,
+1354454461u,
+1108813287u,
+2324008118u,
+2315997713u,
+4181601562u,
+1360882441u,
+92423273u,
+3048866755u,
+3369188505u,
+3664371439u,
+2920710428u,
+1027891570u,
+2653166430u,
+3461888315u,
+1475780447u,
+292769636u,
+1737473313u,
+4064110516u,
+4170160075u,
+762850927u,
+3630603695u,
+2803307356u,
+844987665u,
+460980967u,
+3005635467u,
+2802568977u,
+588668033u,
+2148940781u,
+3239099984u,
+1266953698u,
+3197808789u,
+3519942533u,
+2511995334u,
+2553810188u,
+871667697u,
+1358675720u,
+1499319171u,
+2044931270u,
+1210355103u,
+807152540u,
+3262320756u,
+2810214575u,
+1813386141u,
+4089465863u,
+903928165u,
+1388899322u,
+3209183659u,
+834536144u,
+2733354550u,
+2742289921u,
+3689042563u,
+2655593281u,
+4169686303u,
+415985561u,
+138892376u,
+516115393u,
+65683883u,
+4162865100u,
+889944635u,
+313566528u,
+3346420907u,
+1504303591u,
+2256809275u,
+742243229u,
+779775302u,
+3140940172u,
+2312556111u,
+2304095772u,
+1151741606u,
+2194712422u,
+1714084652u,
+3272736835u,
+1311540658u,
+191179665u,
+3996605106u,
+1657345233u,
+4205442903u,
+1553339212u,
+2351843044u,
+1647502006u,
+2525516233u,
+292202846u,
+1498646290u,
+1429323381u,
+974274898u,
+3759331561u,
+2881238887u,
+826787221u,
+1069622448u,
+221991032u,
+1462969082u,
+2799661508u,
+364022781u,
+2594244377u,
+797773898u,
+4097839290u,
+1529150125u,
+2456805570u,
+541503425u,
+3936326142u,
+3112719954u,
+775223581u,
+3074018423u,
+3198488875u,
+1772191849u,
+2456535211u,
+3154686028u,
+1520862019u,
+4005829426u,
+1306433767u,
+1943028506u,
+2246000782u,
+1057766454u,
+3761996982u,
+3441075333u,
+898641979u,
+3450209088u,
+3941329307u,
+3289922449u,
+3085075827u,
+1814193220u,
+690422997u,
+2627846676u,
+2653520704u,
+3739145533u,
+3996776010u,
+2287072592u,
+1346671698u,
+3082629900u,
+2298811274u,
+3639722036u,
+1729419228u,
+1836765953u,
+3708118742u,
+213436u,
+950223749u,
+3734247682u,
+2924575678u,
+1382024841u,
+2431637732u,
+3448846682u,
+1341301397u,
+4206956590u,
+1730650902u,
+2581075456u,
+1542359141u,
+707222542u,
+2925350541u,
+3846303536u,
+3579103295u,
+3932175763u,
+1339615732u,
+848825750u,
+1070170828u,
+1964973818u,
+577060344u,
+607721296u,
+4031023048u,
+406883794u,
+3991905552u,
+1198544082u,
+872468460u,
+1044847096u,
+3159976313u,
+3020028266u,
+2108700400u,
+3373767922u,
+264431841u,
+2817097007u,
+3700061048u,
+1733731531u,
+3459415893u,
+80378591u,
+1479875104u,
+19735612u,
+1382658977u,
+3416562245u,
+1959852842u,
+2384002344u,
+124683828u,
+3725782174u,
+2300301222u,
+393852269u,
+1302492002u,
+3623776492u,
+3787086417u,
+1730024749u,
+1710531361u,
+443700716u,
+1461987482u,
+671998131u,
+3018380746u,
+2592292305u,
+3390799372u,
+3945101155u,
+3743494852u,
+3716045582u,
+996005166u,
+320698449u,
+3420221765u,
+1518157951u,
+2555810666u,
+3381929684u,
+2019638523u,
+3088262796u,
+2072178906u,
+3433649364u,
+203906916u,
+34663784u,
+290301305u,
+1188021504u,
+3754681145u,
+3920313139u,
+2840496520u,
+1656802962u,
+2288475489u,
+3399185138u,
+1296000826u,
+2362384746u,
+309633360u,
+2719851778u,
+776035930u,
+3200733043u,
+365690832u,
+3326378243u,
+1500331457u,
+1625708592u,
+4230903462u,
+715344888u,
+3363777768u,
+2243620288u,
+2890765789u,
+553154234u,
+4044100108u,
+4056887320u,
+1185656496u,
+3671476744u,
+1064586897u,
+1154949698u,
+3493481974u,
+1294573722u,
+1869224012u,
+2530084956u,
+995321553u,
+833419249u,
+563815282u,
+250258043u,
+2970801822u,
+441007535u,
+42246961u,
+2820426655u,
+2878882436u,
+2363245780u,
+2138489282u,
+2972360481u,
+2312619393u,
+3598664848u,
+3071556076u,
+776990325u,
+3220427357u,
+2257939577u,
+3817305903u,
+1502979698u,
+3159755934u,
+3955997276u,
+2423850008u,
+1959927572u,
+1219782288u,
+4119776679u,
+1124253854u,
+3678052422u,
+2620644947u,
+1262408666u,
+3480072280u,
+2627137665u,
+807538749u,
+3276646337u,
+518510128u,
+1137828655u,
+1498449110u,
+3031692317u,
+1125635969u,
+1130096111u,
+780007336u,
+3111856399u,
+1014917264u,
+780877352u,
+2909458336u,
+4235949214u,
+2423879289u,
+275888892u,
+3891926795u,
+3538163953u,
+54815161u,
+162228302u,
+258154068u,
+3554455591u,
+1801469029u,
+2801563220u,
+726560058u,
+2450221940u,
+3677582978u,
+440993800u,
+424762443u,
+2624525253u,
+2587715329u,
+2292264424u,
+1074856749u,
+3294752007u,
+3164112672u,
+2399146799u,
+1920182465u,
+3858835361u,
+193755240u,
+3333610311u,
+1757504059u,
+2576027039u,
+2775253365u,
+2939191561u,
+1046147275u,
+235149906u,
+4262218222u,
+2900542726u,
+2260154702u,
+1019551635u,
+1194720570u,
+3519118691u,
+3039483153u,
+84918216u,
+3053381097u,
+2572396843u,
+3849763371u,
+2782686780u,
+3710049554u,
+3403430713u,
+2346080784u,
+2496307442u,
+1597281872u,
+696018239u,
+704625714u,
+623026921u,
+3182413559u,
+3794540330u,
+305497722u,
+1592680199u,
+2377854072u,
+3060601746u,
+3953057908u,
+3941551588u,
+1033716182u,
+2765716854u,
+1309699058u,
+3519400181u,
+3073370877u,
+115583008u,
+4032909296u,
+2944563574u,
+3762753718u,
+192842727u,
+1711348701u,
+3086147235u,
+1658229443u,
+1479783872u,
+3839977157u,
+225619117u,
+1349684817u,
+1964813173u,
+565753187u,
+2530252046u,
+840014353u,
+1645183704u,
+3668429078u,
+3438418557u,
+639704059u,
+360837811u,
+2531807958u,
+1572353913u,
+2116037299u,
+1948437512u,
+744553393u,
+2380697034u,
+3775234105u,
+3816065157u,
+301868653u,
+2960939561u,
+3306528247u,
+2389296549u,
+805918610u,
+1759358265u,
+1760876328u,
+2827601706u,
+2944594708u,
+3313666458u,
+2022601495u,
+730938791u,
+193539397u,
+2026103244u,
+802928398u,
+2630934308u,
+782805818u,
+3499326016u,
+293509489u,
+3646131514u,
+3182478647u,
+854800333u,
+2284531628u,
+438528022u,
+2339298129u,
+1692289216u,
+2427728723u,
+46501288u,
+350652353u,
+1355971222u,
+889682372u,
+944799254u,
+2763906061u,
+2807550612u,
+2683762637u,
+100870317u,
+2449357318u,
+2638348436u,
+4206088869u,
+1788948473u,
+3537588549u,
+2782490204u,
+134406470u,
+2409190528u,
+2362439849u,
+1861661528u,
+2101513194u,
+1424834765u,
+3581765745u,
+3185999525u,
+2057487100u,
+2303941176u,
+3639628788u,
+1180265315u,
+230437935u,
+2108319366u,
+1131685143u,
+1055685292u,
+1509007009u,
+1258485140u,
+560525005u,
+3598799040u,
+3835680585u,
+1851859628u,
+332858996u,
+641769248u,
+4252450037u,
+865386707u,
+720719117u,
+3133612164u,
+3833045874u,
+3492515435u,
+2465970289u,
+4234420011u,
+573859916u,
+252532886u,
+870392318u,
+4051320920u,
+894929092u,
+3748361688u,
+699355960u,
+1885212350u,
+1609756949u,
+461896870u,
+1337065461u,
+1775211059u,
+1786193749u,
+2815154643u,
+2128729882u,
+969639529u,
+3960427545u,
+859416958u,
+2739758802u,
+2698032197u,
+2813292418u,
+1985467524u,
+396604317u,
+4122172759u,
+1201259789u,
+4282051702u,
+3270018895u,
+961215209u,
+961075860u,
+4211926998u,
+4088374597u,
+577510509u,
+3058349487u,
+4025377754u,
+2815478438u,
+471023164u,
+3947959608u,
+4161486934u,
+2299888461u,
+1103571511u,
+2450153872u,
+1839939275u,
+108299608u,
+858086440u,
+1030152945u,
+3895328530u,
+3009080718u,
+3690840454u,
+3847025277u,
+152331362u,
+161365689u,
+831319961u,
+2166017294u,
+3945322722u,
+4059970216u,
+1420824131u,
+2770648308u,
+1567250186u,
+2181067149u,
+1939743488u,
+3080158120u,
+3435218248u,
+2495237495u,
+3814085102u,
+3180983013u,
+3199054292u,
+2204745908u,
+1140337267u,
+2213569784u,
+1941879842u,
+2105562605u,
+3618835614u,
+2247103645u,
+2492473487u,
+856414299u,
+166022030u,
+4080104712u,
+3218935344u,
+3284220561u,
+4261581452u,
+1206944836u,
+3496705432u,
+2215996876u,
+3154627465u,
+3384005496u,
+742170556u,
+1333047620u,
+802680366u,
+156833431u,
+2682100354u,
+2493654830u,
+584848366u,
+1691693131u,
+2169934170u,
+779968026u,
+2099545800u,
+1423039695u,
+4292110968u,
+4266576788u,
+149142597u,
+748501873u,
+3865014822u,
+1913588198u,
+130285614u,
+3500768879u,
+915458923u,
+3071792750u,
+1339986633u,
+4143929149u,
+4048379479u,
+725193827u,
+1375113643u,
+2425277412u,
+4144659274u,
+465714768u,
+226991589u,
+2212127704u,
+3936145258u,
+2891024846u,
+3816000225u,
+979331165u,
+1749907536u,
+53847318u,
+1462525833u,
+2961425455u,
+368859113u,
+3572721452u,
+453048644u,
+1628629918u,
+3497673923u,
+3619079585u,
+139870565u,
+1518176798u,
+3933074281u,
+1878623729u,
+2074035641u,
+3016759257u,
+1313053591u,
+2557706970u,
+2348296582u,
+962370022u,
+2337285014u,
+1618936717u,
+1915877085u,
+2743743122u,
+3250783882u,
+1346652536u,
+143311109u,
+2443788461u,
+1048248964u,
+2806619339u,
+3263266976u,
+1668146349u,
+3397428868u,
+3276188862u,
+1774196343u,
+1993847813u,
+2771079610u,
+476672419u,
+2119050359u,
+2918326659u,
+2245402721u,
+2692910474u,
+2374383269u,
+342400227u,
+2961437795u,
+3899230368u,
+337787132u,
+3664444935u,
+1269451153u,
+2971526729u,
+1486511182u,
+791070133u,
+2570319890u,
+3482497490u,
+2134230518u,
+4273391202u,
+1825511330u,
+3947753714u,
+1389755724u,
+3995075516u,
+2081052615u,
+3626343470u,
+4213603435u,
+2137917278u,
+2898987303u,
+3059215715u,
+3383237881u,
+3003674434u,
+409174425u,
+1911915604u,
+2087728055u,
+2942005882u,
+3386522440u,
+714936074u,
+261924004u,
+3268784033u,
+1141188757u,
+2413217552u,
+1515163433u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; IsAlive(farmhashsa::Hash32WithSeed(farm_hash_data, len++, SEED)); IsAlive(farmhashsa::Hash32(farm_hash_data, len++)); IsAlive(farmhashsa::Hash32(farm_hash_data, len++)); len -= 3; return alive > 0; }
Check(farmhashsa::Hash32WithSeed(farm_hash_data + offset, len, SEED));
Check(farmhashsa::Hash32(farm_hash_data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashsaTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashsaTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
cout << farmhashsa::Hash32WithSeed(farm_hash_data + offset, len, SEED) << "u," << endl;
cout << farmhashsa::Hash32(farm_hash_data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashsaTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashsaTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashsaTest::Dump(0, i);
- }
- farmhashsaTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashsaTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashsaTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashsaTest::Dump(0, i);
+ }
+ farmhashsaTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashsuTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-4223616069u,
-3696677242u,
-4081014168u,
-2576519988u,
-2212771159u,
-1112731063u,
-1020067935u,
-3955445564u,
-1451961420u,
-653440099u,
-31917516u,
-2957164615u,
-2590087362u,
-3879448744u,
-176305566u,
-2447367541u,
-1359016305u,
-3363804638u,
-1117290165u,
-1062549743u,
-2437877004u,
-1894455839u,
-673206794u,
-3486923651u,
-3269862919u,
-2303349487u,
-1380660650u,
-595525107u,
-1525325287u,
-2025609358u,
-176408838u,
-1592885012u,
-864896482u,
-2101378090u,
-3489229104u,
-2118965695u,
-581644891u,
-2718789079u,
-631613207u,
-4228658372u,
-3867875546u,
-3531368319u,
-3804516756u,
-3317755099u,
-1619744564u,
-2884717286u,
-1088213445u,
-2667691076u,
-3727873235u,
-2330406762u,
-858590707u,
-457744844u,
-4150036245u,
-2000404290u,
-1478882570u,
-901678172u,
-819171187u,
-195942998u,
-4254302102u,
-3967266927u,
-437030323u,
-4018009204u,
-2868246750u,
-3540087514u,
-3154852132u,
-3319116625u,
-357580983u,
-3177665294u,
-1108813287u,
-1253366798u,
-2315997713u,
-510718750u,
-1360882441u,
-2770216279u,
-3048866755u,
-3406961221u,
-3664371439u,
-1151145514u,
-1027891570u,
-2699067992u,
-3461888315u,
-198061905u,
-292769636u,
-1106771795u,
-4064110516u,
-3258279756u,
-762850927u,
-1818699721u,
-2803307356u,
-3919169404u,
-460980967u,
-3125535078u,
-2802568977u,
-3582546426u,
-2148940781u,
-3963274378u,
-1266953698u,
-204185123u,
-1100034381u,
-3009193601u,
-4200651967u,
-274889605u,
-2700589508u,
-952511689u,
-3765324859u,
-3465498478u,
-4014967037u,
-2070988082u,
-2972423530u,
-3068638223u,
-4156773651u,
-489509804u,
-1323863238u,
-3731914806u,
-2846098469u,
-2728930632u,
-346814072u,
-848146907u,
-551160669u,
-4165126521u,
-2039095001u,
-4179859388u,
-2434936359u,
-2764414551u,
-238491210u,
-732483969u,
-3366512764u,
-478307468u,
-4124179572u,
-4142733597u,
-1953448206u,
-4199329278u,
-865077060u,
-2627662116u,
-2802499360u,
-3141206831u,
-1959218197u,
-911371451u,
-125987200u,
-2821366175u,
-2530992747u,
-2409206225u,
-117991880u,
-2133402461u,
-895510531u,
-428719601u,
-3036014536u,
-1223783733u,
-733793540u,
-970650405u,
-547701766u,
-570764615u,
-3224485368u,
-3192714940u,
-319942831u,
-3940200341u,
-362056204u,
-2832368105u,
-1853281226u,
-3296434636u,
-3752508307u,
-604292768u,
-2231940616u,
-1204094681u,
-866194005u,
-2405201650u,
-2466384396u,
-380829379u,
-230033818u,
-2783417588u,
-4249886729u,
-829569301u,
-2988322580u,
-2299983554u,
-74748560u,
-737514425u,
-3153050211u,
-652642663u,
-1270205115u,
-227197032u,
-2773091790u,
-325849216u,
-49998791u,
-4043203010u,
-3662748068u,
-1709364383u,
-1179105165u,
-1478504366u,
-2980456610u,
-1167476429u,
-1590390732u,
-1306256496u,
-292008135u,
-374690995u,
-1809200819u,
-1680595904u,
-646040226u,
-1742445560u,
-2435776844u,
-3703683804u,
-478742495u,
-814967947u,
-2698190177u,
-1003617993u,
-1436118705u,
-217056304u,
-1412287094u,
-2738417466u,
-2933279339u,
-3461877733u,
-1203141205u,
-2119492857u,
-1134895723u,
-1560001021u,
-3786320122u,
-3748116258u,
-3486219595u,
-702138030u,
-1062984182u,
-232789133u,
-1566523968u,
-3885443778u,
-1820171888u,
-3655858585u,
-2316903005u,
-2678779620u,
-395625433u,
-1609107564u,
-3108726411u,
-2937837224u,
-3911907151u,
-557272509u,
-3893435978u,
-1542613576u,
-1079886893u,
-2624566322u,
-1413700616u,
-2796974006u,
-1922556114u,
-562820464u,
-2845409784u,
-54180312u,
-1898782464u,
-3681814953u,
-2417064617u,
-1815464483u,
-911626132u,
-2964575550u,
-1852696128u,
-2319647785u,
-1998904590u,
-619992689u,
-3073207513u,
-1238163512u,
-3199435982u,
-828667254u,
-3561155502u,
-3943095163u,
-1045711849u,
-2238679131u,
-2114975398u,
-713808403u,
-3871787494u,
-2572031161u,
-2360934075u,
-2337781107u,
-262596504u,
-693836699u,
-2129369850u,
-3543189427u,
-962205222u,
-3685581020u,
-692974477u,
-725182211u,
-646123906u,
-2368836544u,
-2505872733u,
-1999977610u,
-1639885802u,
-1475058032u,
-207023609u,
-2773581234u,
-3524857793u,
-3433371102u,
-3243027613u,
-1787668353u,
-985757946u,
-3896012929u,
-702356957u,
-3559331129u,
-884084870u,
-4009998120u,
-648888720u,
-1403349048u,
-1624342778u,
-1766674171u,
-2518582204u,
-3251243146u,
-792751003u,
-1377201813u,
-3629686054u,
-1583734324u,
-3647107626u,
-4258564381u,
-1469878609u,
-1940598241u,
-2755003690u,
-1907120418u,
-109916701u,
-775347954u,
-2090960874u,
-611281803u,
-3470490146u,
-3301663253u,
-1835412158u,
-1803066146u,
-591872433u,
-550703713u,
-1495089683u,
-826492808u,
-817200035u,
-4177474571u,
-688070143u,
-971427632u,
-1442499481u,
-3568640348u,
-2789993738u,
-85808128u,
-2058346726u,
-394058570u,
-3466511434u,
-318905230u,
-4149248030u,
-415308316u,
-165997598u,
-1219639412u,
-1648022659u,
-2857432523u,
-1422508004u,
-468095522u,
-296968649u,
-430250611u,
-1775562314u,
-2976361671u,
-1040036362u,
-1372510167u,
-292746272u,
-3408238954u,
-626061886u,
-1317637569u,
-1237775792u,
-1218490455u,
-2224234499u,
-590942419u,
-713995643u,
-3541889330u,
-4140218960u,
-3529791107u,
-354462673u,
-842607274u,
-365048533u,
-2638303414u,
-3560458014u,
-31621379u,
-4210854794u,
-1273118792u,
-2572743762u,
-3513175801u,
-402066986u,
-602524471u,
-565029192u,
-180576438u,
-1288605959u,
-2896244423u,
-1420543484u,
-1329862227u,
-1791567324u,
-4248690247u,
-12917038u,
-3483481310u,
-2082050731u,
-1611921143u,
-2443766548u,
-2216338811u,
-2528006095u,
-2984009021u,
-674210884u,
-2857608106u,
-2155534809u,
-1023105067u,
-2968955846u,
-3303624302u,
-2502112850u,
-245749006u,
-3175229091u,
-3342796184u,
-3613785362u,
-1614168851u,
-2582149283u,
-895403488u,
-416205023u,
-3792242000u,
-529397534u,
-299415203u,
-4284673348u,
-2096851282u,
-1864524731u,
-2012577738u,
-3426363316u,
-1387308508u,
-1143610148u,
-2027467219u,
-3772856163u,
-3453862623u,
-2661437174u,
-2047145955u,
-2533381447u,
-2059534115u,
-439426587u,
-1537543414u,
-2384289877u,
-3174229055u,
-2658017753u,
-2293148474u,
-2359450158u,
-3930242475u,
-1510302397u,
-3354288821u,
-920095603u,
-2415746928u,
-2729472638u,
-2261143371u,
-848667611u,
-919157153u,
-3322393117u,
-4103299943u,
-413569608u,
-68911216u,
-3334990170u,
-1228068652u,
-1570056373u,
-1905477543u,
-2622302276u,
-2935063895u,
-3224810004u,
-4211768578u,
-828688131u,
-3556122839u,
-1930935348u,
-2605825202u,
-1540993970u,
-3209115883u,
-122847500u,
-665638794u,
-506571051u,
-2691795295u,
-3996966556u,
-714660621u,
-3662432239u,
-470651837u,
-1807432621u,
-3755290953u,
-359878860u,
-2793081615u,
-4065031431u,
-904653062u,
-2317800777u,
-568501094u,
-3492871707u,
-2738806116u,
-2883859610u,
-3242080257u,
-364246691u,
-3601786516u,
-3159362524u,
-1578272201u,
-1283574375u,
-2912186103u,
-2256279032u,
-1540671086u,
-2356088973u,
-2892277779u,
-3441449267u,
-2225005503u,
-3846428419u,
-2014549218u,
-2290734767u,
-2126684614u,
-4235463487u,
-3811556204u,
-174739661u,
-767525888u,
-47684458u,
-4211168099u,
-889063422u,
-469864411u,
-767407110u,
-413337343u,
-1618456644u,
-2814499820u,
-2401124192u,
-632089437u,
-1234980238u,
-1288585402u,
-3153169944u,
-2917822069u,
-1843320264u,
-3794359132u,
-3074573530u,
-258629454u,
-3813357060u,
-3806887248u,
-1665524736u,
-3324533324u,
-3005091922u,
-793108368u,
-1529669805u,
-2332660395u,
-2217730223u,
-2634687611u,
-442806463u,
-1968135266u,
-454523002u,
-3177866230u,
-2808960136u,
-4259114138u,
-4103264843u,
-3103714075u,
-2462967542u,
-1466891491u,
-477973764u,
-834565647u,
-741089037u,
-218837573u,
-1710536528u,
-2469088212u,
-1229072375u,
-2828341u,
-176923431u,
-985763350u,
-4095477420u,
-1984145538u,
-1870791084u,
-674956677u,
-1978138947u,
-1296493993u,
-1818183554u,
-3443333721u,
-2124949983u,
-2549590262u,
-2700850794u,
-2662736367u,
-739638109u,
-4061447096u,
-2960078422u,
-2453781158u,
-929570940u,
-3200328383u,
-2406328791u,
-1419180666u,
-2152455739u,
-2805741044u,
-3305999074u,
-3183816361u,
-2303165050u,
-4922104u,
-63096005u,
-936656347u,
-3104453886u,
-1088673880u,
-1113407526u,
-1457890086u,
-453478383u,
-1107686695u,
-3626027824u,
-1159687359u,
-2248467888u,
-2004578380u,
-3274954621u,
-1787958646u,
-2628726704u,
-1138419798u,
-3735442315u,
-692385301u,
-313807213u,
-2329068673u,
-59375364u,
-3261084359u,
-2088644507u,
-2471153194u,
-788336435u,
-4024527246u,
-141504460u,
-2307553888u,
-1930559950u,
-48975711u,
-2745693338u,
-230161982u,
-3429230862u,
-1335968626u,
-609591304u,
-57435073u,
-4279281136u,
-3152151665u,
-3984484924u,
-3459883943u,
-397478330u,
-1738762229u,
-3033590066u,
-3611539498u,
-1363463523u,
-3319364965u,
-2671169141u,
-3819548561u,
-1691193757u,
-2423834608u,
-2820147055u,
-1378120632u,
-1240565187u,
-3180720050u,
-680831086u,
-3309658414u,
-1986166490u,
-762099827u,
-510883662u,
-2047373648u,
-3606742294u,
-3894965352u,
-2342078853u,
-1091255717u,
-776594727u,
-3217317445u,
-1574468485u,
-3844504016u,
-2819598918u,
-1037401010u,
-2550943503u,
-3867184001u,
-1687911772u,
-165313836u,
-1679575281u,
-2418947263u,
-2038774952u,
-3913543652u,
-3209155736u,
-149905221u,
-3859604717u,
-713919631u,
-4069810796u,
-1882959164u,
-1019939034u,
-2379867302u,
-3666323035u,
-1157389013u,
-2422300650u,
-3366777340u,
-2526452062u,
-1313747885u,
-1039617868u,
-1620553692u,
-2032976978u,
-578789528u,
-1592846839u,
-2270630604u,
-897850577u,
-1603294178u,
-3105664807u,
-1442670138u,
-1728019360u,
-79313861u,
-1683031101u,
-1913067024u,
-4070719870u,
-708986470u,
-2586453359u,
-3993348863u,
-3358251279u,
-3003552537u,
-750174793u,
-836888956u,
-4190747426u,
-4251291318u,
-4145164938u,
-1366883260u,
-1912910955u,
-510192669u,
-1851315039u,
-3574241274u,
-3220062924u,
-2821142039u,
-1317082195u,
-2274293302u,
-1839219569u,
-126586168u,
-3989293643u,
-2680178207u,
-347056948u,
-799681430u,
-2864517481u,
-3180404853u,
-213140045u,
-1956305184u,
-1474675286u,
-3085723423u,
-2841859626u,
-308421914u,
-3670309263u,
-1765052231u,
-245459238u,
-113434331u,
-4079521092u,
-2115235526u,
-2943408816u,
-1055476938u,
-1506442339u,
-2291296392u,
-3267864332u,
-1282145528u,
-3700108015u,
-1932843667u,
-2677701670u,
-6041177u,
-3889648557u,
-1461025478u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashsuTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+4223616069u,
+3696677242u,
+4081014168u,
+2576519988u,
+2212771159u,
+1112731063u,
+1020067935u,
+3955445564u,
+1451961420u,
+653440099u,
+31917516u,
+2957164615u,
+2590087362u,
+3879448744u,
+176305566u,
+2447367541u,
+1359016305u,
+3363804638u,
+1117290165u,
+1062549743u,
+2437877004u,
+1894455839u,
+673206794u,
+3486923651u,
+3269862919u,
+2303349487u,
+1380660650u,
+595525107u,
+1525325287u,
+2025609358u,
+176408838u,
+1592885012u,
+864896482u,
+2101378090u,
+3489229104u,
+2118965695u,
+581644891u,
+2718789079u,
+631613207u,
+4228658372u,
+3867875546u,
+3531368319u,
+3804516756u,
+3317755099u,
+1619744564u,
+2884717286u,
+1088213445u,
+2667691076u,
+3727873235u,
+2330406762u,
+858590707u,
+457744844u,
+4150036245u,
+2000404290u,
+1478882570u,
+901678172u,
+819171187u,
+195942998u,
+4254302102u,
+3967266927u,
+437030323u,
+4018009204u,
+2868246750u,
+3540087514u,
+3154852132u,
+3319116625u,
+357580983u,
+3177665294u,
+1108813287u,
+1253366798u,
+2315997713u,
+510718750u,
+1360882441u,
+2770216279u,
+3048866755u,
+3406961221u,
+3664371439u,
+1151145514u,
+1027891570u,
+2699067992u,
+3461888315u,
+198061905u,
+292769636u,
+1106771795u,
+4064110516u,
+3258279756u,
+762850927u,
+1818699721u,
+2803307356u,
+3919169404u,
+460980967u,
+3125535078u,
+2802568977u,
+3582546426u,
+2148940781u,
+3963274378u,
+1266953698u,
+204185123u,
+1100034381u,
+3009193601u,
+4200651967u,
+274889605u,
+2700589508u,
+952511689u,
+3765324859u,
+3465498478u,
+4014967037u,
+2070988082u,
+2972423530u,
+3068638223u,
+4156773651u,
+489509804u,
+1323863238u,
+3731914806u,
+2846098469u,
+2728930632u,
+346814072u,
+848146907u,
+551160669u,
+4165126521u,
+2039095001u,
+4179859388u,
+2434936359u,
+2764414551u,
+238491210u,
+732483969u,
+3366512764u,
+478307468u,
+4124179572u,
+4142733597u,
+1953448206u,
+4199329278u,
+865077060u,
+2627662116u,
+2802499360u,
+3141206831u,
+1959218197u,
+911371451u,
+125987200u,
+2821366175u,
+2530992747u,
+2409206225u,
+117991880u,
+2133402461u,
+895510531u,
+428719601u,
+3036014536u,
+1223783733u,
+733793540u,
+970650405u,
+547701766u,
+570764615u,
+3224485368u,
+3192714940u,
+319942831u,
+3940200341u,
+362056204u,
+2832368105u,
+1853281226u,
+3296434636u,
+3752508307u,
+604292768u,
+2231940616u,
+1204094681u,
+866194005u,
+2405201650u,
+2466384396u,
+380829379u,
+230033818u,
+2783417588u,
+4249886729u,
+829569301u,
+2988322580u,
+2299983554u,
+74748560u,
+737514425u,
+3153050211u,
+652642663u,
+1270205115u,
+227197032u,
+2773091790u,
+325849216u,
+49998791u,
+4043203010u,
+3662748068u,
+1709364383u,
+1179105165u,
+1478504366u,
+2980456610u,
+1167476429u,
+1590390732u,
+1306256496u,
+292008135u,
+374690995u,
+1809200819u,
+1680595904u,
+646040226u,
+1742445560u,
+2435776844u,
+3703683804u,
+478742495u,
+814967947u,
+2698190177u,
+1003617993u,
+1436118705u,
+217056304u,
+1412287094u,
+2738417466u,
+2933279339u,
+3461877733u,
+1203141205u,
+2119492857u,
+1134895723u,
+1560001021u,
+3786320122u,
+3748116258u,
+3486219595u,
+702138030u,
+1062984182u,
+232789133u,
+1566523968u,
+3885443778u,
+1820171888u,
+3655858585u,
+2316903005u,
+2678779620u,
+395625433u,
+1609107564u,
+3108726411u,
+2937837224u,
+3911907151u,
+557272509u,
+3893435978u,
+1542613576u,
+1079886893u,
+2624566322u,
+1413700616u,
+2796974006u,
+1922556114u,
+562820464u,
+2845409784u,
+54180312u,
+1898782464u,
+3681814953u,
+2417064617u,
+1815464483u,
+911626132u,
+2964575550u,
+1852696128u,
+2319647785u,
+1998904590u,
+619992689u,
+3073207513u,
+1238163512u,
+3199435982u,
+828667254u,
+3561155502u,
+3943095163u,
+1045711849u,
+2238679131u,
+2114975398u,
+713808403u,
+3871787494u,
+2572031161u,
+2360934075u,
+2337781107u,
+262596504u,
+693836699u,
+2129369850u,
+3543189427u,
+962205222u,
+3685581020u,
+692974477u,
+725182211u,
+646123906u,
+2368836544u,
+2505872733u,
+1999977610u,
+1639885802u,
+1475058032u,
+207023609u,
+2773581234u,
+3524857793u,
+3433371102u,
+3243027613u,
+1787668353u,
+985757946u,
+3896012929u,
+702356957u,
+3559331129u,
+884084870u,
+4009998120u,
+648888720u,
+1403349048u,
+1624342778u,
+1766674171u,
+2518582204u,
+3251243146u,
+792751003u,
+1377201813u,
+3629686054u,
+1583734324u,
+3647107626u,
+4258564381u,
+1469878609u,
+1940598241u,
+2755003690u,
+1907120418u,
+109916701u,
+775347954u,
+2090960874u,
+611281803u,
+3470490146u,
+3301663253u,
+1835412158u,
+1803066146u,
+591872433u,
+550703713u,
+1495089683u,
+826492808u,
+817200035u,
+4177474571u,
+688070143u,
+971427632u,
+1442499481u,
+3568640348u,
+2789993738u,
+85808128u,
+2058346726u,
+394058570u,
+3466511434u,
+318905230u,
+4149248030u,
+415308316u,
+165997598u,
+1219639412u,
+1648022659u,
+2857432523u,
+1422508004u,
+468095522u,
+296968649u,
+430250611u,
+1775562314u,
+2976361671u,
+1040036362u,
+1372510167u,
+292746272u,
+3408238954u,
+626061886u,
+1317637569u,
+1237775792u,
+1218490455u,
+2224234499u,
+590942419u,
+713995643u,
+3541889330u,
+4140218960u,
+3529791107u,
+354462673u,
+842607274u,
+365048533u,
+2638303414u,
+3560458014u,
+31621379u,
+4210854794u,
+1273118792u,
+2572743762u,
+3513175801u,
+402066986u,
+602524471u,
+565029192u,
+180576438u,
+1288605959u,
+2896244423u,
+1420543484u,
+1329862227u,
+1791567324u,
+4248690247u,
+12917038u,
+3483481310u,
+2082050731u,
+1611921143u,
+2443766548u,
+2216338811u,
+2528006095u,
+2984009021u,
+674210884u,
+2857608106u,
+2155534809u,
+1023105067u,
+2968955846u,
+3303624302u,
+2502112850u,
+245749006u,
+3175229091u,
+3342796184u,
+3613785362u,
+1614168851u,
+2582149283u,
+895403488u,
+416205023u,
+3792242000u,
+529397534u,
+299415203u,
+4284673348u,
+2096851282u,
+1864524731u,
+2012577738u,
+3426363316u,
+1387308508u,
+1143610148u,
+2027467219u,
+3772856163u,
+3453862623u,
+2661437174u,
+2047145955u,
+2533381447u,
+2059534115u,
+439426587u,
+1537543414u,
+2384289877u,
+3174229055u,
+2658017753u,
+2293148474u,
+2359450158u,
+3930242475u,
+1510302397u,
+3354288821u,
+920095603u,
+2415746928u,
+2729472638u,
+2261143371u,
+848667611u,
+919157153u,
+3322393117u,
+4103299943u,
+413569608u,
+68911216u,
+3334990170u,
+1228068652u,
+1570056373u,
+1905477543u,
+2622302276u,
+2935063895u,
+3224810004u,
+4211768578u,
+828688131u,
+3556122839u,
+1930935348u,
+2605825202u,
+1540993970u,
+3209115883u,
+122847500u,
+665638794u,
+506571051u,
+2691795295u,
+3996966556u,
+714660621u,
+3662432239u,
+470651837u,
+1807432621u,
+3755290953u,
+359878860u,
+2793081615u,
+4065031431u,
+904653062u,
+2317800777u,
+568501094u,
+3492871707u,
+2738806116u,
+2883859610u,
+3242080257u,
+364246691u,
+3601786516u,
+3159362524u,
+1578272201u,
+1283574375u,
+2912186103u,
+2256279032u,
+1540671086u,
+2356088973u,
+2892277779u,
+3441449267u,
+2225005503u,
+3846428419u,
+2014549218u,
+2290734767u,
+2126684614u,
+4235463487u,
+3811556204u,
+174739661u,
+767525888u,
+47684458u,
+4211168099u,
+889063422u,
+469864411u,
+767407110u,
+413337343u,
+1618456644u,
+2814499820u,
+2401124192u,
+632089437u,
+1234980238u,
+1288585402u,
+3153169944u,
+2917822069u,
+1843320264u,
+3794359132u,
+3074573530u,
+258629454u,
+3813357060u,
+3806887248u,
+1665524736u,
+3324533324u,
+3005091922u,
+793108368u,
+1529669805u,
+2332660395u,
+2217730223u,
+2634687611u,
+442806463u,
+1968135266u,
+454523002u,
+3177866230u,
+2808960136u,
+4259114138u,
+4103264843u,
+3103714075u,
+2462967542u,
+1466891491u,
+477973764u,
+834565647u,
+741089037u,
+218837573u,
+1710536528u,
+2469088212u,
+1229072375u,
+2828341u,
+176923431u,
+985763350u,
+4095477420u,
+1984145538u,
+1870791084u,
+674956677u,
+1978138947u,
+1296493993u,
+1818183554u,
+3443333721u,
+2124949983u,
+2549590262u,
+2700850794u,
+2662736367u,
+739638109u,
+4061447096u,
+2960078422u,
+2453781158u,
+929570940u,
+3200328383u,
+2406328791u,
+1419180666u,
+2152455739u,
+2805741044u,
+3305999074u,
+3183816361u,
+2303165050u,
+4922104u,
+63096005u,
+936656347u,
+3104453886u,
+1088673880u,
+1113407526u,
+1457890086u,
+453478383u,
+1107686695u,
+3626027824u,
+1159687359u,
+2248467888u,
+2004578380u,
+3274954621u,
+1787958646u,
+2628726704u,
+1138419798u,
+3735442315u,
+692385301u,
+313807213u,
+2329068673u,
+59375364u,
+3261084359u,
+2088644507u,
+2471153194u,
+788336435u,
+4024527246u,
+141504460u,
+2307553888u,
+1930559950u,
+48975711u,
+2745693338u,
+230161982u,
+3429230862u,
+1335968626u,
+609591304u,
+57435073u,
+4279281136u,
+3152151665u,
+3984484924u,
+3459883943u,
+397478330u,
+1738762229u,
+3033590066u,
+3611539498u,
+1363463523u,
+3319364965u,
+2671169141u,
+3819548561u,
+1691193757u,
+2423834608u,
+2820147055u,
+1378120632u,
+1240565187u,
+3180720050u,
+680831086u,
+3309658414u,
+1986166490u,
+762099827u,
+510883662u,
+2047373648u,
+3606742294u,
+3894965352u,
+2342078853u,
+1091255717u,
+776594727u,
+3217317445u,
+1574468485u,
+3844504016u,
+2819598918u,
+1037401010u,
+2550943503u,
+3867184001u,
+1687911772u,
+165313836u,
+1679575281u,
+2418947263u,
+2038774952u,
+3913543652u,
+3209155736u,
+149905221u,
+3859604717u,
+713919631u,
+4069810796u,
+1882959164u,
+1019939034u,
+2379867302u,
+3666323035u,
+1157389013u,
+2422300650u,
+3366777340u,
+2526452062u,
+1313747885u,
+1039617868u,
+1620553692u,
+2032976978u,
+578789528u,
+1592846839u,
+2270630604u,
+897850577u,
+1603294178u,
+3105664807u,
+1442670138u,
+1728019360u,
+79313861u,
+1683031101u,
+1913067024u,
+4070719870u,
+708986470u,
+2586453359u,
+3993348863u,
+3358251279u,
+3003552537u,
+750174793u,
+836888956u,
+4190747426u,
+4251291318u,
+4145164938u,
+1366883260u,
+1912910955u,
+510192669u,
+1851315039u,
+3574241274u,
+3220062924u,
+2821142039u,
+1317082195u,
+2274293302u,
+1839219569u,
+126586168u,
+3989293643u,
+2680178207u,
+347056948u,
+799681430u,
+2864517481u,
+3180404853u,
+213140045u,
+1956305184u,
+1474675286u,
+3085723423u,
+2841859626u,
+308421914u,
+3670309263u,
+1765052231u,
+245459238u,
+113434331u,
+4079521092u,
+2115235526u,
+2943408816u,
+1055476938u,
+1506442339u,
+2291296392u,
+3267864332u,
+1282145528u,
+3700108015u,
+1932843667u,
+2677701670u,
+6041177u,
+3889648557u,
+1461025478u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; IsAlive(farmhashsu::Hash32WithSeed(farm_hash_data, len++, SEED)); IsAlive(farmhashsu::Hash32(farm_hash_data, len++)); IsAlive(farmhashsu::Hash32(farm_hash_data, len++)); len -= 3; return alive > 0; }
Check(farmhashsu::Hash32WithSeed(farm_hash_data + offset, len, SEED));
Check(farmhashsu::Hash32(farm_hash_data + offset, len));
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashsuTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashsuTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
cout << farmhashsu::Hash32WithSeed(farm_hash_data + offset, len, SEED) << "u," << endl;
cout << farmhashsu::Hash32(farm_hash_data + offset, len) << "u," << endl;
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashsuTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashsuTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashsuTest::Dump(0, i);
- }
- farmhashsuTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashsuTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashsuTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashsuTest::Dump(0, i);
+ }
+ farmhashsuTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashteTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-1140953930u, 861465670u,
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-890626835u, 800175912u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-3283896453u, 1867689945u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-1110588164u, 4186314283u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-283198166u, 2741341286u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-452473466u, 1706958772u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-236935126u, 2976578695u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-2305012065u, 2169731866u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-3058973506u, 2379411653u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-147814787u, 720739346u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-3425469811u, 3690733394u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-1635026870u, 192883107u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-3969463346u, 1436364519u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-2859809759u, 3808705738u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-4023053163u, 2650381482u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-3476440786u, 3829307897u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-2902102606u, 3600725550u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1448662590u, 397635823u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-180854224u, 2604346966u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-1669465176u, 1341975128u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-1043692997u, 1454396064u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-703505868u, 678706990u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-1933894405u, 3043213226u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-3828089804u, 3632594520u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-3729087873u, 1303930448u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3103338579u, 3064290191u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2295806711u, 1781190011u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-1968445277u, 315203929u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-440398219u, 1891630171u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-4204318635u, 441430649u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-3010839769u, 2837339569u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-4139181436u, 2993479124u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-667183474u, 2084369203u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-1016656857u, 3022024459u,
-3254014218u, 429095991u,
-990500595u, 3056862311u,
-985653208u, 1718653828u,
-623071693u, 366414107u,
-1771289760u, 2293458109u,
-3047342438u, 2991127487u,
-3120876698u, 1684583131u,
-3638043310u, 1170404994u,
-863214540u, 1087193030u,
-199124911u, 520792961u,
-3169775996u, 1577421232u,
-3331828431u, 1013201099u,
-1716848157u, 4033596884u,
-1770708857u, 4229339322u,
-1146169032u, 1434258493u,
-3824360466u, 3242407770u,
-1926419493u, 2649785113u,
-872586426u, 762243036u,
-2736953692u, 816692935u,
-1571283333u, 3555213933u,
-2266795890u, 3781899767u,
-4290630595u, 517646945u,
-3006163611u, 2180594090u,
-959214578u, 558910384u,
-1283799121u, 3047062993u,
-3830962609u, 2391606125u,
-3544509313u, 622325861u,
-834785312u, 382936554u,
-1421463872u, 788479970u,
-1825135056u, 2725923798u,
-580988377u, 2826990641u,
-247825043u, 3167748333u,
-812546227u, 2506885666u,
-2584372201u, 1758123094u,
-1891789696u, 389974094u,
-345313518u, 2022370576u,
-3886113119u, 3338548567u,
-1083486947u, 2583576230u,
-1776047957u, 1771384107u,
-3604937815u, 3198590202u,
-3027522813u, 4155628142u,
-4232136669u, 427759438u,
-4244322689u, 542201663u,
-1549591985u, 2856634168u,
-556609672u, 45845311u,
-1175961330u, 3948351189u,
-4165739882u, 4194218315u,
-1634635545u, 4151937410u,
-713127376u, 1467786451u,
-1327394015u, 2743592929u,
-2638154051u, 810082938u,
-3077742128u, 1062268187u,
-4084325664u, 3810665822u,
-3735739145u, 2794294783u,
-2335576331u, 2560479831u,
-690240711u, 997658837u,
-2442302747u, 3948961926u,
-3958366652u, 3067277639u,
-2059157774u, 1211737169u,
-1516711748u, 2339636583u,
-4188504038u, 59581167u,
-2767897792u, 1389679610u,
-2658147000u, 2643979752u,
-3758739543u, 4189944477u,
-1454470782u, 100876854u,
-2995362413u, 118817200u,
-3252925478u, 2062343506u,
-2804483644u, 3088828656u,
-1231633714u, 4168280671u,
-2931588131u, 3284356565u,
-1255909792u, 3130054947u,
-4173605289u, 1407328702u,
-1677744031u, 3532596884u,
-3162657845u, 3887208531u,
-2256541290u, 3459463480u,
-3740979556u, 259034107u,
-392987633u, 3233195759u,
-3606709555u, 3424793077u,
-315836068u, 3200749877u,
-4065431359u, 760633989u,
-2982018998u, 1811050648u,
-234531934u, 1115203611u,
-3897494162u, 1516407838u,
-1603559457u, 323296368u,
-2632963283u, 1778459926u,
-2879836826u, 2146672889u,
-3486330348u, 492621815u,
-1231665285u, 2457048126u,
-3438440082u, 2217471853u,
-3355404249u, 3275550588u,
-1052645068u, 862072556u,
-4110617119u, 3745267835u,
-2657392572u, 4279236653u,
-1688445808u, 701920051u,
-956734128u, 581695350u,
-3157862788u, 2585726058u,
-1192588249u, 1410111809u,
-1651193125u, 3326135446u,
-1073280453u, 97376972u,
-2513844237u, 2187968410u,
-3976859649u, 4267859263u,
-3429034542u, 564493077u,
-3000537321u, 479241367u,
-3845637831u, 2868987960u,
-51544337u, 1029173765u,
-393624922u, 704325635u,
-2357610553u, 1418509533u,
-2007814586u, 3866658271u,
-3082385053u, 735688735u,
-916110004u, 3283299459u,
-1051684175u, 1083796807u,
-4074716319u, 813690332u,
-144264390u, 1439630796u,
-1508556987u, 675582689u,
-3748881891u, 3195309868u,
-362884708u, 1616408198u,
-43233176u, 837301135u,
-881504822u, 3254795114u,
-1385506591u, 2799925823u,
-1469874582u, 3464841997u,
-497175391u, 3929484338u,
-3975771289u, 1798536177u,
-2926265846u, 1374242438u,
-3675707838u, 4205965408u,
-3153165629u, 1499475160u,
-187287713u, 548490821u,
-3255259608u, 4247675634u,
-1940181471u, 3779953975u,
-687167150u, 2319566715u,
-1742785722u, 785893184u,
-2296977392u, 2778575413u,
-1794720651u, 48131484u,
-4084891412u, 1160134629u,
-3737623280u, 823113169u,
-3423207646u, 3803213486u,
-710625654u, 4116162021u,
-3693420287u, 4167766971u,
-1666602807u, 295320990u,
-3513255468u, 2487440590u,
-234080704u, 4004655503u,
-2971762528u, 1479656873u,
-4090178629u, 4044418876u,
-391947536u, 1462554406u,
-3909295855u, 1239580330u,
-1515601363u, 2011102035u,
-1442068334u, 4265993528u,
-1191921695u, 2291355695u,
-4257172787u, 576405853u,
-314332944u, 4038839101u,
-55559918u, 2378985842u,
-711098718u, 2425317635u,
-1644327317u, 1401013391u,
-4193760037u, 2958260436u,
-3167371443u, 3062418115u,
-3800755475u, 3167030094u,
-3489648204u, 1405430357u,
-526177822u, 2602636307u,
-915406019u, 4264167741u,
-1484090483u, 3070944737u,
-254529415u, 4017058800u,
-1702710265u, 1029665228u,
-2000382906u, 3185573940u,
-1381258384u, 4036354071u,
-2900841028u, 2670703363u,
-2921748807u, 2899069938u,
-4130543625u, 688472265u,
-4186808827u, 1054670286u,
-1132985391u, 2840525968u,
-4175776103u, 338058159u,
-1735964501u, 1539305024u,
-3497121710u, 1568260669u,
-2227290760u, 146827036u,
-3977176001u, 4060134777u,
-857488494u, 250055052u,
-4284109679u, 2502815838u,
-2592281721u, 1603444633u,
-1390562014u, 1556658131u,
-616327404u, 2448966429u,
-3051191726u, 3891353218u,
-1213304082u, 762328245u,
-2239052397u, 1082330589u,
-2455957292u, 201837927u,
-405397452u, 3079886794u,
-2583939798u, 2848283092u,
-3750724631u, 883849006u,
-3204198988u, 3341327098u,
-1855234968u, 1982110346u,
-1485529487u, 541496720u,
-4117290321u, 3607433551u,
-2168864636u, 133643215u,
-1055817409u, 3847827123u,
-2960769387u, 4046101649u,
-1176127003u, 4015671361u,
-4243643405u, 2849988118u,
-517111221u, 1796672358u,
-2045051700u, 3452457457u,
-2948254999u, 2102063419u,
-1556410577u, 1536380876u,
-3776661467u, 3281002516u,
-1735616066u, 1539151988u,
-1087795162u, 3332431596u,
-685631442u, 1147951686u,
-95237878u, 2005032160u,
-4012206915u, 4224354805u,
-3204999386u, 2415262714u,
-1433635018u, 116647396u,
-83167836u, 2881562655u,
-2729416454u, 1029284767u,
-881378302u, 2159170082u,
-555057366u, 1169104445u,
-3963877000u, 1919171906u,
-336034862u, 2017579106u,
-4059340529u, 3020819343u,
-865146997u, 2473524405u,
-944743644u, 1694443528u,
-1804513294u, 2904752429u,
-617975720u, 3671562289u,
-260177668u, 505662155u,
-1885941445u, 2504509403u,
-2260041112u, 1019936943u,
-3722741628u, 1511077569u,
-3100701179u, 1379422864u,
-1535670711u, 773792826u,
-1103819072u, 2089123665u,
-1157547425u, 329152940u,
-4142587430u, 484732447u,
-2475035432u, 1120017626u,
-412145504u, 965125959u,
-324924679u, 2809286837u,
-2842141483u, 4029205195u,
-2974306813u, 515627448u,
-3791551981u, 1097806406u,
-3873078673u, 136118734u,
-1872130856u, 3632422367u,
-3574135531u, 4017075736u,
-1699452298u, 1403506686u,
-344414660u, 1189129691u,
-3487080616u, 1516736273u,
-1805475756u, 2562064338u,
-163335594u, 2732147834u,
-4077452507u, 2984955003u,
-4271866024u, 3071338162u,
-2347111903u, 873829983u,
-1948409509u, 1923531348u,
-459509140u, 771592405u,
-1750124750u, 2334938333u,
-213811117u, 2586632018u,
-185232757u, 4032960199u,
-2447383637u, 284777551u,
-1654276320u, 2687561076u,
-3512945009u, 308584855u,
-1861027147u, 4102279334u,
-3203802620u, 1692079268u,
-4250142168u, 2565680167u,
-1507046104u, 841195925u,
-520565830u, 3674576684u,
-38924274u, 3770488806u,
-2414430882u, 3978473838u,
-3703994407u, 69201295u,
-3099963860u, 1255084262u,
-690971838u, 3539996781u,
-3696902571u, 3593730713u,
-2363435042u, 54945052u,
-1785765213u, 184911581u,
-1586241476u, 1939595371u,
-2534883189u, 2432427547u,
-2374171993u, 2039128933u,
-2955715987u, 2295501078u,
-2741583197u, 1280920000u,
-686818699u, 1238742497u,
-3843660102u, 82177963u,
-1281043691u, 1121403845u,
-1697846708u, 284852964u,
-278661677u, 2889101923u,
-2127558730u, 713121337u,
-872502474u, 511142139u,
-1261140657u, 1747052377u,
-2108187161u, 927011680u,
-955328267u, 3821994995u,
-2707230761u, 4142246789u,
-4134691985u, 1958963937u,
-2498463509u, 1977988705u,
-1419293714u, 1636932722u,
-2567532373u, 4075249328u,
-240575705u, 1956681213u,
-2598802768u, 2025886508u,
-4104757832u, 3026358429u,
-3242615202u, 4026813725u,
-255108733u, 1845587644u,
-3573008472u, 3615577014u,
-1222733548u, 1205557630u,
-917608574u, 1363253259u,
-1541946015u, 3087190425u,
-1138008081u, 1444019663u,
-109793386u, 341851980u,
-857839960u, 2515339233u,
-156283211u, 1906768669u,
-3886713057u, 1276595523u,
-2809830736u, 460237542u,
-3420452099u, 142985419u,
-205970448u, 4198897105u,
-1950698961u, 2069753399u,
-1142216925u, 1113051162u,
-1033680610u, 4278599955u,
-1106466069u, 356742959u,
-531521052u, 3494863964u,
-225629455u, 3735275001u,
-3662626864u, 1750561299u,
-1012864651u, 2101846429u,
-1074553219u, 668829411u,
-992181339u, 3384018814u,
-3330664522u, 860966321u,
-1885071395u, 4233785523u,
-100741310u, 451656820u,
-2148187612u, 1063001151u,
-360256231u, 107312677u,
-3650357479u, 2390172694u,
-22452685u, 237319043u,
-3600462351u, 1216645846u,
-2088767754u, 164402616u,
-2418980170u, 926137824u,
-94638678u, 1689811113u,
-2751052984u, 1767810825u,
-271289013u, 3896132233u,
-103797041u, 1397772514u,
-3441135892u, 3323383489u,
-2491268371u, 1662561885u,
-1612872497u, 2986430557u,
-2756998822u, 207428029u,
-937973965u, 2791656726u,
-1949717207u, 2260498180u,
-2648427775u, 2360400900u,
-2080496169u, 486358863u,
-1582022990u, 1263709570u,
-1396468647u, 1377764574u,
-363008508u, 1293502429u,
-224580012u, 4252610345u,
-1435134775u, 1099809675u,
-533671980u, 1533438766u,
-1820532305u, 2776960536u,
-3374512975u, 3542220540u,
-822810075u, 3716663290u,
-1157398049u, 3752806924u,
-4081637863u, 337070226u,
-3866585976u, 359270190u,
-2110942730u, 3267551635u,
-644850146u, 1306761320u,
-746972907u, 934259457u,
-2341378668u, 2220373824u,
-1242645122u, 4109252858u,
-1625266099u, 1173698481u,
-383517064u, 896322512u,
-3377483696u, 1788337208u,
-455496839u, 3194373887u,
-1837689083u, 1336556841u,
-1658628529u, 2911512007u,
-3838343487u, 2757664765u,
-1537187340u, 3712582785u,
-367022558u, 3071359622u,
-3926147070u, 35432879u,
-3093195926u, 2561488770u,
-4273132307u, 3898950547u,
-2838251049u, 2103926083u,
-2549435227u, 536047554u,
-1858986613u, 2040551642u,
-1147412575u, 1972369852u,
-4166184983u, 3528794619u,
-4077477194u, 3565689036u,
-808048238u, 3826350461u,
-1359641525u, 1197100813u,
-265993036u, 1864569342u,
-725164342u, 2264788336u,
-1831223342u, 3329594980u,
-923017956u, 490608221u,
-3818634478u, 258154469u,
-1441714797u, 1174785921u,
-3833372385u, 3287246572u,
-1677395563u, 3569218731u,
-868981704u, 2163330264u,
-2649450292u, 500120236u,
-465161780u, 746438382u,
-1145009669u, 2520062970u,
-2810524030u, 1561519055u,
-1479878006u, 3864969305u,
-2686075657u, 4042710240u,
-3224066062u, 2774151984u,
-2226179547u, 1643626042u,
-2328730865u, 3160666939u,
-2107011431u, 96459446u,
-3920328742u, 3336407558u,
-829404209u, 1878067032u,
-1235983679u, 4237425634u,
-466519055u, 3870676863u,
-934312076u, 2952135524u,
-276949224u, 4100839753u,
-424001484u, 1955120893u,
-4015478120u, 1265237690u,
-427484362u, 4246879223u,
-3452969617u, 1724363362u,
-1553513184u, 834830418u,
-1858777639u, 3476334357u,
-4144030366u, 2450047160u,
-2950762705u, 4277111759u,
-358032121u, 2511026735u,
-167923105u, 2059208280u,
-251949572u, 3065234219u,
-1535473864u, 556796152u,
-1513237478u, 3150857516u,
-1103404394u, 198182691u,
-1476438092u, 2913077464u,
-207119516u, 3963810232u,
-2954651680u, 1535115487u,
-3051522276u, 4046477658u,
-917804636u, 864395565u,
-632704095u, 140762681u,
-1802040304u, 990407433u,
-3771506212u, 4106024923u,
-1287729497u, 2198985327u,
-4052924496u, 2926590471u,
-3084557148u, 1472898694u,
-1009870118u, 559702706u,
-4265214507u, 82077489u,
-3067891003u, 3295678907u,
-2402308151u, 1096697687u,
-464407878u, 4190838199u,
-4269578403u, 3060919438u,
-2899950405u, 3046872820u,
-733509243u, 1583801700u,
-40453902u, 3879773881u,
-1993425202u, 2185339100u,
-1877837196u, 3912423882u,
-3293122640u, 4104318469u,
-1679617763u, 3703603898u,
-8759461u, 2540185277u,
-1152198475u, 2038345882u,
-2503579743u, 1446869792u,
-2019419351u, 4051584612u,
-3178289407u, 3992503830u,
-2879018745u, 2719373510u,
-700836153u, 1675560450u,
-4121245793u, 2064715719u,
-343595772u, 1996164093u,
-3130433948u, 405251683u,
-2804817126u, 1607133689u,
-463852893u, 2864244470u,
-2224044848u, 4071581802u,
-2537107938u, 2246347953u,
-3207234525u, 2028708916u,
-2272418128u, 803575837u,
-38655481u, 2170452091u,
-3272166407u, 557660441u,
-4019147902u, 3841480082u,
-298459606u, 2600943364u,
-2440657523u, 255451671u,
-3424361375u, 779434428u,
-3088526123u, 490671625u,
-1322855877u, 3452203069u,
-3057021940u, 2285701422u,
-2014993457u, 2390431709u,
-2002090272u, 1568745354u,
-1783152480u, 823305654u,
-4053862835u, 2200236540u,
-3009412313u, 3184047862u,
-3032187389u, 4159715581u,
-2966902888u, 252986948u,
-1849329144u, 3160134214u,
-3420960112u, 3198900547u,
-749160960u, 379139040u,
-1208883495u, 1566527339u,
-3006227299u, 4194096960u,
-556075248u, 497404038u,
-1717327230u, 1496132623u,
-1775955687u, 1719108984u,
-1014328900u, 4189966956u,
-2108574735u, 2584236470u,
-684087286u, 531310503u,
-4264509527u, 773405691u,
-3088905079u, 3456882941u,
-3105682208u, 3382290593u,
-2289363624u, 3296306400u,
-4168438718u, 467441309u,
-777173623u, 3241407531u,
-1183994815u, 1132983260u,
-1610606159u, 2540270567u,
-2649684057u, 1397502982u,
-146657385u, 3318434267u,
-2109315753u, 3348545480u,
-3193669211u, 811750340u,
-1073256162u, 3571673088u,
-546596661u, 1017047954u,
-3403136990u, 2540585554u,
-1477047647u, 4145867423u,
-2826408201u, 3531646869u,
-784952939u, 943914610u,
-2717443875u, 3657384638u,
-1806867885u, 1903578924u,
-3985088434u, 1911188923u,
-1764002686u, 3672748083u,
-1832925325u, 241574049u,
-519948041u, 3181425568u,
-2939747257u, 1634174593u,
-3429894862u, 3529565564u,
-1089679033u, 240953857u,
-2025369941u, 2695166650u,
-517086873u, 2964595704u,
-3017658263u, 3828377737u,
-2144895011u, 994799311u,
-1184683823u, 4260564140u,
-308018483u, 4262383425u,
-1374752558u, 3431057723u,
-1572637805u, 383233885u,
-3188015819u, 4051263539u,
-233319221u, 3794788167u,
-2017406667u, 919677938u,
-4074952232u, 1683612329u,
-4213676186u, 327142514u,
-3032591014u, 4204155962u,
-206775997u, 2283918569u,
-2395147154u, 3427505379u,
-2211319468u, 4153726847u,
-2217060665u, 350160869u,
-2493667051u, 1648200185u,
-3441709766u, 1387233546u,
-140980u, 1891558063u,
-760080239u, 2088061981u,
-1580964938u, 740563169u,
-422986366u, 330624974u,
-4264507722u, 150928357u,
-2738323042u, 2948665536u,
-918718096u, 376390582u,
-3966098971u, 717653678u,
-3219466255u, 3799363969u,
-3424344721u, 3187805406u,
-375347278u, 3490350144u,
-1992212097u, 2263421398u,
-3855037968u, 1928519266u,
-3866327955u, 1129127000u,
-1782515131u, 2746577402u,
-3059200728u, 2108753646u,
-2738070963u, 1336849395u,
-1705302106u, 768287270u,
-1343511943u, 2247006571u,
-1956142255u, 1780259453u,
-3475618043u, 212490675u,
-622521957u, 917121602u,
-1852992332u, 1267987847u,
-3170016833u, 2549835613u,
-3299763344u, 2864033668u,
-3378768767u, 1236609378u,
-4169365948u, 3738062408u,
-2661022773u, 2006922227u,
-2760592161u, 3828932355u,
-2636387819u, 2616619070u,
-1237256330u, 3449066284u,
-2871755260u, 3729280948u,
-3862686086u, 431292293u,
-3285899651u, 786322314u,
-2531158535u, 724901242u,
-2377363130u, 1415970351u,
-1244759631u, 3263135197u,
-965248856u, 174024139u,
-2297418515u, 2954777083u,
-987586766u, 3206261120u,
-4059515114u, 3903854066u,
-1931934525u, 2287507921u,
-1827135136u, 1781944746u,
-574617451u, 2299034788u,
-2650140034u, 4081586725u,
-2482286699u, 1109175923u,
-458483596u, 618705848u,
-4059852729u, 1813855658u,
-4190721328u, 1129462471u,
-4089998050u, 3575732749u,
-2375584220u, 1037031473u,
-1623777358u, 3389003793u,
-546597541u, 352770237u,
-1383747654u, 3122687303u,
-1646071378u, 1164309901u,
-290870767u, 830691298u,
-929335420u, 3193251135u,
-989577914u, 3626554867u,
-591974737u, 3996958215u,
-3163711272u, 3071568023u,
-1516846461u, 3656006011u,
-2698625268u, 2510865430u,
-340274176u, 1167681812u,
-3698796465u, 3155218919u,
-4102288238u, 1673474350u,
-3069708839u, 2704165015u,
-1237411891u, 1854985978u,
-3646837503u, 3625406022u,
-921552000u, 1712976649u,
-3939149151u, 878608872u,
-3406359248u, 1068844551u,
-1834682077u, 4155949943u,
-2437686324u, 3163786257u,
-2645117577u, 1988168803u,
-747285578u, 1626463554u,
-1235300371u, 1256485167u,
-1914142538u, 4141546431u,
-3838102563u, 582664250u,
-1883344352u, 2083771672u,
-2611657933u, 2139079047u,
-2250573853u, 804336148u,
-3066325351u, 2770847216u,
-4275641370u, 1455750577u,
-3346357270u, 1674051445u,
-601221482u, 3992583643u,
-1402445097u, 3622527604u,
-2509017299u, 2966108111u,
-2557027816u, 900741486u,
-1790771021u, 2912643797u,
-2631381069u, 4014551783u,
-90375300u, 300318232u,
-3269968032u, 2679371729u,
-2664752123u, 3517585534u,
-3253901179u, 542270815u,
-1188641600u, 365479232u,
-2210121140u, 760762191u,
-1273768482u, 1216399252u,
-3484324231u, 4287337666u,
-16322182u, 643179562u,
-325675502u, 3652676161u,
-3120716054u, 3330259752u,
-1011990087u, 2990167340u,
-1097584090u, 3262252593u,
-1829409951u, 3665087267u,
-1214854475u, 2134299399u,
-3704419305u, 411263051u,
-1625446136u, 549838529u,
-4283196353u, 1342880802u,
-3460621305u, 1967599860u,
-4282843369u, 1275671016u,
-2544665755u, 853593042u,
-901109753u, 2682611693u,
-110631633u, 797487791u,
-1472073141u, 850464484u,
-797089608u, 3286110054u,
-350397471u, 2775631060u,
-366448238u, 3842907484u,
-2219863904u, 3623364733u,
-1850985302u, 4009616991u,
-294963924u, 3693536939u,
-3061255808u, 1615375832u,
-1920066675u, 4113028420u,
-4032223840u, 2318423400u,
-2701956286u, 4145497671u,
-3991532344u, 2536338351u,
-1679099863u, 1728968857u,
-449740816u, 2686506989u,
-685242457u, 97590863u,
-3258354115u, 1502282913u,
-1235084019u, 2151665147u,
-528459289u, 231097464u,
-2477280726u, 3651607391u,
-2091754612u, 1178454681u,
-980597335u, 1604483865u,
-1842333726u, 4146839064u,
-3213794286u, 2601416506u,
-754220096u, 3571436033u,
-488595746u, 1448097974u,
-4004834921u, 238887261u,
-3320337489u, 1416989070u,
-2928916831u, 4093725287u,
-186020771u, 2367569534u,
-3046087671u, 4090084518u,
-3548184546u, 679517009u,
-1962659444u, 3539886328u,
-4192003933u, 1678423485u,
-3827951761u, 3086277222u,
-2144472852u, 1390394371u,
-2976322029u, 1574517163u,
-3553313841u, 119173722u,
-1702434637u, 1766260771u,
-3629581771u, 1407497759u,
-895654784u, 751439914u,
-4008409498u, 215917713u,
-1482103833u, 695551833u,
-1288382231u, 2656990891u,
-2581779077u, 1570750352u,
-3710689053u, 1741390464u,
-2666411616u, 3533987737u,
-4289478316u, 3576119563u,
-4118694920u, 108199666u,
-3869794273u, 963183826u,
-2081410737u, 3796810515u,
-791123882u, 2525792704u,
-1036883117u, 136547246u,
-875691100u, 2592925324u,
-614302599u, 3013176417u,
-2689342539u, 427154472u,
-532957601u, 1228758574u,
-1898117151u, 1181643858u,
-1908591042u, 1464255968u,
-446980910u, 2984611177u,
-58509511u, 1046943619u,
-3508927906u, 2001585786u,
-2544767379u, 1525438381u,
-552181222u, 1959725830u,
-879448844u, 1348536411u,
-4242243590u, 2861338018u,
-1082052441u, 1034351453u,
-601175800u, 764077711u,
-530635011u, 3785343245u,
-2178026726u, 117256687u,
-2378297261u, 457568934u,
-76438221u, 4104954272u,
-956793873u, 3783168634u,
-2485968477u, 2381948487u,
-4226929450u, 3148473363u,
-2518273601u, 3569490233u,
-879369091u, 2180270337u,
-3674375989u, 1387729170u,
-977997984u, 4270646856u,
-568650985u, 951677556u,
-4213877384u, 2721005055u,
-1073364549u, 2563403831u,
-1678669911u, 66786703u,
-2273631661u, 1149351924u,
-3651298990u, 1581883443u,
-246723096u, 1895026827u,
-3810605772u, 3711056516u,
-4058833288u, 2193790614u,
-2080120290u, 3638638708u,
-2915672708u, 2263003308u,
-2361934197u, 4136767460u,
-1976115991u, 3448840877u,
-2019238520u, 225333538u,
-874340815u, 2976159827u,
-1555273378u, 3797521928u,
-1942347150u, 3262952567u,
-435997738u, 340403353u,
-2817830907u, 2078619498u,
-749534111u, 1178073973u,
-894654712u, 3361226032u,
-841092198u, 3288261538u,
-1696412169u, 1496966875u,
-697501571u, 1059158875u,
-3739946319u, 2481012988u,
-568983526u, 114945840u,
-1559249010u, 2218244008u,
-2841706923u, 1632780103u,
-4020169654u, 2087949619u,
-2438736103u, 24032648u,
-833416317u, 3787017905u,
-2373238993u, 2575395164u,
-3434544481u, 3228481067u,
-2542976862u, 2971726178u,
-2880371864u, 3642087909u,
-2407477975u, 2239080836u,
-1043714217u, 3894199764u,
-2235879182u, 203853421u,
-2933669448u, 2504940536u,
-834683330u, 425935223u,
-3560796393u, 3565833278u,
-1668000829u, 3683399154u,
-3414330886u, 1748785729u,
-1023171602u, 580966986u,
-2531038985u, 3227325488u,
-2657385925u, 2124704694u,
-233442446u, 1107045577u,
-3407293834u, 552770757u,
-3899097693u, 1067532701u,
-115667924u, 1406028344u,
-1707768231u, 3724015962u,
-2419657149u, 18613994u,
-2532882091u, 3476683808u,
-1560838678u, 811220224u,
-895961699u, 3762914298u,
-1328752423u, 1844996900u,
-1420427894u, 1848067707u,
-1210281744u, 904215228u,
-4055325594u, 1118521573u,
-2496554183u, 2579259919u,
-3996647489u, 3657647605u,
-325254059u, 3136157065u,
-3951522674u, 4052925250u,
-3341068436u, 2287683323u,
-1313073005u, 126005630u,
-2505120084u, 1194725057u,
-853746559u, 3555092974u,
-2689238752u, 49515858u,
-1244776042u, 1069300695u,
-61073168u, 1010661841u,
-1269521335u, 1902040126u,
-990632502u, 2378708922u,
-3858321250u, 1400735275u,
-2974699176u, 2771676666u,
-170995186u, 2877798589u,
-545726212u, 2225229957u,
-1086473152u, 3454177594u,
-3859483262u, 1499729584u,
-2088002891u, 2883475137u,
-3222194252u, 4144472319u,
-2212229854u, 4146740722u,
-567988835u, 1051332394u,
-3932046135u, 542648229u,
-3017852446u, 1277887997u,
-162888005u, 1669710469u,
-1492500905u, 553041029u,
-1434876932u, 533989516u,
-3817492747u, 584127807u,
-4147115982u, 2993670925u,
-4020312558u, 710021255u,
-3509733475u, 3587959456u,
-2088550465u, 1745399498u,
-2952242967u, 1259815443u,
-869648362u, 1404723176u,
-3947542735u, 1334333531u,
-3873471582u, 229399758u,
-59634866u, 3239516985u,
-3844250972u, 1275954779u,
-492891666u, 1029533080u,
-1552951157u, 367320647u,
-699480890u, 3684418197u,
-3707014310u, 471105777u,
-1824587258u, 4030809053u,
-3489914436u, 484559105u,
-1235750398u, 1428453396u,
-4230459084u, 4255931645u,
-1848597055u, 4271715616u,
-331780381u, 482425775u,
-2435323270u, 3171911678u,
-3507210587u, 928543347u,
-4197807526u, 3680046204u,
-2766042024u, 2159512867u,
-179373257u, 313902234u,
-4024837592u, 294795361u,
-1622282562u, 647086234u,
-2825039429u, 577214736u,
-4043412446u, 2426981244u,
-1277736097u, 1130129573u,
-2601395338u, 995791646u,
-36668922u, 3344746679u,
-1521532225u, 1645086060u,
-2622763015u, 4122335794u,
-2936887705u, 494465807u,
-2580840343u, 1064648931u,
-1247887787u, 2752145076u,
-1277612417u, 1249660507u,
-2288678613u, 3312498873u,
-2459273912u, 4238535494u,
-3117488020u, 2571979978u,
-2680188909u, 1471227427u,
-1616494033u, 633688562u,
-2268653416u, 3268237290u,
-3021962815u, 1959779970u,
-3321382074u, 766642813u,
-204429780u, 1323319858u,
-3676032891u, 1380896111u,
-4030639049u, 3647601207u,
-1830028502u, 2830263774u,
-1375962216u, 1733961041u,
-939765180u, 521947915u,
-3903267364u, 497472767u,
-1619700946u, 189164145u,
-3115593885u, 486382294u,
-1262445920u, 4062496162u,
-2464795849u, 3770038872u,
-4032121374u, 3235740744u,
-3757765258u, 1777199847u,
-2167243108u, 1912506671u,
-4180515317u, 2276864677u,
-536034089u, 2384915026u,
-162938278u, 1588060152u,
-4018349945u, 2504457929u,
-841450426u, 2790120722u,
-2719983588u, 1471020554u,
-1390856732u, 3623212998u,
-2506944218u, 1035080801u,
-348812127u, 3026631806u,
-746483541u, 2342164722u,
-122104390u, 4074122771u,
-3986865419u, 1674890530u,
-3693306023u, 3011542850u,
-1294951725u, 899303190u,
-3577146915u, 3549160092u,
-1241677652u, 4290680005u,
-3193053279u, 2029187390u,
-3298063095u, 3943068002u,
-3946220635u, 2273781461u,
-889053698u, 1376304022u,
-1486839612u, 2127663659u,
-344127443u, 1646681121u,
-2780117810u, 2142045764u,
-2694572773u, 447810651u,
-2185527146u, 2366308558u,
-290335413u, 584901173u,
-2012370276u, 970504950u,
-3258236042u, 2008155560u,
-3945579565u, 614796295u,
-24452072u, 2695940969u,
-3983727134u, 3444688454u,
-1327044473u, 3545633451u,
-1875293322u, 1739318893u,
-1707527799u, 2683090634u,
-2848082386u, 2814622471u,
-4111401777u, 2774816580u,
-3849839194u, 437560100u,
-2238350150u, 2462124836u,
-665017710u, 512012738u,
-2945294779u, 3305170944u,
-819477765u, 59419271u,
-155125658u, 665292744u,
-444722813u, 3580039116u,
-2355675635u, 663735032u,
-3247800169u, 1579404983u,
-1985115003u, 3397891494u,
-358696453u, 1474896279u,
-516388613u, 710590371u,
-3490497111u, 2514565805u,
-2386143445u, 477509654u,
-412854590u, 3624609754u,
-3214388668u, 3516075816u,
-2731288520u, 1369482895u,
-4033204378u, 1314000850u,
-829769325u, 1935166880u,
-1608191643u, 2607067237u,
-423820371u, 3257747610u,
-1355298041u, 3776931214u,
-4105054901u, 2107080812u,
-1911521879u, 3183054185u,
-3910177801u, 675129307u,
-1209358971u, 4205727791u,
-1435726287u, 3333261712u,
-1400982708u, 1154611403u,
-1663501483u, 2837596667u,
-3164734053u, 2759854023u,
-4012043629u, 1963228038u,
-3981675284u, 2677557877u,
-520119591u, 505138315u,
-897271356u, 1803966773u,
-1016663294u, 616691903u,
-2254742522u, 4032705384u,
-2468470796u, 798395739u,
-3025169002u, 3570037122u,
-1461093710u, 3473799845u,
-3702624858u, 476400898u,
-1043039728u, 2304070437u,
-181576948u, 602972493u,
-3996616030u, 3289878097u,
-2068516226u, 3922247304u,
-1299968266u, 2520311409u,
-1968824721u, 3214794876u,
-1581813122u, 2668800905u,
-3297613974u, 748160407u,
-1145536484u, 1326769504u,
-2973323521u, 3775262814u,
-3218653169u, 902775872u,
-3498603433u, 1372805534u,
-704686363u, 3626542352u,
-2271580579u, 1213925114u,
-46329775u, 3009384989u,
-1330254048u, 1194824134u,
-514204310u, 3781981134u,
-442526164u, 2835608783u,
-3460471867u, 510634034u,
-546406434u, 2716786748u,
-2840500021u, 1669490957u,
-2536189149u, 3251421224u,
-1358736072u, 1089334066u,
-3260749330u, 250756920u,
-2974806681u, 1513718866u,
-82635635u, 4041016629u,
-3391765744u, 2495807367u,
-3962674316u, 2822889695u,
-753413337u, 2008251381u,
-3123390177u, 106212622u,
-490570565u, 1684884205u,
-793892547u, 1927268995u,
-2344148164u, 2251978818u,
-437424236u, 2774023200u,
-2674940754u, 3788056262u,
-2597882666u, 3678660147u,
-3797434193u, 3838215866u,
-279687080u, 2656772270u,
-2190204787u, 1997584981u,
-3384401882u, 3160208845u,
-3629379425u, 2668998785u,
-1050036757u, 2954162084u,
-917091826u, 1744374041u,
-1454282570u, 845687881u,
-2997173625u, 776018378u,
-1137560602u, 1938378389u,
-1748082354u, 2066910012u,
-2677675207u, 918315064u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashteTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+1140953930u, 861465670u,
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+890626835u, 800175912u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+3283896453u, 1867689945u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+1110588164u, 4186314283u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+283198166u, 2741341286u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+452473466u, 1706958772u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+236935126u, 2976578695u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+2305012065u, 2169731866u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+3058973506u, 2379411653u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+147814787u, 720739346u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+3425469811u, 3690733394u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+1635026870u, 192883107u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+3969463346u, 1436364519u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+2859809759u, 3808705738u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+4023053163u, 2650381482u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+3476440786u, 3829307897u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+2902102606u, 3600725550u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1448662590u, 397635823u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+180854224u, 2604346966u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+1669465176u, 1341975128u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+1043692997u, 1454396064u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+703505868u, 678706990u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+1933894405u, 3043213226u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+3828089804u, 3632594520u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+3729087873u, 1303930448u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3103338579u, 3064290191u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2295806711u, 1781190011u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+1968445277u, 315203929u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+440398219u, 1891630171u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+4204318635u, 441430649u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+3010839769u, 2837339569u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+4139181436u, 2993479124u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+667183474u, 2084369203u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+1016656857u, 3022024459u,
+3254014218u, 429095991u,
+990500595u, 3056862311u,
+985653208u, 1718653828u,
+623071693u, 366414107u,
+1771289760u, 2293458109u,
+3047342438u, 2991127487u,
+3120876698u, 1684583131u,
+3638043310u, 1170404994u,
+863214540u, 1087193030u,
+199124911u, 520792961u,
+3169775996u, 1577421232u,
+3331828431u, 1013201099u,
+1716848157u, 4033596884u,
+1770708857u, 4229339322u,
+1146169032u, 1434258493u,
+3824360466u, 3242407770u,
+1926419493u, 2649785113u,
+872586426u, 762243036u,
+2736953692u, 816692935u,
+1571283333u, 3555213933u,
+2266795890u, 3781899767u,
+4290630595u, 517646945u,
+3006163611u, 2180594090u,
+959214578u, 558910384u,
+1283799121u, 3047062993u,
+3830962609u, 2391606125u,
+3544509313u, 622325861u,
+834785312u, 382936554u,
+1421463872u, 788479970u,
+1825135056u, 2725923798u,
+580988377u, 2826990641u,
+247825043u, 3167748333u,
+812546227u, 2506885666u,
+2584372201u, 1758123094u,
+1891789696u, 389974094u,
+345313518u, 2022370576u,
+3886113119u, 3338548567u,
+1083486947u, 2583576230u,
+1776047957u, 1771384107u,
+3604937815u, 3198590202u,
+3027522813u, 4155628142u,
+4232136669u, 427759438u,
+4244322689u, 542201663u,
+1549591985u, 2856634168u,
+556609672u, 45845311u,
+1175961330u, 3948351189u,
+4165739882u, 4194218315u,
+1634635545u, 4151937410u,
+713127376u, 1467786451u,
+1327394015u, 2743592929u,
+2638154051u, 810082938u,
+3077742128u, 1062268187u,
+4084325664u, 3810665822u,
+3735739145u, 2794294783u,
+2335576331u, 2560479831u,
+690240711u, 997658837u,
+2442302747u, 3948961926u,
+3958366652u, 3067277639u,
+2059157774u, 1211737169u,
+1516711748u, 2339636583u,
+4188504038u, 59581167u,
+2767897792u, 1389679610u,
+2658147000u, 2643979752u,
+3758739543u, 4189944477u,
+1454470782u, 100876854u,
+2995362413u, 118817200u,
+3252925478u, 2062343506u,
+2804483644u, 3088828656u,
+1231633714u, 4168280671u,
+2931588131u, 3284356565u,
+1255909792u, 3130054947u,
+4173605289u, 1407328702u,
+1677744031u, 3532596884u,
+3162657845u, 3887208531u,
+2256541290u, 3459463480u,
+3740979556u, 259034107u,
+392987633u, 3233195759u,
+3606709555u, 3424793077u,
+315836068u, 3200749877u,
+4065431359u, 760633989u,
+2982018998u, 1811050648u,
+234531934u, 1115203611u,
+3897494162u, 1516407838u,
+1603559457u, 323296368u,
+2632963283u, 1778459926u,
+2879836826u, 2146672889u,
+3486330348u, 492621815u,
+1231665285u, 2457048126u,
+3438440082u, 2217471853u,
+3355404249u, 3275550588u,
+1052645068u, 862072556u,
+4110617119u, 3745267835u,
+2657392572u, 4279236653u,
+1688445808u, 701920051u,
+956734128u, 581695350u,
+3157862788u, 2585726058u,
+1192588249u, 1410111809u,
+1651193125u, 3326135446u,
+1073280453u, 97376972u,
+2513844237u, 2187968410u,
+3976859649u, 4267859263u,
+3429034542u, 564493077u,
+3000537321u, 479241367u,
+3845637831u, 2868987960u,
+51544337u, 1029173765u,
+393624922u, 704325635u,
+2357610553u, 1418509533u,
+2007814586u, 3866658271u,
+3082385053u, 735688735u,
+916110004u, 3283299459u,
+1051684175u, 1083796807u,
+4074716319u, 813690332u,
+144264390u, 1439630796u,
+1508556987u, 675582689u,
+3748881891u, 3195309868u,
+362884708u, 1616408198u,
+43233176u, 837301135u,
+881504822u, 3254795114u,
+1385506591u, 2799925823u,
+1469874582u, 3464841997u,
+497175391u, 3929484338u,
+3975771289u, 1798536177u,
+2926265846u, 1374242438u,
+3675707838u, 4205965408u,
+3153165629u, 1499475160u,
+187287713u, 548490821u,
+3255259608u, 4247675634u,
+1940181471u, 3779953975u,
+687167150u, 2319566715u,
+1742785722u, 785893184u,
+2296977392u, 2778575413u,
+1794720651u, 48131484u,
+4084891412u, 1160134629u,
+3737623280u, 823113169u,
+3423207646u, 3803213486u,
+710625654u, 4116162021u,
+3693420287u, 4167766971u,
+1666602807u, 295320990u,
+3513255468u, 2487440590u,
+234080704u, 4004655503u,
+2971762528u, 1479656873u,
+4090178629u, 4044418876u,
+391947536u, 1462554406u,
+3909295855u, 1239580330u,
+1515601363u, 2011102035u,
+1442068334u, 4265993528u,
+1191921695u, 2291355695u,
+4257172787u, 576405853u,
+314332944u, 4038839101u,
+55559918u, 2378985842u,
+711098718u, 2425317635u,
+1644327317u, 1401013391u,
+4193760037u, 2958260436u,
+3167371443u, 3062418115u,
+3800755475u, 3167030094u,
+3489648204u, 1405430357u,
+526177822u, 2602636307u,
+915406019u, 4264167741u,
+1484090483u, 3070944737u,
+254529415u, 4017058800u,
+1702710265u, 1029665228u,
+2000382906u, 3185573940u,
+1381258384u, 4036354071u,
+2900841028u, 2670703363u,
+2921748807u, 2899069938u,
+4130543625u, 688472265u,
+4186808827u, 1054670286u,
+1132985391u, 2840525968u,
+4175776103u, 338058159u,
+1735964501u, 1539305024u,
+3497121710u, 1568260669u,
+2227290760u, 146827036u,
+3977176001u, 4060134777u,
+857488494u, 250055052u,
+4284109679u, 2502815838u,
+2592281721u, 1603444633u,
+1390562014u, 1556658131u,
+616327404u, 2448966429u,
+3051191726u, 3891353218u,
+1213304082u, 762328245u,
+2239052397u, 1082330589u,
+2455957292u, 201837927u,
+405397452u, 3079886794u,
+2583939798u, 2848283092u,
+3750724631u, 883849006u,
+3204198988u, 3341327098u,
+1855234968u, 1982110346u,
+1485529487u, 541496720u,
+4117290321u, 3607433551u,
+2168864636u, 133643215u,
+1055817409u, 3847827123u,
+2960769387u, 4046101649u,
+1176127003u, 4015671361u,
+4243643405u, 2849988118u,
+517111221u, 1796672358u,
+2045051700u, 3452457457u,
+2948254999u, 2102063419u,
+1556410577u, 1536380876u,
+3776661467u, 3281002516u,
+1735616066u, 1539151988u,
+1087795162u, 3332431596u,
+685631442u, 1147951686u,
+95237878u, 2005032160u,
+4012206915u, 4224354805u,
+3204999386u, 2415262714u,
+1433635018u, 116647396u,
+83167836u, 2881562655u,
+2729416454u, 1029284767u,
+881378302u, 2159170082u,
+555057366u, 1169104445u,
+3963877000u, 1919171906u,
+336034862u, 2017579106u,
+4059340529u, 3020819343u,
+865146997u, 2473524405u,
+944743644u, 1694443528u,
+1804513294u, 2904752429u,
+617975720u, 3671562289u,
+260177668u, 505662155u,
+1885941445u, 2504509403u,
+2260041112u, 1019936943u,
+3722741628u, 1511077569u,
+3100701179u, 1379422864u,
+1535670711u, 773792826u,
+1103819072u, 2089123665u,
+1157547425u, 329152940u,
+4142587430u, 484732447u,
+2475035432u, 1120017626u,
+412145504u, 965125959u,
+324924679u, 2809286837u,
+2842141483u, 4029205195u,
+2974306813u, 515627448u,
+3791551981u, 1097806406u,
+3873078673u, 136118734u,
+1872130856u, 3632422367u,
+3574135531u, 4017075736u,
+1699452298u, 1403506686u,
+344414660u, 1189129691u,
+3487080616u, 1516736273u,
+1805475756u, 2562064338u,
+163335594u, 2732147834u,
+4077452507u, 2984955003u,
+4271866024u, 3071338162u,
+2347111903u, 873829983u,
+1948409509u, 1923531348u,
+459509140u, 771592405u,
+1750124750u, 2334938333u,
+213811117u, 2586632018u,
+185232757u, 4032960199u,
+2447383637u, 284777551u,
+1654276320u, 2687561076u,
+3512945009u, 308584855u,
+1861027147u, 4102279334u,
+3203802620u, 1692079268u,
+4250142168u, 2565680167u,
+1507046104u, 841195925u,
+520565830u, 3674576684u,
+38924274u, 3770488806u,
+2414430882u, 3978473838u,
+3703994407u, 69201295u,
+3099963860u, 1255084262u,
+690971838u, 3539996781u,
+3696902571u, 3593730713u,
+2363435042u, 54945052u,
+1785765213u, 184911581u,
+1586241476u, 1939595371u,
+2534883189u, 2432427547u,
+2374171993u, 2039128933u,
+2955715987u, 2295501078u,
+2741583197u, 1280920000u,
+686818699u, 1238742497u,
+3843660102u, 82177963u,
+1281043691u, 1121403845u,
+1697846708u, 284852964u,
+278661677u, 2889101923u,
+2127558730u, 713121337u,
+872502474u, 511142139u,
+1261140657u, 1747052377u,
+2108187161u, 927011680u,
+955328267u, 3821994995u,
+2707230761u, 4142246789u,
+4134691985u, 1958963937u,
+2498463509u, 1977988705u,
+1419293714u, 1636932722u,
+2567532373u, 4075249328u,
+240575705u, 1956681213u,
+2598802768u, 2025886508u,
+4104757832u, 3026358429u,
+3242615202u, 4026813725u,
+255108733u, 1845587644u,
+3573008472u, 3615577014u,
+1222733548u, 1205557630u,
+917608574u, 1363253259u,
+1541946015u, 3087190425u,
+1138008081u, 1444019663u,
+109793386u, 341851980u,
+857839960u, 2515339233u,
+156283211u, 1906768669u,
+3886713057u, 1276595523u,
+2809830736u, 460237542u,
+3420452099u, 142985419u,
+205970448u, 4198897105u,
+1950698961u, 2069753399u,
+1142216925u, 1113051162u,
+1033680610u, 4278599955u,
+1106466069u, 356742959u,
+531521052u, 3494863964u,
+225629455u, 3735275001u,
+3662626864u, 1750561299u,
+1012864651u, 2101846429u,
+1074553219u, 668829411u,
+992181339u, 3384018814u,
+3330664522u, 860966321u,
+1885071395u, 4233785523u,
+100741310u, 451656820u,
+2148187612u, 1063001151u,
+360256231u, 107312677u,
+3650357479u, 2390172694u,
+22452685u, 237319043u,
+3600462351u, 1216645846u,
+2088767754u, 164402616u,
+2418980170u, 926137824u,
+94638678u, 1689811113u,
+2751052984u, 1767810825u,
+271289013u, 3896132233u,
+103797041u, 1397772514u,
+3441135892u, 3323383489u,
+2491268371u, 1662561885u,
+1612872497u, 2986430557u,
+2756998822u, 207428029u,
+937973965u, 2791656726u,
+1949717207u, 2260498180u,
+2648427775u, 2360400900u,
+2080496169u, 486358863u,
+1582022990u, 1263709570u,
+1396468647u, 1377764574u,
+363008508u, 1293502429u,
+224580012u, 4252610345u,
+1435134775u, 1099809675u,
+533671980u, 1533438766u,
+1820532305u, 2776960536u,
+3374512975u, 3542220540u,
+822810075u, 3716663290u,
+1157398049u, 3752806924u,
+4081637863u, 337070226u,
+3866585976u, 359270190u,
+2110942730u, 3267551635u,
+644850146u, 1306761320u,
+746972907u, 934259457u,
+2341378668u, 2220373824u,
+1242645122u, 4109252858u,
+1625266099u, 1173698481u,
+383517064u, 896322512u,
+3377483696u, 1788337208u,
+455496839u, 3194373887u,
+1837689083u, 1336556841u,
+1658628529u, 2911512007u,
+3838343487u, 2757664765u,
+1537187340u, 3712582785u,
+367022558u, 3071359622u,
+3926147070u, 35432879u,
+3093195926u, 2561488770u,
+4273132307u, 3898950547u,
+2838251049u, 2103926083u,
+2549435227u, 536047554u,
+1858986613u, 2040551642u,
+1147412575u, 1972369852u,
+4166184983u, 3528794619u,
+4077477194u, 3565689036u,
+808048238u, 3826350461u,
+1359641525u, 1197100813u,
+265993036u, 1864569342u,
+725164342u, 2264788336u,
+1831223342u, 3329594980u,
+923017956u, 490608221u,
+3818634478u, 258154469u,
+1441714797u, 1174785921u,
+3833372385u, 3287246572u,
+1677395563u, 3569218731u,
+868981704u, 2163330264u,
+2649450292u, 500120236u,
+465161780u, 746438382u,
+1145009669u, 2520062970u,
+2810524030u, 1561519055u,
+1479878006u, 3864969305u,
+2686075657u, 4042710240u,
+3224066062u, 2774151984u,
+2226179547u, 1643626042u,
+2328730865u, 3160666939u,
+2107011431u, 96459446u,
+3920328742u, 3336407558u,
+829404209u, 1878067032u,
+1235983679u, 4237425634u,
+466519055u, 3870676863u,
+934312076u, 2952135524u,
+276949224u, 4100839753u,
+424001484u, 1955120893u,
+4015478120u, 1265237690u,
+427484362u, 4246879223u,
+3452969617u, 1724363362u,
+1553513184u, 834830418u,
+1858777639u, 3476334357u,
+4144030366u, 2450047160u,
+2950762705u, 4277111759u,
+358032121u, 2511026735u,
+167923105u, 2059208280u,
+251949572u, 3065234219u,
+1535473864u, 556796152u,
+1513237478u, 3150857516u,
+1103404394u, 198182691u,
+1476438092u, 2913077464u,
+207119516u, 3963810232u,
+2954651680u, 1535115487u,
+3051522276u, 4046477658u,
+917804636u, 864395565u,
+632704095u, 140762681u,
+1802040304u, 990407433u,
+3771506212u, 4106024923u,
+1287729497u, 2198985327u,
+4052924496u, 2926590471u,
+3084557148u, 1472898694u,
+1009870118u, 559702706u,
+4265214507u, 82077489u,
+3067891003u, 3295678907u,
+2402308151u, 1096697687u,
+464407878u, 4190838199u,
+4269578403u, 3060919438u,
+2899950405u, 3046872820u,
+733509243u, 1583801700u,
+40453902u, 3879773881u,
+1993425202u, 2185339100u,
+1877837196u, 3912423882u,
+3293122640u, 4104318469u,
+1679617763u, 3703603898u,
+8759461u, 2540185277u,
+1152198475u, 2038345882u,
+2503579743u, 1446869792u,
+2019419351u, 4051584612u,
+3178289407u, 3992503830u,
+2879018745u, 2719373510u,
+700836153u, 1675560450u,
+4121245793u, 2064715719u,
+343595772u, 1996164093u,
+3130433948u, 405251683u,
+2804817126u, 1607133689u,
+463852893u, 2864244470u,
+2224044848u, 4071581802u,
+2537107938u, 2246347953u,
+3207234525u, 2028708916u,
+2272418128u, 803575837u,
+38655481u, 2170452091u,
+3272166407u, 557660441u,
+4019147902u, 3841480082u,
+298459606u, 2600943364u,
+2440657523u, 255451671u,
+3424361375u, 779434428u,
+3088526123u, 490671625u,
+1322855877u, 3452203069u,
+3057021940u, 2285701422u,
+2014993457u, 2390431709u,
+2002090272u, 1568745354u,
+1783152480u, 823305654u,
+4053862835u, 2200236540u,
+3009412313u, 3184047862u,
+3032187389u, 4159715581u,
+2966902888u, 252986948u,
+1849329144u, 3160134214u,
+3420960112u, 3198900547u,
+749160960u, 379139040u,
+1208883495u, 1566527339u,
+3006227299u, 4194096960u,
+556075248u, 497404038u,
+1717327230u, 1496132623u,
+1775955687u, 1719108984u,
+1014328900u, 4189966956u,
+2108574735u, 2584236470u,
+684087286u, 531310503u,
+4264509527u, 773405691u,
+3088905079u, 3456882941u,
+3105682208u, 3382290593u,
+2289363624u, 3296306400u,
+4168438718u, 467441309u,
+777173623u, 3241407531u,
+1183994815u, 1132983260u,
+1610606159u, 2540270567u,
+2649684057u, 1397502982u,
+146657385u, 3318434267u,
+2109315753u, 3348545480u,
+3193669211u, 811750340u,
+1073256162u, 3571673088u,
+546596661u, 1017047954u,
+3403136990u, 2540585554u,
+1477047647u, 4145867423u,
+2826408201u, 3531646869u,
+784952939u, 943914610u,
+2717443875u, 3657384638u,
+1806867885u, 1903578924u,
+3985088434u, 1911188923u,
+1764002686u, 3672748083u,
+1832925325u, 241574049u,
+519948041u, 3181425568u,
+2939747257u, 1634174593u,
+3429894862u, 3529565564u,
+1089679033u, 240953857u,
+2025369941u, 2695166650u,
+517086873u, 2964595704u,
+3017658263u, 3828377737u,
+2144895011u, 994799311u,
+1184683823u, 4260564140u,
+308018483u, 4262383425u,
+1374752558u, 3431057723u,
+1572637805u, 383233885u,
+3188015819u, 4051263539u,
+233319221u, 3794788167u,
+2017406667u, 919677938u,
+4074952232u, 1683612329u,
+4213676186u, 327142514u,
+3032591014u, 4204155962u,
+206775997u, 2283918569u,
+2395147154u, 3427505379u,
+2211319468u, 4153726847u,
+2217060665u, 350160869u,
+2493667051u, 1648200185u,
+3441709766u, 1387233546u,
+140980u, 1891558063u,
+760080239u, 2088061981u,
+1580964938u, 740563169u,
+422986366u, 330624974u,
+4264507722u, 150928357u,
+2738323042u, 2948665536u,
+918718096u, 376390582u,
+3966098971u, 717653678u,
+3219466255u, 3799363969u,
+3424344721u, 3187805406u,
+375347278u, 3490350144u,
+1992212097u, 2263421398u,
+3855037968u, 1928519266u,
+3866327955u, 1129127000u,
+1782515131u, 2746577402u,
+3059200728u, 2108753646u,
+2738070963u, 1336849395u,
+1705302106u, 768287270u,
+1343511943u, 2247006571u,
+1956142255u, 1780259453u,
+3475618043u, 212490675u,
+622521957u, 917121602u,
+1852992332u, 1267987847u,
+3170016833u, 2549835613u,
+3299763344u, 2864033668u,
+3378768767u, 1236609378u,
+4169365948u, 3738062408u,
+2661022773u, 2006922227u,
+2760592161u, 3828932355u,
+2636387819u, 2616619070u,
+1237256330u, 3449066284u,
+2871755260u, 3729280948u,
+3862686086u, 431292293u,
+3285899651u, 786322314u,
+2531158535u, 724901242u,
+2377363130u, 1415970351u,
+1244759631u, 3263135197u,
+965248856u, 174024139u,
+2297418515u, 2954777083u,
+987586766u, 3206261120u,
+4059515114u, 3903854066u,
+1931934525u, 2287507921u,
+1827135136u, 1781944746u,
+574617451u, 2299034788u,
+2650140034u, 4081586725u,
+2482286699u, 1109175923u,
+458483596u, 618705848u,
+4059852729u, 1813855658u,
+4190721328u, 1129462471u,
+4089998050u, 3575732749u,
+2375584220u, 1037031473u,
+1623777358u, 3389003793u,
+546597541u, 352770237u,
+1383747654u, 3122687303u,
+1646071378u, 1164309901u,
+290870767u, 830691298u,
+929335420u, 3193251135u,
+989577914u, 3626554867u,
+591974737u, 3996958215u,
+3163711272u, 3071568023u,
+1516846461u, 3656006011u,
+2698625268u, 2510865430u,
+340274176u, 1167681812u,
+3698796465u, 3155218919u,
+4102288238u, 1673474350u,
+3069708839u, 2704165015u,
+1237411891u, 1854985978u,
+3646837503u, 3625406022u,
+921552000u, 1712976649u,
+3939149151u, 878608872u,
+3406359248u, 1068844551u,
+1834682077u, 4155949943u,
+2437686324u, 3163786257u,
+2645117577u, 1988168803u,
+747285578u, 1626463554u,
+1235300371u, 1256485167u,
+1914142538u, 4141546431u,
+3838102563u, 582664250u,
+1883344352u, 2083771672u,
+2611657933u, 2139079047u,
+2250573853u, 804336148u,
+3066325351u, 2770847216u,
+4275641370u, 1455750577u,
+3346357270u, 1674051445u,
+601221482u, 3992583643u,
+1402445097u, 3622527604u,
+2509017299u, 2966108111u,
+2557027816u, 900741486u,
+1790771021u, 2912643797u,
+2631381069u, 4014551783u,
+90375300u, 300318232u,
+3269968032u, 2679371729u,
+2664752123u, 3517585534u,
+3253901179u, 542270815u,
+1188641600u, 365479232u,
+2210121140u, 760762191u,
+1273768482u, 1216399252u,
+3484324231u, 4287337666u,
+16322182u, 643179562u,
+325675502u, 3652676161u,
+3120716054u, 3330259752u,
+1011990087u, 2990167340u,
+1097584090u, 3262252593u,
+1829409951u, 3665087267u,
+1214854475u, 2134299399u,
+3704419305u, 411263051u,
+1625446136u, 549838529u,
+4283196353u, 1342880802u,
+3460621305u, 1967599860u,
+4282843369u, 1275671016u,
+2544665755u, 853593042u,
+901109753u, 2682611693u,
+110631633u, 797487791u,
+1472073141u, 850464484u,
+797089608u, 3286110054u,
+350397471u, 2775631060u,
+366448238u, 3842907484u,
+2219863904u, 3623364733u,
+1850985302u, 4009616991u,
+294963924u, 3693536939u,
+3061255808u, 1615375832u,
+1920066675u, 4113028420u,
+4032223840u, 2318423400u,
+2701956286u, 4145497671u,
+3991532344u, 2536338351u,
+1679099863u, 1728968857u,
+449740816u, 2686506989u,
+685242457u, 97590863u,
+3258354115u, 1502282913u,
+1235084019u, 2151665147u,
+528459289u, 231097464u,
+2477280726u, 3651607391u,
+2091754612u, 1178454681u,
+980597335u, 1604483865u,
+1842333726u, 4146839064u,
+3213794286u, 2601416506u,
+754220096u, 3571436033u,
+488595746u, 1448097974u,
+4004834921u, 238887261u,
+3320337489u, 1416989070u,
+2928916831u, 4093725287u,
+186020771u, 2367569534u,
+3046087671u, 4090084518u,
+3548184546u, 679517009u,
+1962659444u, 3539886328u,
+4192003933u, 1678423485u,
+3827951761u, 3086277222u,
+2144472852u, 1390394371u,
+2976322029u, 1574517163u,
+3553313841u, 119173722u,
+1702434637u, 1766260771u,
+3629581771u, 1407497759u,
+895654784u, 751439914u,
+4008409498u, 215917713u,
+1482103833u, 695551833u,
+1288382231u, 2656990891u,
+2581779077u, 1570750352u,
+3710689053u, 1741390464u,
+2666411616u, 3533987737u,
+4289478316u, 3576119563u,
+4118694920u, 108199666u,
+3869794273u, 963183826u,
+2081410737u, 3796810515u,
+791123882u, 2525792704u,
+1036883117u, 136547246u,
+875691100u, 2592925324u,
+614302599u, 3013176417u,
+2689342539u, 427154472u,
+532957601u, 1228758574u,
+1898117151u, 1181643858u,
+1908591042u, 1464255968u,
+446980910u, 2984611177u,
+58509511u, 1046943619u,
+3508927906u, 2001585786u,
+2544767379u, 1525438381u,
+552181222u, 1959725830u,
+879448844u, 1348536411u,
+4242243590u, 2861338018u,
+1082052441u, 1034351453u,
+601175800u, 764077711u,
+530635011u, 3785343245u,
+2178026726u, 117256687u,
+2378297261u, 457568934u,
+76438221u, 4104954272u,
+956793873u, 3783168634u,
+2485968477u, 2381948487u,
+4226929450u, 3148473363u,
+2518273601u, 3569490233u,
+879369091u, 2180270337u,
+3674375989u, 1387729170u,
+977997984u, 4270646856u,
+568650985u, 951677556u,
+4213877384u, 2721005055u,
+1073364549u, 2563403831u,
+1678669911u, 66786703u,
+2273631661u, 1149351924u,
+3651298990u, 1581883443u,
+246723096u, 1895026827u,
+3810605772u, 3711056516u,
+4058833288u, 2193790614u,
+2080120290u, 3638638708u,
+2915672708u, 2263003308u,
+2361934197u, 4136767460u,
+1976115991u, 3448840877u,
+2019238520u, 225333538u,
+874340815u, 2976159827u,
+1555273378u, 3797521928u,
+1942347150u, 3262952567u,
+435997738u, 340403353u,
+2817830907u, 2078619498u,
+749534111u, 1178073973u,
+894654712u, 3361226032u,
+841092198u, 3288261538u,
+1696412169u, 1496966875u,
+697501571u, 1059158875u,
+3739946319u, 2481012988u,
+568983526u, 114945840u,
+1559249010u, 2218244008u,
+2841706923u, 1632780103u,
+4020169654u, 2087949619u,
+2438736103u, 24032648u,
+833416317u, 3787017905u,
+2373238993u, 2575395164u,
+3434544481u, 3228481067u,
+2542976862u, 2971726178u,
+2880371864u, 3642087909u,
+2407477975u, 2239080836u,
+1043714217u, 3894199764u,
+2235879182u, 203853421u,
+2933669448u, 2504940536u,
+834683330u, 425935223u,
+3560796393u, 3565833278u,
+1668000829u, 3683399154u,
+3414330886u, 1748785729u,
+1023171602u, 580966986u,
+2531038985u, 3227325488u,
+2657385925u, 2124704694u,
+233442446u, 1107045577u,
+3407293834u, 552770757u,
+3899097693u, 1067532701u,
+115667924u, 1406028344u,
+1707768231u, 3724015962u,
+2419657149u, 18613994u,
+2532882091u, 3476683808u,
+1560838678u, 811220224u,
+895961699u, 3762914298u,
+1328752423u, 1844996900u,
+1420427894u, 1848067707u,
+1210281744u, 904215228u,
+4055325594u, 1118521573u,
+2496554183u, 2579259919u,
+3996647489u, 3657647605u,
+325254059u, 3136157065u,
+3951522674u, 4052925250u,
+3341068436u, 2287683323u,
+1313073005u, 126005630u,
+2505120084u, 1194725057u,
+853746559u, 3555092974u,
+2689238752u, 49515858u,
+1244776042u, 1069300695u,
+61073168u, 1010661841u,
+1269521335u, 1902040126u,
+990632502u, 2378708922u,
+3858321250u, 1400735275u,
+2974699176u, 2771676666u,
+170995186u, 2877798589u,
+545726212u, 2225229957u,
+1086473152u, 3454177594u,
+3859483262u, 1499729584u,
+2088002891u, 2883475137u,
+3222194252u, 4144472319u,
+2212229854u, 4146740722u,
+567988835u, 1051332394u,
+3932046135u, 542648229u,
+3017852446u, 1277887997u,
+162888005u, 1669710469u,
+1492500905u, 553041029u,
+1434876932u, 533989516u,
+3817492747u, 584127807u,
+4147115982u, 2993670925u,
+4020312558u, 710021255u,
+3509733475u, 3587959456u,
+2088550465u, 1745399498u,
+2952242967u, 1259815443u,
+869648362u, 1404723176u,
+3947542735u, 1334333531u,
+3873471582u, 229399758u,
+59634866u, 3239516985u,
+3844250972u, 1275954779u,
+492891666u, 1029533080u,
+1552951157u, 367320647u,
+699480890u, 3684418197u,
+3707014310u, 471105777u,
+1824587258u, 4030809053u,
+3489914436u, 484559105u,
+1235750398u, 1428453396u,
+4230459084u, 4255931645u,
+1848597055u, 4271715616u,
+331780381u, 482425775u,
+2435323270u, 3171911678u,
+3507210587u, 928543347u,
+4197807526u, 3680046204u,
+2766042024u, 2159512867u,
+179373257u, 313902234u,
+4024837592u, 294795361u,
+1622282562u, 647086234u,
+2825039429u, 577214736u,
+4043412446u, 2426981244u,
+1277736097u, 1130129573u,
+2601395338u, 995791646u,
+36668922u, 3344746679u,
+1521532225u, 1645086060u,
+2622763015u, 4122335794u,
+2936887705u, 494465807u,
+2580840343u, 1064648931u,
+1247887787u, 2752145076u,
+1277612417u, 1249660507u,
+2288678613u, 3312498873u,
+2459273912u, 4238535494u,
+3117488020u, 2571979978u,
+2680188909u, 1471227427u,
+1616494033u, 633688562u,
+2268653416u, 3268237290u,
+3021962815u, 1959779970u,
+3321382074u, 766642813u,
+204429780u, 1323319858u,
+3676032891u, 1380896111u,
+4030639049u, 3647601207u,
+1830028502u, 2830263774u,
+1375962216u, 1733961041u,
+939765180u, 521947915u,
+3903267364u, 497472767u,
+1619700946u, 189164145u,
+3115593885u, 486382294u,
+1262445920u, 4062496162u,
+2464795849u, 3770038872u,
+4032121374u, 3235740744u,
+3757765258u, 1777199847u,
+2167243108u, 1912506671u,
+4180515317u, 2276864677u,
+536034089u, 2384915026u,
+162938278u, 1588060152u,
+4018349945u, 2504457929u,
+841450426u, 2790120722u,
+2719983588u, 1471020554u,
+1390856732u, 3623212998u,
+2506944218u, 1035080801u,
+348812127u, 3026631806u,
+746483541u, 2342164722u,
+122104390u, 4074122771u,
+3986865419u, 1674890530u,
+3693306023u, 3011542850u,
+1294951725u, 899303190u,
+3577146915u, 3549160092u,
+1241677652u, 4290680005u,
+3193053279u, 2029187390u,
+3298063095u, 3943068002u,
+3946220635u, 2273781461u,
+889053698u, 1376304022u,
+1486839612u, 2127663659u,
+344127443u, 1646681121u,
+2780117810u, 2142045764u,
+2694572773u, 447810651u,
+2185527146u, 2366308558u,
+290335413u, 584901173u,
+2012370276u, 970504950u,
+3258236042u, 2008155560u,
+3945579565u, 614796295u,
+24452072u, 2695940969u,
+3983727134u, 3444688454u,
+1327044473u, 3545633451u,
+1875293322u, 1739318893u,
+1707527799u, 2683090634u,
+2848082386u, 2814622471u,
+4111401777u, 2774816580u,
+3849839194u, 437560100u,
+2238350150u, 2462124836u,
+665017710u, 512012738u,
+2945294779u, 3305170944u,
+819477765u, 59419271u,
+155125658u, 665292744u,
+444722813u, 3580039116u,
+2355675635u, 663735032u,
+3247800169u, 1579404983u,
+1985115003u, 3397891494u,
+358696453u, 1474896279u,
+516388613u, 710590371u,
+3490497111u, 2514565805u,
+2386143445u, 477509654u,
+412854590u, 3624609754u,
+3214388668u, 3516075816u,
+2731288520u, 1369482895u,
+4033204378u, 1314000850u,
+829769325u, 1935166880u,
+1608191643u, 2607067237u,
+423820371u, 3257747610u,
+1355298041u, 3776931214u,
+4105054901u, 2107080812u,
+1911521879u, 3183054185u,
+3910177801u, 675129307u,
+1209358971u, 4205727791u,
+1435726287u, 3333261712u,
+1400982708u, 1154611403u,
+1663501483u, 2837596667u,
+3164734053u, 2759854023u,
+4012043629u, 1963228038u,
+3981675284u, 2677557877u,
+520119591u, 505138315u,
+897271356u, 1803966773u,
+1016663294u, 616691903u,
+2254742522u, 4032705384u,
+2468470796u, 798395739u,
+3025169002u, 3570037122u,
+1461093710u, 3473799845u,
+3702624858u, 476400898u,
+1043039728u, 2304070437u,
+181576948u, 602972493u,
+3996616030u, 3289878097u,
+2068516226u, 3922247304u,
+1299968266u, 2520311409u,
+1968824721u, 3214794876u,
+1581813122u, 2668800905u,
+3297613974u, 748160407u,
+1145536484u, 1326769504u,
+2973323521u, 3775262814u,
+3218653169u, 902775872u,
+3498603433u, 1372805534u,
+704686363u, 3626542352u,
+2271580579u, 1213925114u,
+46329775u, 3009384989u,
+1330254048u, 1194824134u,
+514204310u, 3781981134u,
+442526164u, 2835608783u,
+3460471867u, 510634034u,
+546406434u, 2716786748u,
+2840500021u, 1669490957u,
+2536189149u, 3251421224u,
+1358736072u, 1089334066u,
+3260749330u, 250756920u,
+2974806681u, 1513718866u,
+82635635u, 4041016629u,
+3391765744u, 2495807367u,
+3962674316u, 2822889695u,
+753413337u, 2008251381u,
+3123390177u, 106212622u,
+490570565u, 1684884205u,
+793892547u, 1927268995u,
+2344148164u, 2251978818u,
+437424236u, 2774023200u,
+2674940754u, 3788056262u,
+2597882666u, 3678660147u,
+3797434193u, 3838215866u,
+279687080u, 2656772270u,
+2190204787u, 1997584981u,
+3384401882u, 3160208845u,
+3629379425u, 2668998785u,
+1050036757u, 2954162084u,
+917091826u, 1744374041u,
+1454282570u, 845687881u,
+2997173625u, 776018378u,
+1137560602u, 1938378389u,
+1748082354u, 2066910012u,
+2677675207u, 918315064u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; { uint64_t h = farmhashte::Hash64WithSeeds(farm_hash_data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64WithSeed(farm_hash_data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64(farm_hash_data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
{ uint64_t h = farmhashte::Hash64WithSeeds(farm_hash_data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
{ uint64_t h = farmhashte::Hash64WithSeed(farm_hash_data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
{ uint64_t h = farmhashte::Hash64(farm_hash_data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashteTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashteTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
{ uint64_t h = farmhashte::Hash64WithSeeds(farm_hash_data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint64_t h = farmhashte::Hash64WithSeed(farm_hash_data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint64_t h = farmhashte::Hash64(farm_hash_data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashteTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashteTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashteTest::Dump(0, i);
- }
- farmhashteTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashteTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashteTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashteTest::Dump(0, i);
+ }
+ farmhashteTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashuoTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-3254014218u, 429095991u,
-165589978u, 1578546616u,
-623071693u, 366414107u,
-249776086u, 1207522198u,
-3120876698u, 1684583131u,
-46987739u, 1157614300u,
-199124911u, 520792961u,
-3614377032u, 586863115u,
-1716848157u, 4033596884u,
-1164298657u, 4140791139u,
-3824360466u, 3242407770u,
-3725511003u, 232064808u,
-2736953692u, 816692935u,
-512845449u, 3748861010u,
-4290630595u, 517646945u,
-22638523u, 648000590u,
-1283799121u, 3047062993u,
-1024246061u, 4027776454u,
-834785312u, 382936554u,
-411505255u, 1973395102u,
-580988377u, 2826990641u,
-3474970689u, 1029055034u,
-2584372201u, 1758123094u,
-589567754u, 325737734u,
-3886113119u, 3338548567u,
-257578986u, 3698087965u,
-3604937815u, 3198590202u,
-2305332220u, 191910725u,
-4244322689u, 542201663u,
-3315355162u, 2135941665u,
-1175961330u, 3948351189u,
-23075771u, 3252374102u,
-713127376u, 1467786451u,
-663013031u, 3444053918u,
-3077742128u, 1062268187u,
-2115441882u, 4081398201u,
-2335576331u, 2560479831u,
-1379288194u, 4225182569u,
-3958366652u, 3067277639u,
-3667516477u, 1709989541u,
-4188504038u, 59581167u,
-2725013602u, 3639843023u,
-3758739543u, 4189944477u,
-2470483982u, 877580602u,
-3252925478u, 2062343506u,
-3981838403u, 3762572073u,
-2931588131u, 3284356565u,
-1129162571u, 732225574u,
-1677744031u, 3532596884u,
-3232041815u, 1652884780u,
-3740979556u, 259034107u,
-2227121257u, 1426140634u,
-315836068u, 3200749877u,
-1386256573u, 24035717u,
-234531934u, 1115203611u,
-1598686658u, 3146815575u,
-2632963283u, 1778459926u,
-739944537u, 579625482u,
-1231665285u, 2457048126u,
-3903349120u, 389846205u,
-1052645068u, 862072556u,
-2834153464u, 1481069623u,
-1688445808u, 701920051u,
-3740748788u, 3388062747u,
-1192588249u, 1410111809u,
-2633463887u, 4050419847u,
-2513844237u, 2187968410u,
-2951683019u, 3015806005u,
-3000537321u, 479241367u,
-252167538u, 1231057113u,
-393624922u, 704325635u,
-1467197045u, 2066433573u,
-3082385053u, 735688735u,
-956434529u, 4028590195u,
-4074716319u, 813690332u,
-2124740535u, 804073145u,
-3748881891u, 3195309868u,
-841856605u, 2585865274u,
-881504822u, 3254795114u,
-1241815736u, 970796142u,
-497175391u, 3929484338u,
-4264993211u, 1835322201u,
-3675707838u, 4205965408u,
-300298607u, 3858319990u,
-3255259608u, 4247675634u,
-1095823272u, 1197245408u,
-1742785722u, 785893184u,
-1702965674u, 850401405u,
-4084891412u, 1160134629u,
-2555998391u, 1972759056u,
-710625654u, 4116162021u,
-3352753742u, 85121177u,
-3513255468u, 2487440590u,
-2480032715u, 2287747045u,
-4090178629u, 4044418876u,
-1703944517u, 486290428u,
-1515601363u, 2011102035u,
-573985957u, 3536053779u,
-4257172787u, 576405853u,
-1523550693u, 1014952061u,
-711098718u, 2425317635u,
-3460807169u, 3688987163u,
-3167371443u, 3062418115u,
-3330028292u, 1713171303u,
-526177822u, 2602636307u,
-1245357025u, 3346699703u,
-254529415u, 4017058800u,
-1829738451u, 2164236533u,
-1381258384u, 4036354071u,
-1749181924u, 4118435443u,
-4130543625u, 688472265u,
-2731071299u, 2547657502u,
-4175776103u, 338058159u,
-3729582129u, 4181845558u,
-2227290760u, 146827036u,
-2459178427u, 1025353883u,
-4284109679u, 2502815838u,
-825124804u, 2533140036u,
-616327404u, 2448966429u,
-413992636u, 2334782461u,
-2239052397u, 1082330589u,
-3381164715u, 199381437u,
-2583939798u, 2848283092u,
-2300168091u, 2156336315u,
-1855234968u, 1982110346u,
-2482046810u, 3158163887u,
-2168864636u, 133643215u,
-3904021624u, 3646514568u,
-1176127003u, 4015671361u,
-100525019u, 3534706803u,
-2045051700u, 3452457457u,
-1492267772u, 2308393828u,
-3776661467u, 3281002516u,
-4246334524u, 743955039u,
-685631442u, 1147951686u,
-2040912376u, 2911148054u,
-3204999386u, 2415262714u,
-313209105u, 777065474u,
-2729416454u, 1029284767u,
-1632078298u, 1817552554u,
-3963877000u, 1919171906u,
-3843219958u, 3073580867u,
-865146997u, 2473524405u,
-2593817617u, 3643076308u,
-617975720u, 3671562289u,
-121812599u, 2902367378u,
-2260041112u, 1019936943u,
-320945955u, 2337845588u,
-1535670711u, 773792826u,
-3152195900u, 4090794518u,
-4142587430u, 484732447u,
-419191319u, 3377973345u,
-324924679u, 2809286837u,
-1562277603u, 1378362199u,
-3791551981u, 1097806406u,
-1386297408u, 2304900033u,
-3574135531u, 4017075736u,
-1161238398u, 1358056883u,
-3487080616u, 1516736273u,
-851615042u, 2927899494u,
-4077452507u, 2984955003u,
-3907754394u, 3578173844u,
-1948409509u, 1923531348u,
-3578472493u, 3710074193u,
-213811117u, 2586632018u,
-1922589216u, 274958014u,
-1654276320u, 2687561076u,
-2569061755u, 3122046057u,
-3203802620u, 1692079268u,
-477806878u, 140587742u,
-520565830u, 3674576684u,
-91246882u, 1010215946u,
-3703994407u, 69201295u,
-776213083u, 3677771507u,
-3696902571u, 3593730713u,
-2907901228u, 3239753796u,
-1586241476u, 1939595371u,
-2268396558u, 3468719670u,
-2955715987u, 2295501078u,
-2775848696u, 1358532390u,
-3843660102u, 82177963u,
-4094477877u, 191727221u,
-278661677u, 2889101923u,
-1352525614u, 2844977667u,
-1261140657u, 1747052377u,
-2334120653u, 645125282u,
-2707230761u, 4142246789u,
-1068639717u, 2288162940u,
-1419293714u, 1636932722u,
-3252686293u, 318543902u,
-2598802768u, 2025886508u,
-2250788464u, 2711763065u,
-255108733u, 1845587644u,
-3719270134u, 3940707863u,
-917608574u, 1363253259u,
-788659330u, 673256220u,
-109793386u, 341851980u,
-2698465479u, 3011229884u,
-3886713057u, 1276595523u,
-2439962760u, 2700515456u,
-205970448u, 4198897105u,
-875511891u, 371715572u,
-1033680610u, 4278599955u,
-3120038721u, 1256300069u,
-225629455u, 3735275001u,
-3961944123u, 1769389163u,
-1074553219u, 668829411u,
-1098679359u, 2573697509u,
-1885071395u, 4233785523u,
-2513878053u, 2030193788u,
-360256231u, 107312677u,
-310517502u, 2618936366u,
-3600462351u, 1216645846u,
-2970730323u, 4278812598u,
-94638678u, 1689811113u,
-4125738800u, 3103759730u,
-103797041u, 1397772514u,
-1669653333u, 572567964u,
-1612872497u, 2986430557u,
-214990655u, 3117607990u,
-1949717207u, 2260498180u,
-1493936866u, 3554860960u,
-1582022990u, 1263709570u,
-1244120487u, 3416600761u,
-224580012u, 4252610345u,
-286306391u, 814956796u,
-1820532305u, 2776960536u,
-3082703465u, 1659265982u,
-1157398049u, 3752806924u,
-3508246460u, 2902716664u,
-2110942730u, 3267551635u,
-902835431u, 405228165u,
-2341378668u, 2220373824u,
-3303626294u, 1175118221u,
-383517064u, 896322512u,
-1697257567u, 2202820683u,
-1837689083u, 1336556841u,
-914535232u, 3634083711u,
-1537187340u, 3712582785u,
-1088201893u, 3270984620u,
-3093195926u, 2561488770u,
-1962968100u, 236189500u,
-2549435227u, 536047554u,
-422609195u, 2958815818u,
-4166184983u, 3528794619u,
-1042329086u, 3914176886u,
-1359641525u, 1197100813u,
-1269739674u, 3301844628u,
-1831223342u, 3329594980u,
-2433669782u, 494908536u,
-1441714797u, 1174785921u,
-1933050423u, 958901065u,
-868981704u, 2163330264u,
-3243110680u, 1443133429u,
-1145009669u, 2520062970u,
-3851564853u, 2664619323u,
-2686075657u, 4042710240u,
-2125408249u, 4165697916u,
-2328730865u, 3160666939u,
-588683409u, 2126275847u,
-829404209u, 1878067032u,
-2567792910u, 897670516u,
-934312076u, 2952135524u,
-504832490u, 3312698056u,
-4015478120u, 1265237690u,
-3376133707u, 967674402u,
-1553513184u, 834830418u,
-2396504772u, 3278582098u,
-2950762705u, 4277111759u,
-4159211303u, 1290097509u,
-251949572u, 3065234219u,
-1832020534u, 312136369u,
-1103404394u, 198182691u,
-1369599600u, 3906710870u,
-2954651680u, 1535115487u,
-2389327507u, 1813520230u,
-632704095u, 140762681u,
-3123202913u, 3336005523u,
-1287729497u, 2198985327u,
-2470730783u, 3821758006u,
-1009870118u, 559702706u,
-4274686257u, 3187546567u,
-2402308151u, 1096697687u,
-678932329u, 3716363135u,
-2899950405u, 3046872820u,
-3754655641u, 2021741414u,
-1993425202u, 2185339100u,
-2838253700u, 3099212100u,
-1679617763u, 3703603898u,
-1135665833u, 3559875668u,
-2503579743u, 1446869792u,
-879818611u, 3788305533u,
-2879018745u, 2719373510u,
-3606051203u, 2166567748u,
-343595772u, 1996164093u,
-1577656121u, 475248376u,
-463852893u, 2864244470u,
-1332049663u, 3326459767u,
-3207234525u, 2028708916u,
-938916154u, 3115246264u,
-3272166407u, 557660441u,
-1265684026u, 245033807u,
-2440657523u, 255451671u,
-3811885130u, 1399880284u,
-1322855877u, 3452203069u,
-1324994449u, 3796404024u,
-2002090272u, 1568745354u,
-3700047753u, 31799506u,
-3009412313u, 3184047862u,
-728680761u, 3848624873u,
-1849329144u, 3160134214u,
-1272923193u, 1474278816u,
-1208883495u, 1566527339u,
-4136466541u, 630825649u,
-1717327230u, 1496132623u,
-2449386742u, 128106940u,
-2108574735u, 2584236470u,
-2872246579u, 397338552u,
-3088905079u, 3456882941u,
-1715915153u, 2940716269u,
-4168438718u, 467441309u,
-872996731u, 3206901319u,
-1610606159u, 2540270567u,
-1301658081u, 2379410194u,
-2109315753u, 3348545480u,
-2041927873u, 2644077493u,
-546596661u, 1017047954u,
-2596792972u, 2783958892u,
-2826408201u, 3531646869u,
-2219352672u, 4217451852u,
-1806867885u, 1903578924u,
-2076465705u, 2373061493u,
-1832925325u, 241574049u,
-1509517110u, 3703614272u,
-3429894862u, 3529565564u,
-4010000614u, 2256197939u,
-517086873u, 2964595704u,
-3501035294u, 4079457298u,
-1184683823u, 4260564140u,
-2339268412u, 3871564102u,
-1572637805u, 383233885u,
-3351411126u, 3419328182u,
-2017406667u, 919677938u,
-29804156u, 46276077u,
-3032591014u, 4204155962u,
-1172319502u, 969309871u,
-2211319468u, 4153726847u,
-3094193193u, 4240669441u,
-3441709766u, 1387233546u,
-4048882438u, 1217896566u,
-1580964938u, 740563169u,
-3691850348u, 3176426539u,
-2738323042u, 2948665536u,
-1474029445u, 3513354882u,
-3219466255u, 3799363969u,
-3961796122u, 1055550923u,
-1992212097u, 2263421398u,
-4289759174u, 2516844140u,
-1782515131u, 2746577402u,
-721928440u, 3529570984u,
-1705302106u, 768287270u,
-3474902815u, 4000011125u,
-3475618043u, 212490675u,
-549130471u, 2970128275u,
-3170016833u, 2549835613u,
-3691104824u, 2694324482u,
-4169365948u, 3738062408u,
-602930397u, 2148954730u,
-2636387819u, 2616619070u,
-301617872u, 374657036u,
-3862686086u, 431292293u,
-4225245165u, 1358580562u,
-2377363130u, 1415970351u,
-3885060756u, 1438379807u,
-2297418515u, 2954777083u,
-3970368221u, 1229801760u,
-1931934525u, 2287507921u,
-1713471510u, 2145608111u,
-2650140034u, 4081586725u,
-4196863572u, 1896558394u,
-4059852729u, 1813855658u,
-2618400836u, 1396056469u,
-2375584220u, 1037031473u,
-249284003u, 2450077637u,
-1383747654u, 3122687303u,
-2664431743u, 3855028730u,
-929335420u, 3193251135u,
-137313762u, 1850894384u,
-3163711272u, 3071568023u,
-418541677u, 3621223039u,
-340274176u, 1167681812u,
-4106647531u, 4022465625u,
-3069708839u, 2704165015u,
-2332023349u, 641449034u,
-921552000u, 1712976649u,
-1876484273u, 2343049860u,
-1834682077u, 4155949943u,
-2061821157u, 4240649383u,
-747285578u, 1626463554u,
-165503115u, 359629739u,
-3838102563u, 582664250u,
-3878924635u, 4117237498u,
-2250573853u, 804336148u,
-331393443u, 4242530387u,
-3346357270u, 1674051445u,
-3348019777u, 1722242971u,
-2509017299u, 2966108111u,
-4189102509u, 3323592310u,
-2631381069u, 4014551783u,
-4250787412u, 3448394212u,
-2664752123u, 3517585534u,
-3605365141u, 1669471183u,
-2210121140u, 760762191u,
-249697459u, 3416920106u,
-16322182u, 643179562u,
-1564226597u, 2134630675u,
-1011990087u, 2990167340u,
-2349550842u, 1642428946u,
-1214854475u, 2134299399u,
-2704221532u, 2104175211u,
-4283196353u, 1342880802u,
-198529755u, 2004468390u,
-2544665755u, 853593042u,
-2090611294u, 2970943872u,
-1472073141u, 850464484u,
-1407609278u, 3062461105u,
-366448238u, 3842907484u,
-488797416u, 1432670231u,
-294963924u, 3693536939u,
-3390549825u, 1583234720u,
-4032223840u, 2318423400u,
-2965642867u, 930822729u,
-1679099863u, 1728968857u,
-900822335u, 702309817u,
-3258354115u, 1502282913u,
-2811888503u, 3924947660u,
-2477280726u, 3651607391u,
-3788310204u, 1300369123u,
-1842333726u, 4146839064u,
-2468893861u, 4091095953u,
-488595746u, 1448097974u,
-1159634090u, 1738834113u,
-2928916831u, 4093725287u,
-530850094u, 291657799u,
-3548184546u, 679517009u,
-399175380u, 2658337143u,
-3827951761u, 3086277222u,
-2067718397u, 3632376023u,
-3553313841u, 119173722u,
-1702434637u, 1766260771u,
-895654784u, 751439914u,
-4008409498u, 215917713u,
-1288382231u, 2656990891u,
-2581779077u, 1570750352u,
-2666411616u, 3533987737u,
-4289478316u, 3576119563u,
-3869794273u, 963183826u,
-2081410737u, 3796810515u,
-1036883117u, 136547246u,
-875691100u, 2592925324u,
-2689342539u, 427154472u,
-532957601u, 1228758574u,
-1908591042u, 1464255968u,
-446980910u, 2984611177u,
-3508927906u, 2001585786u,
-2544767379u, 1525438381u,
-879448844u, 1348536411u,
-4242243590u, 2861338018u,
-601175800u, 764077711u,
-530635011u, 3785343245u,
-2378297261u, 457568934u,
-76438221u, 4104954272u,
-2485968477u, 2381948487u,
-4226929450u, 3148473363u,
-879369091u, 2180270337u,
-3674375989u, 1387729170u,
-568650985u, 951677556u,
-4213877384u, 2721005055u,
-1678669911u, 66786703u,
-2273631661u, 1149351924u,
-246723096u, 1895026827u,
-3810605772u, 3711056516u,
-2080120290u, 3638638708u,
-2915672708u, 2263003308u,
-1976115991u, 3448840877u,
-2019238520u, 225333538u,
-1555273378u, 3797521928u,
-1942347150u, 3262952567u,
-2817830907u, 2078619498u,
-749534111u, 1178073973u,
-841092198u, 3288261538u,
-1696412169u, 1496966875u,
-3739946319u, 2481012988u,
-568983526u, 114945840u,
-2841706923u, 1632780103u,
-4020169654u, 2087949619u,
-833416317u, 3787017905u,
-2373238993u, 2575395164u,
-2542976862u, 2971726178u,
-2880371864u, 3642087909u,
-1043714217u, 3894199764u,
-2235879182u, 203853421u,
-834683330u, 425935223u,
-3560796393u, 3565833278u,
-3414330886u, 1748785729u,
-1023171602u, 580966986u,
-2657385925u, 2124704694u,
-233442446u, 1107045577u,
-3899097693u, 1067532701u,
-115667924u, 1406028344u,
-2419657149u, 18613994u,
-2532882091u, 3476683808u,
-895961699u, 3762914298u,
-1328752423u, 1844996900u,
-1210281744u, 904215228u,
-4055325594u, 1118521573u,
-3996647489u, 3657647605u,
-325254059u, 3136157065u,
-3341068436u, 2287683323u,
-1313073005u, 126005630u,
-853746559u, 3555092974u,
-2689238752u, 49515858u,
-61073168u, 1010661841u,
-1269521335u, 1902040126u,
-3858321250u, 1400735275u,
-2974699176u, 2771676666u,
-545726212u, 2225229957u,
-1086473152u, 3454177594u,
-2088002891u, 2883475137u,
-3222194252u, 4144472319u,
-567988835u, 1051332394u,
-3932046135u, 542648229u,
-162888005u, 1669710469u,
-1492500905u, 553041029u,
-3817492747u, 584127807u,
-4147115982u, 2993670925u,
-3509733475u, 3587959456u,
-2088550465u, 1745399498u,
-869648362u, 1404723176u,
-3947542735u, 1334333531u,
-59634866u, 3239516985u,
-3844250972u, 1275954779u,
-2512155003u, 1685649437u,
-639306006u, 2524620206u,
-576786501u, 655707039u,
-2864351838u, 3736264674u,
-1200907897u, 2384379464u,
-15823708u, 206117476u,
-1193310960u, 1093099415u,
-3696538026u, 4112584792u,
-2069527017u, 547588820u,
-4178147211u, 2827259351u,
-940846775u, 1054995047u,
-2976960697u, 1934305529u,
-2199137382u, 1005722394u,
-1875867180u, 2064356511u,
-4019734130u, 3096333006u,
-2069509024u, 2906358341u,
-2232866485u, 1456016086u,
-1422674894u, 867282151u,
-1612503136u, 1739843072u,
-134947567u, 2978775774u,
-1284167756u, 1090844589u,
-831688783u, 2079216362u,
-1626991196u, 3644714163u,
-3678110059u, 898470030u,
-3916646913u, 3182422972u,
-3630426828u, 969847973u,
-3427164640u, 3463937250u,
-3044785046u, 897322257u,
-3443872170u, 4185408854u,
-2557463241u, 4080940424u,
-2048168570u, 2429169982u,
-3174690447u, 2513494106u,
-1213061732u, 3143736628u,
-3482268149u, 1250714337u,
-31648125u, 3872383625u,
-1565760579u, 36665130u,
-751041229u, 2257179590u,
-2915361862u, 280819225u,
-2907818413u, 4254297769u,
-3493178615u, 3755944354u,
-4043533423u, 1134196225u,
-4177134659u, 127246419u,
-2442615581u, 923049607u,
-1004426206u, 782768297u,
-2410586681u, 1430106871u,
-4103323427u, 3168399477u,
-3716682375u, 3616334719u,
-3413209549u, 656672786u,
-2876965944u, 182894450u,
-456581318u, 2683752067u,
-3877875910u, 3190666241u,
-3240336907u, 4024807233u,
-1681224377u, 1576191191u,
-3599250276u, 2381111980u,
-3495321877u, 3956024585u,
-1611608524u, 3815677453u,
-2062334396u, 1656117707u,
-5457134u, 3234118251u,
-470187419u, 2688566989u,
-3259870297u, 660100446u,
-442236198u, 2542452448u,
-493137955u, 392411099u,
-947967568u, 1234595917u,
-4230082284u, 2762976773u,
-2870085764u, 1455086530u,
-2762099647u, 4011882747u,
-1215981925u, 3227517889u,
-3269061963u, 4037515364u,
-3168911474u, 4255057396u,
-2026092260u, 1736192508u,
-3909727042u, 3114708966u,
-1938800693u, 680793595u,
-1525265867u, 2808224480u,
-2122290603u, 1211197714u,
-3520488321u, 3979192396u,
-3540779343u, 4192918639u,
-2736030448u, 1120335563u,
-1698949078u, 3993310631u,
-1966048551u, 2228221363u,
-597941119u, 3498018399u,
-393987327u, 454500547u,
-1222959566u, 567151340u,
-3774764786u, 1492844524u,
-3308300614u, 805568076u,
-868414882u, 177406999u,
-1608110313u, 642061169u,
-1027515771u, 3131251981u,
-2851936150u, 4272755262u,
-1532845092u, 709643652u,
-682573592u, 1244104217u,
-796769556u, 2500467040u,
-3002618826u, 1112998535u,
-1780193104u, 1243644607u,
-3691719535u, 2958853053u,
-466635014u, 2277292580u,
-4082276003u, 1030800045u,
-1750863246u, 379050598u,
-3576413281u, 731493104u,
-132259176u, 4115195437u,
-1769890695u, 2715470335u,
-1819263183u, 2028531518u,
-2154809766u, 3672399742u,
-76727603u, 4198182186u,
-2304993586u, 1666387627u,
-284366017u, 3359785538u,
-3469807328u, 2926494787u,
-3829072836u, 2493478921u,
-3738499303u, 3311304980u,
-932916545u, 2235559063u,
-2909742396u, 1765719309u,
-1456588655u, 508290328u,
-1490719640u, 3356513470u,
-2908490783u, 251085588u,
-830410677u, 3172220325u,
-3897208579u, 1940535730u,
-151909546u, 2384458112u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashuoTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+3254014218u, 429095991u,
+165589978u, 1578546616u,
+623071693u, 366414107u,
+249776086u, 1207522198u,
+3120876698u, 1684583131u,
+46987739u, 1157614300u,
+199124911u, 520792961u,
+3614377032u, 586863115u,
+1716848157u, 4033596884u,
+1164298657u, 4140791139u,
+3824360466u, 3242407770u,
+3725511003u, 232064808u,
+2736953692u, 816692935u,
+512845449u, 3748861010u,
+4290630595u, 517646945u,
+22638523u, 648000590u,
+1283799121u, 3047062993u,
+1024246061u, 4027776454u,
+834785312u, 382936554u,
+411505255u, 1973395102u,
+580988377u, 2826990641u,
+3474970689u, 1029055034u,
+2584372201u, 1758123094u,
+589567754u, 325737734u,
+3886113119u, 3338548567u,
+257578986u, 3698087965u,
+3604937815u, 3198590202u,
+2305332220u, 191910725u,
+4244322689u, 542201663u,
+3315355162u, 2135941665u,
+1175961330u, 3948351189u,
+23075771u, 3252374102u,
+713127376u, 1467786451u,
+663013031u, 3444053918u,
+3077742128u, 1062268187u,
+2115441882u, 4081398201u,
+2335576331u, 2560479831u,
+1379288194u, 4225182569u,
+3958366652u, 3067277639u,
+3667516477u, 1709989541u,
+4188504038u, 59581167u,
+2725013602u, 3639843023u,
+3758739543u, 4189944477u,
+2470483982u, 877580602u,
+3252925478u, 2062343506u,
+3981838403u, 3762572073u,
+2931588131u, 3284356565u,
+1129162571u, 732225574u,
+1677744031u, 3532596884u,
+3232041815u, 1652884780u,
+3740979556u, 259034107u,
+2227121257u, 1426140634u,
+315836068u, 3200749877u,
+1386256573u, 24035717u,
+234531934u, 1115203611u,
+1598686658u, 3146815575u,
+2632963283u, 1778459926u,
+739944537u, 579625482u,
+1231665285u, 2457048126u,
+3903349120u, 389846205u,
+1052645068u, 862072556u,
+2834153464u, 1481069623u,
+1688445808u, 701920051u,
+3740748788u, 3388062747u,
+1192588249u, 1410111809u,
+2633463887u, 4050419847u,
+2513844237u, 2187968410u,
+2951683019u, 3015806005u,
+3000537321u, 479241367u,
+252167538u, 1231057113u,
+393624922u, 704325635u,
+1467197045u, 2066433573u,
+3082385053u, 735688735u,
+956434529u, 4028590195u,
+4074716319u, 813690332u,
+2124740535u, 804073145u,
+3748881891u, 3195309868u,
+841856605u, 2585865274u,
+881504822u, 3254795114u,
+1241815736u, 970796142u,
+497175391u, 3929484338u,
+4264993211u, 1835322201u,
+3675707838u, 4205965408u,
+300298607u, 3858319990u,
+3255259608u, 4247675634u,
+1095823272u, 1197245408u,
+1742785722u, 785893184u,
+1702965674u, 850401405u,
+4084891412u, 1160134629u,
+2555998391u, 1972759056u,
+710625654u, 4116162021u,
+3352753742u, 85121177u,
+3513255468u, 2487440590u,
+2480032715u, 2287747045u,
+4090178629u, 4044418876u,
+1703944517u, 486290428u,
+1515601363u, 2011102035u,
+573985957u, 3536053779u,
+4257172787u, 576405853u,
+1523550693u, 1014952061u,
+711098718u, 2425317635u,
+3460807169u, 3688987163u,
+3167371443u, 3062418115u,
+3330028292u, 1713171303u,
+526177822u, 2602636307u,
+1245357025u, 3346699703u,
+254529415u, 4017058800u,
+1829738451u, 2164236533u,
+1381258384u, 4036354071u,
+1749181924u, 4118435443u,
+4130543625u, 688472265u,
+2731071299u, 2547657502u,
+4175776103u, 338058159u,
+3729582129u, 4181845558u,
+2227290760u, 146827036u,
+2459178427u, 1025353883u,
+4284109679u, 2502815838u,
+825124804u, 2533140036u,
+616327404u, 2448966429u,
+413992636u, 2334782461u,
+2239052397u, 1082330589u,
+3381164715u, 199381437u,
+2583939798u, 2848283092u,
+2300168091u, 2156336315u,
+1855234968u, 1982110346u,
+2482046810u, 3158163887u,
+2168864636u, 133643215u,
+3904021624u, 3646514568u,
+1176127003u, 4015671361u,
+100525019u, 3534706803u,
+2045051700u, 3452457457u,
+1492267772u, 2308393828u,
+3776661467u, 3281002516u,
+4246334524u, 743955039u,
+685631442u, 1147951686u,
+2040912376u, 2911148054u,
+3204999386u, 2415262714u,
+313209105u, 777065474u,
+2729416454u, 1029284767u,
+1632078298u, 1817552554u,
+3963877000u, 1919171906u,
+3843219958u, 3073580867u,
+865146997u, 2473524405u,
+2593817617u, 3643076308u,
+617975720u, 3671562289u,
+121812599u, 2902367378u,
+2260041112u, 1019936943u,
+320945955u, 2337845588u,
+1535670711u, 773792826u,
+3152195900u, 4090794518u,
+4142587430u, 484732447u,
+419191319u, 3377973345u,
+324924679u, 2809286837u,
+1562277603u, 1378362199u,
+3791551981u, 1097806406u,
+1386297408u, 2304900033u,
+3574135531u, 4017075736u,
+1161238398u, 1358056883u,
+3487080616u, 1516736273u,
+851615042u, 2927899494u,
+4077452507u, 2984955003u,
+3907754394u, 3578173844u,
+1948409509u, 1923531348u,
+3578472493u, 3710074193u,
+213811117u, 2586632018u,
+1922589216u, 274958014u,
+1654276320u, 2687561076u,
+2569061755u, 3122046057u,
+3203802620u, 1692079268u,
+477806878u, 140587742u,
+520565830u, 3674576684u,
+91246882u, 1010215946u,
+3703994407u, 69201295u,
+776213083u, 3677771507u,
+3696902571u, 3593730713u,
+2907901228u, 3239753796u,
+1586241476u, 1939595371u,
+2268396558u, 3468719670u,
+2955715987u, 2295501078u,
+2775848696u, 1358532390u,
+3843660102u, 82177963u,
+4094477877u, 191727221u,
+278661677u, 2889101923u,
+1352525614u, 2844977667u,
+1261140657u, 1747052377u,
+2334120653u, 645125282u,
+2707230761u, 4142246789u,
+1068639717u, 2288162940u,
+1419293714u, 1636932722u,
+3252686293u, 318543902u,
+2598802768u, 2025886508u,
+2250788464u, 2711763065u,
+255108733u, 1845587644u,
+3719270134u, 3940707863u,
+917608574u, 1363253259u,
+788659330u, 673256220u,
+109793386u, 341851980u,
+2698465479u, 3011229884u,
+3886713057u, 1276595523u,
+2439962760u, 2700515456u,
+205970448u, 4198897105u,
+875511891u, 371715572u,
+1033680610u, 4278599955u,
+3120038721u, 1256300069u,
+225629455u, 3735275001u,
+3961944123u, 1769389163u,
+1074553219u, 668829411u,
+1098679359u, 2573697509u,
+1885071395u, 4233785523u,
+2513878053u, 2030193788u,
+360256231u, 107312677u,
+310517502u, 2618936366u,
+3600462351u, 1216645846u,
+2970730323u, 4278812598u,
+94638678u, 1689811113u,
+4125738800u, 3103759730u,
+103797041u, 1397772514u,
+1669653333u, 572567964u,
+1612872497u, 2986430557u,
+214990655u, 3117607990u,
+1949717207u, 2260498180u,
+1493936866u, 3554860960u,
+1582022990u, 1263709570u,
+1244120487u, 3416600761u,
+224580012u, 4252610345u,
+286306391u, 814956796u,
+1820532305u, 2776960536u,
+3082703465u, 1659265982u,
+1157398049u, 3752806924u,
+3508246460u, 2902716664u,
+2110942730u, 3267551635u,
+902835431u, 405228165u,
+2341378668u, 2220373824u,
+3303626294u, 1175118221u,
+383517064u, 896322512u,
+1697257567u, 2202820683u,
+1837689083u, 1336556841u,
+914535232u, 3634083711u,
+1537187340u, 3712582785u,
+1088201893u, 3270984620u,
+3093195926u, 2561488770u,
+1962968100u, 236189500u,
+2549435227u, 536047554u,
+422609195u, 2958815818u,
+4166184983u, 3528794619u,
+1042329086u, 3914176886u,
+1359641525u, 1197100813u,
+1269739674u, 3301844628u,
+1831223342u, 3329594980u,
+2433669782u, 494908536u,
+1441714797u, 1174785921u,
+1933050423u, 958901065u,
+868981704u, 2163330264u,
+3243110680u, 1443133429u,
+1145009669u, 2520062970u,
+3851564853u, 2664619323u,
+2686075657u, 4042710240u,
+2125408249u, 4165697916u,
+2328730865u, 3160666939u,
+588683409u, 2126275847u,
+829404209u, 1878067032u,
+2567792910u, 897670516u,
+934312076u, 2952135524u,
+504832490u, 3312698056u,
+4015478120u, 1265237690u,
+3376133707u, 967674402u,
+1553513184u, 834830418u,
+2396504772u, 3278582098u,
+2950762705u, 4277111759u,
+4159211303u, 1290097509u,
+251949572u, 3065234219u,
+1832020534u, 312136369u,
+1103404394u, 198182691u,
+1369599600u, 3906710870u,
+2954651680u, 1535115487u,
+2389327507u, 1813520230u,
+632704095u, 140762681u,
+3123202913u, 3336005523u,
+1287729497u, 2198985327u,
+2470730783u, 3821758006u,
+1009870118u, 559702706u,
+4274686257u, 3187546567u,
+2402308151u, 1096697687u,
+678932329u, 3716363135u,
+2899950405u, 3046872820u,
+3754655641u, 2021741414u,
+1993425202u, 2185339100u,
+2838253700u, 3099212100u,
+1679617763u, 3703603898u,
+1135665833u, 3559875668u,
+2503579743u, 1446869792u,
+879818611u, 3788305533u,
+2879018745u, 2719373510u,
+3606051203u, 2166567748u,
+343595772u, 1996164093u,
+1577656121u, 475248376u,
+463852893u, 2864244470u,
+1332049663u, 3326459767u,
+3207234525u, 2028708916u,
+938916154u, 3115246264u,
+3272166407u, 557660441u,
+1265684026u, 245033807u,
+2440657523u, 255451671u,
+3811885130u, 1399880284u,
+1322855877u, 3452203069u,
+1324994449u, 3796404024u,
+2002090272u, 1568745354u,
+3700047753u, 31799506u,
+3009412313u, 3184047862u,
+728680761u, 3848624873u,
+1849329144u, 3160134214u,
+1272923193u, 1474278816u,
+1208883495u, 1566527339u,
+4136466541u, 630825649u,
+1717327230u, 1496132623u,
+2449386742u, 128106940u,
+2108574735u, 2584236470u,
+2872246579u, 397338552u,
+3088905079u, 3456882941u,
+1715915153u, 2940716269u,
+4168438718u, 467441309u,
+872996731u, 3206901319u,
+1610606159u, 2540270567u,
+1301658081u, 2379410194u,
+2109315753u, 3348545480u,
+2041927873u, 2644077493u,
+546596661u, 1017047954u,
+2596792972u, 2783958892u,
+2826408201u, 3531646869u,
+2219352672u, 4217451852u,
+1806867885u, 1903578924u,
+2076465705u, 2373061493u,
+1832925325u, 241574049u,
+1509517110u, 3703614272u,
+3429894862u, 3529565564u,
+4010000614u, 2256197939u,
+517086873u, 2964595704u,
+3501035294u, 4079457298u,
+1184683823u, 4260564140u,
+2339268412u, 3871564102u,
+1572637805u, 383233885u,
+3351411126u, 3419328182u,
+2017406667u, 919677938u,
+29804156u, 46276077u,
+3032591014u, 4204155962u,
+1172319502u, 969309871u,
+2211319468u, 4153726847u,
+3094193193u, 4240669441u,
+3441709766u, 1387233546u,
+4048882438u, 1217896566u,
+1580964938u, 740563169u,
+3691850348u, 3176426539u,
+2738323042u, 2948665536u,
+1474029445u, 3513354882u,
+3219466255u, 3799363969u,
+3961796122u, 1055550923u,
+1992212097u, 2263421398u,
+4289759174u, 2516844140u,
+1782515131u, 2746577402u,
+721928440u, 3529570984u,
+1705302106u, 768287270u,
+3474902815u, 4000011125u,
+3475618043u, 212490675u,
+549130471u, 2970128275u,
+3170016833u, 2549835613u,
+3691104824u, 2694324482u,
+4169365948u, 3738062408u,
+602930397u, 2148954730u,
+2636387819u, 2616619070u,
+301617872u, 374657036u,
+3862686086u, 431292293u,
+4225245165u, 1358580562u,
+2377363130u, 1415970351u,
+3885060756u, 1438379807u,
+2297418515u, 2954777083u,
+3970368221u, 1229801760u,
+1931934525u, 2287507921u,
+1713471510u, 2145608111u,
+2650140034u, 4081586725u,
+4196863572u, 1896558394u,
+4059852729u, 1813855658u,
+2618400836u, 1396056469u,
+2375584220u, 1037031473u,
+249284003u, 2450077637u,
+1383747654u, 3122687303u,
+2664431743u, 3855028730u,
+929335420u, 3193251135u,
+137313762u, 1850894384u,
+3163711272u, 3071568023u,
+418541677u, 3621223039u,
+340274176u, 1167681812u,
+4106647531u, 4022465625u,
+3069708839u, 2704165015u,
+2332023349u, 641449034u,
+921552000u, 1712976649u,
+1876484273u, 2343049860u,
+1834682077u, 4155949943u,
+2061821157u, 4240649383u,
+747285578u, 1626463554u,
+165503115u, 359629739u,
+3838102563u, 582664250u,
+3878924635u, 4117237498u,
+2250573853u, 804336148u,
+331393443u, 4242530387u,
+3346357270u, 1674051445u,
+3348019777u, 1722242971u,
+2509017299u, 2966108111u,
+4189102509u, 3323592310u,
+2631381069u, 4014551783u,
+4250787412u, 3448394212u,
+2664752123u, 3517585534u,
+3605365141u, 1669471183u,
+2210121140u, 760762191u,
+249697459u, 3416920106u,
+16322182u, 643179562u,
+1564226597u, 2134630675u,
+1011990087u, 2990167340u,
+2349550842u, 1642428946u,
+1214854475u, 2134299399u,
+2704221532u, 2104175211u,
+4283196353u, 1342880802u,
+198529755u, 2004468390u,
+2544665755u, 853593042u,
+2090611294u, 2970943872u,
+1472073141u, 850464484u,
+1407609278u, 3062461105u,
+366448238u, 3842907484u,
+488797416u, 1432670231u,
+294963924u, 3693536939u,
+3390549825u, 1583234720u,
+4032223840u, 2318423400u,
+2965642867u, 930822729u,
+1679099863u, 1728968857u,
+900822335u, 702309817u,
+3258354115u, 1502282913u,
+2811888503u, 3924947660u,
+2477280726u, 3651607391u,
+3788310204u, 1300369123u,
+1842333726u, 4146839064u,
+2468893861u, 4091095953u,
+488595746u, 1448097974u,
+1159634090u, 1738834113u,
+2928916831u, 4093725287u,
+530850094u, 291657799u,
+3548184546u, 679517009u,
+399175380u, 2658337143u,
+3827951761u, 3086277222u,
+2067718397u, 3632376023u,
+3553313841u, 119173722u,
+1702434637u, 1766260771u,
+895654784u, 751439914u,
+4008409498u, 215917713u,
+1288382231u, 2656990891u,
+2581779077u, 1570750352u,
+2666411616u, 3533987737u,
+4289478316u, 3576119563u,
+3869794273u, 963183826u,
+2081410737u, 3796810515u,
+1036883117u, 136547246u,
+875691100u, 2592925324u,
+2689342539u, 427154472u,
+532957601u, 1228758574u,
+1908591042u, 1464255968u,
+446980910u, 2984611177u,
+3508927906u, 2001585786u,
+2544767379u, 1525438381u,
+879448844u, 1348536411u,
+4242243590u, 2861338018u,
+601175800u, 764077711u,
+530635011u, 3785343245u,
+2378297261u, 457568934u,
+76438221u, 4104954272u,
+2485968477u, 2381948487u,
+4226929450u, 3148473363u,
+879369091u, 2180270337u,
+3674375989u, 1387729170u,
+568650985u, 951677556u,
+4213877384u, 2721005055u,
+1678669911u, 66786703u,
+2273631661u, 1149351924u,
+246723096u, 1895026827u,
+3810605772u, 3711056516u,
+2080120290u, 3638638708u,
+2915672708u, 2263003308u,
+1976115991u, 3448840877u,
+2019238520u, 225333538u,
+1555273378u, 3797521928u,
+1942347150u, 3262952567u,
+2817830907u, 2078619498u,
+749534111u, 1178073973u,
+841092198u, 3288261538u,
+1696412169u, 1496966875u,
+3739946319u, 2481012988u,
+568983526u, 114945840u,
+2841706923u, 1632780103u,
+4020169654u, 2087949619u,
+833416317u, 3787017905u,
+2373238993u, 2575395164u,
+2542976862u, 2971726178u,
+2880371864u, 3642087909u,
+1043714217u, 3894199764u,
+2235879182u, 203853421u,
+834683330u, 425935223u,
+3560796393u, 3565833278u,
+3414330886u, 1748785729u,
+1023171602u, 580966986u,
+2657385925u, 2124704694u,
+233442446u, 1107045577u,
+3899097693u, 1067532701u,
+115667924u, 1406028344u,
+2419657149u, 18613994u,
+2532882091u, 3476683808u,
+895961699u, 3762914298u,
+1328752423u, 1844996900u,
+1210281744u, 904215228u,
+4055325594u, 1118521573u,
+3996647489u, 3657647605u,
+325254059u, 3136157065u,
+3341068436u, 2287683323u,
+1313073005u, 126005630u,
+853746559u, 3555092974u,
+2689238752u, 49515858u,
+61073168u, 1010661841u,
+1269521335u, 1902040126u,
+3858321250u, 1400735275u,
+2974699176u, 2771676666u,
+545726212u, 2225229957u,
+1086473152u, 3454177594u,
+2088002891u, 2883475137u,
+3222194252u, 4144472319u,
+567988835u, 1051332394u,
+3932046135u, 542648229u,
+162888005u, 1669710469u,
+1492500905u, 553041029u,
+3817492747u, 584127807u,
+4147115982u, 2993670925u,
+3509733475u, 3587959456u,
+2088550465u, 1745399498u,
+869648362u, 1404723176u,
+3947542735u, 1334333531u,
+59634866u, 3239516985u,
+3844250972u, 1275954779u,
+2512155003u, 1685649437u,
+639306006u, 2524620206u,
+576786501u, 655707039u,
+2864351838u, 3736264674u,
+1200907897u, 2384379464u,
+15823708u, 206117476u,
+1193310960u, 1093099415u,
+3696538026u, 4112584792u,
+2069527017u, 547588820u,
+4178147211u, 2827259351u,
+940846775u, 1054995047u,
+2976960697u, 1934305529u,
+2199137382u, 1005722394u,
+1875867180u, 2064356511u,
+4019734130u, 3096333006u,
+2069509024u, 2906358341u,
+2232866485u, 1456016086u,
+1422674894u, 867282151u,
+1612503136u, 1739843072u,
+134947567u, 2978775774u,
+1284167756u, 1090844589u,
+831688783u, 2079216362u,
+1626991196u, 3644714163u,
+3678110059u, 898470030u,
+3916646913u, 3182422972u,
+3630426828u, 969847973u,
+3427164640u, 3463937250u,
+3044785046u, 897322257u,
+3443872170u, 4185408854u,
+2557463241u, 4080940424u,
+2048168570u, 2429169982u,
+3174690447u, 2513494106u,
+1213061732u, 3143736628u,
+3482268149u, 1250714337u,
+31648125u, 3872383625u,
+1565760579u, 36665130u,
+751041229u, 2257179590u,
+2915361862u, 280819225u,
+2907818413u, 4254297769u,
+3493178615u, 3755944354u,
+4043533423u, 1134196225u,
+4177134659u, 127246419u,
+2442615581u, 923049607u,
+1004426206u, 782768297u,
+2410586681u, 1430106871u,
+4103323427u, 3168399477u,
+3716682375u, 3616334719u,
+3413209549u, 656672786u,
+2876965944u, 182894450u,
+456581318u, 2683752067u,
+3877875910u, 3190666241u,
+3240336907u, 4024807233u,
+1681224377u, 1576191191u,
+3599250276u, 2381111980u,
+3495321877u, 3956024585u,
+1611608524u, 3815677453u,
+2062334396u, 1656117707u,
+5457134u, 3234118251u,
+470187419u, 2688566989u,
+3259870297u, 660100446u,
+442236198u, 2542452448u,
+493137955u, 392411099u,
+947967568u, 1234595917u,
+4230082284u, 2762976773u,
+2870085764u, 1455086530u,
+2762099647u, 4011882747u,
+1215981925u, 3227517889u,
+3269061963u, 4037515364u,
+3168911474u, 4255057396u,
+2026092260u, 1736192508u,
+3909727042u, 3114708966u,
+1938800693u, 680793595u,
+1525265867u, 2808224480u,
+2122290603u, 1211197714u,
+3520488321u, 3979192396u,
+3540779343u, 4192918639u,
+2736030448u, 1120335563u,
+1698949078u, 3993310631u,
+1966048551u, 2228221363u,
+597941119u, 3498018399u,
+393987327u, 454500547u,
+1222959566u, 567151340u,
+3774764786u, 1492844524u,
+3308300614u, 805568076u,
+868414882u, 177406999u,
+1608110313u, 642061169u,
+1027515771u, 3131251981u,
+2851936150u, 4272755262u,
+1532845092u, 709643652u,
+682573592u, 1244104217u,
+796769556u, 2500467040u,
+3002618826u, 1112998535u,
+1780193104u, 1243644607u,
+3691719535u, 2958853053u,
+466635014u, 2277292580u,
+4082276003u, 1030800045u,
+1750863246u, 379050598u,
+3576413281u, 731493104u,
+132259176u, 4115195437u,
+1769890695u, 2715470335u,
+1819263183u, 2028531518u,
+2154809766u, 3672399742u,
+76727603u, 4198182186u,
+2304993586u, 1666387627u,
+284366017u, 3359785538u,
+3469807328u, 2926494787u,
+3829072836u, 2493478921u,
+3738499303u, 3311304980u,
+932916545u, 2235559063u,
+2909742396u, 1765719309u,
+1456588655u, 508290328u,
+1490719640u, 3356513470u,
+2908490783u, 251085588u,
+830410677u, 3172220325u,
+3897208579u, 1940535730u,
+151909546u, 2384458112u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; { uint64_t h = farmhashuo::Hash64WithSeed(farm_hash_data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(farm_hash_data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(farm_hash_data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
{ uint64_t h = farmhashuo::Hash64WithSeed(farm_hash_data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
{ uint64_t h = farmhashuo::Hash64(farm_hash_data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashuoTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashuoTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
{ uint64_t h = farmhashuo::Hash64WithSeed(farm_hash_data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint64_t h = farmhashuo::Hash64(farm_hash_data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashuoTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashuoTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashuoTest::Dump(0, i);
- }
- farmhashuoTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-#ifndef FARMHASH_SELF_TEST_GUARD
-#define FARMHASH_SELF_TEST_GUARD
-#include <cstdio>
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::hex;
-
-static const uint64_t kSeed0 = 1234567;
-static const uint64_t kSeed1 = k0;
-static const int kDataSize = 1 << 20;
-static const int kTestSize = 300;
-#define kSeed128 Uint128(kSeed0, kSeed1)
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashuoTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashuoTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashuoTest::Dump(0, i);
+ }
+ farmhashuoTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+#ifndef FARMHASH_SELF_TEST_GUARD
+#define FARMHASH_SELF_TEST_GUARD
+#include <cstdio>
+#include <iostream>
+#include <string.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::hex;
+
+static const uint64_t kSeed0 = 1234567;
+static const uint64_t kSeed1 = k0;
+static const int kDataSize = 1 << 20;
+static const int kTestSize = 300;
+#define kSeed128 Uint128(kSeed0, kSeed1)
+
static char farm_hash_data[kDataSize];
-
-static int completed_self_tests = 0;
-static int errors = 0;
-
+
+static int completed_self_tests = 0;
+static int errors = 0;
+
// Initialize farm_hash_data to pseudorandom values.
-void Setup() {
- if (completed_self_tests == 0) {
- uint64_t a = 9;
- uint64_t b = 777;
- for (int i = 0; i < kDataSize; i++) {
- a += b;
- b += a;
- a = (a ^ (a >> 41)) * k0;
- b = (b ^ (b >> 41)) * k0 + i;
- uint8_t u = b >> 37;
+void Setup() {
+ if (completed_self_tests == 0) {
+ uint64_t a = 9;
+ uint64_t b = 777;
+ for (int i = 0; i < kDataSize; i++) {
+ a += b;
+ b += a;
+ a = (a ^ (a >> 41)) * k0;
+ b = (b ^ (b >> 41)) * k0 + i;
+ uint8_t u = b >> 37;
memcpy(farm_hash_data + i, &u, 1); // uint8_t -> char
- }
- }
-}
-
-int NoteErrors() {
-#define NUM_SELF_TESTS 9
- if (++completed_self_tests == NUM_SELF_TESTS)
- std::exit(errors > 0);
- return errors;
-}
-
-template <typename T> inline bool IsNonZero(T x) {
- return x != 0;
-}
-
-template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
- return x != Uint128(0, 0);
-}
-
-#endif // FARMHASH_SELF_TEST_GUARD
-
-namespace farmhashxoTest {
-
-uint32_t CreateSeed(int offset, int salt) {
- uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h += static_cast<uint32_t>(offset & 0xffffffff);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- h = h * c1;
- h ^= (h >> 17);
- return h;
-}
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-#define SEED CreateSeed(offset, -1)
-#define SEED0 CreateSeed(offset, 0)
-#define SEED1 CreateSeed(offset, 1)
-
-#undef TESTING
-#define TESTING 1
-#if TESTING
-uint32_t expected[] = {
-1140953930u, 861465670u,
-3277735313u, 2681724312u,
-2598464059u, 797982799u,
-890626835u, 800175912u,
-2603993599u, 921001710u,
-1410420968u, 2134990486u,
-3283896453u, 1867689945u,
-2914424215u, 2244477846u,
-255297188u, 2992121793u,
-1110588164u, 4186314283u,
-161451183u, 3943596029u,
-4019337850u, 452431531u,
-283198166u, 2741341286u,
-3379021470u, 2557197665u,
-299850021u, 2532580744u,
-452473466u, 1706958772u,
-1298374911u, 3099673830u,
-2199864459u, 3696623795u,
-236935126u, 2976578695u,
-4055299123u, 3281581178u,
-1053458494u, 1882212500u,
-2305012065u, 2169731866u,
-3456121707u, 275903667u,
-458884671u, 3033004529u,
-3058973506u, 2379411653u,
-1898235244u, 1402319660u,
-2700149065u, 2699376854u,
-147814787u, 720739346u,
-2433714046u, 4222949502u,
-4220361840u, 1712034059u,
-3425469811u, 3690733394u,
-4148372108u, 1330324210u,
-594028478u, 2921867846u,
-1635026870u, 192883107u,
-780716741u, 1728752234u,
-3280331829u, 326029180u,
-3969463346u, 1436364519u,
-393215742u, 3349570000u,
-3824583307u, 1612122221u,
-2859809759u, 3808705738u,
-1379537552u, 1646032583u,
-2233466664u, 1432476832u,
-4023053163u, 2650381482u,
-2052294713u, 3552092450u,
-1628777059u, 1499109081u,
-3476440786u, 3829307897u,
-2960536756u, 1554038301u,
-1145519619u, 3190844552u,
-2902102606u, 3600725550u,
-237495366u, 540224401u,
-65721842u, 489963606u,
-1448662590u, 397635823u,
-1596489240u, 1562872448u,
-1790705123u, 2128624475u,
-180854224u, 2604346966u,
-1435705557u, 1262831810u,
-155445229u, 1672724608u,
-1669465176u, 1341975128u,
-663607706u, 2077310004u,
-3610042449u, 1911523866u,
-1043692997u, 1454396064u,
-2563776023u, 294527927u,
-1099072299u, 1389770549u,
-703505868u, 678706990u,
-2952353448u, 2026137563u,
-3603803785u, 629449419u,
-1933894405u, 3043213226u,
-226132789u, 2489287368u,
-1552847036u, 645684964u,
-3828089804u, 3632594520u,
-187883449u, 230403464u,
-3151491850u, 3272648435u,
-3729087873u, 1303930448u,
-2002861219u, 165370827u,
-916494250u, 1230085527u,
-3103338579u, 3064290191u,
-3807265751u, 3628174014u,
-231181488u, 851743255u,
-2295806711u, 1781190011u,
-2988893883u, 1554380634u,
-1142264800u, 3667013118u,
-1968445277u, 315203929u,
-2638023604u, 2290487377u,
-732137533u, 1909203251u,
-440398219u, 1891630171u,
-1380301172u, 1498556724u,
-4072067757u, 4165088768u,
-4204318635u, 441430649u,
-3931792696u, 197618179u,
-956300927u, 914413116u,
-3010839769u, 2837339569u,
-2148126371u, 1913303225u,
-3074915312u, 3117299654u,
-4139181436u, 2993479124u,
-3178848746u, 1357272220u,
-1438494951u, 507436733u,
-667183474u, 2084369203u,
-3854939912u, 1413396341u,
-126024219u, 146044391u,
-1016656857u, 3022024459u,
-3254014218u, 429095991u,
-990500595u, 3056862311u,
-985653208u, 1718653828u,
-623071693u, 366414107u,
-1771289760u, 2293458109u,
-3047342438u, 2991127487u,
-3120876698u, 1684583131u,
-3638043310u, 1170404994u,
-863214540u, 1087193030u,
-199124911u, 520792961u,
-3169775996u, 1577421232u,
-3331828431u, 1013201099u,
-1716848157u, 4033596884u,
-1770708857u, 4229339322u,
-1146169032u, 1434258493u,
-3824360466u, 3242407770u,
-1926419493u, 2649785113u,
-872586426u, 762243036u,
-2736953692u, 816692935u,
-1571283333u, 3555213933u,
-2266795890u, 3781899767u,
-4290630595u, 517646945u,
-3006163611u, 2180594090u,
-959214578u, 558910384u,
-1283799121u, 3047062993u,
-3830962609u, 2391606125u,
-3544509313u, 622325861u,
-834785312u, 382936554u,
-1421463872u, 788479970u,
-1825135056u, 2725923798u,
-580988377u, 2826990641u,
-247825043u, 3167748333u,
-812546227u, 2506885666u,
-2584372201u, 1758123094u,
-1891789696u, 389974094u,
-345313518u, 2022370576u,
-3886113119u, 3338548567u,
-1083486947u, 2583576230u,
-1776047957u, 1771384107u,
-3604937815u, 3198590202u,
-3027522813u, 4155628142u,
-4232136669u, 427759438u,
-4244322689u, 542201663u,
-1549591985u, 2856634168u,
-556609672u, 45845311u,
-1175961330u, 3948351189u,
-4165739882u, 4194218315u,
-1634635545u, 4151937410u,
-713127376u, 1467786451u,
-1327394015u, 2743592929u,
-2638154051u, 810082938u,
-3077742128u, 1062268187u,
-4084325664u, 3810665822u,
-3735739145u, 2794294783u,
-2335576331u, 2560479831u,
-690240711u, 997658837u,
-2442302747u, 3948961926u,
-3958366652u, 3067277639u,
-2059157774u, 1211737169u,
-1516711748u, 2339636583u,
-4188504038u, 59581167u,
-2767897792u, 1389679610u,
-2658147000u, 2643979752u,
-3758739543u, 4189944477u,
-1454470782u, 100876854u,
-2995362413u, 118817200u,
-3252925478u, 2062343506u,
-2804483644u, 3088828656u,
-1231633714u, 4168280671u,
-2931588131u, 3284356565u,
-1255909792u, 3130054947u,
-4173605289u, 1407328702u,
-1677744031u, 3532596884u,
-3162657845u, 3887208531u,
-2256541290u, 3459463480u,
-3740979556u, 259034107u,
-392987633u, 3233195759u,
-3606709555u, 3424793077u,
-315836068u, 3200749877u,
-4065431359u, 760633989u,
-2982018998u, 1811050648u,
-234531934u, 1115203611u,
-3897494162u, 1516407838u,
-1603559457u, 323296368u,
-2632963283u, 1778459926u,
-2879836826u, 2146672889u,
-3486330348u, 492621815u,
-1231665285u, 2457048126u,
-3438440082u, 2217471853u,
-3355404249u, 3275550588u,
-1052645068u, 862072556u,
-4110617119u, 3745267835u,
-2657392572u, 4279236653u,
-1688445808u, 701920051u,
-956734128u, 581695350u,
-3157862788u, 2585726058u,
-1192588249u, 1410111809u,
-1651193125u, 3326135446u,
-1073280453u, 97376972u,
-2513844237u, 2187968410u,
-3976859649u, 4267859263u,
-3429034542u, 564493077u,
-3000537321u, 479241367u,
-3845637831u, 2868987960u,
-51544337u, 1029173765u,
-393624922u, 704325635u,
-2357610553u, 1418509533u,
-2007814586u, 3866658271u,
-3082385053u, 735688735u,
-916110004u, 3283299459u,
-1051684175u, 1083796807u,
-4074716319u, 813690332u,
-144264390u, 1439630796u,
-1508556987u, 675582689u,
-3748881891u, 3195309868u,
-362884708u, 1616408198u,
-43233176u, 837301135u,
-881504822u, 3254795114u,
-1385506591u, 2799925823u,
-1469874582u, 3464841997u,
-497175391u, 3929484338u,
-3975771289u, 1798536177u,
-2926265846u, 1374242438u,
-3675707838u, 4205965408u,
-3153165629u, 1499475160u,
-187287713u, 548490821u,
-3255259608u, 4247675634u,
-1940181471u, 3779953975u,
-687167150u, 2319566715u,
-1742785722u, 785893184u,
-2296977392u, 2778575413u,
-1794720651u, 48131484u,
-4084891412u, 1160134629u,
-3737623280u, 823113169u,
-3423207646u, 3803213486u,
-710625654u, 4116162021u,
-3693420287u, 4167766971u,
-1666602807u, 295320990u,
-3513255468u, 2487440590u,
-234080704u, 4004655503u,
-2971762528u, 1479656873u,
-4090178629u, 4044418876u,
-391947536u, 1462554406u,
-3909295855u, 1239580330u,
-1515601363u, 2011102035u,
-1442068334u, 4265993528u,
-1191921695u, 2291355695u,
-4257172787u, 576405853u,
-314332944u, 4038839101u,
-55559918u, 2378985842u,
-711098718u, 2425317635u,
-1644327317u, 1401013391u,
-4193760037u, 2958260436u,
-3167371443u, 3062418115u,
-3800755475u, 3167030094u,
-3489648204u, 1405430357u,
-526177822u, 2602636307u,
-915406019u, 4264167741u,
-1484090483u, 3070944737u,
-254529415u, 4017058800u,
-1702710265u, 1029665228u,
-2000382906u, 3185573940u,
-1381258384u, 4036354071u,
-2900841028u, 2670703363u,
-2921748807u, 2899069938u,
-4130543625u, 688472265u,
-4186808827u, 1054670286u,
-1132985391u, 2840525968u,
-4175776103u, 338058159u,
-1735964501u, 1539305024u,
-3497121710u, 1568260669u,
-2227290760u, 146827036u,
-3977176001u, 4060134777u,
-857488494u, 250055052u,
-4284109679u, 2502815838u,
-2592281721u, 1603444633u,
-1390562014u, 1556658131u,
-616327404u, 2448966429u,
-3051191726u, 3891353218u,
-1213304082u, 762328245u,
-2239052397u, 1082330589u,
-2455957292u, 201837927u,
-405397452u, 3079886794u,
-2583939798u, 2848283092u,
-3750724631u, 883849006u,
-3204198988u, 3341327098u,
-1855234968u, 1982110346u,
-1485529487u, 541496720u,
-4117290321u, 3607433551u,
-2168864636u, 133643215u,
-1055817409u, 3847827123u,
-2960769387u, 4046101649u,
-1176127003u, 4015671361u,
-4243643405u, 2849988118u,
-517111221u, 1796672358u,
-2045051700u, 3452457457u,
-2948254999u, 2102063419u,
-1556410577u, 1536380876u,
-3776661467u, 3281002516u,
-1735616066u, 1539151988u,
-1087795162u, 3332431596u,
-685631442u, 1147951686u,
-95237878u, 2005032160u,
-4012206915u, 4224354805u,
-3204999386u, 2415262714u,
-1433635018u, 116647396u,
-83167836u, 2881562655u,
-2729416454u, 1029284767u,
-881378302u, 2159170082u,
-555057366u, 1169104445u,
-3963877000u, 1919171906u,
-336034862u, 2017579106u,
-4059340529u, 3020819343u,
-865146997u, 2473524405u,
-944743644u, 1694443528u,
-1804513294u, 2904752429u,
-617975720u, 3671562289u,
-260177668u, 505662155u,
-1885941445u, 2504509403u,
-2260041112u, 1019936943u,
-3722741628u, 1511077569u,
-3100701179u, 1379422864u,
-1535670711u, 773792826u,
-1103819072u, 2089123665u,
-1157547425u, 329152940u,
-4142587430u, 484732447u,
-2475035432u, 1120017626u,
-412145504u, 965125959u,
-324924679u, 2809286837u,
-2842141483u, 4029205195u,
-2974306813u, 515627448u,
-3791551981u, 1097806406u,
-3873078673u, 136118734u,
-1872130856u, 3632422367u,
-3574135531u, 4017075736u,
-1699452298u, 1403506686u,
-344414660u, 1189129691u,
-3487080616u, 1516736273u,
-1805475756u, 2562064338u,
-163335594u, 2732147834u,
-4077452507u, 2984955003u,
-4271866024u, 3071338162u,
-2347111903u, 873829983u,
-1948409509u, 1923531348u,
-459509140u, 771592405u,
-1750124750u, 2334938333u,
-213811117u, 2586632018u,
-185232757u, 4032960199u,
-2447383637u, 284777551u,
-1654276320u, 2687561076u,
-3512945009u, 308584855u,
-1861027147u, 4102279334u,
-3203802620u, 1692079268u,
-4250142168u, 2565680167u,
-1507046104u, 841195925u,
-520565830u, 3674576684u,
-38924274u, 3770488806u,
-2414430882u, 3978473838u,
-3703994407u, 69201295u,
-3099963860u, 1255084262u,
-690971838u, 3539996781u,
-3696902571u, 3593730713u,
-2363435042u, 54945052u,
-1785765213u, 184911581u,
-1586241476u, 1939595371u,
-2534883189u, 2432427547u,
-2374171993u, 2039128933u,
-2955715987u, 2295501078u,
-2741583197u, 1280920000u,
-686818699u, 1238742497u,
-3843660102u, 82177963u,
-1281043691u, 1121403845u,
-1697846708u, 284852964u,
-278661677u, 2889101923u,
-2127558730u, 713121337u,
-872502474u, 511142139u,
-1261140657u, 1747052377u,
-2108187161u, 927011680u,
-955328267u, 3821994995u,
-2707230761u, 4142246789u,
-4134691985u, 1958963937u,
-2498463509u, 1977988705u,
-1419293714u, 1636932722u,
-2567532373u, 4075249328u,
-240575705u, 1956681213u,
-2598802768u, 2025886508u,
-4104757832u, 3026358429u,
-3242615202u, 4026813725u,
-255108733u, 1845587644u,
-3573008472u, 3615577014u,
-1222733548u, 1205557630u,
-917608574u, 1363253259u,
-1541946015u, 3087190425u,
-1138008081u, 1444019663u,
-109793386u, 341851980u,
-857839960u, 2515339233u,
-156283211u, 1906768669u,
-3886713057u, 1276595523u,
-2809830736u, 460237542u,
-3420452099u, 142985419u,
-205970448u, 4198897105u,
-1950698961u, 2069753399u,
-1142216925u, 1113051162u,
-1033680610u, 4278599955u,
-1106466069u, 356742959u,
-531521052u, 3494863964u,
-225629455u, 3735275001u,
-3662626864u, 1750561299u,
-1012864651u, 2101846429u,
-1074553219u, 668829411u,
-992181339u, 3384018814u,
-3330664522u, 860966321u,
-1885071395u, 4233785523u,
-100741310u, 451656820u,
-2148187612u, 1063001151u,
-360256231u, 107312677u,
-3650357479u, 2390172694u,
-22452685u, 237319043u,
-3600462351u, 1216645846u,
-2088767754u, 164402616u,
-2418980170u, 926137824u,
-94638678u, 1689811113u,
-2751052984u, 1767810825u,
-271289013u, 3896132233u,
-103797041u, 1397772514u,
-3441135892u, 3323383489u,
-2491268371u, 1662561885u,
-1612872497u, 2986430557u,
-2756998822u, 207428029u,
-937973965u, 2791656726u,
-1949717207u, 2260498180u,
-2648427775u, 2360400900u,
-2080496169u, 486358863u,
-1582022990u, 1263709570u,
-1396468647u, 1377764574u,
-363008508u, 1293502429u,
-224580012u, 4252610345u,
-1435134775u, 1099809675u,
-533671980u, 1533438766u,
-1820532305u, 2776960536u,
-3374512975u, 3542220540u,
-822810075u, 3716663290u,
-1157398049u, 3752806924u,
-4081637863u, 337070226u,
-3866585976u, 359270190u,
-2110942730u, 3267551635u,
-644850146u, 1306761320u,
-746972907u, 934259457u,
-2341378668u, 2220373824u,
-1242645122u, 4109252858u,
-1625266099u, 1173698481u,
-383517064u, 896322512u,
-3377483696u, 1788337208u,
-455496839u, 3194373887u,
-1837689083u, 1336556841u,
-1658628529u, 2911512007u,
-3838343487u, 2757664765u,
-1537187340u, 3712582785u,
-367022558u, 3071359622u,
-3926147070u, 35432879u,
-3093195926u, 2561488770u,
-4273132307u, 3898950547u,
-2838251049u, 2103926083u,
-2549435227u, 536047554u,
-1858986613u, 2040551642u,
-1147412575u, 1972369852u,
-4166184983u, 3528794619u,
-4077477194u, 3565689036u,
-808048238u, 3826350461u,
-1359641525u, 1197100813u,
-265993036u, 1864569342u,
-725164342u, 2264788336u,
-1831223342u, 3329594980u,
-923017956u, 490608221u,
-3818634478u, 258154469u,
-1441714797u, 1174785921u,
-3833372385u, 3287246572u,
-1677395563u, 3569218731u,
-868981704u, 2163330264u,
-2649450292u, 500120236u,
-465161780u, 746438382u,
-1145009669u, 2520062970u,
-2810524030u, 1561519055u,
-1479878006u, 3864969305u,
-2686075657u, 4042710240u,
-3224066062u, 2774151984u,
-2226179547u, 1643626042u,
-2328730865u, 3160666939u,
-2107011431u, 96459446u,
-3920328742u, 3336407558u,
-829404209u, 1878067032u,
-1235983679u, 4237425634u,
-466519055u, 3870676863u,
-934312076u, 2952135524u,
-276949224u, 4100839753u,
-424001484u, 1955120893u,
-4015478120u, 1265237690u,
-427484362u, 4246879223u,
-3452969617u, 1724363362u,
-1553513184u, 834830418u,
-1858777639u, 3476334357u,
-4144030366u, 2450047160u,
-2950762705u, 4277111759u,
-358032121u, 2511026735u,
-167923105u, 2059208280u,
-251949572u, 3065234219u,
-1535473864u, 556796152u,
-1513237478u, 3150857516u,
-1103404394u, 198182691u,
-1476438092u, 2913077464u,
-207119516u, 3963810232u,
-2954651680u, 1535115487u,
-3051522276u, 4046477658u,
-917804636u, 864395565u,
-632704095u, 140762681u,
-1802040304u, 990407433u,
-3771506212u, 4106024923u,
-1287729497u, 2198985327u,
-4052924496u, 2926590471u,
-3084557148u, 1472898694u,
-1009870118u, 559702706u,
-4265214507u, 82077489u,
-3067891003u, 3295678907u,
-2402308151u, 1096697687u,
-464407878u, 4190838199u,
-4269578403u, 3060919438u,
-2899950405u, 3046872820u,
-733509243u, 1583801700u,
-40453902u, 3879773881u,
-1993425202u, 2185339100u,
-1877837196u, 3912423882u,
-3293122640u, 4104318469u,
-1679617763u, 3703603898u,
-8759461u, 2540185277u,
-1152198475u, 2038345882u,
-2503579743u, 1446869792u,
-2019419351u, 4051584612u,
-3178289407u, 3992503830u,
-2879018745u, 2719373510u,
-700836153u, 1675560450u,
-4121245793u, 2064715719u,
-343595772u, 1996164093u,
-3130433948u, 405251683u,
-2804817126u, 1607133689u,
-463852893u, 2864244470u,
-2224044848u, 4071581802u,
-2537107938u, 2246347953u,
-3207234525u, 2028708916u,
-2272418128u, 803575837u,
-38655481u, 2170452091u,
-3272166407u, 557660441u,
-4019147902u, 3841480082u,
-298459606u, 2600943364u,
-2440657523u, 255451671u,
-3424361375u, 779434428u,
-3088526123u, 490671625u,
-1322855877u, 3452203069u,
-3057021940u, 2285701422u,
-2014993457u, 2390431709u,
-2002090272u, 1568745354u,
-1783152480u, 823305654u,
-4053862835u, 2200236540u,
-3009412313u, 3184047862u,
-3032187389u, 4159715581u,
-2966902888u, 252986948u,
-1849329144u, 3160134214u,
-3420960112u, 3198900547u,
-749160960u, 379139040u,
-1208883495u, 1566527339u,
-3006227299u, 4194096960u,
-556075248u, 497404038u,
-1717327230u, 1496132623u,
-1775955687u, 1719108984u,
-1014328900u, 4189966956u,
-2108574735u, 2584236470u,
-684087286u, 531310503u,
-4264509527u, 773405691u,
-3088905079u, 3456882941u,
-3105682208u, 3382290593u,
-2289363624u, 3296306400u,
-4168438718u, 467441309u,
-777173623u, 3241407531u,
-1183994815u, 1132983260u,
-1610606159u, 2540270567u,
-2649684057u, 1397502982u,
-146657385u, 3318434267u,
-2109315753u, 3348545480u,
-3193669211u, 811750340u,
-1073256162u, 3571673088u,
-546596661u, 1017047954u,
-3403136990u, 2540585554u,
-1477047647u, 4145867423u,
-2826408201u, 3531646869u,
-784952939u, 943914610u,
-2717443875u, 3657384638u,
-1806867885u, 1903578924u,
-3985088434u, 1911188923u,
-1764002686u, 3672748083u,
-1832925325u, 241574049u,
-519948041u, 3181425568u,
-2939747257u, 1634174593u,
-3429894862u, 3529565564u,
-1089679033u, 240953857u,
-2025369941u, 2695166650u,
-517086873u, 2964595704u,
-3017658263u, 3828377737u,
-2144895011u, 994799311u,
-1184683823u, 4260564140u,
-308018483u, 4262383425u,
-1374752558u, 3431057723u,
-1572637805u, 383233885u,
-3188015819u, 4051263539u,
-233319221u, 3794788167u,
-2017406667u, 919677938u,
-4074952232u, 1683612329u,
-4213676186u, 327142514u,
-3032591014u, 4204155962u,
-206775997u, 2283918569u,
-2395147154u, 3427505379u,
-2211319468u, 4153726847u,
-2217060665u, 350160869u,
-2493667051u, 1648200185u,
-3441709766u, 1387233546u,
-140980u, 1891558063u,
-760080239u, 2088061981u,
-1580964938u, 740563169u,
-422986366u, 330624974u,
-4264507722u, 150928357u,
-2738323042u, 2948665536u,
-918718096u, 376390582u,
-3966098971u, 717653678u,
-3219466255u, 3799363969u,
-3424344721u, 3187805406u,
-375347278u, 3490350144u,
-1992212097u, 2263421398u,
-3855037968u, 1928519266u,
-3866327955u, 1129127000u,
-1782515131u, 2746577402u,
-3059200728u, 2108753646u,
-2738070963u, 1336849395u,
-1705302106u, 768287270u,
-1343511943u, 2247006571u,
-1956142255u, 1780259453u,
-3475618043u, 212490675u,
-622521957u, 917121602u,
-1852992332u, 1267987847u,
-3170016833u, 2549835613u,
-3299763344u, 2864033668u,
-3378768767u, 1236609378u,
-4169365948u, 3738062408u,
-2661022773u, 2006922227u,
-2760592161u, 3828932355u,
-2636387819u, 2616619070u,
-1237256330u, 3449066284u,
-2871755260u, 3729280948u,
-3862686086u, 431292293u,
-3285899651u, 786322314u,
-2531158535u, 724901242u,
-2377363130u, 1415970351u,
-1244759631u, 3263135197u,
-965248856u, 174024139u,
-2297418515u, 2954777083u,
-987586766u, 3206261120u,
-4059515114u, 3903854066u,
-1931934525u, 2287507921u,
-1827135136u, 1781944746u,
-574617451u, 2299034788u,
-2650140034u, 4081586725u,
-2482286699u, 1109175923u,
-458483596u, 618705848u,
-4059852729u, 1813855658u,
-4190721328u, 1129462471u,
-4089998050u, 3575732749u,
-2375584220u, 1037031473u,
-1623777358u, 3389003793u,
-546597541u, 352770237u,
-1383747654u, 3122687303u,
-1646071378u, 1164309901u,
-290870767u, 830691298u,
-929335420u, 3193251135u,
-989577914u, 3626554867u,
-591974737u, 3996958215u,
-3163711272u, 3071568023u,
-1516846461u, 3656006011u,
-2698625268u, 2510865430u,
-340274176u, 1167681812u,
-3698796465u, 3155218919u,
-4102288238u, 1673474350u,
-3069708839u, 2704165015u,
-1237411891u, 1854985978u,
-3646837503u, 3625406022u,
-921552000u, 1712976649u,
-3939149151u, 878608872u,
-3406359248u, 1068844551u,
-1834682077u, 4155949943u,
-2437686324u, 3163786257u,
-2645117577u, 1988168803u,
-747285578u, 1626463554u,
-1235300371u, 1256485167u,
-1914142538u, 4141546431u,
-3838102563u, 582664250u,
-1883344352u, 2083771672u,
-2611657933u, 2139079047u,
-2250573853u, 804336148u,
-3066325351u, 2770847216u,
-4275641370u, 1455750577u,
-3346357270u, 1674051445u,
-601221482u, 3992583643u,
-1402445097u, 3622527604u,
-2509017299u, 2966108111u,
-2557027816u, 900741486u,
-1790771021u, 2912643797u,
-2631381069u, 4014551783u,
-90375300u, 300318232u,
-3269968032u, 2679371729u,
-2664752123u, 3517585534u,
-3253901179u, 542270815u,
-1188641600u, 365479232u,
-2210121140u, 760762191u,
-1273768482u, 1216399252u,
-3484324231u, 4287337666u,
-16322182u, 643179562u,
-325675502u, 3652676161u,
-3120716054u, 3330259752u,
-1011990087u, 2990167340u,
-1097584090u, 3262252593u,
-1829409951u, 3665087267u,
-1214854475u, 2134299399u,
-3704419305u, 411263051u,
-1625446136u, 549838529u,
-4283196353u, 1342880802u,
-3460621305u, 1967599860u,
-4282843369u, 1275671016u,
-2544665755u, 853593042u,
-901109753u, 2682611693u,
-110631633u, 797487791u,
-1472073141u, 850464484u,
-797089608u, 3286110054u,
-350397471u, 2775631060u,
-366448238u, 3842907484u,
-2219863904u, 3623364733u,
-1850985302u, 4009616991u,
-294963924u, 3693536939u,
-3061255808u, 1615375832u,
-1920066675u, 4113028420u,
-4032223840u, 2318423400u,
-2701956286u, 4145497671u,
-3991532344u, 2536338351u,
-1679099863u, 1728968857u,
-449740816u, 2686506989u,
-685242457u, 97590863u,
-3258354115u, 1502282913u,
-1235084019u, 2151665147u,
-528459289u, 231097464u,
-2477280726u, 3651607391u,
-2091754612u, 1178454681u,
-980597335u, 1604483865u,
-1842333726u, 4146839064u,
-3213794286u, 2601416506u,
-754220096u, 3571436033u,
-488595746u, 1448097974u,
-4004834921u, 238887261u,
-3320337489u, 1416989070u,
-2928916831u, 4093725287u,
-186020771u, 2367569534u,
-3046087671u, 4090084518u,
-3548184546u, 679517009u,
-1962659444u, 3539886328u,
-4192003933u, 1678423485u,
-3827951761u, 3086277222u,
-2144472852u, 1390394371u,
-2976322029u, 1574517163u,
-3553313841u, 119173722u,
-1702434637u, 1766260771u,
-3629581771u, 1407497759u,
-895654784u, 751439914u,
-4008409498u, 215917713u,
-1482103833u, 695551833u,
-1288382231u, 2656990891u,
-2581779077u, 1570750352u,
-3710689053u, 1741390464u,
-2666411616u, 3533987737u,
-4289478316u, 3576119563u,
-4118694920u, 108199666u,
-3869794273u, 963183826u,
-2081410737u, 3796810515u,
-791123882u, 2525792704u,
-1036883117u, 136547246u,
-875691100u, 2592925324u,
-614302599u, 3013176417u,
-2689342539u, 427154472u,
-532957601u, 1228758574u,
-1898117151u, 1181643858u,
-1908591042u, 1464255968u,
-446980910u, 2984611177u,
-58509511u, 1046943619u,
-3508927906u, 2001585786u,
-2544767379u, 1525438381u,
-552181222u, 1959725830u,
-879448844u, 1348536411u,
-4242243590u, 2861338018u,
-1082052441u, 1034351453u,
-601175800u, 764077711u,
-530635011u, 3785343245u,
-2178026726u, 117256687u,
-2378297261u, 457568934u,
-76438221u, 4104954272u,
-956793873u, 3783168634u,
-2485968477u, 2381948487u,
-4226929450u, 3148473363u,
-2518273601u, 3569490233u,
-879369091u, 2180270337u,
-3674375989u, 1387729170u,
-977997984u, 4270646856u,
-568650985u, 951677556u,
-4213877384u, 2721005055u,
-1073364549u, 2563403831u,
-1678669911u, 66786703u,
-2273631661u, 1149351924u,
-3651298990u, 1581883443u,
-246723096u, 1895026827u,
-3810605772u, 3711056516u,
-4058833288u, 2193790614u,
-2080120290u, 3638638708u,
-2915672708u, 2263003308u,
-2361934197u, 4136767460u,
-1976115991u, 3448840877u,
-2019238520u, 225333538u,
-874340815u, 2976159827u,
-1555273378u, 3797521928u,
-1942347150u, 3262952567u,
-435997738u, 340403353u,
-2817830907u, 2078619498u,
-749534111u, 1178073973u,
-894654712u, 3361226032u,
-841092198u, 3288261538u,
-1696412169u, 1496966875u,
-697501571u, 1059158875u,
-3739946319u, 2481012988u,
-568983526u, 114945840u,
-1559249010u, 2218244008u,
-2841706923u, 1632780103u,
-4020169654u, 2087949619u,
-2438736103u, 24032648u,
-833416317u, 3787017905u,
-2373238993u, 2575395164u,
-3434544481u, 3228481067u,
-2542976862u, 2971726178u,
-2880371864u, 3642087909u,
-2407477975u, 2239080836u,
-1043714217u, 3894199764u,
-2235879182u, 203853421u,
-2933669448u, 2504940536u,
-834683330u, 425935223u,
-3560796393u, 3565833278u,
-1668000829u, 3683399154u,
-3414330886u, 1748785729u,
-1023171602u, 580966986u,
-2531038985u, 3227325488u,
-2657385925u, 2124704694u,
-233442446u, 1107045577u,
-3407293834u, 552770757u,
-3899097693u, 1067532701u,
-115667924u, 1406028344u,
-1707768231u, 3724015962u,
-2419657149u, 18613994u,
-2532882091u, 3476683808u,
-1560838678u, 811220224u,
-895961699u, 3762914298u,
-1328752423u, 1844996900u,
-1420427894u, 1848067707u,
-1210281744u, 904215228u,
-4055325594u, 1118521573u,
-2496554183u, 2579259919u,
-3996647489u, 3657647605u,
-325254059u, 3136157065u,
-3951522674u, 4052925250u,
-3341068436u, 2287683323u,
-1313073005u, 126005630u,
-2505120084u, 1194725057u,
-853746559u, 3555092974u,
-2689238752u, 49515858u,
-1244776042u, 1069300695u,
-61073168u, 1010661841u,
-1269521335u, 1902040126u,
-990632502u, 2378708922u,
-3858321250u, 1400735275u,
-2974699176u, 2771676666u,
-170995186u, 2877798589u,
-545726212u, 2225229957u,
-1086473152u, 3454177594u,
-3859483262u, 1499729584u,
-2088002891u, 2883475137u,
-3222194252u, 4144472319u,
-2212229854u, 4146740722u,
-567988835u, 1051332394u,
-3932046135u, 542648229u,
-3017852446u, 1277887997u,
-162888005u, 1669710469u,
-1492500905u, 553041029u,
-1434876932u, 533989516u,
-3817492747u, 584127807u,
-4147115982u, 2993670925u,
-4020312558u, 710021255u,
-3509733475u, 3587959456u,
-2088550465u, 1745399498u,
-2952242967u, 1259815443u,
-869648362u, 1404723176u,
-3947542735u, 1334333531u,
-3873471582u, 229399758u,
-59634866u, 3239516985u,
-3844250972u, 1275954779u,
-1385684948u, 2243700741u,
-2512155003u, 1685649437u,
-639306006u, 2524620206u,
-955360345u, 1646776457u,
-576786501u, 655707039u,
-2864351838u, 3736264674u,
-655621239u, 362070173u,
-1200907897u, 2384379464u,
-15823708u, 206117476u,
-3652870937u, 122927134u,
-1193310960u, 1093099415u,
-3696538026u, 4112584792u,
-1834541277u, 845639252u,
-2069527017u, 547588820u,
-4178147211u, 2827259351u,
-1764455305u, 3312003602u,
-940846775u, 1054995047u,
-2976960697u, 1934305529u,
-3095615046u, 3354962706u,
-2199137382u, 1005722394u,
-1875867180u, 2064356511u,
-3363633633u, 2688499147u,
-4019734130u, 3096333006u,
-2069509024u, 2906358341u,
-3247463123u, 4191788132u,
-2232866485u, 1456016086u,
-1422674894u, 867282151u,
-1851386407u, 1268304058u,
-1612503136u, 1739843072u,
-134947567u, 2978775774u,
-2051592101u, 1017127033u,
-1284167756u, 1090844589u,
-831688783u, 2079216362u,
-2079309682u, 1950585801u,
-1626991196u, 3644714163u,
-3678110059u, 898470030u,
-1117570988u, 2517572125u,
-3916646913u, 3182422972u,
-3630426828u, 969847973u,
-2835126238u, 53541366u,
-3427164640u, 3463937250u,
-3044785046u, 897322257u,
-103038235u, 3804506837u,
-3443872170u, 4185408854u,
-2557463241u, 4080940424u,
-3669923099u, 2789619871u,
-2048168570u, 2429169982u,
-3174690447u, 2513494106u,
-3099587829u, 2627855577u,
-1213061732u, 3143736628u,
-3482268149u, 1250714337u,
-3553412672u, 2689632914u,
-31648125u, 3872383625u,
-1565760579u, 36665130u,
-1282106920u, 359361724u,
-751041229u, 2257179590u,
-2915361862u, 280819225u,
-954406473u, 4101682199u,
-2907818413u, 4254297769u,
-3493178615u, 3755944354u,
-3539557658u, 3330196096u,
-4043533423u, 1134196225u,
-4177134659u, 127246419u,
-4213770762u, 1978302978u,
-2442615581u, 923049607u,
-1004426206u, 782768297u,
-2702745496u, 1880389457u,
-2410586681u, 1430106871u,
-4103323427u, 3168399477u,
-201787012u, 3105353527u,
-3716682375u, 3616334719u,
-3413209549u, 656672786u,
-526032790u, 2895072131u,
-2876965944u, 182894450u,
-456581318u, 2683752067u,
-1287916294u, 1270745752u,
-3877875910u, 3190666241u,
-3240336907u, 4024807233u,
-4227999465u, 2389301430u,
-1681224377u, 1576191191u,
-3599250276u, 2381111980u,
-3995044500u, 995595530u,
-3495321877u, 3956024585u,
-1611608524u, 3815677453u,
-1520987487u, 3669102590u,
-2062334396u, 1656117707u,
-5457134u, 3234118251u,
-4242065111u, 596879987u,
-470187419u, 2688566989u,
-3259870297u, 660100446u,
-1042378442u, 2206034096u,
-442236198u, 2542452448u,
-493137955u, 392411099u,
-3111186954u, 438250493u,
-947967568u, 1234595917u,
-4230082284u, 2762976773u,
-421203727u, 3728409592u,
-2870085764u, 1455086530u,
-2762099647u, 4011882747u,
-1785430706u, 3684427488u,
-1215981925u, 3227517889u,
-3269061963u, 4037515364u,
-1749401388u, 2167451566u,
-3168911474u, 4255057396u,
-2026092260u, 1736192508u,
-4123254745u, 2319366806u,
-3909727042u, 3114708966u,
-1938800693u, 680793595u,
-3933041672u, 616863613u,
-1525265867u, 2808224480u,
-2122290603u, 1211197714u,
-1186177814u, 2395325006u,
-3520488321u, 3979192396u,
-3540779343u, 4192918639u,
-1763872074u, 3402419930u,
-2736030448u, 1120335563u,
-1698949078u, 3993310631u,
-2947659998u, 1461045789u,
-1966048551u, 2228221363u,
-597941119u, 3498018399u,
-1441110751u, 2229999711u,
-393987327u, 454500547u,
-1222959566u, 567151340u,
-2496952483u, 1708770195u,
-3774764786u, 1492844524u,
-3308300614u, 805568076u,
-4068812294u, 3404648243u,
-868414882u, 177406999u,
-1608110313u, 642061169u,
-2093999089u, 222470301u,
-1027515771u, 3131251981u,
-2851936150u, 4272755262u,
-2763002551u, 1881527822u,
-1532845092u, 709643652u,
-682573592u, 1244104217u,
-440905170u, 1111321746u,
-796769556u, 2500467040u,
-3002618826u, 1112998535u,
-1188525643u, 4212674512u,
-1780193104u, 1243644607u,
-3691719535u, 2958853053u,
-2813437721u, 4036584207u,
-466635014u, 2277292580u,
-4082276003u, 1030800045u,
-1899531424u, 609466946u,
-1750863246u, 379050598u,
-3576413281u, 731493104u,
-2707384133u, 2289193651u,
-132259176u, 4115195437u,
-1769890695u, 2715470335u,
-3348954692u, 2166575624u,
-1819263183u, 2028531518u,
-2154809766u, 3672399742u,
-1142139448u, 88299682u,
-76727603u, 4198182186u,
-2304993586u, 1666387627u,
-2488475423u, 3832777692u,
-284366017u, 3359785538u,
-3469807328u, 2926494787u,
-1914195188u, 1134129972u,
-3829072836u, 2493478921u,
-3738499303u, 3311304980u,
-726951526u, 911080963u,
-932916545u, 2235559063u,
-2909742396u, 1765719309u,
-465269850u, 3803621553u,
-1456588655u, 508290328u,
-1490719640u, 3356513470u,
-2262196163u, 1451774941u,
-2908490783u, 251085588u,
-830410677u, 3172220325u,
-4039692645u, 1383603170u,
-3897208579u, 1940535730u,
-151909546u, 2384458112u,
-};
-
-// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
-bool Test(int offset, int len = 0) {
-#undef Check
-#undef IsAlive
-
-#define Check(x) do { \
- const uint32_t actual = (x), e = expected[index++]; \
- bool ok = actual == e; \
- if (!ok) { \
- cerr << "expected " << hex << e << " but got " << actual << endl; \
- ++errors; \
- } \
- assert(ok); \
-} while (0)
-
-#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
-
- // After the following line is where the uses of "Check" and such will go.
- static int index = 0;
+ }
+ }
+}
+
+int NoteErrors() {
+#define NUM_SELF_TESTS 9
+ if (++completed_self_tests == NUM_SELF_TESTS)
+ std::exit(errors > 0);
+ return errors;
+}
+
+template <typename T> inline bool IsNonZero(T x) {
+ return x != 0;
+}
+
+template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
+ return x != Uint128(0, 0);
+}
+
+#endif // FARMHASH_SELF_TEST_GUARD
+
+namespace farmhashxoTest {
+
+uint32_t CreateSeed(int offset, int salt) {
+ uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h += static_cast<uint32_t>(offset & 0xffffffff);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ h = h * c1;
+ h ^= (h >> 17);
+ return h;
+}
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+#define SEED CreateSeed(offset, -1)
+#define SEED0 CreateSeed(offset, 0)
+#define SEED1 CreateSeed(offset, 1)
+
+#undef TESTING
+#define TESTING 1
+#if TESTING
+uint32_t expected[] = {
+1140953930u, 861465670u,
+3277735313u, 2681724312u,
+2598464059u, 797982799u,
+890626835u, 800175912u,
+2603993599u, 921001710u,
+1410420968u, 2134990486u,
+3283896453u, 1867689945u,
+2914424215u, 2244477846u,
+255297188u, 2992121793u,
+1110588164u, 4186314283u,
+161451183u, 3943596029u,
+4019337850u, 452431531u,
+283198166u, 2741341286u,
+3379021470u, 2557197665u,
+299850021u, 2532580744u,
+452473466u, 1706958772u,
+1298374911u, 3099673830u,
+2199864459u, 3696623795u,
+236935126u, 2976578695u,
+4055299123u, 3281581178u,
+1053458494u, 1882212500u,
+2305012065u, 2169731866u,
+3456121707u, 275903667u,
+458884671u, 3033004529u,
+3058973506u, 2379411653u,
+1898235244u, 1402319660u,
+2700149065u, 2699376854u,
+147814787u, 720739346u,
+2433714046u, 4222949502u,
+4220361840u, 1712034059u,
+3425469811u, 3690733394u,
+4148372108u, 1330324210u,
+594028478u, 2921867846u,
+1635026870u, 192883107u,
+780716741u, 1728752234u,
+3280331829u, 326029180u,
+3969463346u, 1436364519u,
+393215742u, 3349570000u,
+3824583307u, 1612122221u,
+2859809759u, 3808705738u,
+1379537552u, 1646032583u,
+2233466664u, 1432476832u,
+4023053163u, 2650381482u,
+2052294713u, 3552092450u,
+1628777059u, 1499109081u,
+3476440786u, 3829307897u,
+2960536756u, 1554038301u,
+1145519619u, 3190844552u,
+2902102606u, 3600725550u,
+237495366u, 540224401u,
+65721842u, 489963606u,
+1448662590u, 397635823u,
+1596489240u, 1562872448u,
+1790705123u, 2128624475u,
+180854224u, 2604346966u,
+1435705557u, 1262831810u,
+155445229u, 1672724608u,
+1669465176u, 1341975128u,
+663607706u, 2077310004u,
+3610042449u, 1911523866u,
+1043692997u, 1454396064u,
+2563776023u, 294527927u,
+1099072299u, 1389770549u,
+703505868u, 678706990u,
+2952353448u, 2026137563u,
+3603803785u, 629449419u,
+1933894405u, 3043213226u,
+226132789u, 2489287368u,
+1552847036u, 645684964u,
+3828089804u, 3632594520u,
+187883449u, 230403464u,
+3151491850u, 3272648435u,
+3729087873u, 1303930448u,
+2002861219u, 165370827u,
+916494250u, 1230085527u,
+3103338579u, 3064290191u,
+3807265751u, 3628174014u,
+231181488u, 851743255u,
+2295806711u, 1781190011u,
+2988893883u, 1554380634u,
+1142264800u, 3667013118u,
+1968445277u, 315203929u,
+2638023604u, 2290487377u,
+732137533u, 1909203251u,
+440398219u, 1891630171u,
+1380301172u, 1498556724u,
+4072067757u, 4165088768u,
+4204318635u, 441430649u,
+3931792696u, 197618179u,
+956300927u, 914413116u,
+3010839769u, 2837339569u,
+2148126371u, 1913303225u,
+3074915312u, 3117299654u,
+4139181436u, 2993479124u,
+3178848746u, 1357272220u,
+1438494951u, 507436733u,
+667183474u, 2084369203u,
+3854939912u, 1413396341u,
+126024219u, 146044391u,
+1016656857u, 3022024459u,
+3254014218u, 429095991u,
+990500595u, 3056862311u,
+985653208u, 1718653828u,
+623071693u, 366414107u,
+1771289760u, 2293458109u,
+3047342438u, 2991127487u,
+3120876698u, 1684583131u,
+3638043310u, 1170404994u,
+863214540u, 1087193030u,
+199124911u, 520792961u,
+3169775996u, 1577421232u,
+3331828431u, 1013201099u,
+1716848157u, 4033596884u,
+1770708857u, 4229339322u,
+1146169032u, 1434258493u,
+3824360466u, 3242407770u,
+1926419493u, 2649785113u,
+872586426u, 762243036u,
+2736953692u, 816692935u,
+1571283333u, 3555213933u,
+2266795890u, 3781899767u,
+4290630595u, 517646945u,
+3006163611u, 2180594090u,
+959214578u, 558910384u,
+1283799121u, 3047062993u,
+3830962609u, 2391606125u,
+3544509313u, 622325861u,
+834785312u, 382936554u,
+1421463872u, 788479970u,
+1825135056u, 2725923798u,
+580988377u, 2826990641u,
+247825043u, 3167748333u,
+812546227u, 2506885666u,
+2584372201u, 1758123094u,
+1891789696u, 389974094u,
+345313518u, 2022370576u,
+3886113119u, 3338548567u,
+1083486947u, 2583576230u,
+1776047957u, 1771384107u,
+3604937815u, 3198590202u,
+3027522813u, 4155628142u,
+4232136669u, 427759438u,
+4244322689u, 542201663u,
+1549591985u, 2856634168u,
+556609672u, 45845311u,
+1175961330u, 3948351189u,
+4165739882u, 4194218315u,
+1634635545u, 4151937410u,
+713127376u, 1467786451u,
+1327394015u, 2743592929u,
+2638154051u, 810082938u,
+3077742128u, 1062268187u,
+4084325664u, 3810665822u,
+3735739145u, 2794294783u,
+2335576331u, 2560479831u,
+690240711u, 997658837u,
+2442302747u, 3948961926u,
+3958366652u, 3067277639u,
+2059157774u, 1211737169u,
+1516711748u, 2339636583u,
+4188504038u, 59581167u,
+2767897792u, 1389679610u,
+2658147000u, 2643979752u,
+3758739543u, 4189944477u,
+1454470782u, 100876854u,
+2995362413u, 118817200u,
+3252925478u, 2062343506u,
+2804483644u, 3088828656u,
+1231633714u, 4168280671u,
+2931588131u, 3284356565u,
+1255909792u, 3130054947u,
+4173605289u, 1407328702u,
+1677744031u, 3532596884u,
+3162657845u, 3887208531u,
+2256541290u, 3459463480u,
+3740979556u, 259034107u,
+392987633u, 3233195759u,
+3606709555u, 3424793077u,
+315836068u, 3200749877u,
+4065431359u, 760633989u,
+2982018998u, 1811050648u,
+234531934u, 1115203611u,
+3897494162u, 1516407838u,
+1603559457u, 323296368u,
+2632963283u, 1778459926u,
+2879836826u, 2146672889u,
+3486330348u, 492621815u,
+1231665285u, 2457048126u,
+3438440082u, 2217471853u,
+3355404249u, 3275550588u,
+1052645068u, 862072556u,
+4110617119u, 3745267835u,
+2657392572u, 4279236653u,
+1688445808u, 701920051u,
+956734128u, 581695350u,
+3157862788u, 2585726058u,
+1192588249u, 1410111809u,
+1651193125u, 3326135446u,
+1073280453u, 97376972u,
+2513844237u, 2187968410u,
+3976859649u, 4267859263u,
+3429034542u, 564493077u,
+3000537321u, 479241367u,
+3845637831u, 2868987960u,
+51544337u, 1029173765u,
+393624922u, 704325635u,
+2357610553u, 1418509533u,
+2007814586u, 3866658271u,
+3082385053u, 735688735u,
+916110004u, 3283299459u,
+1051684175u, 1083796807u,
+4074716319u, 813690332u,
+144264390u, 1439630796u,
+1508556987u, 675582689u,
+3748881891u, 3195309868u,
+362884708u, 1616408198u,
+43233176u, 837301135u,
+881504822u, 3254795114u,
+1385506591u, 2799925823u,
+1469874582u, 3464841997u,
+497175391u, 3929484338u,
+3975771289u, 1798536177u,
+2926265846u, 1374242438u,
+3675707838u, 4205965408u,
+3153165629u, 1499475160u,
+187287713u, 548490821u,
+3255259608u, 4247675634u,
+1940181471u, 3779953975u,
+687167150u, 2319566715u,
+1742785722u, 785893184u,
+2296977392u, 2778575413u,
+1794720651u, 48131484u,
+4084891412u, 1160134629u,
+3737623280u, 823113169u,
+3423207646u, 3803213486u,
+710625654u, 4116162021u,
+3693420287u, 4167766971u,
+1666602807u, 295320990u,
+3513255468u, 2487440590u,
+234080704u, 4004655503u,
+2971762528u, 1479656873u,
+4090178629u, 4044418876u,
+391947536u, 1462554406u,
+3909295855u, 1239580330u,
+1515601363u, 2011102035u,
+1442068334u, 4265993528u,
+1191921695u, 2291355695u,
+4257172787u, 576405853u,
+314332944u, 4038839101u,
+55559918u, 2378985842u,
+711098718u, 2425317635u,
+1644327317u, 1401013391u,
+4193760037u, 2958260436u,
+3167371443u, 3062418115u,
+3800755475u, 3167030094u,
+3489648204u, 1405430357u,
+526177822u, 2602636307u,
+915406019u, 4264167741u,
+1484090483u, 3070944737u,
+254529415u, 4017058800u,
+1702710265u, 1029665228u,
+2000382906u, 3185573940u,
+1381258384u, 4036354071u,
+2900841028u, 2670703363u,
+2921748807u, 2899069938u,
+4130543625u, 688472265u,
+4186808827u, 1054670286u,
+1132985391u, 2840525968u,
+4175776103u, 338058159u,
+1735964501u, 1539305024u,
+3497121710u, 1568260669u,
+2227290760u, 146827036u,
+3977176001u, 4060134777u,
+857488494u, 250055052u,
+4284109679u, 2502815838u,
+2592281721u, 1603444633u,
+1390562014u, 1556658131u,
+616327404u, 2448966429u,
+3051191726u, 3891353218u,
+1213304082u, 762328245u,
+2239052397u, 1082330589u,
+2455957292u, 201837927u,
+405397452u, 3079886794u,
+2583939798u, 2848283092u,
+3750724631u, 883849006u,
+3204198988u, 3341327098u,
+1855234968u, 1982110346u,
+1485529487u, 541496720u,
+4117290321u, 3607433551u,
+2168864636u, 133643215u,
+1055817409u, 3847827123u,
+2960769387u, 4046101649u,
+1176127003u, 4015671361u,
+4243643405u, 2849988118u,
+517111221u, 1796672358u,
+2045051700u, 3452457457u,
+2948254999u, 2102063419u,
+1556410577u, 1536380876u,
+3776661467u, 3281002516u,
+1735616066u, 1539151988u,
+1087795162u, 3332431596u,
+685631442u, 1147951686u,
+95237878u, 2005032160u,
+4012206915u, 4224354805u,
+3204999386u, 2415262714u,
+1433635018u, 116647396u,
+83167836u, 2881562655u,
+2729416454u, 1029284767u,
+881378302u, 2159170082u,
+555057366u, 1169104445u,
+3963877000u, 1919171906u,
+336034862u, 2017579106u,
+4059340529u, 3020819343u,
+865146997u, 2473524405u,
+944743644u, 1694443528u,
+1804513294u, 2904752429u,
+617975720u, 3671562289u,
+260177668u, 505662155u,
+1885941445u, 2504509403u,
+2260041112u, 1019936943u,
+3722741628u, 1511077569u,
+3100701179u, 1379422864u,
+1535670711u, 773792826u,
+1103819072u, 2089123665u,
+1157547425u, 329152940u,
+4142587430u, 484732447u,
+2475035432u, 1120017626u,
+412145504u, 965125959u,
+324924679u, 2809286837u,
+2842141483u, 4029205195u,
+2974306813u, 515627448u,
+3791551981u, 1097806406u,
+3873078673u, 136118734u,
+1872130856u, 3632422367u,
+3574135531u, 4017075736u,
+1699452298u, 1403506686u,
+344414660u, 1189129691u,
+3487080616u, 1516736273u,
+1805475756u, 2562064338u,
+163335594u, 2732147834u,
+4077452507u, 2984955003u,
+4271866024u, 3071338162u,
+2347111903u, 873829983u,
+1948409509u, 1923531348u,
+459509140u, 771592405u,
+1750124750u, 2334938333u,
+213811117u, 2586632018u,
+185232757u, 4032960199u,
+2447383637u, 284777551u,
+1654276320u, 2687561076u,
+3512945009u, 308584855u,
+1861027147u, 4102279334u,
+3203802620u, 1692079268u,
+4250142168u, 2565680167u,
+1507046104u, 841195925u,
+520565830u, 3674576684u,
+38924274u, 3770488806u,
+2414430882u, 3978473838u,
+3703994407u, 69201295u,
+3099963860u, 1255084262u,
+690971838u, 3539996781u,
+3696902571u, 3593730713u,
+2363435042u, 54945052u,
+1785765213u, 184911581u,
+1586241476u, 1939595371u,
+2534883189u, 2432427547u,
+2374171993u, 2039128933u,
+2955715987u, 2295501078u,
+2741583197u, 1280920000u,
+686818699u, 1238742497u,
+3843660102u, 82177963u,
+1281043691u, 1121403845u,
+1697846708u, 284852964u,
+278661677u, 2889101923u,
+2127558730u, 713121337u,
+872502474u, 511142139u,
+1261140657u, 1747052377u,
+2108187161u, 927011680u,
+955328267u, 3821994995u,
+2707230761u, 4142246789u,
+4134691985u, 1958963937u,
+2498463509u, 1977988705u,
+1419293714u, 1636932722u,
+2567532373u, 4075249328u,
+240575705u, 1956681213u,
+2598802768u, 2025886508u,
+4104757832u, 3026358429u,
+3242615202u, 4026813725u,
+255108733u, 1845587644u,
+3573008472u, 3615577014u,
+1222733548u, 1205557630u,
+917608574u, 1363253259u,
+1541946015u, 3087190425u,
+1138008081u, 1444019663u,
+109793386u, 341851980u,
+857839960u, 2515339233u,
+156283211u, 1906768669u,
+3886713057u, 1276595523u,
+2809830736u, 460237542u,
+3420452099u, 142985419u,
+205970448u, 4198897105u,
+1950698961u, 2069753399u,
+1142216925u, 1113051162u,
+1033680610u, 4278599955u,
+1106466069u, 356742959u,
+531521052u, 3494863964u,
+225629455u, 3735275001u,
+3662626864u, 1750561299u,
+1012864651u, 2101846429u,
+1074553219u, 668829411u,
+992181339u, 3384018814u,
+3330664522u, 860966321u,
+1885071395u, 4233785523u,
+100741310u, 451656820u,
+2148187612u, 1063001151u,
+360256231u, 107312677u,
+3650357479u, 2390172694u,
+22452685u, 237319043u,
+3600462351u, 1216645846u,
+2088767754u, 164402616u,
+2418980170u, 926137824u,
+94638678u, 1689811113u,
+2751052984u, 1767810825u,
+271289013u, 3896132233u,
+103797041u, 1397772514u,
+3441135892u, 3323383489u,
+2491268371u, 1662561885u,
+1612872497u, 2986430557u,
+2756998822u, 207428029u,
+937973965u, 2791656726u,
+1949717207u, 2260498180u,
+2648427775u, 2360400900u,
+2080496169u, 486358863u,
+1582022990u, 1263709570u,
+1396468647u, 1377764574u,
+363008508u, 1293502429u,
+224580012u, 4252610345u,
+1435134775u, 1099809675u,
+533671980u, 1533438766u,
+1820532305u, 2776960536u,
+3374512975u, 3542220540u,
+822810075u, 3716663290u,
+1157398049u, 3752806924u,
+4081637863u, 337070226u,
+3866585976u, 359270190u,
+2110942730u, 3267551635u,
+644850146u, 1306761320u,
+746972907u, 934259457u,
+2341378668u, 2220373824u,
+1242645122u, 4109252858u,
+1625266099u, 1173698481u,
+383517064u, 896322512u,
+3377483696u, 1788337208u,
+455496839u, 3194373887u,
+1837689083u, 1336556841u,
+1658628529u, 2911512007u,
+3838343487u, 2757664765u,
+1537187340u, 3712582785u,
+367022558u, 3071359622u,
+3926147070u, 35432879u,
+3093195926u, 2561488770u,
+4273132307u, 3898950547u,
+2838251049u, 2103926083u,
+2549435227u, 536047554u,
+1858986613u, 2040551642u,
+1147412575u, 1972369852u,
+4166184983u, 3528794619u,
+4077477194u, 3565689036u,
+808048238u, 3826350461u,
+1359641525u, 1197100813u,
+265993036u, 1864569342u,
+725164342u, 2264788336u,
+1831223342u, 3329594980u,
+923017956u, 490608221u,
+3818634478u, 258154469u,
+1441714797u, 1174785921u,
+3833372385u, 3287246572u,
+1677395563u, 3569218731u,
+868981704u, 2163330264u,
+2649450292u, 500120236u,
+465161780u, 746438382u,
+1145009669u, 2520062970u,
+2810524030u, 1561519055u,
+1479878006u, 3864969305u,
+2686075657u, 4042710240u,
+3224066062u, 2774151984u,
+2226179547u, 1643626042u,
+2328730865u, 3160666939u,
+2107011431u, 96459446u,
+3920328742u, 3336407558u,
+829404209u, 1878067032u,
+1235983679u, 4237425634u,
+466519055u, 3870676863u,
+934312076u, 2952135524u,
+276949224u, 4100839753u,
+424001484u, 1955120893u,
+4015478120u, 1265237690u,
+427484362u, 4246879223u,
+3452969617u, 1724363362u,
+1553513184u, 834830418u,
+1858777639u, 3476334357u,
+4144030366u, 2450047160u,
+2950762705u, 4277111759u,
+358032121u, 2511026735u,
+167923105u, 2059208280u,
+251949572u, 3065234219u,
+1535473864u, 556796152u,
+1513237478u, 3150857516u,
+1103404394u, 198182691u,
+1476438092u, 2913077464u,
+207119516u, 3963810232u,
+2954651680u, 1535115487u,
+3051522276u, 4046477658u,
+917804636u, 864395565u,
+632704095u, 140762681u,
+1802040304u, 990407433u,
+3771506212u, 4106024923u,
+1287729497u, 2198985327u,
+4052924496u, 2926590471u,
+3084557148u, 1472898694u,
+1009870118u, 559702706u,
+4265214507u, 82077489u,
+3067891003u, 3295678907u,
+2402308151u, 1096697687u,
+464407878u, 4190838199u,
+4269578403u, 3060919438u,
+2899950405u, 3046872820u,
+733509243u, 1583801700u,
+40453902u, 3879773881u,
+1993425202u, 2185339100u,
+1877837196u, 3912423882u,
+3293122640u, 4104318469u,
+1679617763u, 3703603898u,
+8759461u, 2540185277u,
+1152198475u, 2038345882u,
+2503579743u, 1446869792u,
+2019419351u, 4051584612u,
+3178289407u, 3992503830u,
+2879018745u, 2719373510u,
+700836153u, 1675560450u,
+4121245793u, 2064715719u,
+343595772u, 1996164093u,
+3130433948u, 405251683u,
+2804817126u, 1607133689u,
+463852893u, 2864244470u,
+2224044848u, 4071581802u,
+2537107938u, 2246347953u,
+3207234525u, 2028708916u,
+2272418128u, 803575837u,
+38655481u, 2170452091u,
+3272166407u, 557660441u,
+4019147902u, 3841480082u,
+298459606u, 2600943364u,
+2440657523u, 255451671u,
+3424361375u, 779434428u,
+3088526123u, 490671625u,
+1322855877u, 3452203069u,
+3057021940u, 2285701422u,
+2014993457u, 2390431709u,
+2002090272u, 1568745354u,
+1783152480u, 823305654u,
+4053862835u, 2200236540u,
+3009412313u, 3184047862u,
+3032187389u, 4159715581u,
+2966902888u, 252986948u,
+1849329144u, 3160134214u,
+3420960112u, 3198900547u,
+749160960u, 379139040u,
+1208883495u, 1566527339u,
+3006227299u, 4194096960u,
+556075248u, 497404038u,
+1717327230u, 1496132623u,
+1775955687u, 1719108984u,
+1014328900u, 4189966956u,
+2108574735u, 2584236470u,
+684087286u, 531310503u,
+4264509527u, 773405691u,
+3088905079u, 3456882941u,
+3105682208u, 3382290593u,
+2289363624u, 3296306400u,
+4168438718u, 467441309u,
+777173623u, 3241407531u,
+1183994815u, 1132983260u,
+1610606159u, 2540270567u,
+2649684057u, 1397502982u,
+146657385u, 3318434267u,
+2109315753u, 3348545480u,
+3193669211u, 811750340u,
+1073256162u, 3571673088u,
+546596661u, 1017047954u,
+3403136990u, 2540585554u,
+1477047647u, 4145867423u,
+2826408201u, 3531646869u,
+784952939u, 943914610u,
+2717443875u, 3657384638u,
+1806867885u, 1903578924u,
+3985088434u, 1911188923u,
+1764002686u, 3672748083u,
+1832925325u, 241574049u,
+519948041u, 3181425568u,
+2939747257u, 1634174593u,
+3429894862u, 3529565564u,
+1089679033u, 240953857u,
+2025369941u, 2695166650u,
+517086873u, 2964595704u,
+3017658263u, 3828377737u,
+2144895011u, 994799311u,
+1184683823u, 4260564140u,
+308018483u, 4262383425u,
+1374752558u, 3431057723u,
+1572637805u, 383233885u,
+3188015819u, 4051263539u,
+233319221u, 3794788167u,
+2017406667u, 919677938u,
+4074952232u, 1683612329u,
+4213676186u, 327142514u,
+3032591014u, 4204155962u,
+206775997u, 2283918569u,
+2395147154u, 3427505379u,
+2211319468u, 4153726847u,
+2217060665u, 350160869u,
+2493667051u, 1648200185u,
+3441709766u, 1387233546u,
+140980u, 1891558063u,
+760080239u, 2088061981u,
+1580964938u, 740563169u,
+422986366u, 330624974u,
+4264507722u, 150928357u,
+2738323042u, 2948665536u,
+918718096u, 376390582u,
+3966098971u, 717653678u,
+3219466255u, 3799363969u,
+3424344721u, 3187805406u,
+375347278u, 3490350144u,
+1992212097u, 2263421398u,
+3855037968u, 1928519266u,
+3866327955u, 1129127000u,
+1782515131u, 2746577402u,
+3059200728u, 2108753646u,
+2738070963u, 1336849395u,
+1705302106u, 768287270u,
+1343511943u, 2247006571u,
+1956142255u, 1780259453u,
+3475618043u, 212490675u,
+622521957u, 917121602u,
+1852992332u, 1267987847u,
+3170016833u, 2549835613u,
+3299763344u, 2864033668u,
+3378768767u, 1236609378u,
+4169365948u, 3738062408u,
+2661022773u, 2006922227u,
+2760592161u, 3828932355u,
+2636387819u, 2616619070u,
+1237256330u, 3449066284u,
+2871755260u, 3729280948u,
+3862686086u, 431292293u,
+3285899651u, 786322314u,
+2531158535u, 724901242u,
+2377363130u, 1415970351u,
+1244759631u, 3263135197u,
+965248856u, 174024139u,
+2297418515u, 2954777083u,
+987586766u, 3206261120u,
+4059515114u, 3903854066u,
+1931934525u, 2287507921u,
+1827135136u, 1781944746u,
+574617451u, 2299034788u,
+2650140034u, 4081586725u,
+2482286699u, 1109175923u,
+458483596u, 618705848u,
+4059852729u, 1813855658u,
+4190721328u, 1129462471u,
+4089998050u, 3575732749u,
+2375584220u, 1037031473u,
+1623777358u, 3389003793u,
+546597541u, 352770237u,
+1383747654u, 3122687303u,
+1646071378u, 1164309901u,
+290870767u, 830691298u,
+929335420u, 3193251135u,
+989577914u, 3626554867u,
+591974737u, 3996958215u,
+3163711272u, 3071568023u,
+1516846461u, 3656006011u,
+2698625268u, 2510865430u,
+340274176u, 1167681812u,
+3698796465u, 3155218919u,
+4102288238u, 1673474350u,
+3069708839u, 2704165015u,
+1237411891u, 1854985978u,
+3646837503u, 3625406022u,
+921552000u, 1712976649u,
+3939149151u, 878608872u,
+3406359248u, 1068844551u,
+1834682077u, 4155949943u,
+2437686324u, 3163786257u,
+2645117577u, 1988168803u,
+747285578u, 1626463554u,
+1235300371u, 1256485167u,
+1914142538u, 4141546431u,
+3838102563u, 582664250u,
+1883344352u, 2083771672u,
+2611657933u, 2139079047u,
+2250573853u, 804336148u,
+3066325351u, 2770847216u,
+4275641370u, 1455750577u,
+3346357270u, 1674051445u,
+601221482u, 3992583643u,
+1402445097u, 3622527604u,
+2509017299u, 2966108111u,
+2557027816u, 900741486u,
+1790771021u, 2912643797u,
+2631381069u, 4014551783u,
+90375300u, 300318232u,
+3269968032u, 2679371729u,
+2664752123u, 3517585534u,
+3253901179u, 542270815u,
+1188641600u, 365479232u,
+2210121140u, 760762191u,
+1273768482u, 1216399252u,
+3484324231u, 4287337666u,
+16322182u, 643179562u,
+325675502u, 3652676161u,
+3120716054u, 3330259752u,
+1011990087u, 2990167340u,
+1097584090u, 3262252593u,
+1829409951u, 3665087267u,
+1214854475u, 2134299399u,
+3704419305u, 411263051u,
+1625446136u, 549838529u,
+4283196353u, 1342880802u,
+3460621305u, 1967599860u,
+4282843369u, 1275671016u,
+2544665755u, 853593042u,
+901109753u, 2682611693u,
+110631633u, 797487791u,
+1472073141u, 850464484u,
+797089608u, 3286110054u,
+350397471u, 2775631060u,
+366448238u, 3842907484u,
+2219863904u, 3623364733u,
+1850985302u, 4009616991u,
+294963924u, 3693536939u,
+3061255808u, 1615375832u,
+1920066675u, 4113028420u,
+4032223840u, 2318423400u,
+2701956286u, 4145497671u,
+3991532344u, 2536338351u,
+1679099863u, 1728968857u,
+449740816u, 2686506989u,
+685242457u, 97590863u,
+3258354115u, 1502282913u,
+1235084019u, 2151665147u,
+528459289u, 231097464u,
+2477280726u, 3651607391u,
+2091754612u, 1178454681u,
+980597335u, 1604483865u,
+1842333726u, 4146839064u,
+3213794286u, 2601416506u,
+754220096u, 3571436033u,
+488595746u, 1448097974u,
+4004834921u, 238887261u,
+3320337489u, 1416989070u,
+2928916831u, 4093725287u,
+186020771u, 2367569534u,
+3046087671u, 4090084518u,
+3548184546u, 679517009u,
+1962659444u, 3539886328u,
+4192003933u, 1678423485u,
+3827951761u, 3086277222u,
+2144472852u, 1390394371u,
+2976322029u, 1574517163u,
+3553313841u, 119173722u,
+1702434637u, 1766260771u,
+3629581771u, 1407497759u,
+895654784u, 751439914u,
+4008409498u, 215917713u,
+1482103833u, 695551833u,
+1288382231u, 2656990891u,
+2581779077u, 1570750352u,
+3710689053u, 1741390464u,
+2666411616u, 3533987737u,
+4289478316u, 3576119563u,
+4118694920u, 108199666u,
+3869794273u, 963183826u,
+2081410737u, 3796810515u,
+791123882u, 2525792704u,
+1036883117u, 136547246u,
+875691100u, 2592925324u,
+614302599u, 3013176417u,
+2689342539u, 427154472u,
+532957601u, 1228758574u,
+1898117151u, 1181643858u,
+1908591042u, 1464255968u,
+446980910u, 2984611177u,
+58509511u, 1046943619u,
+3508927906u, 2001585786u,
+2544767379u, 1525438381u,
+552181222u, 1959725830u,
+879448844u, 1348536411u,
+4242243590u, 2861338018u,
+1082052441u, 1034351453u,
+601175800u, 764077711u,
+530635011u, 3785343245u,
+2178026726u, 117256687u,
+2378297261u, 457568934u,
+76438221u, 4104954272u,
+956793873u, 3783168634u,
+2485968477u, 2381948487u,
+4226929450u, 3148473363u,
+2518273601u, 3569490233u,
+879369091u, 2180270337u,
+3674375989u, 1387729170u,
+977997984u, 4270646856u,
+568650985u, 951677556u,
+4213877384u, 2721005055u,
+1073364549u, 2563403831u,
+1678669911u, 66786703u,
+2273631661u, 1149351924u,
+3651298990u, 1581883443u,
+246723096u, 1895026827u,
+3810605772u, 3711056516u,
+4058833288u, 2193790614u,
+2080120290u, 3638638708u,
+2915672708u, 2263003308u,
+2361934197u, 4136767460u,
+1976115991u, 3448840877u,
+2019238520u, 225333538u,
+874340815u, 2976159827u,
+1555273378u, 3797521928u,
+1942347150u, 3262952567u,
+435997738u, 340403353u,
+2817830907u, 2078619498u,
+749534111u, 1178073973u,
+894654712u, 3361226032u,
+841092198u, 3288261538u,
+1696412169u, 1496966875u,
+697501571u, 1059158875u,
+3739946319u, 2481012988u,
+568983526u, 114945840u,
+1559249010u, 2218244008u,
+2841706923u, 1632780103u,
+4020169654u, 2087949619u,
+2438736103u, 24032648u,
+833416317u, 3787017905u,
+2373238993u, 2575395164u,
+3434544481u, 3228481067u,
+2542976862u, 2971726178u,
+2880371864u, 3642087909u,
+2407477975u, 2239080836u,
+1043714217u, 3894199764u,
+2235879182u, 203853421u,
+2933669448u, 2504940536u,
+834683330u, 425935223u,
+3560796393u, 3565833278u,
+1668000829u, 3683399154u,
+3414330886u, 1748785729u,
+1023171602u, 580966986u,
+2531038985u, 3227325488u,
+2657385925u, 2124704694u,
+233442446u, 1107045577u,
+3407293834u, 552770757u,
+3899097693u, 1067532701u,
+115667924u, 1406028344u,
+1707768231u, 3724015962u,
+2419657149u, 18613994u,
+2532882091u, 3476683808u,
+1560838678u, 811220224u,
+895961699u, 3762914298u,
+1328752423u, 1844996900u,
+1420427894u, 1848067707u,
+1210281744u, 904215228u,
+4055325594u, 1118521573u,
+2496554183u, 2579259919u,
+3996647489u, 3657647605u,
+325254059u, 3136157065u,
+3951522674u, 4052925250u,
+3341068436u, 2287683323u,
+1313073005u, 126005630u,
+2505120084u, 1194725057u,
+853746559u, 3555092974u,
+2689238752u, 49515858u,
+1244776042u, 1069300695u,
+61073168u, 1010661841u,
+1269521335u, 1902040126u,
+990632502u, 2378708922u,
+3858321250u, 1400735275u,
+2974699176u, 2771676666u,
+170995186u, 2877798589u,
+545726212u, 2225229957u,
+1086473152u, 3454177594u,
+3859483262u, 1499729584u,
+2088002891u, 2883475137u,
+3222194252u, 4144472319u,
+2212229854u, 4146740722u,
+567988835u, 1051332394u,
+3932046135u, 542648229u,
+3017852446u, 1277887997u,
+162888005u, 1669710469u,
+1492500905u, 553041029u,
+1434876932u, 533989516u,
+3817492747u, 584127807u,
+4147115982u, 2993670925u,
+4020312558u, 710021255u,
+3509733475u, 3587959456u,
+2088550465u, 1745399498u,
+2952242967u, 1259815443u,
+869648362u, 1404723176u,
+3947542735u, 1334333531u,
+3873471582u, 229399758u,
+59634866u, 3239516985u,
+3844250972u, 1275954779u,
+1385684948u, 2243700741u,
+2512155003u, 1685649437u,
+639306006u, 2524620206u,
+955360345u, 1646776457u,
+576786501u, 655707039u,
+2864351838u, 3736264674u,
+655621239u, 362070173u,
+1200907897u, 2384379464u,
+15823708u, 206117476u,
+3652870937u, 122927134u,
+1193310960u, 1093099415u,
+3696538026u, 4112584792u,
+1834541277u, 845639252u,
+2069527017u, 547588820u,
+4178147211u, 2827259351u,
+1764455305u, 3312003602u,
+940846775u, 1054995047u,
+2976960697u, 1934305529u,
+3095615046u, 3354962706u,
+2199137382u, 1005722394u,
+1875867180u, 2064356511u,
+3363633633u, 2688499147u,
+4019734130u, 3096333006u,
+2069509024u, 2906358341u,
+3247463123u, 4191788132u,
+2232866485u, 1456016086u,
+1422674894u, 867282151u,
+1851386407u, 1268304058u,
+1612503136u, 1739843072u,
+134947567u, 2978775774u,
+2051592101u, 1017127033u,
+1284167756u, 1090844589u,
+831688783u, 2079216362u,
+2079309682u, 1950585801u,
+1626991196u, 3644714163u,
+3678110059u, 898470030u,
+1117570988u, 2517572125u,
+3916646913u, 3182422972u,
+3630426828u, 969847973u,
+2835126238u, 53541366u,
+3427164640u, 3463937250u,
+3044785046u, 897322257u,
+103038235u, 3804506837u,
+3443872170u, 4185408854u,
+2557463241u, 4080940424u,
+3669923099u, 2789619871u,
+2048168570u, 2429169982u,
+3174690447u, 2513494106u,
+3099587829u, 2627855577u,
+1213061732u, 3143736628u,
+3482268149u, 1250714337u,
+3553412672u, 2689632914u,
+31648125u, 3872383625u,
+1565760579u, 36665130u,
+1282106920u, 359361724u,
+751041229u, 2257179590u,
+2915361862u, 280819225u,
+954406473u, 4101682199u,
+2907818413u, 4254297769u,
+3493178615u, 3755944354u,
+3539557658u, 3330196096u,
+4043533423u, 1134196225u,
+4177134659u, 127246419u,
+4213770762u, 1978302978u,
+2442615581u, 923049607u,
+1004426206u, 782768297u,
+2702745496u, 1880389457u,
+2410586681u, 1430106871u,
+4103323427u, 3168399477u,
+201787012u, 3105353527u,
+3716682375u, 3616334719u,
+3413209549u, 656672786u,
+526032790u, 2895072131u,
+2876965944u, 182894450u,
+456581318u, 2683752067u,
+1287916294u, 1270745752u,
+3877875910u, 3190666241u,
+3240336907u, 4024807233u,
+4227999465u, 2389301430u,
+1681224377u, 1576191191u,
+3599250276u, 2381111980u,
+3995044500u, 995595530u,
+3495321877u, 3956024585u,
+1611608524u, 3815677453u,
+1520987487u, 3669102590u,
+2062334396u, 1656117707u,
+5457134u, 3234118251u,
+4242065111u, 596879987u,
+470187419u, 2688566989u,
+3259870297u, 660100446u,
+1042378442u, 2206034096u,
+442236198u, 2542452448u,
+493137955u, 392411099u,
+3111186954u, 438250493u,
+947967568u, 1234595917u,
+4230082284u, 2762976773u,
+421203727u, 3728409592u,
+2870085764u, 1455086530u,
+2762099647u, 4011882747u,
+1785430706u, 3684427488u,
+1215981925u, 3227517889u,
+3269061963u, 4037515364u,
+1749401388u, 2167451566u,
+3168911474u, 4255057396u,
+2026092260u, 1736192508u,
+4123254745u, 2319366806u,
+3909727042u, 3114708966u,
+1938800693u, 680793595u,
+3933041672u, 616863613u,
+1525265867u, 2808224480u,
+2122290603u, 1211197714u,
+1186177814u, 2395325006u,
+3520488321u, 3979192396u,
+3540779343u, 4192918639u,
+1763872074u, 3402419930u,
+2736030448u, 1120335563u,
+1698949078u, 3993310631u,
+2947659998u, 1461045789u,
+1966048551u, 2228221363u,
+597941119u, 3498018399u,
+1441110751u, 2229999711u,
+393987327u, 454500547u,
+1222959566u, 567151340u,
+2496952483u, 1708770195u,
+3774764786u, 1492844524u,
+3308300614u, 805568076u,
+4068812294u, 3404648243u,
+868414882u, 177406999u,
+1608110313u, 642061169u,
+2093999089u, 222470301u,
+1027515771u, 3131251981u,
+2851936150u, 4272755262u,
+2763002551u, 1881527822u,
+1532845092u, 709643652u,
+682573592u, 1244104217u,
+440905170u, 1111321746u,
+796769556u, 2500467040u,
+3002618826u, 1112998535u,
+1188525643u, 4212674512u,
+1780193104u, 1243644607u,
+3691719535u, 2958853053u,
+2813437721u, 4036584207u,
+466635014u, 2277292580u,
+4082276003u, 1030800045u,
+1899531424u, 609466946u,
+1750863246u, 379050598u,
+3576413281u, 731493104u,
+2707384133u, 2289193651u,
+132259176u, 4115195437u,
+1769890695u, 2715470335u,
+3348954692u, 2166575624u,
+1819263183u, 2028531518u,
+2154809766u, 3672399742u,
+1142139448u, 88299682u,
+76727603u, 4198182186u,
+2304993586u, 1666387627u,
+2488475423u, 3832777692u,
+284366017u, 3359785538u,
+3469807328u, 2926494787u,
+1914195188u, 1134129972u,
+3829072836u, 2493478921u,
+3738499303u, 3311304980u,
+726951526u, 911080963u,
+932916545u, 2235559063u,
+2909742396u, 1765719309u,
+465269850u, 3803621553u,
+1456588655u, 508290328u,
+1490719640u, 3356513470u,
+2262196163u, 1451774941u,
+2908490783u, 251085588u,
+830410677u, 3172220325u,
+4039692645u, 1383603170u,
+3897208579u, 1940535730u,
+151909546u, 2384458112u,
+};
+
+// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
+bool Test(int offset, int len = 0) {
+#undef Check
+#undef IsAlive
+
+#define Check(x) do { \
+ const uint32_t actual = (x), e = expected[index++]; \
+ bool ok = actual == e; \
+ if (!ok) { \
+ cerr << "expected " << hex << e << " but got " << actual << endl; \
+ ++errors; \
+ } \
+ assert(ok); \
+} while (0)
+
+#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
+
+ // After the following line is where the uses of "Check" and such will go.
+ static int index = 0;
if (offset == -1) { int alive = 0; { uint64_t h = farmhashxo::Hash64WithSeeds(farm_hash_data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64WithSeed(farm_hash_data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64(farm_hash_data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
{ uint64_t h = farmhashxo::Hash64WithSeeds(farm_hash_data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
{ uint64_t h = farmhashxo::Hash64WithSeed(farm_hash_data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
{ uint64_t h = farmhashxo::Hash64(farm_hash_data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
-
- return true;
-#undef Check
-#undef IsAlive
-}
-
-int RunTest() {
- Setup();
- int i = 0;
- cout << "Running farmhashxoTest";
- if (!Test(-1)) {
- cout << "... Unavailable\n";
- return NoteErrors();
- }
- // Good. The function is attempting to hash, so run the full test.
- int errors_prior_to_test = errors;
- for ( ; i < kTestSize - 1; i++) {
- Test(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- Test(0, i);
- }
- Test(0, kDataSize);
- cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
- return NoteErrors();
-}
-
-#else
-
-// After the following line is where the code to print hash codes will go.
-void Dump(int offset, int len) {
+
+ return true;
+#undef Check
+#undef IsAlive
+}
+
+int RunTest() {
+ Setup();
+ int i = 0;
+ cout << "Running farmhashxoTest";
+ if (!Test(-1)) {
+ cout << "... Unavailable\n";
+ return NoteErrors();
+ }
+ // Good. The function is attempting to hash, so run the full test.
+ int errors_prior_to_test = errors;
+ for ( ; i < kTestSize - 1; i++) {
+ Test(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ Test(0, i);
+ }
+ Test(0, kDataSize);
+ cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
+ return NoteErrors();
+}
+
+#else
+
+// After the following line is where the code to print hash codes will go.
+void Dump(int offset, int len) {
{ uint64_t h = farmhashxo::Hash64WithSeeds(farm_hash_data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint64_t h = farmhashxo::Hash64WithSeed(farm_hash_data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
{ uint64_t h = farmhashxo::Hash64(farm_hash_data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
-}
-
-#endif
-
-#undef SEED
-#undef SEED1
-#undef SEED0
-
-} // namespace farmhashxoTest
-
-#if !TESTING
-int main(int argc, char** argv) {
- Setup();
- cout << "uint32_t expected[] = {\n";
- int i = 0;
- for ( ; i < kTestSize - 1; i++) {
- farmhashxoTest::Dump(i * i, i);
- }
- for ( ; i < kDataSize; i += i / 7) {
- farmhashxoTest::Dump(0, i);
- }
- farmhashxoTest::Dump(0, kDataSize);
- cout << "};\n";
-}
-#endif
-
+}
+
+#endif
+
+#undef SEED
+#undef SEED1
+#undef SEED0
+
+} // namespace farmhashxoTest
+
+#if !TESTING
+int main(int argc, char** argv) {
+ Setup();
+ cout << "uint32_t expected[] = {\n";
+ int i = 0;
+ for ( ; i < kTestSize - 1; i++) {
+ farmhashxoTest::Dump(i * i, i);
+ }
+ for ( ; i < kDataSize; i += i / 7) {
+ farmhashxoTest::Dump(0, i);
+ }
+ farmhashxoTest::Dump(0, kDataSize);
+ cout << "};\n";
+}
+#endif
+
Y_UNIT_TEST_SUITE(FarmhashTest) {
Y_UNIT_TEST(Test) {
- UNIT_ASSERT(farmhashccTest::RunTest() == 0);
- UNIT_ASSERT(farmhashmkTest::RunTest() == 0);
- UNIT_ASSERT(farmhashnaTest::RunTest() == 0);
- UNIT_ASSERT(farmhashntTest::RunTest() == 0);
- UNIT_ASSERT(farmhashsaTest::RunTest() == 0);
- UNIT_ASSERT(farmhashsuTest::RunTest() == 0);
- UNIT_ASSERT(farmhashteTest::RunTest() == 0);
- UNIT_ASSERT(farmhashuoTest::RunTest() == 0);
- UNIT_ASSERT(farmhashxoTest::RunTest() == 0);
- }
-}
-
-#endif // FARMHASHSELFTEST
+ UNIT_ASSERT(farmhashccTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashmkTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashnaTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashntTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashsaTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashsuTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashteTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashuoTest::RunTest() == 0);
+ UNIT_ASSERT(farmhashxoTest::RunTest() == 0);
+ }
+}
+
+#endif // FARMHASHSELFTEST
diff --git a/contrib/libs/farmhash/ut/ya.make b/contrib/libs/farmhash/ut/ya.make
index a7f689f8c5..94c6d15208 100644
--- a/contrib/libs/farmhash/ut/ya.make
+++ b/contrib/libs/farmhash/ut/ya.make
@@ -1,13 +1,13 @@
-UNITTEST_FOR(contrib/libs/farmhash)
-
+UNITTEST_FOR(contrib/libs/farmhash)
+
OWNER(
somov
)
-
-NO_COMPILER_WARNINGS()
-
-CFLAGS(-DFARMHASHSELFTEST)
-
-SRCS(test.cc)
-
-END()
+
+NO_COMPILER_WARNINGS()
+
+CFLAGS(-DFARMHASHSELFTEST)
+
+SRCS(test.cc)
+
+END()
diff --git a/contrib/libs/farmhash/ya.make b/contrib/libs/farmhash/ya.make
index 8348d45d32..5e1a631819 100644
--- a/contrib/libs/farmhash/ya.make
+++ b/contrib/libs/farmhash/ya.make
@@ -1,30 +1,30 @@
-LIBRARY()
-
-LICENSE(MIT)
-
+LIBRARY()
+
+LICENSE(MIT)
+
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
VERSION(2017-06-26-23eecfbe7e84ebf2e229bd02248f431c36e12f1a)
OWNER(somov)
-
+
ADDINCL(GLOBAL contrib/libs/farmhash/include)
-PEERDIR(
- contrib/libs/farmhash/arch/sse41
- contrib/libs/farmhash/arch/sse42
- contrib/libs/farmhash/arch/sse42_aesni
-)
-
-NO_COMPILER_WARNINGS()
-
-SRCS(
- farmhashuo.cc
- farmhashxo.cc
- farmhashna.cc
- farmhashmk.cc
- farmhashcc.cc
- farmhash_iface.cc
-)
-
-END()
+PEERDIR(
+ contrib/libs/farmhash/arch/sse41
+ contrib/libs/farmhash/arch/sse42
+ contrib/libs/farmhash/arch/sse42_aesni
+)
+
+NO_COMPILER_WARNINGS()
+
+SRCS(
+ farmhashuo.cc
+ farmhashxo.cc
+ farmhashna.cc
+ farmhashmk.cc
+ farmhashcc.cc
+ farmhash_iface.cc
+)
+
+END()
diff --git a/contrib/libs/fastlz/LICENSE b/contrib/libs/fastlz/LICENSE
index 8381d113a4..4a6abd6acb 100644
--- a/contrib/libs/fastlz/LICENSE
+++ b/contrib/libs/fastlz/LICENSE
@@ -1,24 +1,24 @@
-FastLZ - lightning-fast lossless compression library
-
-Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
-Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
-Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
+FastLZ - lightning-fast lossless compression library
+
+Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/contrib/libs/grpc/src/python/grpcio/ya.make b/contrib/libs/grpc/src/python/grpcio/ya.make
index bef1e7f43f..5cdb0230c4 100644
--- a/contrib/libs/grpc/src/python/grpcio/ya.make
+++ b/contrib/libs/grpc/src/python/grpcio/ya.make
@@ -1,7 +1,7 @@
PY23_LIBRARY()
-LICENSE(Apache-2.0)
-
+LICENSE(Apache-2.0)
+
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
OWNER(
diff --git a/contrib/libs/grpc/ya.make b/contrib/libs/grpc/ya.make
index 4f26dbf992..29848d23ea 100644
--- a/contrib/libs/grpc/ya.make
+++ b/contrib/libs/grpc/ya.make
@@ -57,7 +57,7 @@ RECURSE(
RECURSE_FOR_TESTS(
src/proto/grpc/testing
src/proto/grpc/testing/duplicate
- src/proto/grpc/testing/xds
+ src/proto/grpc/testing/xds
src/python/grpcio_tests
test/core/util
test/cpp/end2end
diff --git a/contrib/libs/highwayhash/IMPORT b/contrib/libs/highwayhash/IMPORT
index 7b70d9300b..c1b4084ec0 100644
--- a/contrib/libs/highwayhash/IMPORT
+++ b/contrib/libs/highwayhash/IMPORT
@@ -1 +1 @@
-Imported from https://github.com/google/highwayhash commit 2b666ae078292b01024453d01480f3b362a2a012 (master branch, 2017-05-08)
+Imported from https://github.com/google/highwayhash commit 2b666ae078292b01024453d01480f3b362a2a012 (master branch, 2017-05-08)
diff --git a/contrib/libs/highwayhash/LICENSE b/contrib/libs/highwayhash/LICENSE
index 4d581db0a5..6b0b1270ff 100644
--- a/contrib/libs/highwayhash/LICENSE
+++ b/contrib/libs/highwayhash/LICENSE
@@ -1,203 +1,203 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/contrib/libs/highwayhash/README.md b/contrib/libs/highwayhash/README.md
index 4d120be2a2..2d311c66c1 100644
--- a/contrib/libs/highwayhash/README.md
+++ b/contrib/libs/highwayhash/README.md
@@ -1,350 +1,350 @@
-Strong (well-distributed and unpredictable) hashes:
-
-* Portable implementation of
- [SipHash](https://www.131002.net/siphash/siphash.pdf)
-* HighwayHash, a 5x faster SIMD hash with [security
- claims](https://arxiv.org/abs/1612.06257)
-
-## Quick Start
-
-To build on a Linux or Mac platform, simply run `make`. For Windows, we provide
-a Visual Studio 2015 project in the `msvc` subdirectory.
-
-Run `benchmark` for speed measurements. `sip_hash_test` and `highwayhash_test`
-ensure the implementations return known-good values for a given set of inputs.
-
-64-bit SipHash for any CPU:
-
- #include "highwayhash/sip_hash.h"
- using namespace highwayhash;
- const HH_U64 key2[2] HH_ALIGNAS(16) = {1234, 5678};
- char in[8] = {1};
- return SipHash(key2, in, 8);
-
-64, 128 or 256 bit HighwayHash for the CPU determined by compiler flags:
-
- #include "highwayhash/highwayhash.h"
- using namespace highwayhash;
- const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
- char in[8] = {1};
- HHResult64 result; // or HHResult128 or HHResult256
- HHStateT<HH_TARGET> state(key);
- HighwayHashT(&state, in, 8, &result);
-
-64, 128 or 256 bit HighwayHash for the CPU on which we're currently running:
-
- #include "highwayhash/highwayhash_target.h"
- #include "highwayhash/instruction_sets.h"
- using namespace highwayhash;
- const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
- char in[8] = {1};
- HHResult64 result; // or HHResult128 or HHResult256
- InstructionSets::Run<HighwayHash>(key, in, 8, &result);
-
-C-callable 64-bit HighwayHash for the CPU on which we're currently running:
-
- #include "highwayhash/c_bindings.h"
- const uint64_t key[4] = {1, 2, 3, 4};
- char in[8] = {1};
- return HighwayHash64(key, in, 8);
-
-## Introduction
-
-Hash functions are widely used, so it is desirable to increase their speed and
-security. This package provides two 'strong' (well-distributed and
-unpredictable) hash functions: a faster version of SipHash, and an even faster
-algorithm we call HighwayHash.
-
-SipHash is a fast but 'cryptographically strong' pseudo-random function by
-Aumasson and Bernstein [https://www.131002.net/siphash/siphash.pdf].
-
-HighwayHash is a new way of mixing inputs which may inspire new
-cryptographically strong hashes. Large inputs are processed at a rate of 0.24
-cycles per byte, and latency remains low even for small inputs. HighwayHash is
-faster than SipHash for all input sizes, with 5 times higher throughput at 1
-KiB. We discuss design choices and provide statistical analysis and preliminary
-cryptanalysis in https://arxiv.org/abs/1612.06257.
-
-## Applications
-
-Unlike prior strong hashes, these functions are fast enough to be recommended
-as safer replacements for weak hashes in many applications. The additional CPU
-cost appears affordable, based on profiling data indicating C++ hash functions
-account for less than 0.25% of CPU usage.
-
-Hash-based selection of random subsets is useful for A/B experiments and similar
-applications. Such random generators are idempotent (repeatable and
-deterministic), which is helpful for parallel algorithms and testing. To avoid
-bias, it is important that the hash function be unpredictable and
-indistinguishable from a uniform random generator. We have verified the bit
-distribution and avalanche properties of SipHash and HighwayHash.
-
-64-bit hashes are also useful for authenticating short-lived messages such as
-network/RPC packets. This requires that the hash function withstand
-differential, length extension and other attacks. We have published a formal
-security analysis for HighwayHash. New cryptanalysis tools may still need to be
-developed for further analysis.
-
-Strong hashes are also important parts of methods for protecting hash tables
-against unacceptable worst-case behavior and denial of service attacks
-(see "hash flooding" below).
-
-## SipHash
-
-Our SipHash implementation is a fast and portable drop-in replacement for
-the reference C code. Outputs are identical for the given test cases (messages
-between 0 and 63 bytes).
-
-Interestingly, it is about twice as fast as a SIMD implementation using SSE4.1
-(https://goo.gl/80GBSD). This is presumably due to the lack of SIMD bit rotate
-instructions.
-
-SipHash13 is a faster but weaker variant with one mixing round per update and
-three during finalization.
-
-We also provide a data-parallel 'tree hash' variant that enables efficient SIMD
-while retaining safety guarantees. This is about twice as fast as SipHash, but
-does not return the same results.
-
-## HighwayHash
-
-We have devised a new way of mixing inputs with AVX2 multiply and permute
-instructions. The multiplications are 32x32 -> 64 bits and therefore infeasible
-to reverse. Permuting equalizes the distribution of the resulting bytes.
-
-The internal state occupies four 256-bit AVX2 registers. Due to limitations of
-the instruction set, the registers are partitioned into two 512-bit halves that
-remain independent until the reduce phase. The algorithm outputs 64 bit digests
-or up to 256 bits at no extra cost.
-
-In addition to high throughput, the algorithm is designed for low finalization
-cost. The result is more than twice as fast as SipTreeHash.
-
-For older CPUs, we also provide an SSE4.1 version (80% as fast for large inputs
-and 95% as fast for short inputs) and a portable version (10% as fast).
-
-Statistical analyses and preliminary cryptanalysis are given in
-https://arxiv.org/abs/1612.06257.
-
-## Versioning and stability
-
-SipHash and HighwayHash 1.0 are 'fingerprint functions' whose input -> hash
-mapping will not change. This is important for applications that write hashes to
-persistent storage.
-
-HighwayHash has not yet reached 1.0 and may still change in the near future. We
-will announce when it is frozen.
-
-## Speed measurements
-
-To measure the CPU cost of a hash function, we can either create an artificial
-'microbenchmark' (easier to control, but probably not representative of the
-actual runtime), or insert instrumentation directly into an application (risks
-influencing the results through observer overhead). We provide novel variants of
-both approaches that mitigate their respective disadvantages.
-
-profiler.h uses software write-combining to stream program traces to memory
-with minimal overhead. These can be analyzed offline, or when memory is full,
-to learn how much time was spent in each (possibly nested) zone.
-
-nanobenchmark.h enables cycle-accurate measurements of very short functions.
-It uses CPU fences and robust statistics to minimize variability, and also
-avoids unrealistic branch prediction effects.
-
-We compile the C++ implementations with a patched GCC 4.9 and run on a single
-core of a Xeon E5-2690 v3 clocked at 2.6 GHz. CPU cost is measured as cycles per
-byte for various input sizes:
-
-Algorithm | 8 | 31 | 32 | 63 | 64 | 1024
----------------- | ----- | ---- | ---- | ---- | ---- | ----
-HighwayHashAVX2 | 7.34 | 1.81 | 1.71 | 1.04 | 0.95 | 0.24
-HighwayHashSSE41 | 8.00 | 2.11 | 1.75 | 1.13 | 0.96 | 0.30
-SipTreeHash | 16.51 | 4.57 | 4.09 | 2.22 | 2.29 | 0.57
-SipTreeHash13 | 12.33 | 3.47 | 3.06 | 1.68 | 1.63 | 0.33
-SipHash | 8.13 | 2.58 | 2.73 | 1.87 | 1.93 | 1.26
-SipHash13 | 6.96 | 2.09 | 2.12 | 1.32 | 1.33 | 0.68
-
-SipTreeHash is slower than SipHash for small inputs because it processes blocks
-of 32 bytes. AVX2 and SSE4.1 HighwayHash are faster than SipHash for all input
-sizes due to their highly optimized handling of partial vectors.
-
-Note that previous measurements included the initialization of their input,
-which dramatically increased timings especially for small inputs.
-
-## CPU requirements
-
-SipTreeHash[13] requires an AVX2-capable CPU (e.g. Haswell). HighwayHash
-includes a dispatcher that chooses the best available (AVX2, SSE4.1 or portable)
-implementation at runtime, as well as a directly callable function template that
-can only run on the CPU for which it was built. SipHash[13] and
-ScalarSipTreeHash[13] have no particular CPU requirements.
-
-Our implementations use custom AVX2 vector classes with overloaded operators
-(e.g. `const V4x64U a = b + c`) for type-safety and improved readability vs.
-compiler intrinsics (e.g. `const __m256i a = _mm256_add_epi64(b, c)`).
-
-We intend to port HighwayHash to other SIMD-capable platforms, especially ARM.
-
-Our instruction_sets dispatcher avoids running newer instructions on older CPUs
-that do not support them. However, intrinsics, and therefore also any vector
-classes that use them, require a compiler flag that also enables the compiler to
-generate code for that CPU. This means the intrinsics must be placed in separate
-translation units that are compiled with the required flags. It is important
-that these source files and their headers not define any inline functions,
-because that might break the one definition rule and cause crashes.
-
-To minimize dispatch overhead when hashes are computed often (e.g. in a loop),
-we can inline the hash function into its caller using templates. The dispatch
-overhead will only be paid once (e.g. before the loop). The template mechanism
-also avoids duplicating code in each CPU-specific implementation.
-
-## Defending against hash flooding
-
-To mitigate hash flooding attacks, we need to take both the hash function and
-the data structure into account.
-
-We wish to defend (web) services that utilize hash sets/maps against
-denial-of-service attacks. Such data structures assign attacker-controlled
-input messages `m` to a hash table bin `b` by computing the hash `H(s, m)`
-using a hash function `H` seeded by `s`, and mapping it to a bin with some
-narrowing function `b = R(h)`, discussed below.
-
-Attackers may attempt to trigger 'flooding' (excessive work in insertions or
-lookups) by finding multiple `m` that map to the same bin. If the attacker has
-local access, they can do far worse, so we assume the attacker can only issue
-remote requests. If the attacker is able to send large numbers of requests,
-they can already deny service, so we need only ensure the attacker's cost is
-sufficiently large compared to the service's provisioning.
-
-If the hash function is 'weak', attackers can easily generate 'hash collisions'
-(inputs mapping to the same hash values) that are independent of the seed. In
-other words, certain input messages will cause collisions regardless of the seed
-value. The author of SipHash has published C++ programs to generate such
-'universal (key-independent) multicollisions' for CityHash and Murmur. Similar
-'differential' attacks are likely possible for any hash function consisting only
-of reversible operations (e.g. addition/multiplication/rotation) with a constant
-operand. `n` requests with such inputs cause `n^2` work for an unprotected hash
-table, which is unacceptable.
-
-By contrast, 'strong' hashes such as SipHash or HighwayHash require infeasible
-attacker effort to find a hash collision (an expected 2^32 guesses of `m` per
-the birthday paradox) or recover the seed (2^63 requests). These security claims
-assume the seed is secret. It is reasonable to suppose `s` is initially unknown
-to attackers, e.g. generated on startup or even per-connection. A timing attack
-by Wool/Bar-Yosef recovers 13-bit seeds by testing all 8K possibilities using
-millions of requests, which takes several days (even assuming unrealistic 150 us
-round-trip times). It appears infeasible to recover 64-bit seeds in this way.
-
-However, attackers are only looking for multiple `m` mapping to the same bin
-rather than identical hash values. We assume they know or are able to discover
-the hash table size `p`. It is common to choose `p = 2^i` to enable an efficient
-`R(h) := h & (p - 1)`, which simply retains the lower hash bits. It may be
-easier for attackers to compute partial collisions where only the lower `i` bits
-match. This can be prevented by choosing a prime `p` so that `R(h) := h % p`
-incorporates all hash bits. The costly modulo operation can be avoided by
-multiplying with the inverse (https://goo.gl/l7ASm8). An interesting alternative
-suggested by Kyoung Jae Seo chooses a random subset of the `h` bits. Such an `R`
-function can be computed in just 3 cycles using PEXT from the BMI2 instruction
-set. This is expected to defend against SAT-solver attacks on the hash bits at a
-slightly lower cost than the multiplicative inverse method, and still allows
-power-of-two table sizes.
-
-Summary thus far: given a strong hash function and secret seed, it appears
-infeasible for attackers to generate hash collisions because `s` and/or `R` are
-unknown. However, they can still observe the timings of data structure
-operations for various `m`. With typical table sizes of 2^10 to 2^17 entries,
-attackers can detect some 'bin collisions' (inputs mapping to the same bin).
-Although this will be costly for the attacker, they can then send many instances
-of such inputs, so we need to limit the resulting work for our data structure.
-
-Hash tables with separate chaining typically store bin entries in a linked list,
-so worst-case inputs lead to unacceptable linear-time lookup cost. We instead
-seek optimal asymptotic worst-case complexity for each operation (insertion,
-deletion and lookups), which is a constant factor times the logarithm of the
-data structure size. This naturally leads to a tree-like data structure for each
-bin. The Java8 HashMap only replaces its linked list with trees when needed.
-This leads to additional cost and complexity for deciding whether a bin is a
-list or tree.
-
-Our first proposal (suggested by Github user funny-falcon) avoids this overhead
-by always storing one tree per bin. It may also be worthwhile to store the first
-entry directly in the bin, which avoids allocating any tree nodes in the common
-case where bins are sparsely populated. What kind of tree should be used?
-Scapegoat and splay trees only offer amortized complexity guarantees, whereas
-treaps require an entropy source and have higher constant factors in practice.
-Self-balancing structures such as 2-3 or red-black trees require additional
-bookkeeping information. We can hope to reduce rebalancing cost by realizing
-that the output bits of strong `H` functions are uniformly distributed. When
-using them as keys instead of the original message `m`, recent relaxed balancing
-schemes such as left-leaning red-black or weak AVL trees may require fewer tree
-rotations to maintain their invariants. Note that `H` already determines the
-bin, so we should only use the remaining bits. 64-bit hashes are likely
-sufficient for this purpose, and HighwayHash generates up to 256 bits. It seems
-unlikely that attackers can craft inputs resulting in worst cases for both the
-bin index and tree key without being able to generate hash collisions, which
-would contradict the security claims of strong hashes. Even if they succeed, the
-relaxed tree balancing still guarantees an upper bound on height and therefore
-the worst-case operation cost. For the AVL variant, the constant factors are
-slightly lower than for red-black trees.
-
-The second proposed approach uses augmented/de-amortized cuckoo hash tables
-(https://goo.gl/PFwwkx). These guarantee worst-case `log n` bounds for all
-operations, but only if the hash function is 'indistinguishable from random'
-(uniformly distributed regardless of the input distribution), which is claimed
-for SipHash and HighwayHash but certainly not for weak hashes.
-
-Both alternatives retain good average case performance and defend against
-flooding by limiting the amount of extra work an attacker can cause. The first
-approach guarantees an upper bound of `log n` additional work even if the hash
-function is compromised.
-
-In summary, a strong hash function is not, by itself, sufficient to protect a
-chained hash table from flooding attacks. However, strong hash functions are
-important parts of two schemes for preventing denial of service. Using weak hash
-functions can slightly accelerate the best-case and average-case performance of
-a service, but at the risk of greatly reduced attack costs and worst-case
-performance.
-
-## Third-party implementations / bindings
-
-Thanks to Damian Gryski for making us aware of these third-party
-implementations or bindings. Please feel free to get in touch or
-raise an issue and we'll add yours as well.
-
-By | Language | URL
---- | --- | ---
-Damian Gryski | Go and SSE | https://github.com/dgryski/go-highway/
-Lovell Fuller | node.js bindings | https://github.com/lovell/highwayhash
-Vinzent Steinberg | Rust bindings | https://github.com/vks/highwayhash-rs
-
-## Modules
-
-### Hashes
-
-* c_bindings.h declares C-callable versions of SipHash/HighwayHash.
-* sip_hash.cc is the compatible implementation of SipHash, and also provides
- the final reduction for sip_tree_hash.
-* sip_tree_hash.cc is the faster but incompatible SIMD j-lanes tree hash.
-* scalar_sip_tree_hash.cc is a non-SIMD version.
-* state_helpers.h simplifies the implementation of the SipHash variants.
-* highwayhash.h is our new, fast hash function.
-* hh_avx2.h, hh_sse41.h and hh_portable.h are its various implementations.
-* highwayhash_target.h chooses the best available implementation at runtime.
-
-### Infrastructure
-
-* arch_specific.h offers byte swapping and CPUID detection.
-* compiler_specific.h defines some compiler-dependent language extensions.
-* data_parallel.h provides a C++11 ThreadPool and PerThread (similar to
- OpenMP).
-* instruction_sets.h and targets.h enable efficient CPU-specific dispatching.
-* nanobenchmark.h measures elapsed times with < 1 cycle variability.
-* os_specific.h sets thread affinity and priority for benchmarking.
-* profiler.h is a low-overhead, deterministic hierarchical profiler.
-* tsc_timer.h obtains high-resolution timestamps without CPU reordering.
-* vector256.h and vector128.h contain wrapper classes for AVX2 and SSE4.1.
-
-By Jan Wassenberg <jan.wassenberg@gmail.com> and Jyrki Alakuijala
-<jyrki.alakuijala@gmail.com>, updated 2017-02-07
-
-This is not an official Google product.
+Strong (well-distributed and unpredictable) hashes:
+
+* Portable implementation of
+ [SipHash](https://www.131002.net/siphash/siphash.pdf)
+* HighwayHash, a 5x faster SIMD hash with [security
+ claims](https://arxiv.org/abs/1612.06257)
+
+## Quick Start
+
+To build on a Linux or Mac platform, simply run `make`. For Windows, we provide
+a Visual Studio 2015 project in the `msvc` subdirectory.
+
+Run `benchmark` for speed measurements. `sip_hash_test` and `highwayhash_test`
+ensure the implementations return known-good values for a given set of inputs.
+
+64-bit SipHash for any CPU:
+
+ #include "highwayhash/sip_hash.h"
+ using namespace highwayhash;
+ const HH_U64 key2[2] HH_ALIGNAS(16) = {1234, 5678};
+ char in[8] = {1};
+ return SipHash(key2, in, 8);
+
+64, 128 or 256 bit HighwayHash for the CPU determined by compiler flags:
+
+ #include "highwayhash/highwayhash.h"
+ using namespace highwayhash;
+ const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
+ char in[8] = {1};
+ HHResult64 result; // or HHResult128 or HHResult256
+ HHStateT<HH_TARGET> state(key);
+ HighwayHashT(&state, in, 8, &result);
+
+64, 128 or 256 bit HighwayHash for the CPU on which we're currently running:
+
+ #include "highwayhash/highwayhash_target.h"
+ #include "highwayhash/instruction_sets.h"
+ using namespace highwayhash;
+ const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
+ char in[8] = {1};
+ HHResult64 result; // or HHResult128 or HHResult256
+ InstructionSets::Run<HighwayHash>(key, in, 8, &result);
+
+C-callable 64-bit HighwayHash for the CPU on which we're currently running:
+
+ #include "highwayhash/c_bindings.h"
+ const uint64_t key[4] = {1, 2, 3, 4};
+ char in[8] = {1};
+ return HighwayHash64(key, in, 8);
+
+## Introduction
+
+Hash functions are widely used, so it is desirable to increase their speed and
+security. This package provides two 'strong' (well-distributed and
+unpredictable) hash functions: a faster version of SipHash, and an even faster
+algorithm we call HighwayHash.
+
+SipHash is a fast but 'cryptographically strong' pseudo-random function by
+Aumasson and Bernstein [https://www.131002.net/siphash/siphash.pdf].
+
+HighwayHash is a new way of mixing inputs which may inspire new
+cryptographically strong hashes. Large inputs are processed at a rate of 0.24
+cycles per byte, and latency remains low even for small inputs. HighwayHash is
+faster than SipHash for all input sizes, with 5 times higher throughput at 1
+KiB. We discuss design choices and provide statistical analysis and preliminary
+cryptanalysis in https://arxiv.org/abs/1612.06257.
+
+## Applications
+
+Unlike prior strong hashes, these functions are fast enough to be recommended
+as safer replacements for weak hashes in many applications. The additional CPU
+cost appears affordable, based on profiling data indicating C++ hash functions
+account for less than 0.25% of CPU usage.
+
+Hash-based selection of random subsets is useful for A/B experiments and similar
+applications. Such random generators are idempotent (repeatable and
+deterministic), which is helpful for parallel algorithms and testing. To avoid
+bias, it is important that the hash function be unpredictable and
+indistinguishable from a uniform random generator. We have verified the bit
+distribution and avalanche properties of SipHash and HighwayHash.
+
+64-bit hashes are also useful for authenticating short-lived messages such as
+network/RPC packets. This requires that the hash function withstand
+differential, length extension and other attacks. We have published a formal
+security analysis for HighwayHash. New cryptanalysis tools may still need to be
+developed for further analysis.
+
+Strong hashes are also important parts of methods for protecting hash tables
+against unacceptable worst-case behavior and denial of service attacks
+(see "hash flooding" below).
+
+## SipHash
+
+Our SipHash implementation is a fast and portable drop-in replacement for
+the reference C code. Outputs are identical for the given test cases (messages
+between 0 and 63 bytes).
+
+Interestingly, it is about twice as fast as a SIMD implementation using SSE4.1
+(https://goo.gl/80GBSD). This is presumably due to the lack of SIMD bit rotate
+instructions.
+
+SipHash13 is a faster but weaker variant with one mixing round per update and
+three during finalization.
+
+We also provide a data-parallel 'tree hash' variant that enables efficient SIMD
+while retaining safety guarantees. This is about twice as fast as SipHash, but
+does not return the same results.
+
+## HighwayHash
+
+We have devised a new way of mixing inputs with AVX2 multiply and permute
+instructions. The multiplications are 32x32 -> 64 bits and therefore infeasible
+to reverse. Permuting equalizes the distribution of the resulting bytes.
+
+The internal state occupies four 256-bit AVX2 registers. Due to limitations of
+the instruction set, the registers are partitioned into two 512-bit halves that
+remain independent until the reduce phase. The algorithm outputs 64 bit digests
+or up to 256 bits at no extra cost.
+
+In addition to high throughput, the algorithm is designed for low finalization
+cost. The result is more than twice as fast as SipTreeHash.
+
+For older CPUs, we also provide an SSE4.1 version (80% as fast for large inputs
+and 95% as fast for short inputs) and a portable version (10% as fast).
+
+Statistical analyses and preliminary cryptanalysis are given in
+https://arxiv.org/abs/1612.06257.
+
+## Versioning and stability
+
+SipHash and HighwayHash 1.0 are 'fingerprint functions' whose input -> hash
+mapping will not change. This is important for applications that write hashes to
+persistent storage.
+
+HighwayHash has not yet reached 1.0 and may still change in the near future. We
+will announce when it is frozen.
+
+## Speed measurements
+
+To measure the CPU cost of a hash function, we can either create an artificial
+'microbenchmark' (easier to control, but probably not representative of the
+actual runtime), or insert instrumentation directly into an application (risks
+influencing the results through observer overhead). We provide novel variants of
+both approaches that mitigate their respective disadvantages.
+
+profiler.h uses software write-combining to stream program traces to memory
+with minimal overhead. These can be analyzed offline, or when memory is full,
+to learn how much time was spent in each (possibly nested) zone.
+
+nanobenchmark.h enables cycle-accurate measurements of very short functions.
+It uses CPU fences and robust statistics to minimize variability, and also
+avoids unrealistic branch prediction effects.
+
+We compile the C++ implementations with a patched GCC 4.9 and run on a single
+core of a Xeon E5-2690 v3 clocked at 2.6 GHz. CPU cost is measured as cycles per
+byte for various input sizes:
+
+Algorithm | 8 | 31 | 32 | 63 | 64 | 1024
+---------------- | ----- | ---- | ---- | ---- | ---- | ----
+HighwayHashAVX2 | 7.34 | 1.81 | 1.71 | 1.04 | 0.95 | 0.24
+HighwayHashSSE41 | 8.00 | 2.11 | 1.75 | 1.13 | 0.96 | 0.30
+SipTreeHash | 16.51 | 4.57 | 4.09 | 2.22 | 2.29 | 0.57
+SipTreeHash13 | 12.33 | 3.47 | 3.06 | 1.68 | 1.63 | 0.33
+SipHash | 8.13 | 2.58 | 2.73 | 1.87 | 1.93 | 1.26
+SipHash13 | 6.96 | 2.09 | 2.12 | 1.32 | 1.33 | 0.68
+
+SipTreeHash is slower than SipHash for small inputs because it processes blocks
+of 32 bytes. AVX2 and SSE4.1 HighwayHash are faster than SipHash for all input
+sizes due to their highly optimized handling of partial vectors.
+
+Note that previous measurements included the initialization of their input,
+which dramatically increased timings especially for small inputs.
+
+## CPU requirements
+
+SipTreeHash[13] requires an AVX2-capable CPU (e.g. Haswell). HighwayHash
+includes a dispatcher that chooses the best available (AVX2, SSE4.1 or portable)
+implementation at runtime, as well as a directly callable function template that
+can only run on the CPU for which it was built. SipHash[13] and
+ScalarSipTreeHash[13] have no particular CPU requirements.
+
+Our implementations use custom AVX2 vector classes with overloaded operators
+(e.g. `const V4x64U a = b + c`) for type-safety and improved readability vs.
+compiler intrinsics (e.g. `const __m256i a = _mm256_add_epi64(b, c)`).
+
+We intend to port HighwayHash to other SIMD-capable platforms, especially ARM.
+
+Our instruction_sets dispatcher avoids running newer instructions on older CPUs
+that do not support them. However, intrinsics, and therefore also any vector
+classes that use them, require a compiler flag that also enables the compiler to
+generate code for that CPU. This means the intrinsics must be placed in separate
+translation units that are compiled with the required flags. It is important
+that these source files and their headers not define any inline functions,
+because that might break the one definition rule and cause crashes.
+
+To minimize dispatch overhead when hashes are computed often (e.g. in a loop),
+we can inline the hash function into its caller using templates. The dispatch
+overhead will only be paid once (e.g. before the loop). The template mechanism
+also avoids duplicating code in each CPU-specific implementation.
+
+## Defending against hash flooding
+
+To mitigate hash flooding attacks, we need to take both the hash function and
+the data structure into account.
+
+We wish to defend (web) services that utilize hash sets/maps against
+denial-of-service attacks. Such data structures assign attacker-controlled
+input messages `m` to a hash table bin `b` by computing the hash `H(s, m)`
+using a hash function `H` seeded by `s`, and mapping it to a bin with some
+narrowing function `b = R(h)`, discussed below.
+
+Attackers may attempt to trigger 'flooding' (excessive work in insertions or
+lookups) by finding multiple `m` that map to the same bin. If the attacker has
+local access, they can do far worse, so we assume the attacker can only issue
+remote requests. If the attacker is able to send large numbers of requests,
+they can already deny service, so we need only ensure the attacker's cost is
+sufficiently large compared to the service's provisioning.
+
+If the hash function is 'weak', attackers can easily generate 'hash collisions'
+(inputs mapping to the same hash values) that are independent of the seed. In
+other words, certain input messages will cause collisions regardless of the seed
+value. The author of SipHash has published C++ programs to generate such
+'universal (key-independent) multicollisions' for CityHash and Murmur. Similar
+'differential' attacks are likely possible for any hash function consisting only
+of reversible operations (e.g. addition/multiplication/rotation) with a constant
+operand. `n` requests with such inputs cause `n^2` work for an unprotected hash
+table, which is unacceptable.
+
+By contrast, 'strong' hashes such as SipHash or HighwayHash require infeasible
+attacker effort to find a hash collision (an expected 2^32 guesses of `m` per
+the birthday paradox) or recover the seed (2^63 requests). These security claims
+assume the seed is secret. It is reasonable to suppose `s` is initially unknown
+to attackers, e.g. generated on startup or even per-connection. A timing attack
+by Wool/Bar-Yosef recovers 13-bit seeds by testing all 8K possibilities using
+millions of requests, which takes several days (even assuming unrealistic 150 us
+round-trip times). It appears infeasible to recover 64-bit seeds in this way.
+
+However, attackers are only looking for multiple `m` mapping to the same bin
+rather than identical hash values. We assume they know or are able to discover
+the hash table size `p`. It is common to choose `p = 2^i` to enable an efficient
+`R(h) := h & (p - 1)`, which simply retains the lower hash bits. It may be
+easier for attackers to compute partial collisions where only the lower `i` bits
+match. This can be prevented by choosing a prime `p` so that `R(h) := h % p`
+incorporates all hash bits. The costly modulo operation can be avoided by
+multiplying with the inverse (https://goo.gl/l7ASm8). An interesting alternative
+suggested by Kyoung Jae Seo chooses a random subset of the `h` bits. Such an `R`
+function can be computed in just 3 cycles using PEXT from the BMI2 instruction
+set. This is expected to defend against SAT-solver attacks on the hash bits at a
+slightly lower cost than the multiplicative inverse method, and still allows
+power-of-two table sizes.
+
+Summary thus far: given a strong hash function and secret seed, it appears
+infeasible for attackers to generate hash collisions because `s` and/or `R` are
+unknown. However, they can still observe the timings of data structure
+operations for various `m`. With typical table sizes of 2^10 to 2^17 entries,
+attackers can detect some 'bin collisions' (inputs mapping to the same bin).
+Although this will be costly for the attacker, they can then send many instances
+of such inputs, so we need to limit the resulting work for our data structure.
+
+Hash tables with separate chaining typically store bin entries in a linked list,
+so worst-case inputs lead to unacceptable linear-time lookup cost. We instead
+seek optimal asymptotic worst-case complexity for each operation (insertion,
+deletion and lookups), which is a constant factor times the logarithm of the
+data structure size. This naturally leads to a tree-like data structure for each
+bin. The Java8 HashMap only replaces its linked list with trees when needed.
+This leads to additional cost and complexity for deciding whether a bin is a
+list or tree.
+
+Our first proposal (suggested by Github user funny-falcon) avoids this overhead
+by always storing one tree per bin. It may also be worthwhile to store the first
+entry directly in the bin, which avoids allocating any tree nodes in the common
+case where bins are sparsely populated. What kind of tree should be used?
+Scapegoat and splay trees only offer amortized complexity guarantees, whereas
+treaps require an entropy source and have higher constant factors in practice.
+Self-balancing structures such as 2-3 or red-black trees require additional
+bookkeeping information. We can hope to reduce rebalancing cost by realizing
+that the output bits of strong `H` functions are uniformly distributed. When
+using them as keys instead of the original message `m`, recent relaxed balancing
+schemes such as left-leaning red-black or weak AVL trees may require fewer tree
+rotations to maintain their invariants. Note that `H` already determines the
+bin, so we should only use the remaining bits. 64-bit hashes are likely
+sufficient for this purpose, and HighwayHash generates up to 256 bits. It seems
+unlikely that attackers can craft inputs resulting in worst cases for both the
+bin index and tree key without being able to generate hash collisions, which
+would contradict the security claims of strong hashes. Even if they succeed, the
+relaxed tree balancing still guarantees an upper bound on height and therefore
+the worst-case operation cost. For the AVL variant, the constant factors are
+slightly lower than for red-black trees.
+
+The second proposed approach uses augmented/de-amortized cuckoo hash tables
+(https://goo.gl/PFwwkx). These guarantee worst-case `log n` bounds for all
+operations, but only if the hash function is 'indistinguishable from random'
+(uniformly distributed regardless of the input distribution), which is claimed
+for SipHash and HighwayHash but certainly not for weak hashes.
+
+Both alternatives retain good average case performance and defend against
+flooding by limiting the amount of extra work an attacker can cause. The first
+approach guarantees an upper bound of `log n` additional work even if the hash
+function is compromised.
+
+In summary, a strong hash function is not, by itself, sufficient to protect a
+chained hash table from flooding attacks. However, strong hash functions are
+important parts of two schemes for preventing denial of service. Using weak hash
+functions can slightly accelerate the best-case and average-case performance of
+a service, but at the risk of greatly reduced attack costs and worst-case
+performance.
+
+## Third-party implementations / bindings
+
+Thanks to Damian Gryski for making us aware of these third-party
+implementations or bindings. Please feel free to get in touch or
+raise an issue and we'll add yours as well.
+
+By | Language | URL
+--- | --- | ---
+Damian Gryski | Go and SSE | https://github.com/dgryski/go-highway/
+Lovell Fuller | node.js bindings | https://github.com/lovell/highwayhash
+Vinzent Steinberg | Rust bindings | https://github.com/vks/highwayhash-rs
+
+## Modules
+
+### Hashes
+
+* c_bindings.h declares C-callable versions of SipHash/HighwayHash.
+* sip_hash.cc is the compatible implementation of SipHash, and also provides
+ the final reduction for sip_tree_hash.
+* sip_tree_hash.cc is the faster but incompatible SIMD j-lanes tree hash.
+* scalar_sip_tree_hash.cc is a non-SIMD version.
+* state_helpers.h simplifies the implementation of the SipHash variants.
+* highwayhash.h is our new, fast hash function.
+* hh_avx2.h, hh_sse41.h and hh_portable.h are its various implementations.
+* highwayhash_target.h chooses the best available implementation at runtime.
+
+### Infrastructure
+
+* arch_specific.h offers byte swapping and CPUID detection.
+* compiler_specific.h defines some compiler-dependent language extensions.
+* data_parallel.h provides a C++11 ThreadPool and PerThread (similar to
+ OpenMP).
+* instruction_sets.h and targets.h enable efficient CPU-specific dispatching.
+* nanobenchmark.h measures elapsed times with < 1 cycle variability.
+* os_specific.h sets thread affinity and priority for benchmarking.
+* profiler.h is a low-overhead, deterministic hierarchical profiler.
+* tsc_timer.h obtains high-resolution timestamps without CPU reordering.
+* vector256.h and vector128.h contain wrapper classes for AVX2 and SSE4.1.
+
+By Jan Wassenberg <jan.wassenberg@gmail.com> and Jyrki Alakuijala
+<jyrki.alakuijala@gmail.com>, updated 2017-02-07
+
+This is not an official Google product.
diff --git a/contrib/libs/highwayhash/arch/avx2/ya.make b/contrib/libs/highwayhash/arch/avx2/ya.make
index df09ac249e..3084a352d8 100644
--- a/contrib/libs/highwayhash/arch/avx2/ya.make
+++ b/contrib/libs/highwayhash/arch/avx2/ya.make
@@ -1,22 +1,22 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(Apache-2.0)
OWNER(somov)
-
-ADDINCL(contrib/libs/highwayhash)
-
-SRCDIR(contrib/libs/highwayhash/highwayhash)
-
-CFLAGS(-mavx2)
-
-NO_COMPILER_WARNINGS()
-
-SRCS(
- sip_tree_hash.cc
- hh_avx2.cc
-)
-
-END()
+
+ADDINCL(contrib/libs/highwayhash)
+
+SRCDIR(contrib/libs/highwayhash/highwayhash)
+
+CFLAGS(-mavx2)
+
+NO_COMPILER_WARNINGS()
+
+SRCS(
+ sip_tree_hash.cc
+ hh_avx2.cc
+)
+
+END()
diff --git a/contrib/libs/highwayhash/arch/sse41/ya.make b/contrib/libs/highwayhash/arch/sse41/ya.make
index e56731ef9a..d94ad97038 100644
--- a/contrib/libs/highwayhash/arch/sse41/ya.make
+++ b/contrib/libs/highwayhash/arch/sse41/ya.make
@@ -1,21 +1,21 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(Apache-2.0)
OWNER(somov)
-
-ADDINCL(contrib/libs/highwayhash)
-
-SRCDIR(contrib/libs/highwayhash/highwayhash)
-
-CFLAGS(-msse4.1)
-
-NO_COMPILER_WARNINGS()
-
-SRCS(
- hh_sse41.cc
-)
-
-END()
+
+ADDINCL(contrib/libs/highwayhash)
+
+SRCDIR(contrib/libs/highwayhash/highwayhash)
+
+CFLAGS(-msse4.1)
+
+NO_COMPILER_WARNINGS()
+
+SRCS(
+ hh_sse41.cc
+)
+
+END()
diff --git a/contrib/libs/highwayhash/highwayhash/arch_specific.cc b/contrib/libs/highwayhash/highwayhash/arch_specific.cc
index b8048e46ee..1ab839f58b 100644
--- a/contrib/libs/highwayhash/highwayhash/arch_specific.cc
+++ b/contrib/libs/highwayhash/highwayhash/arch_specific.cc
@@ -1,118 +1,118 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/arch_specific.h"
-
-#include <stdint.h>
-
-#if HH_ARCH_X64 && !HH_MSC_VERSION
-# include <cpuid.h>
-#endif
-
-#include <string.h> // memcpy
-#include <string>
-
-namespace highwayhash {
-
-const char* TargetName(const TargetBits target_bit) {
- switch (target_bit) {
- case HH_TARGET_Portable:
- return "Portable";
- case HH_TARGET_SSE41:
- return "SSE41";
- case HH_TARGET_AVX2:
- return "AVX2";
- default:
- return nullptr; // zero, multiple, or unknown bits
- }
-}
-
-#if HH_ARCH_X64
-
-void Cpuid(const uint32_t level, const uint32_t count,
- uint32_t* HH_RESTRICT abcd) {
-#if HH_MSC_VERSION
- int regs[4];
- __cpuidex(regs, level, count);
- for (int i = 0; i < 4; ++i) {
- abcd[i] = regs[i];
- }
-#else
- uint32_t a, b, c, d;
- __cpuid_count(level, count, a, b, c, d);
- abcd[0] = a;
- abcd[1] = b;
- abcd[2] = c;
- abcd[3] = d;
-#endif
-}
-
-uint32_t ApicId() {
- uint32_t abcd[4];
- Cpuid(1, 0, abcd);
- return abcd[1] >> 24; // ebx
-}
-
-namespace {
-
-std::string BrandString() {
- char brand_string[49];
- uint32_t abcd[4];
-
- // Check if brand string is supported (it is on all reasonable Intel/AMD)
- Cpuid(0x80000000U, 0, abcd);
- if (abcd[0] < 0x80000004U) {
- return std::string();
- }
-
- for (int i = 0; i < 3; ++i) {
- Cpuid(0x80000002U + i, 0, abcd);
- memcpy(brand_string + i * 16, &abcd, sizeof(abcd));
- }
- brand_string[48] = 0;
- return brand_string;
-}
-
-double DetectInvariantCyclesPerSecond() {
- const std::string& brand_string = BrandString();
- // Brand strings include the maximum configured frequency. These prefixes are
- // defined by Intel CPUID documentation.
- const char* prefixes[3] = {"MHz", "GHz", "THz"};
- const double multipliers[3] = {1E6, 1E9, 1E12};
- for (size_t i = 0; i < 3; ++i) {
- const size_t pos_prefix = brand_string.find(prefixes[i]);
- if (pos_prefix != std::string::npos) {
- const size_t pos_space = brand_string.rfind(' ', pos_prefix - 1);
- if (pos_space != std::string::npos) {
- const std::string digits =
- brand_string.substr(pos_space + 1, pos_prefix - pos_space - 1);
- return std::stod(digits) * multipliers[i];
- }
- }
- }
-
- return 0.0;
-}
-
-} // namespace
-
-double InvariantCyclesPerSecond() {
- // Thread-safe caching - this is called several times.
- static const double cycles_per_second = DetectInvariantCyclesPerSecond();
- return cycles_per_second;
-}
-
-#endif // HH_ARCH_X64
-
-} // namespace highwayhash
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/arch_specific.h"
+
+#include <stdint.h>
+
+#if HH_ARCH_X64 && !HH_MSC_VERSION
+# include <cpuid.h>
+#endif
+
+#include <string.h> // memcpy
+#include <string>
+
+namespace highwayhash {
+
+const char* TargetName(const TargetBits target_bit) {
+ switch (target_bit) {
+ case HH_TARGET_Portable:
+ return "Portable";
+ case HH_TARGET_SSE41:
+ return "SSE41";
+ case HH_TARGET_AVX2:
+ return "AVX2";
+ default:
+ return nullptr; // zero, multiple, or unknown bits
+ }
+}
+
+#if HH_ARCH_X64
+
+void Cpuid(const uint32_t level, const uint32_t count,
+ uint32_t* HH_RESTRICT abcd) {
+#if HH_MSC_VERSION
+ int regs[4];
+ __cpuidex(regs, level, count);
+ for (int i = 0; i < 4; ++i) {
+ abcd[i] = regs[i];
+ }
+#else
+ uint32_t a, b, c, d;
+ __cpuid_count(level, count, a, b, c, d);
+ abcd[0] = a;
+ abcd[1] = b;
+ abcd[2] = c;
+ abcd[3] = d;
+#endif
+}
+
+uint32_t ApicId() {
+ uint32_t abcd[4];
+ Cpuid(1, 0, abcd);
+ return abcd[1] >> 24; // ebx
+}
+
+namespace {
+
+std::string BrandString() {
+ char brand_string[49];
+ uint32_t abcd[4];
+
+ // Check if brand string is supported (it is on all reasonable Intel/AMD)
+ Cpuid(0x80000000U, 0, abcd);
+ if (abcd[0] < 0x80000004U) {
+ return std::string();
+ }
+
+ for (int i = 0; i < 3; ++i) {
+ Cpuid(0x80000002U + i, 0, abcd);
+ memcpy(brand_string + i * 16, &abcd, sizeof(abcd));
+ }
+ brand_string[48] = 0;
+ return brand_string;
+}
+
+double DetectInvariantCyclesPerSecond() {
+ const std::string& brand_string = BrandString();
+ // Brand strings include the maximum configured frequency. These prefixes are
+ // defined by Intel CPUID documentation.
+ const char* prefixes[3] = {"MHz", "GHz", "THz"};
+ const double multipliers[3] = {1E6, 1E9, 1E12};
+ for (size_t i = 0; i < 3; ++i) {
+ const size_t pos_prefix = brand_string.find(prefixes[i]);
+ if (pos_prefix != std::string::npos) {
+ const size_t pos_space = brand_string.rfind(' ', pos_prefix - 1);
+ if (pos_space != std::string::npos) {
+ const std::string digits =
+ brand_string.substr(pos_space + 1, pos_prefix - pos_space - 1);
+ return std::stod(digits) * multipliers[i];
+ }
+ }
+ }
+
+ return 0.0;
+}
+
+} // namespace
+
+double InvariantCyclesPerSecond() {
+ // Thread-safe caching - this is called several times.
+ static const double cycles_per_second = DetectInvariantCyclesPerSecond();
+ return cycles_per_second;
+}
+
+#endif // HH_ARCH_X64
+
+} // namespace highwayhash
diff --git a/contrib/libs/highwayhash/highwayhash/arch_specific.h b/contrib/libs/highwayhash/highwayhash/arch_specific.h
index 9fce08bd85..7419d8ebbc 100644
--- a/contrib/libs/highwayhash/highwayhash/arch_specific.h
+++ b/contrib/libs/highwayhash/highwayhash/arch_specific.h
@@ -1,153 +1,153 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_ARCH_SPECIFIC_H_
-#define HIGHWAYHASH_ARCH_SPECIFIC_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME.
-//
-// Background: older GCC/Clang require flags such as -mavx2 before AVX2 SIMD
-// intrinsics can be used. These intrinsics are only used within blocks that
-// first verify CPU capabilities. However, the flag also allows the compiler to
-// generate AVX2 code in other places. This can violate the One Definition Rule,
-// which requires multiple instances of a function with external linkage
-// (e.g. extern inline in a header) to be "equivalent". To prevent the resulting
-// crashes on non-AVX2 CPUs, any header (transitively) included from a
-// translation unit compiled with different flags is "restricted". This means
-// all function definitions must have internal linkage (e.g. static inline), or
-// reside in namespace HH_TARGET_NAME, which expands to a name unique to the
-// current compiler flags.
-//
-// Most C system headers are safe to include, but C++ headers should generally
-// be avoided because they often do not specify static linkage and cannot
-// reliably be wrapped in a namespace.
-
-#include "highwayhash/compiler_specific.h"
-
-#include <stdint.h>
-
-#if HH_MSC_VERSION
-#include <intrin.h> // _byteswap_*
-#endif
-
-namespace highwayhash {
-
-#if defined(__x86_64__) || defined(_M_X64)
-#define HH_ARCH_X64 1
-#else
-#define HH_ARCH_X64 0
-#endif
-
-#ifdef __aarch64__
-#define HH_ARCH_AARCH64 1
-#else
-#define HH_ARCH_AARCH64 0
-#endif
-
-#if defined(__powerpc64__) || defined(_M_PPC)
-#define HH_ARCH_PPC 1
-#else
-#define HH_ARCH_PPC 0
-#endif
-
-// Target := instruction set extension(s) such as SSE41. A translation unit can
-// only provide a single target-specific implementation because they require
-// different compiler flags.
-
-// Either the build system specifies the target by defining HH_TARGET_NAME
-// (which is necessary for Portable on X64, and SSE41 on MSVC), or we'll choose
-// the most efficient one that can be compiled given the current flags:
-#ifndef HH_TARGET_NAME
-
-// To avoid excessive code size and dispatch overhead, we only support a few
-// groups of extensions, e.g. FMA+BMI2+AVX+AVX2 =: "AVX2". These names must
-// match the HH_TARGET_* suffixes below.
-#ifdef __AVX2__
-#define HH_TARGET_NAME AVX2
-#elif defined(__SSE4_1__)
-#define HH_TARGET_NAME SSE41
-#else
-#define HH_TARGET_NAME Portable
-#endif
-
-#endif // HH_TARGET_NAME
-
-#define HH_CONCAT(first, second) first##second
-// Required due to macro expansion rules.
-#define HH_EXPAND_CONCAT(first, second) HH_CONCAT(first, second)
-// Appends HH_TARGET_NAME to "identifier_prefix".
-#define HH_ADD_TARGET_SUFFIX(identifier_prefix) \
- HH_EXPAND_CONCAT(identifier_prefix, HH_TARGET_NAME)
-
-// HH_TARGET expands to an integer constant. Typical usage: HHStateT<HH_TARGET>.
-// This ensures your code will work correctly when compiler flags are changed,
-// and benefit from subsequently added targets/specializations.
-#define HH_TARGET HH_ADD_TARGET_SUFFIX(HH_TARGET_)
-
-// Deprecated former name of HH_TARGET; please use HH_TARGET instead.
-#define HH_TARGET_PREFERRED HH_TARGET
-
-// Associate targets with integer literals so the preprocessor can compare them
-// with HH_TARGET. Do not instantiate templates with these values - use
-// HH_TARGET instead. Must be unique powers of two, see TargetBits. Always
-// defined even if unavailable on this HH_ARCH to allow calling TargetName.
-// The suffixes must match the HH_TARGET_NAME identifiers.
-#define HH_TARGET_Portable 1
-#define HH_TARGET_SSE41 2
-#define HH_TARGET_AVX2 4
-
-// Bit array for one or more HH_TARGET_*. Used to indicate which target(s) are
-// supported or were called by InstructionSets::RunAll.
-using TargetBits = unsigned;
-
-namespace HH_TARGET_NAME {
-
-// Calls func(bit_value) for every nonzero bit in "bits".
-template <class Func>
-void ForeachTarget(TargetBits bits, const Func& func) {
- while (bits != 0) {
- const TargetBits lowest = bits & (~bits + 1);
- func(lowest);
- bits &= ~lowest;
- }
-}
-
-} // namespace HH_TARGET_NAME
-
-// Returns a brief human-readable string literal identifying one of the above
-// bits, or nullptr if zero, multiple, or unknown bits are set.
-const char* TargetName(const TargetBits target_bit);
-
-#if HH_ARCH_X64
-
-// Calls CPUID instruction with eax=level and ecx=count and returns the result
-// in abcd array where abcd = {eax, ebx, ecx, edx} (hence the name abcd).
-void Cpuid(const uint32_t level, const uint32_t count,
- uint32_t* HH_RESTRICT abcd);
-
-// Returns the APIC ID of the CPU on which we're currently running.
-uint32_t ApicId();
-
-// Returns nominal CPU clock frequency for converting tsc_timer cycles to
-// seconds. This is unaffected by CPU throttling ("invariant"). Thread-safe.
-double InvariantCyclesPerSecond();
-
-#endif // HH_ARCH_X64
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_ARCH_SPECIFIC_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_ARCH_SPECIFIC_H_
+#define HIGHWAYHASH_ARCH_SPECIFIC_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME.
+//
+// Background: older GCC/Clang require flags such as -mavx2 before AVX2 SIMD
+// intrinsics can be used. These intrinsics are only used within blocks that
+// first verify CPU capabilities. However, the flag also allows the compiler to
+// generate AVX2 code in other places. This can violate the One Definition Rule,
+// which requires multiple instances of a function with external linkage
+// (e.g. extern inline in a header) to be "equivalent". To prevent the resulting
+// crashes on non-AVX2 CPUs, any header (transitively) included from a
+// translation unit compiled with different flags is "restricted". This means
+// all function definitions must have internal linkage (e.g. static inline), or
+// reside in namespace HH_TARGET_NAME, which expands to a name unique to the
+// current compiler flags.
+//
+// Most C system headers are safe to include, but C++ headers should generally
+// be avoided because they often do not specify static linkage and cannot
+// reliably be wrapped in a namespace.
+
+#include "highwayhash/compiler_specific.h"
+
+#include <stdint.h>
+
+#if HH_MSC_VERSION
+#include <intrin.h> // _byteswap_*
+#endif
+
+namespace highwayhash {
+
+#if defined(__x86_64__) || defined(_M_X64)
+#define HH_ARCH_X64 1
+#else
+#define HH_ARCH_X64 0
+#endif
+
+#ifdef __aarch64__
+#define HH_ARCH_AARCH64 1
+#else
+#define HH_ARCH_AARCH64 0
+#endif
+
+#if defined(__powerpc64__) || defined(_M_PPC)
+#define HH_ARCH_PPC 1
+#else
+#define HH_ARCH_PPC 0
+#endif
+
+// Target := instruction set extension(s) such as SSE41. A translation unit can
+// only provide a single target-specific implementation because they require
+// different compiler flags.
+
+// Either the build system specifies the target by defining HH_TARGET_NAME
+// (which is necessary for Portable on X64, and SSE41 on MSVC), or we'll choose
+// the most efficient one that can be compiled given the current flags:
+#ifndef HH_TARGET_NAME
+
+// To avoid excessive code size and dispatch overhead, we only support a few
+// groups of extensions, e.g. FMA+BMI2+AVX+AVX2 =: "AVX2". These names must
+// match the HH_TARGET_* suffixes below.
+#ifdef __AVX2__
+#define HH_TARGET_NAME AVX2
+#elif defined(__SSE4_1__)
+#define HH_TARGET_NAME SSE41
+#else
+#define HH_TARGET_NAME Portable
+#endif
+
+#endif // HH_TARGET_NAME
+
+#define HH_CONCAT(first, second) first##second
+// Required due to macro expansion rules.
+#define HH_EXPAND_CONCAT(first, second) HH_CONCAT(first, second)
+// Appends HH_TARGET_NAME to "identifier_prefix".
+#define HH_ADD_TARGET_SUFFIX(identifier_prefix) \
+ HH_EXPAND_CONCAT(identifier_prefix, HH_TARGET_NAME)
+
+// HH_TARGET expands to an integer constant. Typical usage: HHStateT<HH_TARGET>.
+// This ensures your code will work correctly when compiler flags are changed,
+// and benefit from subsequently added targets/specializations.
+#define HH_TARGET HH_ADD_TARGET_SUFFIX(HH_TARGET_)
+
+// Deprecated former name of HH_TARGET; please use HH_TARGET instead.
+#define HH_TARGET_PREFERRED HH_TARGET
+
+// Associate targets with integer literals so the preprocessor can compare them
+// with HH_TARGET. Do not instantiate templates with these values - use
+// HH_TARGET instead. Must be unique powers of two, see TargetBits. Always
+// defined even if unavailable on this HH_ARCH to allow calling TargetName.
+// The suffixes must match the HH_TARGET_NAME identifiers.
+#define HH_TARGET_Portable 1
+#define HH_TARGET_SSE41 2
+#define HH_TARGET_AVX2 4
+
+// Bit array for one or more HH_TARGET_*. Used to indicate which target(s) are
+// supported or were called by InstructionSets::RunAll.
+using TargetBits = unsigned;
+
+namespace HH_TARGET_NAME {
+
+// Calls func(bit_value) for every nonzero bit in "bits".
+template <class Func>
+void ForeachTarget(TargetBits bits, const Func& func) {
+ while (bits != 0) {
+ const TargetBits lowest = bits & (~bits + 1);
+ func(lowest);
+ bits &= ~lowest;
+ }
+}
+
+} // namespace HH_TARGET_NAME
+
+// Returns a brief human-readable string literal identifying one of the above
+// bits, or nullptr if zero, multiple, or unknown bits are set.
+const char* TargetName(const TargetBits target_bit);
+
+#if HH_ARCH_X64
+
+// Calls CPUID instruction with eax=level and ecx=count and returns the result
+// in abcd array where abcd = {eax, ebx, ecx, edx} (hence the name abcd).
+void Cpuid(const uint32_t level, const uint32_t count,
+ uint32_t* HH_RESTRICT abcd);
+
+// Returns the APIC ID of the CPU on which we're currently running.
+uint32_t ApicId();
+
+// Returns nominal CPU clock frequency for converting tsc_timer cycles to
+// seconds. This is unaffected by CPU throttling ("invariant"). Thread-safe.
+double InvariantCyclesPerSecond();
+
+#endif // HH_ARCH_X64
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_ARCH_SPECIFIC_H_
diff --git a/contrib/libs/highwayhash/highwayhash/benchmark.cc b/contrib/libs/highwayhash/highwayhash/benchmark.cc
index 7279b295b9..0422690872 100644
--- a/contrib/libs/highwayhash/highwayhash/benchmark.cc
+++ b/contrib/libs/highwayhash/highwayhash/benchmark.cc
@@ -1,313 +1,313 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Measures hash function throughput for various input sizes.
-
-#include <algorithm>
-#include <cassert>
-#include <cstddef>
-#include <cstdio>
-#include <cstdlib>
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/instruction_sets.h"
-#include "highwayhash/nanobenchmark.h"
-#include "highwayhash/os_specific.h"
-#include "highwayhash/robust_statistics.h"
-
-// Which functions to enable (includes check for compiler support)
-#define BENCHMARK_SIP 0
-#define BENCHMARK_SIP_TREE 0
-#define BENCHMARK_HIGHWAY 1
-#define BENCHMARK_HIGHWAY_CAT 1
-#define BENCHMARK_FARM 0
-
-#include "highwayhash/highwayhash_test_target.h"
-#if BENCHMARK_SIP
-#include "highwayhash/sip_hash.h"
-#endif
-#if BENCHMARK_SIP_TREE
-#include "highwayhash/scalar_sip_tree_hash.h"
-#include "highwayhash/sip_tree_hash.h"
-#endif
-#if BENCHMARK_FARM
-#include "third_party/farmhash/src/farmhash.h"
-#endif
-
-namespace highwayhash {
-namespace {
-
-// Stores time measurements from benchmarks, with support for printing them
-// as LaTeX figures or tables.
-class Measurements {
- public:
- void Add(const char* caption, const size_t bytes, const double cycles) {
- const float cpb = static_cast<float>(cycles / bytes);
- results_.emplace_back(caption, static_cast<int>(bytes), cpb);
- }
-
- // Prints results as a LaTeX table (only for in_sizes matching the
- // desired values).
- void PrintTable(const std::vector<size_t>& in_sizes) {
- std::vector<size_t> unique = in_sizes;
- std::sort(unique.begin(), unique.end());
- unique.erase(std::unique(unique.begin(), unique.end()), unique.end());
-
- printf("\\begin{tabular}{");
- for (size_t i = 0; i < unique.size() + 1; ++i) {
- printf("%s", i == 0 ? "r" : "|r");
- }
- printf("}\n\\toprule\nAlgorithm");
- for (const size_t in_size : unique) {
- printf(" & %zu", in_size);
- }
- printf("\\\\\n\\midrule\n");
-
- const SpeedsForCaption cpb_for_caption = SortByCaptionFilterBySize(unique);
- for (const auto& item : cpb_for_caption) {
- printf("%22s", item.first.c_str());
- for (const float cpb : item.second) {
- printf(" & %5.2f", cpb);
- }
- printf("\\\\\n");
- }
- }
-
- // Prints results suitable for pgfplots.
- void PrintPlots() {
- const SpeedsForCaption cpb_for_caption = SortByCaption();
- assert(!cpb_for_caption.empty());
- const size_t num_sizes = cpb_for_caption.begin()->second.size();
-
- printf("Size ");
- // Flatten per-caption vectors into one iterator.
- std::vector<std::vector<float>::const_iterator> iterators;
- for (const auto& item : cpb_for_caption) {
- printf("%21s ", item.first.c_str());
- assert(item.second.size() == num_sizes);
- iterators.push_back(item.second.begin());
- }
- printf("\n");
-
- const std::vector<int>& sizes = UniqueSizes();
- assert(num_sizes == sizes.size());
- for (int i = 0; i < static_cast<int>(num_sizes); ++i) {
- printf("%d ", sizes[i]);
- for (auto& it : iterators) {
- printf("%5.2f ", 1.0f / *it); // bytes per cycle
- ++it;
- }
- printf("\n");
- }
- }
-
- private:
- struct Result {
- Result(const char* caption, const int in_size, const float cpb)
- : caption(caption), in_size(in_size), cpb(cpb) {}
-
- // Algorithm name.
- std::string caption;
- // Size of the input data [bytes].
- int in_size;
- // Measured throughput [cycles per byte].
- float cpb;
- };
-
- // Returns set of all input sizes for the first column of a size/speed plot.
- std::vector<int> UniqueSizes() {
- std::vector<int> sizes;
- sizes.reserve(results_.size());
- for (const Result& result : results_) {
- sizes.push_back(result.in_size);
- }
- std::sort(sizes.begin(), sizes.end());
- sizes.erase(std::unique(sizes.begin(), sizes.end()), sizes.end());
- return sizes;
- }
-
- using SpeedsForCaption = std::map<std::string, std::vector<float>>;
-
- SpeedsForCaption SortByCaption() const {
- SpeedsForCaption cpb_for_caption;
- for (const Result& result : results_) {
- cpb_for_caption[result.caption].push_back(result.cpb);
- }
- return cpb_for_caption;
- }
-
- // Only includes measurement results matching one of the given sizes.
- SpeedsForCaption SortByCaptionFilterBySize(
- const std::vector<size_t>& in_sizes) const {
- SpeedsForCaption cpb_for_caption;
- for (const Result& result : results_) {
- for (const size_t in_size : in_sizes) {
- if (result.in_size == static_cast<int>(in_size)) {
- cpb_for_caption[result.caption].push_back(result.cpb);
- }
- }
- }
- return cpb_for_caption;
- }
-
- std::vector<Result> results_;
-};
-
-void AddMeasurements(DurationsForInputs* input_map, const char* caption,
- Measurements* measurements) {
- for (size_t i = 0; i < input_map->num_items; ++i) {
- const DurationsForInputs::Item& item = input_map->items[i];
- std::vector<float> durations(item.durations,
- item.durations + item.num_durations);
- const float median = Median(&durations);
- const float variability = MedianAbsoluteDeviation(durations, median);
- printf("%s %4zu: median=%6.1f cycles; median L1 norm =%4.1f cycles\n",
- caption, item.input, median, variability);
- measurements->Add(caption, item.input, median);
- }
- input_map->num_items = 0;
-}
-
-#if BENCHMARK_SIP || BENCHMARK_FARM || (BENCHMARK_SIP_TREE && defined(__AVX2__))
-
-void MeasureAndAdd(DurationsForInputs* input_map, const char* caption,
- const Func func, Measurements* measurements) {
- MeasureDurations(func, input_map);
- AddMeasurements(input_map, caption, measurements);
-}
-
-#endif
-
-// InstructionSets::RunAll callback.
-void AddMeasurementsWithPrefix(const char* prefix, const char* target_name,
- DurationsForInputs* input_map, void* context) {
- std::string caption(prefix);
- caption += target_name;
- AddMeasurements(input_map, caption.c_str(),
- static_cast<Measurements*>(context));
-}
-
-#if BENCHMARK_SIP
-
-uint64_t RunSip(const size_t size) {
- const HH_U64 key2[2] HH_ALIGNAS(16) = {0, 1};
- char in[kMaxBenchmarkInputSize];
- memcpy(in, &size, sizeof(size));
- return SipHash(key2, in, size);
-}
-
-uint64_t RunSip13(const size_t size) {
- const HH_U64 key2[2] HH_ALIGNAS(16) = {0, 1};
- char in[kMaxBenchmarkInputSize];
- memcpy(in, &size, sizeof(size));
- return SipHash13(key2, in, size);
-}
-
-#endif
-
-#if BENCHMARK_SIP_TREE
-
-uint64_t RunSipTree(const size_t size) {
- const HH_U64 key4[4] HH_ALIGNAS(32) = {0, 1, 2, 3};
- char in[kMaxBenchmarkInputSize];
- memcpy(in, &size, sizeof(size));
- return SipTreeHash(key4, in, size);
-}
-
-uint64_t RunSipTree13(const size_t size) {
- const HH_U64 key4[4] HH_ALIGNAS(32) = {0, 1, 2, 3};
- char in[kMaxBenchmarkInputSize];
- memcpy(in, &size, sizeof(size));
- return SipTreeHash13(key4, in, size);
-}
-
-#endif
-
-#if BENCHMARK_FARM
-
-uint64_t RunFarm(const size_t size) {
- char in[kMaxBenchmarkInputSize];
- memcpy(in, &size, sizeof(size));
- return farmhash::Fingerprint64(reinterpret_cast<const char*>(in), size);
-}
-
-#endif
-
-void AddMeasurements(const std::vector<size_t>& in_sizes,
- Measurements* measurements) {
- DurationsForInputs input_map(in_sizes.data(), in_sizes.size(), 40);
-#if BENCHMARK_SIP
- MeasureAndAdd(&input_map, "SipHash", RunSip, measurements);
- MeasureAndAdd(&input_map, "SipHash13", RunSip13, measurements);
-#endif
-
-#if BENCHMARK_SIP_TREE && defined(__AVX2__)
- MeasureAndAdd(&input_map, "SipTreeHash", RunSipTree, measurements);
- MeasureAndAdd(&input_map, "SipTreeHash13", RunSipTree13, measurements);
-#endif
-
-#if BENCHMARK_FARM
- MeasureAndAdd(&input_map, "Farm", &RunFarm, measurements);
-#endif
-
-#if BENCHMARK_HIGHWAY
- InstructionSets::RunAll<HighwayHashBenchmark>(
- &input_map, &AddMeasurementsWithPrefix, measurements);
-#endif
-
-#if BENCHMARK_HIGHWAY_CAT
- InstructionSets::RunAll<HighwayHashCatBenchmark>(
- &input_map, &AddMeasurementsWithPrefix, measurements);
-#endif
-}
-
-void PrintTable() {
- const std::vector<size_t> in_sizes = {
- 7, 8, 31, 32, 63, 64, kMaxBenchmarkInputSize};
- Measurements measurements;
- AddMeasurements(in_sizes, &measurements);
- measurements.PrintTable(in_sizes);
-}
-
-void PrintPlots() {
- std::vector<size_t> in_sizes;
- for (int num_vectors = 0; num_vectors < 12; ++num_vectors) {
- for (int remainder : {0, 9, 18, 27}) {
- in_sizes.push_back(num_vectors * 32 + remainder);
- assert(in_sizes.back() <= kMaxBenchmarkInputSize);
- }
- }
-
- Measurements measurements;
- AddMeasurements(in_sizes, &measurements);
- measurements.PrintPlots();
-}
-
-} // namespace
-} // namespace highwayhash
-
-int main(int argc, char* argv[]) {
- highwayhash::PinThreadToRandomCPU();
- // No argument or t => table
- if (argc < 2 || argv[1][0] == 't') {
- highwayhash::PrintTable();
- } else if (argv[1][0] == 'p') {
- highwayhash::PrintPlots();
- }
- return 0;
-}
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Measures hash function throughput for various input sizes.
+
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/instruction_sets.h"
+#include "highwayhash/nanobenchmark.h"
+#include "highwayhash/os_specific.h"
+#include "highwayhash/robust_statistics.h"
+
+// Which functions to enable (includes check for compiler support)
+#define BENCHMARK_SIP 0
+#define BENCHMARK_SIP_TREE 0
+#define BENCHMARK_HIGHWAY 1
+#define BENCHMARK_HIGHWAY_CAT 1
+#define BENCHMARK_FARM 0
+
+#include "highwayhash/highwayhash_test_target.h"
+#if BENCHMARK_SIP
+#include "highwayhash/sip_hash.h"
+#endif
+#if BENCHMARK_SIP_TREE
+#include "highwayhash/scalar_sip_tree_hash.h"
+#include "highwayhash/sip_tree_hash.h"
+#endif
+#if BENCHMARK_FARM
+#include "third_party/farmhash/src/farmhash.h"
+#endif
+
+namespace highwayhash {
+namespace {
+
+// Stores time measurements from benchmarks, with support for printing them
+// as LaTeX figures or tables.
+class Measurements {
+ public:
+ void Add(const char* caption, const size_t bytes, const double cycles) {
+ const float cpb = static_cast<float>(cycles / bytes);
+ results_.emplace_back(caption, static_cast<int>(bytes), cpb);
+ }
+
+ // Prints results as a LaTeX table (only for in_sizes matching the
+ // desired values).
+ void PrintTable(const std::vector<size_t>& in_sizes) {
+ std::vector<size_t> unique = in_sizes;
+ std::sort(unique.begin(), unique.end());
+ unique.erase(std::unique(unique.begin(), unique.end()), unique.end());
+
+ printf("\\begin{tabular}{");
+ for (size_t i = 0; i < unique.size() + 1; ++i) {
+ printf("%s", i == 0 ? "r" : "|r");
+ }
+ printf("}\n\\toprule\nAlgorithm");
+ for (const size_t in_size : unique) {
+ printf(" & %zu", in_size);
+ }
+ printf("\\\\\n\\midrule\n");
+
+ const SpeedsForCaption cpb_for_caption = SortByCaptionFilterBySize(unique);
+ for (const auto& item : cpb_for_caption) {
+ printf("%22s", item.first.c_str());
+ for (const float cpb : item.second) {
+ printf(" & %5.2f", cpb);
+ }
+ printf("\\\\\n");
+ }
+ }
+
+ // Prints results suitable for pgfplots.
+ void PrintPlots() {
+ const SpeedsForCaption cpb_for_caption = SortByCaption();
+ assert(!cpb_for_caption.empty());
+ const size_t num_sizes = cpb_for_caption.begin()->second.size();
+
+ printf("Size ");
+ // Flatten per-caption vectors into one iterator.
+ std::vector<std::vector<float>::const_iterator> iterators;
+ for (const auto& item : cpb_for_caption) {
+ printf("%21s ", item.first.c_str());
+ assert(item.second.size() == num_sizes);
+ iterators.push_back(item.second.begin());
+ }
+ printf("\n");
+
+ const std::vector<int>& sizes = UniqueSizes();
+ assert(num_sizes == sizes.size());
+ for (int i = 0; i < static_cast<int>(num_sizes); ++i) {
+ printf("%d ", sizes[i]);
+ for (auto& it : iterators) {
+ printf("%5.2f ", 1.0f / *it); // bytes per cycle
+ ++it;
+ }
+ printf("\n");
+ }
+ }
+
+ private:
+ struct Result {
+ Result(const char* caption, const int in_size, const float cpb)
+ : caption(caption), in_size(in_size), cpb(cpb) {}
+
+ // Algorithm name.
+ std::string caption;
+ // Size of the input data [bytes].
+ int in_size;
+ // Measured throughput [cycles per byte].
+ float cpb;
+ };
+
+ // Returns set of all input sizes for the first column of a size/speed plot.
+ std::vector<int> UniqueSizes() {
+ std::vector<int> sizes;
+ sizes.reserve(results_.size());
+ for (const Result& result : results_) {
+ sizes.push_back(result.in_size);
+ }
+ std::sort(sizes.begin(), sizes.end());
+ sizes.erase(std::unique(sizes.begin(), sizes.end()), sizes.end());
+ return sizes;
+ }
+
+ using SpeedsForCaption = std::map<std::string, std::vector<float>>;
+
+ SpeedsForCaption SortByCaption() const {
+ SpeedsForCaption cpb_for_caption;
+ for (const Result& result : results_) {
+ cpb_for_caption[result.caption].push_back(result.cpb);
+ }
+ return cpb_for_caption;
+ }
+
+ // Only includes measurement results matching one of the given sizes.
+ SpeedsForCaption SortByCaptionFilterBySize(
+ const std::vector<size_t>& in_sizes) const {
+ SpeedsForCaption cpb_for_caption;
+ for (const Result& result : results_) {
+ for (const size_t in_size : in_sizes) {
+ if (result.in_size == static_cast<int>(in_size)) {
+ cpb_for_caption[result.caption].push_back(result.cpb);
+ }
+ }
+ }
+ return cpb_for_caption;
+ }
+
+ std::vector<Result> results_;
+};
+
+void AddMeasurements(DurationsForInputs* input_map, const char* caption,
+ Measurements* measurements) {
+ for (size_t i = 0; i < input_map->num_items; ++i) {
+ const DurationsForInputs::Item& item = input_map->items[i];
+ std::vector<float> durations(item.durations,
+ item.durations + item.num_durations);
+ const float median = Median(&durations);
+ const float variability = MedianAbsoluteDeviation(durations, median);
+ printf("%s %4zu: median=%6.1f cycles; median L1 norm =%4.1f cycles\n",
+ caption, item.input, median, variability);
+ measurements->Add(caption, item.input, median);
+ }
+ input_map->num_items = 0;
+}
+
+#if BENCHMARK_SIP || BENCHMARK_FARM || (BENCHMARK_SIP_TREE && defined(__AVX2__))
+
+void MeasureAndAdd(DurationsForInputs* input_map, const char* caption,
+ const Func func, Measurements* measurements) {
+ MeasureDurations(func, input_map);
+ AddMeasurements(input_map, caption, measurements);
+}
+
+#endif
+
+// InstructionSets::RunAll callback.
+void AddMeasurementsWithPrefix(const char* prefix, const char* target_name,
+ DurationsForInputs* input_map, void* context) {
+ std::string caption(prefix);
+ caption += target_name;
+ AddMeasurements(input_map, caption.c_str(),
+ static_cast<Measurements*>(context));
+}
+
+#if BENCHMARK_SIP
+
+uint64_t RunSip(const size_t size) {
+ const HH_U64 key2[2] HH_ALIGNAS(16) = {0, 1};
+ char in[kMaxBenchmarkInputSize];
+ memcpy(in, &size, sizeof(size));
+ return SipHash(key2, in, size);
+}
+
+uint64_t RunSip13(const size_t size) {
+ const HH_U64 key2[2] HH_ALIGNAS(16) = {0, 1};
+ char in[kMaxBenchmarkInputSize];
+ memcpy(in, &size, sizeof(size));
+ return SipHash13(key2, in, size);
+}
+
+#endif
+
+#if BENCHMARK_SIP_TREE
+
+uint64_t RunSipTree(const size_t size) {
+ const HH_U64 key4[4] HH_ALIGNAS(32) = {0, 1, 2, 3};
+ char in[kMaxBenchmarkInputSize];
+ memcpy(in, &size, sizeof(size));
+ return SipTreeHash(key4, in, size);
+}
+
+uint64_t RunSipTree13(const size_t size) {
+ const HH_U64 key4[4] HH_ALIGNAS(32) = {0, 1, 2, 3};
+ char in[kMaxBenchmarkInputSize];
+ memcpy(in, &size, sizeof(size));
+ return SipTreeHash13(key4, in, size);
+}
+
+#endif
+
+#if BENCHMARK_FARM
+
+uint64_t RunFarm(const size_t size) {
+ char in[kMaxBenchmarkInputSize];
+ memcpy(in, &size, sizeof(size));
+ return farmhash::Fingerprint64(reinterpret_cast<const char*>(in), size);
+}
+
+#endif
+
+void AddMeasurements(const std::vector<size_t>& in_sizes,
+ Measurements* measurements) {
+ DurationsForInputs input_map(in_sizes.data(), in_sizes.size(), 40);
+#if BENCHMARK_SIP
+ MeasureAndAdd(&input_map, "SipHash", RunSip, measurements);
+ MeasureAndAdd(&input_map, "SipHash13", RunSip13, measurements);
+#endif
+
+#if BENCHMARK_SIP_TREE && defined(__AVX2__)
+ MeasureAndAdd(&input_map, "SipTreeHash", RunSipTree, measurements);
+ MeasureAndAdd(&input_map, "SipTreeHash13", RunSipTree13, measurements);
+#endif
+
+#if BENCHMARK_FARM
+ MeasureAndAdd(&input_map, "Farm", &RunFarm, measurements);
+#endif
+
+#if BENCHMARK_HIGHWAY
+ InstructionSets::RunAll<HighwayHashBenchmark>(
+ &input_map, &AddMeasurementsWithPrefix, measurements);
+#endif
+
+#if BENCHMARK_HIGHWAY_CAT
+ InstructionSets::RunAll<HighwayHashCatBenchmark>(
+ &input_map, &AddMeasurementsWithPrefix, measurements);
+#endif
+}
+
+void PrintTable() {
+ const std::vector<size_t> in_sizes = {
+ 7, 8, 31, 32, 63, 64, kMaxBenchmarkInputSize};
+ Measurements measurements;
+ AddMeasurements(in_sizes, &measurements);
+ measurements.PrintTable(in_sizes);
+}
+
+void PrintPlots() {
+ std::vector<size_t> in_sizes;
+ for (int num_vectors = 0; num_vectors < 12; ++num_vectors) {
+ for (int remainder : {0, 9, 18, 27}) {
+ in_sizes.push_back(num_vectors * 32 + remainder);
+ assert(in_sizes.back() <= kMaxBenchmarkInputSize);
+ }
+ }
+
+ Measurements measurements;
+ AddMeasurements(in_sizes, &measurements);
+ measurements.PrintPlots();
+}
+
+} // namespace
+} // namespace highwayhash
+
+int main(int argc, char* argv[]) {
+ highwayhash::PinThreadToRandomCPU();
+ // No argument or t => table
+ if (argc < 2 || argv[1][0] == 't') {
+ highwayhash::PrintTable();
+ } else if (argv[1][0] == 'p') {
+ highwayhash::PrintPlots();
+ }
+ return 0;
+}
diff --git a/contrib/libs/highwayhash/highwayhash/c_bindings.cc b/contrib/libs/highwayhash/highwayhash/c_bindings.cc
index 21d5c3652d..7e0488fb46 100644
--- a/contrib/libs/highwayhash/highwayhash/c_bindings.cc
+++ b/contrib/libs/highwayhash/highwayhash/c_bindings.cc
@@ -1,35 +1,35 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/c_bindings.h"
-
-#include "highwayhash/highwayhash_target.h"
-#include "highwayhash/instruction_sets.h"
-
-using highwayhash::InstructionSets;
-using highwayhash::HighwayHash;
-
-extern "C" {
-
-// Ideally this would reside in highwayhash_target.cc, but that file is
-// compiled multiple times and we must only define this function once.
-uint64_t HighwayHash64(const HHKey key, const char* bytes,
- const uint64_t size) {
- HHResult64 result;
- InstructionSets::Run<HighwayHash>(*reinterpret_cast<const HHKey*>(key), bytes,
- size, &result);
- return result;
-}
-
-} // extern "C"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/c_bindings.h"
+
+#include "highwayhash/highwayhash_target.h"
+#include "highwayhash/instruction_sets.h"
+
+using highwayhash::InstructionSets;
+using highwayhash::HighwayHash;
+
+extern "C" {
+
+// Ideally this would reside in highwayhash_target.cc, but that file is
+// compiled multiple times and we must only define this function once.
+uint64_t HighwayHash64(const HHKey key, const char* bytes,
+ const uint64_t size) {
+ HHResult64 result;
+ InstructionSets::Run<HighwayHash>(*reinterpret_cast<const HHKey*>(key), bytes,
+ size, &result);
+ return result;
+}
+
+} // extern "C"
diff --git a/contrib/libs/highwayhash/highwayhash/c_bindings.h b/contrib/libs/highwayhash/highwayhash/c_bindings.h
index dd24019041..7d52de7d75 100644
--- a/contrib/libs/highwayhash/highwayhash/c_bindings.h
+++ b/contrib/libs/highwayhash/highwayhash/c_bindings.h
@@ -1,55 +1,55 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HIGHWAYHASH_C_BINDINGS_H_
-#define HIGHWAYHASH_HIGHWAYHASH_C_BINDINGS_H_
-
-// C-callable function prototypes, documented in the other header files.
-
-#include <stdint.h>
-
-#include "hh_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-
-// Bring the symbols out of the namespace.
-using highwayhash::HHKey;
-using highwayhash::HHPacket;
-using highwayhash::HHResult64;
-using highwayhash::HHResult128;
-using highwayhash::HHResult256;
-#endif
-
-uint64_t SipHashC(const uint64_t* key, const char* bytes, const uint64_t size);
-uint64_t SipHash13C(const uint64_t* key, const char* bytes,
- const uint64_t size);
-
-// Uses the best implementation of HighwayHash for the current CPU and
-// calculates 64-bit hash of given data.
-uint64_t HighwayHash64(const HHKey key, const char* bytes, const uint64_t size);
-
-// Defined by highwayhash_target.cc, which requires a _Target* suffix.
-uint64_t HighwayHash64_TargetPortable(const HHKey key, const char* bytes,
- const uint64_t size);
-uint64_t HighwayHash64_TargetSSE41(const HHKey key, const char* bytes,
- const uint64_t size);
-uint64_t HighwayHash64_TargetAVX2(const HHKey key, const char* bytes,
- const uint64_t size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // HIGHWAYHASH_HIGHWAYHASH_C_BINDINGS_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HIGHWAYHASH_C_BINDINGS_H_
+#define HIGHWAYHASH_HIGHWAYHASH_C_BINDINGS_H_
+
+// C-callable function prototypes, documented in the other header files.
+
+#include <stdint.h>
+
+#include "hh_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+
+// Bring the symbols out of the namespace.
+using highwayhash::HHKey;
+using highwayhash::HHPacket;
+using highwayhash::HHResult64;
+using highwayhash::HHResult128;
+using highwayhash::HHResult256;
+#endif
+
+uint64_t SipHashC(const uint64_t* key, const char* bytes, const uint64_t size);
+uint64_t SipHash13C(const uint64_t* key, const char* bytes,
+ const uint64_t size);
+
+// Uses the best implementation of HighwayHash for the current CPU and
+// calculates 64-bit hash of given data.
+uint64_t HighwayHash64(const HHKey key, const char* bytes, const uint64_t size);
+
+// Defined by highwayhash_target.cc, which requires a _Target* suffix.
+uint64_t HighwayHash64_TargetPortable(const HHKey key, const char* bytes,
+ const uint64_t size);
+uint64_t HighwayHash64_TargetSSE41(const HHKey key, const char* bytes,
+ const uint64_t size);
+uint64_t HighwayHash64_TargetAVX2(const HHKey key, const char* bytes,
+ const uint64_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HIGHWAYHASH_HIGHWAYHASH_C_BINDINGS_H_
diff --git a/contrib/libs/highwayhash/highwayhash/compiler_specific.h b/contrib/libs/highwayhash/highwayhash/compiler_specific.h
index 958cb6849e..4789f9a610 100644
--- a/contrib/libs/highwayhash/highwayhash/compiler_specific.h
+++ b/contrib/libs/highwayhash/highwayhash/compiler_specific.h
@@ -1,90 +1,90 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_COMPILER_SPECIFIC_H_
-#define HIGHWAYHASH_COMPILER_SPECIFIC_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-// Compiler
-
-// #if is shorter and safer than #ifdef. *_VERSION are zero if not detected,
-// otherwise 100 * major + minor version. Note that other packages check for
-// #ifdef COMPILER_MSVC, so we cannot use that same name.
-
-#ifdef _MSC_VER
-#define HH_MSC_VERSION _MSC_VER
-#else
-#define HH_MSC_VERSION 0
-#endif
-
-#ifdef __GNUC__
-#define HH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
-#else
-#define HH_GCC_VERSION 0
-#endif
-
-#ifdef __clang__
-#define HH_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
-#else
-#define HH_CLANG_VERSION 0
-#endif
-
-//-----------------------------------------------------------------------------
-
-#if HH_GCC_VERSION && HH_GCC_VERSION < 408
-#define HH_ALIGNAS(multiple) __attribute__((aligned(multiple)))
-#else
-#define HH_ALIGNAS(multiple) alignas(multiple) // C++11
-#endif
-
-#if HH_MSC_VERSION
-#define HH_RESTRICT __restrict
-#elif HH_GCC_VERSION
-#define HH_RESTRICT __restrict__
-#else
-#define HH_RESTRICT
-#endif
-
-#if HH_MSC_VERSION
-#define HH_INLINE __forceinline
-#define HH_NOINLINE __declspec(noinline)
-#else
-#define HH_INLINE inline
-#define HH_NOINLINE __attribute__((noinline))
-#endif
-
-#if HH_MSC_VERSION
-// Unsupported, __assume is not the same.
-#define HH_LIKELY(expr) expr
-#define HH_UNLIKELY(expr) expr
-#else
-#define HH_LIKELY(expr) __builtin_expect(!!(expr), 1)
-#define HH_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
-#endif
-
-#if HH_MSC_VERSION
-#include <intrin.h>
-#pragma intrinsic(_ReadWriteBarrier)
-#define HH_COMPILER_FENCE _ReadWriteBarrier()
-#elif HH_GCC_VERSION
-#define HH_COMPILER_FENCE asm volatile("" : : : "memory")
-#else
-#define HH_COMPILER_FENCE
-#endif
-
-#endif // HIGHWAYHASH_COMPILER_SPECIFIC_H_
+// Copyright 2015 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_COMPILER_SPECIFIC_H_
+#define HIGHWAYHASH_COMPILER_SPECIFIC_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+// Compiler
+
+// #if is shorter and safer than #ifdef. *_VERSION are zero if not detected,
+// otherwise 100 * major + minor version. Note that other packages check for
+// #ifdef COMPILER_MSVC, so we cannot use that same name.
+
+#ifdef _MSC_VER
+#define HH_MSC_VERSION _MSC_VER
+#else
+#define HH_MSC_VERSION 0
+#endif
+
+#ifdef __GNUC__
+#define HH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+#else
+#define HH_GCC_VERSION 0
+#endif
+
+#ifdef __clang__
+#define HH_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
+#else
+#define HH_CLANG_VERSION 0
+#endif
+
+//-----------------------------------------------------------------------------
+
+#if HH_GCC_VERSION && HH_GCC_VERSION < 408
+#define HH_ALIGNAS(multiple) __attribute__((aligned(multiple)))
+#else
+#define HH_ALIGNAS(multiple) alignas(multiple) // C++11
+#endif
+
+#if HH_MSC_VERSION
+#define HH_RESTRICT __restrict
+#elif HH_GCC_VERSION
+#define HH_RESTRICT __restrict__
+#else
+#define HH_RESTRICT
+#endif
+
+#if HH_MSC_VERSION
+#define HH_INLINE __forceinline
+#define HH_NOINLINE __declspec(noinline)
+#else
+#define HH_INLINE inline
+#define HH_NOINLINE __attribute__((noinline))
+#endif
+
+#if HH_MSC_VERSION
+// Unsupported, __assume is not the same.
+#define HH_LIKELY(expr) expr
+#define HH_UNLIKELY(expr) expr
+#else
+#define HH_LIKELY(expr) __builtin_expect(!!(expr), 1)
+#define HH_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
+#endif
+
+#if HH_MSC_VERSION
+#include <intrin.h>
+#pragma intrinsic(_ReadWriteBarrier)
+#define HH_COMPILER_FENCE _ReadWriteBarrier()
+#elif HH_GCC_VERSION
+#define HH_COMPILER_FENCE asm volatile("" : : : "memory")
+#else
+#define HH_COMPILER_FENCE
+#endif
+
+#endif // HIGHWAYHASH_COMPILER_SPECIFIC_H_
diff --git a/contrib/libs/highwayhash/highwayhash/data_parallel.h b/contrib/libs/highwayhash/highwayhash/data_parallel.h
index 72d6a47e24..d72afc953e 100644
--- a/contrib/libs/highwayhash/highwayhash/data_parallel.h
+++ b/contrib/libs/highwayhash/highwayhash/data_parallel.h
@@ -1,341 +1,341 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_DATA_PARALLEL_H_
-#define HIGHWAYHASH_DATA_PARALLEL_H_
-
-// Portable C++11 alternative to OpenMP for data-parallel computations:
-// provides low-overhead ThreadPool, plus PerThread with support for reduction.
-
-#include <stdio.h>
-#include <algorithm> // find_if
-#include <atomic>
-#include <condition_variable> //NOLINT
-#include <cstdint>
-#include <cstdlib>
-#include <functional>
-#include <memory>
-#include <mutex> //NOLINT
-#include <thread> //NOLINT
-#include <utility>
-#include <vector>
-
-#define DATA_PARALLEL_CHECK(condition) \
- while (!(condition)) { \
- printf("data_parallel check failed at line %d\n", __LINE__); \
- abort(); \
- }
-
-namespace highwayhash {
-
-// Highly scalable thread pool, especially suitable for data-parallel
-// computations in the fork-join model, where clients need to know when all
-// tasks have completed.
-//
-// Thread pools usually store small numbers of heterogeneous tasks in a queue.
-// When tasks are identical or differ only by an integer input parameter, it is
-// much faster to store just one function of an integer parameter and call it
-// for each value.
-//
-// This thread pool can efficiently load-balance millions of tasks using an
-// atomic counter, thus avoiding per-task syscalls. With 48 hyperthreads and
-// 1M tasks that add to an atomic counter, overall runtime is 10-20x higher
-// when using std::async, and up to 200x for a queue-based ThreadPool.
-//
-// Usage:
-// ThreadPool pool;
-// pool.Run(0, 1000000, [](const int i) { Func1(i); });
-// // When Run returns, all of its tasks have finished.
-//
-// pool.RunTasks({Func2, Func3, Func4});
-// // The destructor waits until all worker threads have exited cleanly.
-class ThreadPool {
- public:
- // Starts the given number of worker threads and blocks until they are ready.
- // "num_threads" defaults to one per hyperthread.
- explicit ThreadPool(
- const int num_threads = std::thread::hardware_concurrency())
- : num_threads_(num_threads) {
- DATA_PARALLEL_CHECK(num_threads_ > 0);
- threads_.reserve(num_threads_);
- for (int i = 0; i < num_threads_; ++i) {
- threads_.emplace_back(ThreadFunc, this);
- }
-
- padding_[0] = 0; // avoid unused member warning.
-
- WorkersReadyBarrier();
- }
-
- ThreadPool(const ThreadPool&) = delete;
- ThreadPool& operator&(const ThreadPool&) = delete;
-
- // Waits for all threads to exit.
- ~ThreadPool() {
- StartWorkers(kWorkerExit);
-
- for (std::thread& thread : threads_) {
- thread.join();
- }
- }
-
- // Runs func(i) on worker thread(s) for every i in [begin, end).
- // Not thread-safe - no two calls to Run and RunTasks may overlap.
- // Subsequent calls will reuse the same threads.
- //
- // Precondition: 0 <= begin <= end.
- template <class Func>
- void Run(const int begin, const int end, const Func& func) {
- DATA_PARALLEL_CHECK(0 <= begin && begin <= end);
- if (begin == end) {
- return;
- }
- const WorkerCommand worker_command = (WorkerCommand(end) << 32) + begin;
- // Ensure the inputs do not result in a reserved command.
- DATA_PARALLEL_CHECK(worker_command != kWorkerWait);
- DATA_PARALLEL_CHECK(worker_command != kWorkerExit);
-
- // If Func is large (many captures), this will allocate memory, but it is
- // still slower to use a std::ref wrapper.
- task_ = func;
- num_reserved_.store(0);
-
- StartWorkers(worker_command);
- WorkersReadyBarrier();
- }
-
- // Runs each task (closure, typically a lambda function) on worker thread(s).
- // Not thread-safe - no two calls to Run and RunTasks may overlap.
- // Subsequent calls will reuse the same threads.
- //
- // This is a more conventional interface for heterogeneous tasks that may be
- // independent/unrelated.
- void RunTasks(const std::vector<std::function<void(void)>>& tasks) {
- Run(0, static_cast<int>(tasks.size()),
- [&tasks](const int i) { tasks[i](); });
- }
-
- // Statically (and deterministically) splits [begin, end) into ranges and
- // calls "func" for each of them. Useful when "func" involves some overhead
- // (e.g. for PerThread::Get or random seeding) that should be amortized over
- // a range of values. "func" is void(int chunk, uint32_t begin, uint32_t end).
- template <class Func>
- void RunRanges(const uint32_t begin, const uint32_t end, const Func& func) {
- const uint32_t length = end - begin;
-
- // Use constant rather than num_threads_ for machine-independent splitting.
- const uint32_t chunk = std::max(1U, (length + 127) / 128);
- std::vector<std::pair<uint32_t, uint32_t>> ranges; // begin/end
- ranges.reserve(length / chunk + 1);
- for (uint32_t i = 0; i < length; i += chunk) {
- ranges.emplace_back(begin + i, begin + std::min(i + chunk, length));
- }
-
- Run(0, static_cast<int>(ranges.size()), [&ranges, func](const int i) {
- func(i, ranges[i].first, ranges[i].second);
- });
- }
-
- private:
- // After construction and between calls to Run, workers are "ready", i.e.
- // waiting on worker_start_cv_. They are "started" by sending a "command"
- // and notifying all worker_start_cv_ waiters. (That is why all workers
- // must be ready/waiting - otherwise, the notification will not reach all of
- // them and the main thread waits in vain for them to report readiness.)
- using WorkerCommand = uint64_t;
-
- // Special values; all others encode the begin/end parameters.
- static constexpr WorkerCommand kWorkerWait = 0;
- static constexpr WorkerCommand kWorkerExit = ~0ULL;
-
- void WorkersReadyBarrier() {
- std::unique_lock<std::mutex> lock(mutex_);
- workers_ready_cv_.wait(lock,
- [this]() { return workers_ready_ == num_threads_; });
- workers_ready_ = 0;
- }
-
- // Precondition: all workers are ready.
- void StartWorkers(const WorkerCommand worker_command) {
- std::unique_lock<std::mutex> lock(mutex_);
- worker_start_command_ = worker_command;
- // Workers will need this lock, so release it before they wake up.
- lock.unlock();
- worker_start_cv_.notify_all();
- }
-
- // Attempts to reserve and perform some work from the global range of tasks,
- // which is encoded within "command". Returns after all tasks are reserved.
- static void RunRange(ThreadPool* self, const WorkerCommand command) {
- const int begin = command & 0xFFFFFFFF;
- const int end = command >> 32;
- const int num_tasks = end - begin;
-
- // OpenMP introduced several "schedule" strategies:
- // "single" (static assignment of exactly one chunk per thread): slower.
- // "dynamic" (allocates k tasks at a time): competitive for well-chosen k.
- // "guided" (allocates k tasks, decreases k): computing k = remaining/n
- // is faster than halving k each iteration. We prefer this strategy
- // because it avoids user-specified parameters.
-
- for (;;) {
- const int num_reserved = self->num_reserved_.load();
- const int num_remaining = num_tasks - num_reserved;
- const int my_size = std::max(num_remaining / (self->num_threads_ * 2), 1);
- const int my_begin = begin + self->num_reserved_.fetch_add(my_size);
- const int my_end = std::min(my_begin + my_size, begin + num_tasks);
- // Another thread already reserved the last task.
- if (my_begin >= my_end) {
- break;
- }
- for (int i = my_begin; i < my_end; ++i) {
- self->task_(i);
- }
- }
- }
-
- static void ThreadFunc(ThreadPool* self) {
- // Until kWorkerExit command received:
- for (;;) {
- std::unique_lock<std::mutex> lock(self->mutex_);
- // Notify main thread that this thread is ready.
- if (++self->workers_ready_ == self->num_threads_) {
- self->workers_ready_cv_.notify_one();
- }
- RESUME_WAIT:
- // Wait for a command.
- self->worker_start_cv_.wait(lock);
- const WorkerCommand command = self->worker_start_command_;
- switch (command) {
- case kWorkerWait: // spurious wakeup:
- goto RESUME_WAIT; // lock still held, avoid incrementing ready.
- case kWorkerExit:
- return; // exits thread
- }
-
- lock.unlock();
- RunRange(self, command);
- }
- }
-
- const int num_threads_;
-
- // Unmodified after ctor, but cannot be const because we call thread::join().
- std::vector<std::thread> threads_;
-
- std::mutex mutex_; // guards both cv and their variables.
- std::condition_variable workers_ready_cv_;
- int workers_ready_ = 0;
- std::condition_variable worker_start_cv_;
- WorkerCommand worker_start_command_;
-
- // Written by main thread, read by workers (after mutex lock/unlock).
- std::function<void(int)> task_;
-
- // Updated by workers; alignment/padding avoids false sharing.
- alignas(64) std::atomic<int> num_reserved_{0};
- int padding_[15];
-};
-
-// Thread-local storage with support for reduction (combining into one result).
-// The "T" type must be unique to the call site because the list of threads'
-// copies is a static member. (With knowledge of the underlying threads, we
-// could eliminate this list and T allocations, but that is difficult to
-// arrange and we prefer this to be usable independently of ThreadPool.)
-//
-// Usage:
-// for (int i = 0; i < N; ++i) {
-// // in each thread:
-// T& my_copy = PerThread<T>::Get();
-// my_copy.Modify();
-//
-// // single-threaded:
-// T& combined = PerThread<T>::Reduce();
-// Use(combined);
-// PerThread<T>::Destroy();
-// }
-//
-// T is duck-typed and implements the following interface:
-//
-// // Returns true if T is default-initialized or Destroy was called without
-// // any subsequent re-initialization.
-// bool IsNull() const;
-//
-// // Releases any resources. Postcondition: IsNull() == true.
-// void Destroy();
-//
-// // Merges in data from "victim". Precondition: !IsNull() && !victim.IsNull().
-// void Assimilate(const T& victim);
-template <class T>
-class PerThread {
- public:
- // Returns reference to this thread's T instance (dynamically allocated,
- // so its address is unique). Callers are responsible for any initialization
- // beyond the default ctor.
- static T& Get() {
- static thread_local T* t;
- if (t == nullptr) {
- t = new T;
- static std::mutex mutex;
- std::lock_guard<std::mutex> lock(mutex);
- Threads().push_back(t);
- }
- return *t;
- }
-
- // Returns vector of all per-thread T. Used inside Reduce() or by clients
- // that require direct access to T instead of Assimilating them.
- // Function wrapper avoids separate static member variable definition.
- static std::vector<T*>& Threads() {
- static std::vector<T*> threads;
- return threads;
- }
-
- // Returns the first non-null T after assimilating all other threads' T
- // into it. Precondition: at least one non-null T exists (caller must have
- // called Get() and initialized the result).
- static T& Reduce() {
- std::vector<T*>& threads = Threads();
-
- // Find first non-null T
- const auto it = std::find_if(threads.begin(), threads.end(),
- [](const T* t) { return !t->IsNull(); });
- if (it == threads.end()) {
- abort();
- }
- T* const first = *it;
-
- for (const T* t : threads) {
- if (t != first && !t->IsNull()) {
- first->Assimilate(*t);
- }
- }
- return *first;
- }
-
- // Calls each thread's T::Destroy to release resources and/or prepare for
- // reuse by the same threads/ThreadPool. Note that all T remain allocated
- // (we need thread-independent pointers for iterating over each thread's T,
- // and deleting them would leave dangling pointers in each thread, which is
- // unacceptable because the same thread may call Get() again later.)
- static void Destroy() {
- for (T* t : Threads()) {
- t->Destroy();
- }
- }
-};
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_DATA_PARALLEL_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_DATA_PARALLEL_H_
+#define HIGHWAYHASH_DATA_PARALLEL_H_
+
+// Portable C++11 alternative to OpenMP for data-parallel computations:
+// provides low-overhead ThreadPool, plus PerThread with support for reduction.
+
+#include <stdio.h>
+#include <algorithm> // find_if
+#include <atomic>
+#include <condition_variable> //NOLINT
+#include <cstdint>
+#include <cstdlib>
+#include <functional>
+#include <memory>
+#include <mutex> //NOLINT
+#include <thread> //NOLINT
+#include <utility>
+#include <vector>
+
+#define DATA_PARALLEL_CHECK(condition) \
+ while (!(condition)) { \
+ printf("data_parallel check failed at line %d\n", __LINE__); \
+ abort(); \
+ }
+
+namespace highwayhash {
+
+// Highly scalable thread pool, especially suitable for data-parallel
+// computations in the fork-join model, where clients need to know when all
+// tasks have completed.
+//
+// Thread pools usually store small numbers of heterogeneous tasks in a queue.
+// When tasks are identical or differ only by an integer input parameter, it is
+// much faster to store just one function of an integer parameter and call it
+// for each value.
+//
+// This thread pool can efficiently load-balance millions of tasks using an
+// atomic counter, thus avoiding per-task syscalls. With 48 hyperthreads and
+// 1M tasks that add to an atomic counter, overall runtime is 10-20x higher
+// when using std::async, and up to 200x for a queue-based ThreadPool.
+//
+// Usage:
+// ThreadPool pool;
+// pool.Run(0, 1000000, [](const int i) { Func1(i); });
+// // When Run returns, all of its tasks have finished.
+//
+// pool.RunTasks({Func2, Func3, Func4});
+// // The destructor waits until all worker threads have exited cleanly.
+class ThreadPool {
+ public:
+ // Starts the given number of worker threads and blocks until they are ready.
+ // "num_threads" defaults to one per hyperthread.
+ explicit ThreadPool(
+ const int num_threads = std::thread::hardware_concurrency())
+ : num_threads_(num_threads) {
+ DATA_PARALLEL_CHECK(num_threads_ > 0);
+ threads_.reserve(num_threads_);
+ for (int i = 0; i < num_threads_; ++i) {
+ threads_.emplace_back(ThreadFunc, this);
+ }
+
+ padding_[0] = 0; // avoid unused member warning.
+
+ WorkersReadyBarrier();
+ }
+
+ ThreadPool(const ThreadPool&) = delete;
+ ThreadPool& operator&(const ThreadPool&) = delete;
+
+ // Waits for all threads to exit.
+ ~ThreadPool() {
+ StartWorkers(kWorkerExit);
+
+ for (std::thread& thread : threads_) {
+ thread.join();
+ }
+ }
+
+ // Runs func(i) on worker thread(s) for every i in [begin, end).
+ // Not thread-safe - no two calls to Run and RunTasks may overlap.
+ // Subsequent calls will reuse the same threads.
+ //
+ // Precondition: 0 <= begin <= end.
+ template <class Func>
+ void Run(const int begin, const int end, const Func& func) {
+ DATA_PARALLEL_CHECK(0 <= begin && begin <= end);
+ if (begin == end) {
+ return;
+ }
+ const WorkerCommand worker_command = (WorkerCommand(end) << 32) + begin;
+ // Ensure the inputs do not result in a reserved command.
+ DATA_PARALLEL_CHECK(worker_command != kWorkerWait);
+ DATA_PARALLEL_CHECK(worker_command != kWorkerExit);
+
+ // If Func is large (many captures), this will allocate memory, but it is
+ // still slower to use a std::ref wrapper.
+ task_ = func;
+ num_reserved_.store(0);
+
+ StartWorkers(worker_command);
+ WorkersReadyBarrier();
+ }
+
+ // Runs each task (closure, typically a lambda function) on worker thread(s).
+ // Not thread-safe - no two calls to Run and RunTasks may overlap.
+ // Subsequent calls will reuse the same threads.
+ //
+ // This is a more conventional interface for heterogeneous tasks that may be
+ // independent/unrelated.
+ void RunTasks(const std::vector<std::function<void(void)>>& tasks) {
+ Run(0, static_cast<int>(tasks.size()),
+ [&tasks](const int i) { tasks[i](); });
+ }
+
+ // Statically (and deterministically) splits [begin, end) into ranges and
+ // calls "func" for each of them. Useful when "func" involves some overhead
+ // (e.g. for PerThread::Get or random seeding) that should be amortized over
+ // a range of values. "func" is void(int chunk, uint32_t begin, uint32_t end).
+ template <class Func>
+ void RunRanges(const uint32_t begin, const uint32_t end, const Func& func) {
+ const uint32_t length = end - begin;
+
+ // Use constant rather than num_threads_ for machine-independent splitting.
+ const uint32_t chunk = std::max(1U, (length + 127) / 128);
+ std::vector<std::pair<uint32_t, uint32_t>> ranges; // begin/end
+ ranges.reserve(length / chunk + 1);
+ for (uint32_t i = 0; i < length; i += chunk) {
+ ranges.emplace_back(begin + i, begin + std::min(i + chunk, length));
+ }
+
+ Run(0, static_cast<int>(ranges.size()), [&ranges, func](const int i) {
+ func(i, ranges[i].first, ranges[i].second);
+ });
+ }
+
+ private:
+ // After construction and between calls to Run, workers are "ready", i.e.
+ // waiting on worker_start_cv_. They are "started" by sending a "command"
+ // and notifying all worker_start_cv_ waiters. (That is why all workers
+ // must be ready/waiting - otherwise, the notification will not reach all of
+ // them and the main thread waits in vain for them to report readiness.)
+ using WorkerCommand = uint64_t;
+
+ // Special values; all others encode the begin/end parameters.
+ static constexpr WorkerCommand kWorkerWait = 0;
+ static constexpr WorkerCommand kWorkerExit = ~0ULL;
+
+ void WorkersReadyBarrier() {
+ std::unique_lock<std::mutex> lock(mutex_);
+ workers_ready_cv_.wait(lock,
+ [this]() { return workers_ready_ == num_threads_; });
+ workers_ready_ = 0;
+ }
+
+ // Precondition: all workers are ready.
+ void StartWorkers(const WorkerCommand worker_command) {
+ std::unique_lock<std::mutex> lock(mutex_);
+ worker_start_command_ = worker_command;
+ // Workers will need this lock, so release it before they wake up.
+ lock.unlock();
+ worker_start_cv_.notify_all();
+ }
+
+ // Attempts to reserve and perform some work from the global range of tasks,
+ // which is encoded within "command". Returns after all tasks are reserved.
+ static void RunRange(ThreadPool* self, const WorkerCommand command) {
+ const int begin = command & 0xFFFFFFFF;
+ const int end = command >> 32;
+ const int num_tasks = end - begin;
+
+ // OpenMP introduced several "schedule" strategies:
+ // "single" (static assignment of exactly one chunk per thread): slower.
+ // "dynamic" (allocates k tasks at a time): competitive for well-chosen k.
+ // "guided" (allocates k tasks, decreases k): computing k = remaining/n
+ // is faster than halving k each iteration. We prefer this strategy
+ // because it avoids user-specified parameters.
+
+ for (;;) {
+ const int num_reserved = self->num_reserved_.load();
+ const int num_remaining = num_tasks - num_reserved;
+ const int my_size = std::max(num_remaining / (self->num_threads_ * 2), 1);
+ const int my_begin = begin + self->num_reserved_.fetch_add(my_size);
+ const int my_end = std::min(my_begin + my_size, begin + num_tasks);
+ // Another thread already reserved the last task.
+ if (my_begin >= my_end) {
+ break;
+ }
+ for (int i = my_begin; i < my_end; ++i) {
+ self->task_(i);
+ }
+ }
+ }
+
+ static void ThreadFunc(ThreadPool* self) {
+ // Until kWorkerExit command received:
+ for (;;) {
+ std::unique_lock<std::mutex> lock(self->mutex_);
+ // Notify main thread that this thread is ready.
+ if (++self->workers_ready_ == self->num_threads_) {
+ self->workers_ready_cv_.notify_one();
+ }
+ RESUME_WAIT:
+ // Wait for a command.
+ self->worker_start_cv_.wait(lock);
+ const WorkerCommand command = self->worker_start_command_;
+ switch (command) {
+ case kWorkerWait: // spurious wakeup:
+ goto RESUME_WAIT; // lock still held, avoid incrementing ready.
+ case kWorkerExit:
+ return; // exits thread
+ }
+
+ lock.unlock();
+ RunRange(self, command);
+ }
+ }
+
+ const int num_threads_;
+
+ // Unmodified after ctor, but cannot be const because we call thread::join().
+ std::vector<std::thread> threads_;
+
+ std::mutex mutex_; // guards both cv and their variables.
+ std::condition_variable workers_ready_cv_;
+ int workers_ready_ = 0;
+ std::condition_variable worker_start_cv_;
+ WorkerCommand worker_start_command_;
+
+ // Written by main thread, read by workers (after mutex lock/unlock).
+ std::function<void(int)> task_;
+
+ // Updated by workers; alignment/padding avoids false sharing.
+ alignas(64) std::atomic<int> num_reserved_{0};
+ int padding_[15];
+};
+
+// Thread-local storage with support for reduction (combining into one result).
+// The "T" type must be unique to the call site because the list of threads'
+// copies is a static member. (With knowledge of the underlying threads, we
+// could eliminate this list and T allocations, but that is difficult to
+// arrange and we prefer this to be usable independently of ThreadPool.)
+//
+// Usage:
+// for (int i = 0; i < N; ++i) {
+// // in each thread:
+// T& my_copy = PerThread<T>::Get();
+// my_copy.Modify();
+//
+// // single-threaded:
+// T& combined = PerThread<T>::Reduce();
+// Use(combined);
+// PerThread<T>::Destroy();
+// }
+//
+// T is duck-typed and implements the following interface:
+//
+// // Returns true if T is default-initialized or Destroy was called without
+// // any subsequent re-initialization.
+// bool IsNull() const;
+//
+// // Releases any resources. Postcondition: IsNull() == true.
+// void Destroy();
+//
+// // Merges in data from "victim". Precondition: !IsNull() && !victim.IsNull().
+// void Assimilate(const T& victim);
+template <class T>
+class PerThread {
+ public:
+ // Returns reference to this thread's T instance (dynamically allocated,
+ // so its address is unique). Callers are responsible for any initialization
+ // beyond the default ctor.
+ static T& Get() {
+ static thread_local T* t;
+ if (t == nullptr) {
+ t = new T;
+ static std::mutex mutex;
+ std::lock_guard<std::mutex> lock(mutex);
+ Threads().push_back(t);
+ }
+ return *t;
+ }
+
+ // Returns vector of all per-thread T. Used inside Reduce() or by clients
+ // that require direct access to T instead of Assimilating them.
+ // Function wrapper avoids separate static member variable definition.
+ static std::vector<T*>& Threads() {
+ static std::vector<T*> threads;
+ return threads;
+ }
+
+ // Returns the first non-null T after assimilating all other threads' T
+ // into it. Precondition: at least one non-null T exists (caller must have
+ // called Get() and initialized the result).
+ static T& Reduce() {
+ std::vector<T*>& threads = Threads();
+
+ // Find first non-null T
+ const auto it = std::find_if(threads.begin(), threads.end(),
+ [](const T* t) { return !t->IsNull(); });
+ if (it == threads.end()) {
+ abort();
+ }
+ T* const first = *it;
+
+ for (const T* t : threads) {
+ if (t != first && !t->IsNull()) {
+ first->Assimilate(*t);
+ }
+ }
+ return *first;
+ }
+
+ // Calls each thread's T::Destroy to release resources and/or prepare for
+ // reuse by the same threads/ThreadPool. Note that all T remain allocated
+ // (we need thread-independent pointers for iterating over each thread's T,
+ // and deleting them would leave dangling pointers in each thread, which is
+ // unacceptable because the same thread may call Get() again later.)
+ static void Destroy() {
+ for (T* t : Threads()) {
+ t->Destroy();
+ }
+ }
+};
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_DATA_PARALLEL_H_
diff --git a/contrib/libs/highwayhash/highwayhash/data_parallel_benchmark.cc b/contrib/libs/highwayhash/highwayhash/data_parallel_benchmark.cc
index fafdd93dbd..ddc88b067f 100644
--- a/contrib/libs/highwayhash/highwayhash/data_parallel_benchmark.cc
+++ b/contrib/libs/highwayhash/highwayhash/data_parallel_benchmark.cc
@@ -1,151 +1,151 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <cmath>
-#include <cstdio>
-#include <future> //NOLINT
-#include <set>
-#include "testing/base/public/gunit.h"
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/data_parallel.h"
-#include "thread/threadpool.h"
-
-namespace highwayhash {
-namespace {
-
-constexpr int kBenchmarkTasks = 1000000;
-
-// Returns elapsed time [nanoseconds] for std::async.
-double BenchmarkAsync(uint64_t* total) {
- const base::Time t0 = base::Now();
- std::atomic<uint64_t> sum1{0};
- std::atomic<uint64_t> sum2{0};
-
- std::vector<std::future<void>> futures;
- futures.reserve(kBenchmarkTasks);
- for (int i = 0; i < kBenchmarkTasks; ++i) {
- futures.push_back(std::async(
- [&sum1, &sum2](const int i) {
- sum1.fetch_add(i);
- sum2.fetch_add(1);
- },
- i));
- }
-
- for (auto& future : futures) {
- future.get();
- }
-
- const base::Time t1 = base::Now();
- *total = sum1.load() + sum2.load();
- return base::ToDoubleNanoseconds(t1 - t0);
-}
-
-// Returns elapsed time [nanoseconds] for (atomic) ThreadPool.
-double BenchmarkPoolA(uint64_t* total) {
- const base::Time t0 = base::Now();
- std::atomic<uint64_t> sum1{0};
- std::atomic<uint64_t> sum2{0};
-
- ThreadPool pool;
- pool.Run(0, kBenchmarkTasks, [&sum1, &sum2](const int i) {
- sum1.fetch_add(i);
- sum2.fetch_add(1);
- });
-
- const base::Time t1 = base::Now();
- *total = sum1.load() + sum2.load();
- return base::ToDoubleNanoseconds(t1 - t0);
-}
-
-// Returns elapsed time [nanoseconds] for ::ThreadPool.
-double BenchmarkPoolG(uint64_t* total) {
- const base::Time t0 = base::Now();
- std::atomic<uint64_t> sum1{0};
- std::atomic<uint64_t> sum2{0};
-
- {
- ::ThreadPool pool(std::thread::hardware_concurrency());
- pool.StartWorkers();
- for (int i = 0; i < kBenchmarkTasks; ++i) {
- pool.Schedule([&sum1, &sum2, i]() {
- sum1.fetch_add(i);
- sum2.fetch_add(1);
- });
- }
- }
-
- const base::Time t1 = base::Now();
- *total = sum1.load() + sum2.load();
- return base::ToDoubleNanoseconds(t1 - t0);
-}
-
-// Compares ThreadPool speed to std::async and ::ThreadPool.
-TEST(DataParallelTest, Benchmarks) {
- uint64_t sum1, sum2, sum3;
- const double async_ns = BenchmarkAsync(&sum1);
- const double poolA_ns = BenchmarkPoolA(&sum2);
- const double poolG_ns = BenchmarkPoolG(&sum3);
-
- printf("Async %11.0f ns\nPoolA %11.0f ns\nPoolG %11.0f ns\n", async_ns,
- poolA_ns, poolG_ns);
- // baseline 20x, 10x with asan or msan, 5x with tsan
- EXPECT_GT(async_ns, poolA_ns * 4);
- // baseline 200x, 180x with asan, 70x with msan, 50x with tsan.
- EXPECT_GT(poolG_ns, poolA_ns * 20);
-
- // Should reach same result.
- EXPECT_EQ(sum1, sum2);
- EXPECT_EQ(sum2, sum3);
-}
-
-// Ensures multiple hardware threads are used (decided by the OS scheduler).
-TEST(DataParallelTest, TestApicIds) {
- for (int num_threads = 1; num_threads <= std::thread::hardware_concurrency();
- ++num_threads) {
- ThreadPool pool(num_threads);
-
- std::mutex mutex;
- std::set<unsigned> ids;
- double total = 0.0;
- pool.Run(0, 2 * num_threads, [&mutex, &ids, &total](const int i) {
- // Useless computations to keep the processor busy so that threads
- // can't just reuse the same processor.
- double sum = 0.0;
- for (int rep = 0; rep < 900 * (i + 30); ++rep) {
- sum += pow(rep, 0.5);
- }
-
- mutex.lock();
- ids.insert(ApicId());
- total += sum;
- mutex.unlock();
- });
-
- // No core ID / APIC ID available
- if (num_threads > 1 && ids.size() == 1) {
- EXPECT_EQ(0, *ids.begin());
- } else {
- // (The Linux scheduler doesn't use all available HTs, but the
- // computations should at least keep most cores busy.)
- EXPECT_GT(ids.size() + 2, num_threads / 4);
- }
-
- // (Ensure the busy-work is not elided.)
- EXPECT_GT(total, 1E4);
- }
-}
-
-} // namespace
-} // namespace highwayhash
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cmath>
+#include <cstdio>
+#include <future> //NOLINT
+#include <set>
+#include "testing/base/public/gunit.h"
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/data_parallel.h"
+#include "thread/threadpool.h"
+
+namespace highwayhash {
+namespace {
+
+constexpr int kBenchmarkTasks = 1000000;
+
+// Returns elapsed time [nanoseconds] for std::async.
+double BenchmarkAsync(uint64_t* total) {
+ const base::Time t0 = base::Now();
+ std::atomic<uint64_t> sum1{0};
+ std::atomic<uint64_t> sum2{0};
+
+ std::vector<std::future<void>> futures;
+ futures.reserve(kBenchmarkTasks);
+ for (int i = 0; i < kBenchmarkTasks; ++i) {
+ futures.push_back(std::async(
+ [&sum1, &sum2](const int i) {
+ sum1.fetch_add(i);
+ sum2.fetch_add(1);
+ },
+ i));
+ }
+
+ for (auto& future : futures) {
+ future.get();
+ }
+
+ const base::Time t1 = base::Now();
+ *total = sum1.load() + sum2.load();
+ return base::ToDoubleNanoseconds(t1 - t0);
+}
+
+// Returns elapsed time [nanoseconds] for (atomic) ThreadPool.
+double BenchmarkPoolA(uint64_t* total) {
+ const base::Time t0 = base::Now();
+ std::atomic<uint64_t> sum1{0};
+ std::atomic<uint64_t> sum2{0};
+
+ ThreadPool pool;
+ pool.Run(0, kBenchmarkTasks, [&sum1, &sum2](const int i) {
+ sum1.fetch_add(i);
+ sum2.fetch_add(1);
+ });
+
+ const base::Time t1 = base::Now();
+ *total = sum1.load() + sum2.load();
+ return base::ToDoubleNanoseconds(t1 - t0);
+}
+
+// Returns elapsed time [nanoseconds] for ::ThreadPool.
+double BenchmarkPoolG(uint64_t* total) {
+ const base::Time t0 = base::Now();
+ std::atomic<uint64_t> sum1{0};
+ std::atomic<uint64_t> sum2{0};
+
+ {
+ ::ThreadPool pool(std::thread::hardware_concurrency());
+ pool.StartWorkers();
+ for (int i = 0; i < kBenchmarkTasks; ++i) {
+ pool.Schedule([&sum1, &sum2, i]() {
+ sum1.fetch_add(i);
+ sum2.fetch_add(1);
+ });
+ }
+ }
+
+ const base::Time t1 = base::Now();
+ *total = sum1.load() + sum2.load();
+ return base::ToDoubleNanoseconds(t1 - t0);
+}
+
+// Compares ThreadPool speed to std::async and ::ThreadPool.
+TEST(DataParallelTest, Benchmarks) {
+ uint64_t sum1, sum2, sum3;
+ const double async_ns = BenchmarkAsync(&sum1);
+ const double poolA_ns = BenchmarkPoolA(&sum2);
+ const double poolG_ns = BenchmarkPoolG(&sum3);
+
+ printf("Async %11.0f ns\nPoolA %11.0f ns\nPoolG %11.0f ns\n", async_ns,
+ poolA_ns, poolG_ns);
+ // baseline 20x, 10x with asan or msan, 5x with tsan
+ EXPECT_GT(async_ns, poolA_ns * 4);
+ // baseline 200x, 180x with asan, 70x with msan, 50x with tsan.
+ EXPECT_GT(poolG_ns, poolA_ns * 20);
+
+ // Should reach same result.
+ EXPECT_EQ(sum1, sum2);
+ EXPECT_EQ(sum2, sum3);
+}
+
+// Ensures multiple hardware threads are used (decided by the OS scheduler).
+TEST(DataParallelTest, TestApicIds) {
+ for (int num_threads = 1; num_threads <= std::thread::hardware_concurrency();
+ ++num_threads) {
+ ThreadPool pool(num_threads);
+
+ std::mutex mutex;
+ std::set<unsigned> ids;
+ double total = 0.0;
+ pool.Run(0, 2 * num_threads, [&mutex, &ids, &total](const int i) {
+ // Useless computations to keep the processor busy so that threads
+ // can't just reuse the same processor.
+ double sum = 0.0;
+ for (int rep = 0; rep < 900 * (i + 30); ++rep) {
+ sum += pow(rep, 0.5);
+ }
+
+ mutex.lock();
+ ids.insert(ApicId());
+ total += sum;
+ mutex.unlock();
+ });
+
+ // No core ID / APIC ID available
+ if (num_threads > 1 && ids.size() == 1) {
+ EXPECT_EQ(0, *ids.begin());
+ } else {
+ // (The Linux scheduler doesn't use all available HTs, but the
+ // computations should at least keep most cores busy.)
+ EXPECT_GT(ids.size() + 2, num_threads / 4);
+ }
+
+ // (Ensure the busy-work is not elided.)
+ EXPECT_GT(total, 1E4);
+ }
+}
+
+} // namespace
+} // namespace highwayhash
diff --git a/contrib/libs/highwayhash/highwayhash/data_parallel_test.cc b/contrib/libs/highwayhash/highwayhash/data_parallel_test.cc
index d733620099..2728b7d3ad 100644
--- a/contrib/libs/highwayhash/highwayhash/data_parallel_test.cc
+++ b/contrib/libs/highwayhash/highwayhash/data_parallel_test.cc
@@ -1,175 +1,175 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <unistd.h>
-#include <cstdint>
-
-#include "testing/base/public/gunit.h"
-#include "highwayhash/data_parallel.h"
-
-namespace highwayhash {
-namespace {
-
-int PopulationCount(uint64_t bits) {
- int num_set = 0;
- while (bits != 0) {
- num_set += bits & 1;
- bits >>= 1;
- }
- return num_set;
-}
-
-std::atomic<int> func_counts{0};
-
-void Func2() {
- usleep(200000);
- func_counts.fetch_add(4);
-}
-
-void Func3() {
- usleep(300000);
- func_counts.fetch_add(16);
-}
-
-void Func4() {
- usleep(400000);
- func_counts.fetch_add(256);
-}
-
-// Exercises the RunTasks feature (running arbitrary tasks/closures)
-TEST(DataParallelTest, TestRunTasks) {
- ThreadPool pool(4);
- pool.RunTasks({Func2, Func3, Func4});
- EXPECT_EQ(276, func_counts.load());
-}
-
-// Ensures task parameter is in bounds, every parameter is reached,
-// pool can be reused (multiple consecutive Run calls), pool can be destroyed
-// (joining with its threads).
-TEST(DataParallelTest, TestPool) {
- for (int num_threads = 1; num_threads <= 18; ++num_threads) {
- ThreadPool pool(num_threads);
- for (int num_tasks = 0; num_tasks < 32; ++num_tasks) {
- std::vector<int> mementos(num_tasks, 0);
- for (int begin = 0; begin < 32; ++begin) {
- std::fill(mementos.begin(), mementos.end(), 0);
- pool.Run(begin, begin + num_tasks,
- [begin, num_tasks, &mementos](const int i) {
- // Parameter is in the given range
- EXPECT_GE(i, begin);
- EXPECT_LT(i, begin + num_tasks);
-
- // Store mementos to be sure we visited each i.
- mementos.at(i - begin) = 1000 + i;
- });
- for (int i = begin; i < begin + num_tasks; ++i) {
- EXPECT_EQ(1000 + i, mementos.at(i - begin));
- }
- }
- }
- }
-}
-
-TEST(DataParallelTest, TestRunRanges) {
- for (int num_threads = 1; num_threads <= 18; ++num_threads) {
- ThreadPool pool(num_threads);
- for (int num_tasks = 0; num_tasks < 32; ++num_tasks) {
- std::vector<int> mementos(num_tasks, 0);
- for (int begin = 0; begin < 32; ++begin) {
- std::fill(mementos.begin(), mementos.end(), 0);
- pool.RunRanges(begin, begin + num_tasks,
- [begin, num_tasks, &mementos](const int chunk,
- const uint32_t my_begin,
- const uint32_t my_end) {
- for (uint32_t i = my_begin; i < my_end; ++i) {
- // Parameter is in the given range
- EXPECT_GE(i, begin);
- EXPECT_LT(i, begin + num_tasks);
-
- // Store mementos to be sure we visited each i.
- mementos.at(i - begin) = 1000 + i;
- }
- });
- for (int i = begin; i < begin + num_tasks; ++i) {
- EXPECT_EQ(1000 + i, mementos.at(i - begin));
- }
- }
- }
- }
-}
-
-// Ensures each of N threads processes exactly 1 of N tasks, i.e. the
-// work distribution is perfectly fair for small counts.
-TEST(DataParallelTest, TestSmallAssignments) {
- for (int num_threads = 1; num_threads <= 64; ++num_threads) {
- ThreadPool pool(num_threads);
-
- std::atomic<int> counter{0};
- // (Avoid mutex because it may perturb the worker thread scheduling)
- std::atomic<uint64_t> id_bits{0};
-
- pool.Run(0, num_threads, [&counter, num_threads, &id_bits](const int i) {
- const int id = counter.fetch_add(1);
- EXPECT_LT(id, num_threads);
- uint64_t bits = id_bits.load(std::memory_order_relaxed);
- while (!id_bits.compare_exchange_weak(bits, bits | (1ULL << id))) {
- }
- });
-
- const int num_participants = PopulationCount(id_bits.load());
- EXPECT_EQ(num_threads, num_participants);
- }
-}
-
-// Test payload for PerThread.
-struct CheckUniqueIDs {
- bool IsNull() const { return false; }
- void Destroy() { id_bits = 0; }
- void Assimilate(const CheckUniqueIDs& victim) {
- // Cannot overlap because each PerThread has unique bits.
- EXPECT_EQ(0, id_bits & victim.id_bits);
- id_bits |= victim.id_bits;
- }
-
- uint64_t id_bits = 0;
-};
-
-// Ensures each thread has a PerThread instance, that they are successfully
-// combined/reduced into a single result, and that reuse is possible after
-// Destroy().
-TEST(DataParallelTest, TestPerThread) {
- // We use a uint64_t bit array for convenience => no more than 64 threads.
- const int max_threads = std::min(64U, std::thread::hardware_concurrency());
- for (int num_threads = 1; num_threads <= max_threads; ++num_threads) {
- ThreadPool pool(num_threads);
-
- std::atomic<int> counter{0};
- pool.Run(0, num_threads, [&counter, num_threads](const int i) {
- const int id = counter.fetch_add(1);
- EXPECT_LT(id, num_threads);
- PerThread<CheckUniqueIDs>::Get().id_bits |= 1ULL << id;
- });
-
- // Verify each thread's bit is set.
- const uint64_t all_bits = PerThread<CheckUniqueIDs>::Reduce().id_bits;
- // Avoid shifting by 64 (undefined).
- const uint64_t expected =
- num_threads == 64 ? ~0ULL : (1ULL << num_threads) - 1;
- EXPECT_EQ(expected, all_bits);
- PerThread<CheckUniqueIDs>::Destroy();
- }
-}
-
-} // namespace
-} // namespace highwayhash
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <unistd.h>
+#include <cstdint>
+
+#include "testing/base/public/gunit.h"
+#include "highwayhash/data_parallel.h"
+
+namespace highwayhash {
+namespace {
+
+int PopulationCount(uint64_t bits) {
+ int num_set = 0;
+ while (bits != 0) {
+ num_set += bits & 1;
+ bits >>= 1;
+ }
+ return num_set;
+}
+
+std::atomic<int> func_counts{0};
+
+void Func2() {
+ usleep(200000);
+ func_counts.fetch_add(4);
+}
+
+void Func3() {
+ usleep(300000);
+ func_counts.fetch_add(16);
+}
+
+void Func4() {
+ usleep(400000);
+ func_counts.fetch_add(256);
+}
+
+// Exercises the RunTasks feature (running arbitrary tasks/closures)
+TEST(DataParallelTest, TestRunTasks) {
+ ThreadPool pool(4);
+ pool.RunTasks({Func2, Func3, Func4});
+ EXPECT_EQ(276, func_counts.load());
+}
+
+// Ensures task parameter is in bounds, every parameter is reached,
+// pool can be reused (multiple consecutive Run calls), pool can be destroyed
+// (joining with its threads).
+TEST(DataParallelTest, TestPool) {
+ for (int num_threads = 1; num_threads <= 18; ++num_threads) {
+ ThreadPool pool(num_threads);
+ for (int num_tasks = 0; num_tasks < 32; ++num_tasks) {
+ std::vector<int> mementos(num_tasks, 0);
+ for (int begin = 0; begin < 32; ++begin) {
+ std::fill(mementos.begin(), mementos.end(), 0);
+ pool.Run(begin, begin + num_tasks,
+ [begin, num_tasks, &mementos](const int i) {
+ // Parameter is in the given range
+ EXPECT_GE(i, begin);
+ EXPECT_LT(i, begin + num_tasks);
+
+ // Store mementos to be sure we visited each i.
+ mementos.at(i - begin) = 1000 + i;
+ });
+ for (int i = begin; i < begin + num_tasks; ++i) {
+ EXPECT_EQ(1000 + i, mementos.at(i - begin));
+ }
+ }
+ }
+ }
+}
+
+TEST(DataParallelTest, TestRunRanges) {
+ for (int num_threads = 1; num_threads <= 18; ++num_threads) {
+ ThreadPool pool(num_threads);
+ for (int num_tasks = 0; num_tasks < 32; ++num_tasks) {
+ std::vector<int> mementos(num_tasks, 0);
+ for (int begin = 0; begin < 32; ++begin) {
+ std::fill(mementos.begin(), mementos.end(), 0);
+ pool.RunRanges(begin, begin + num_tasks,
+ [begin, num_tasks, &mementos](const int chunk,
+ const uint32_t my_begin,
+ const uint32_t my_end) {
+ for (uint32_t i = my_begin; i < my_end; ++i) {
+ // Parameter is in the given range
+ EXPECT_GE(i, begin);
+ EXPECT_LT(i, begin + num_tasks);
+
+ // Store mementos to be sure we visited each i.
+ mementos.at(i - begin) = 1000 + i;
+ }
+ });
+ for (int i = begin; i < begin + num_tasks; ++i) {
+ EXPECT_EQ(1000 + i, mementos.at(i - begin));
+ }
+ }
+ }
+ }
+}
+
+// Ensures each of N threads processes exactly 1 of N tasks, i.e. the
+// work distribution is perfectly fair for small counts.
+TEST(DataParallelTest, TestSmallAssignments) {
+ for (int num_threads = 1; num_threads <= 64; ++num_threads) {
+ ThreadPool pool(num_threads);
+
+ std::atomic<int> counter{0};
+ // (Avoid mutex because it may perturb the worker thread scheduling)
+ std::atomic<uint64_t> id_bits{0};
+
+ pool.Run(0, num_threads, [&counter, num_threads, &id_bits](const int i) {
+ const int id = counter.fetch_add(1);
+ EXPECT_LT(id, num_threads);
+ uint64_t bits = id_bits.load(std::memory_order_relaxed);
+ while (!id_bits.compare_exchange_weak(bits, bits | (1ULL << id))) {
+ }
+ });
+
+ const int num_participants = PopulationCount(id_bits.load());
+ EXPECT_EQ(num_threads, num_participants);
+ }
+}
+
+// Test payload for PerThread.
+struct CheckUniqueIDs {
+ bool IsNull() const { return false; }
+ void Destroy() { id_bits = 0; }
+ void Assimilate(const CheckUniqueIDs& victim) {
+ // Cannot overlap because each PerThread has unique bits.
+ EXPECT_EQ(0, id_bits & victim.id_bits);
+ id_bits |= victim.id_bits;
+ }
+
+ uint64_t id_bits = 0;
+};
+
+// Ensures each thread has a PerThread instance, that they are successfully
+// combined/reduced into a single result, and that reuse is possible after
+// Destroy().
+TEST(DataParallelTest, TestPerThread) {
+ // We use a uint64_t bit array for convenience => no more than 64 threads.
+ const int max_threads = std::min(64U, std::thread::hardware_concurrency());
+ for (int num_threads = 1; num_threads <= max_threads; ++num_threads) {
+ ThreadPool pool(num_threads);
+
+ std::atomic<int> counter{0};
+ pool.Run(0, num_threads, [&counter, num_threads](const int i) {
+ const int id = counter.fetch_add(1);
+ EXPECT_LT(id, num_threads);
+ PerThread<CheckUniqueIDs>::Get().id_bits |= 1ULL << id;
+ });
+
+ // Verify each thread's bit is set.
+ const uint64_t all_bits = PerThread<CheckUniqueIDs>::Reduce().id_bits;
+ // Avoid shifting by 64 (undefined).
+ const uint64_t expected =
+ num_threads == 64 ? ~0ULL : (1ULL << num_threads) - 1;
+ EXPECT_EQ(expected, all_bits);
+ PerThread<CheckUniqueIDs>::Destroy();
+ }
+}
+
+} // namespace
+} // namespace highwayhash
diff --git a/contrib/libs/highwayhash/highwayhash/endianess.h b/contrib/libs/highwayhash/highwayhash/endianess.h
index 6c82d6e50c..776a02fa21 100644
--- a/contrib/libs/highwayhash/highwayhash/endianess.h
+++ b/contrib/libs/highwayhash/highwayhash/endianess.h
@@ -1,108 +1,108 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_ENDIANESS_H_
-#define HIGHWAYHASH_ENDIANESS_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stdint.h>
-
-#if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
-
- /* Someone has already included <endian.h> or equivalent. */
-
-#elif defined(__LITTLE_ENDIAN__)
-
-# define HH_IS_LITTLE_ENDIAN 1
-# define HH_IS_BIG_ENDIAN 0
-# ifdef __BIG_ENDIAN__
-# error "Platform is both little and big endian?"
-# endif
-
-#elif defined(__BIG_ENDIAN__)
-
-# define HH_IS_LITTLE_ENDIAN 0
-# define HH_IS_BIG_ENDIAN 1
-
-#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
- defined(__ORDER_LITTLE_ENDIAN__)
-
-# define HH_IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
-# define HH_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
-
-#elif defined(__linux__) || defined(__CYGWIN__) || defined( __GNUC__ ) || \
- defined( __GNU_LIBRARY__ )
-
-# include <endian.h>
-
-#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || \
- defined(__DragonFly__)
-
-# include <sys/endian.h>
-
-#elif defined(_WIN32)
-
-#define HH_IS_LITTLE_ENDIAN 1
-#define HH_IS_BIG_ENDIAN 0
-
-#else
-
-# error "Unsupported platform. Cannot determine byte order."
-
-#endif
-
-
-#ifndef HH_IS_LITTLE_ENDIAN
-# define HH_IS_LITTLE_ENDIAN (BYTE_ORDER == LITTLE_ENDIAN)
-# define HH_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
-#endif
-
-
-namespace highwayhash {
-
-#if HH_IS_LITTLE_ENDIAN
-
-static inline uint32_t le32_from_host(uint32_t x) { return x; }
-static inline uint32_t host_from_le32(uint32_t x) { return x; }
-static inline uint64_t le64_from_host(uint64_t x) { return x; }
-static inline uint64_t host_from_le64(uint64_t x) { return x; }
-
-#elif !HH_IS_BIG_ENDIAN
-
-# error "Unsupported byte order."
-
-#elif defined(_WIN16) || defined(_WIN32) || defined(_WIN64)
-
-#include <intrin.h>
-static inline uint32_t host_from_le32(uint32_t x) { return _byteswap_ulong(x); }
-static inline uint32_t le32_from_host(uint32_t x) { return _byteswap_ulong(x); }
-static inline uint64_t host_from_le64(uint64_t x) { return _byteswap_uint64(x);}
-static inline uint64_t le64_from_host(uint64_t x) { return _byteswap_uint64(x);}
-
-#else
-
-static inline uint32_t host_from_le32(uint32_t x) {return __builtin_bswap32(x);}
-static inline uint32_t le32_from_host(uint32_t x) {return __builtin_bswap32(x);}
-static inline uint64_t host_from_le64(uint64_t x) {return __builtin_bswap64(x);}
-static inline uint64_t le64_from_host(uint64_t x) {return __builtin_bswap64(x);}
-
-#endif
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_ENDIANESS_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_ENDIANESS_H_
+#define HIGHWAYHASH_ENDIANESS_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stdint.h>
+
+#if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
+
+ /* Someone has already included <endian.h> or equivalent. */
+
+#elif defined(__LITTLE_ENDIAN__)
+
+# define HH_IS_LITTLE_ENDIAN 1
+# define HH_IS_BIG_ENDIAN 0
+# ifdef __BIG_ENDIAN__
+# error "Platform is both little and big endian?"
+# endif
+
+#elif defined(__BIG_ENDIAN__)
+
+# define HH_IS_LITTLE_ENDIAN 0
+# define HH_IS_BIG_ENDIAN 1
+
+#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
+ defined(__ORDER_LITTLE_ENDIAN__)
+
+# define HH_IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+# define HH_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+
+#elif defined(__linux__) || defined(__CYGWIN__) || defined( __GNUC__ ) || \
+ defined( __GNU_LIBRARY__ )
+
+# include <endian.h>
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || \
+ defined(__DragonFly__)
+
+# include <sys/endian.h>
+
+#elif defined(_WIN32)
+
+#define HH_IS_LITTLE_ENDIAN 1
+#define HH_IS_BIG_ENDIAN 0
+
+#else
+
+# error "Unsupported platform. Cannot determine byte order."
+
+#endif
+
+
+#ifndef HH_IS_LITTLE_ENDIAN
+# define HH_IS_LITTLE_ENDIAN (BYTE_ORDER == LITTLE_ENDIAN)
+# define HH_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
+#endif
+
+
+namespace highwayhash {
+
+#if HH_IS_LITTLE_ENDIAN
+
+static inline uint32_t le32_from_host(uint32_t x) { return x; }
+static inline uint32_t host_from_le32(uint32_t x) { return x; }
+static inline uint64_t le64_from_host(uint64_t x) { return x; }
+static inline uint64_t host_from_le64(uint64_t x) { return x; }
+
+#elif !HH_IS_BIG_ENDIAN
+
+# error "Unsupported byte order."
+
+#elif defined(_WIN16) || defined(_WIN32) || defined(_WIN64)
+
+#include <intrin.h>
+static inline uint32_t host_from_le32(uint32_t x) { return _byteswap_ulong(x); }
+static inline uint32_t le32_from_host(uint32_t x) { return _byteswap_ulong(x); }
+static inline uint64_t host_from_le64(uint64_t x) { return _byteswap_uint64(x);}
+static inline uint64_t le64_from_host(uint64_t x) { return _byteswap_uint64(x);}
+
+#else
+
+static inline uint32_t host_from_le32(uint32_t x) {return __builtin_bswap32(x);}
+static inline uint32_t le32_from_host(uint32_t x) {return __builtin_bswap32(x);}
+static inline uint64_t host_from_le64(uint64_t x) {return __builtin_bswap64(x);}
+static inline uint64_t le64_from_host(uint64_t x) {return __builtin_bswap64(x);}
+
+#endif
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_ENDIANESS_H_
diff --git a/contrib/libs/highwayhash/highwayhash/example.cc b/contrib/libs/highwayhash/highwayhash/example.cc
index ed7c6a3173..587e3c5985 100644
--- a/contrib/libs/highwayhash/highwayhash/example.cc
+++ b/contrib/libs/highwayhash/highwayhash/example.cc
@@ -1,30 +1,30 @@
-// Minimal usage example: prints a hash. Tested on x86, ppc, arm.
-
-#include "highwayhash/highwayhash.h"
-
-#include <algorithm>
-#include <iostream>
-
-using namespace highwayhash;
-
-int main(int argc, char* argv[]) {
- // Please use a different key to ensure your hashes aren't identical.
- const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
- // Aligning inputs to 32 bytes may help but is not required.
- const char in[] = "bytes_to_hash";
- // Type determines the hash size; can also be HHResult128 or HHResult256.
- HHResult64 result;
- // HH_TARGET_PREFERRED expands to the best specialization available for the
- // CPU detected via compiler flags (e.g. AVX2 #ifdef __AVX2__).
- HHStateT<HH_TARGET_PREFERRED> state(key);
- // Using argc prevents the compiler from eliding the hash computations.
- const size_t size = std::min(sizeof(in), static_cast<size_t>(argc));
- HighwayHashT(&state, in, size, &result);
- std::cout << "Hash : " << result << std::endl;
-
- HighwayHashCatT<HH_TARGET_PREFERRED> cat(key);
- cat.Append(in, size);
- cat.Finalize(&result);
- std::cout << "HashCat: " << result << std::endl;
- return 0;
-}
+// Minimal usage example: prints a hash. Tested on x86, ppc, arm.
+
+#include "highwayhash/highwayhash.h"
+
+#include <algorithm>
+#include <iostream>
+
+using namespace highwayhash;
+
+int main(int argc, char* argv[]) {
+ // Please use a different key to ensure your hashes aren't identical.
+ const HHKey key HH_ALIGNAS(32) = {1, 2, 3, 4};
+ // Aligning inputs to 32 bytes may help but is not required.
+ const char in[] = "bytes_to_hash";
+ // Type determines the hash size; can also be HHResult128 or HHResult256.
+ HHResult64 result;
+ // HH_TARGET_PREFERRED expands to the best specialization available for the
+ // CPU detected via compiler flags (e.g. AVX2 #ifdef __AVX2__).
+ HHStateT<HH_TARGET_PREFERRED> state(key);
+ // Using argc prevents the compiler from eliding the hash computations.
+ const size_t size = std::min(sizeof(in), static_cast<size_t>(argc));
+ HighwayHashT(&state, in, size, &result);
+ std::cout << "Hash : " << result << std::endl;
+
+ HighwayHashCatT<HH_TARGET_PREFERRED> cat(key);
+ cat.Append(in, size);
+ cat.Finalize(&result);
+ std::cout << "HashCat: " << result << std::endl;
+ return 0;
+}
diff --git a/contrib/libs/highwayhash/highwayhash/hh_avx2.cc b/contrib/libs/highwayhash/highwayhash/hh_avx2.cc
index b4477ad2e2..7e3ddff0d4 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_avx2.cc
+++ b/contrib/libs/highwayhash/highwayhash/hh_avx2.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME AVX2
-#include "highwayhash/highwayhash_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME AVX2
+#include "highwayhash/highwayhash_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/hh_avx2.h b/contrib/libs/highwayhash/highwayhash/hh_avx2.h
index dfb85ab32a..2912a31b11 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_avx2.h
+++ b/contrib/libs/highwayhash/highwayhash/hh_avx2.h
@@ -1,383 +1,383 @@
-// Copyright 2015-2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HH_AVX2_H_
-#define HIGHWAYHASH_HH_AVX2_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/hh_buffer.h"
-#include "highwayhash/hh_types.h"
-#include "highwayhash/load3.h"
-#include "highwayhash/vector128.h"
-#include "highwayhash/vector256.h"
-
-// For auto-dependency generation, we need to include all headers but not their
-// contents (otherwise compilation fails because -mavx2 is not specified).
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-
-namespace highwayhash {
-// See vector128.h for why this namespace is necessary; matching it here makes
-// it easier use the vector128 symbols, but requires textual inclusion.
-namespace HH_TARGET_NAME {
-
-class HHStateAVX2 {
- public:
- explicit HH_INLINE HHStateAVX2(const HHKey key_lanes) { Reset(key_lanes); }
-
- HH_INLINE void Reset(const HHKey key_lanes) {
- // "Nothing up my sleeve" numbers, concatenated hex digits of Pi from
- // http://www.numberworld.org/digits/Pi/, retrieved Feb 22, 2016.
- //
- // We use this python code to generate the fourth number to have
- // more even mixture of bits:
- /*
-def x(a,b,c):
- retval = 0
- for i in range(64):
- count = ((a >> i) & 1) + ((b >> i) & 1) + ((c >> i) & 1)
- if (count <= 1):
- retval |= 1 << i
- return retval
- */
- const V4x64U init0(0x243f6a8885a308d3ull, 0x13198a2e03707344ull,
- 0xa4093822299f31d0ull, 0xdbe6d5d5fe4cce2full);
- const V4x64U init1(0x452821e638d01377ull, 0xbe5466cf34e90c6cull,
- 0xc0acf169b5f18a8cull, 0x3bd39e10cb0ef593ull);
- const V4x64U key = LoadUnaligned<V4x64U>(key_lanes);
- v0 = key ^ init0;
- v1 = Rotate64By32(key) ^ init1;
- mul0 = init0;
- mul1 = init1;
- }
-
- HH_INLINE void Update(const HHPacket& packet_bytes) {
- const uint64_t* HH_RESTRICT packet =
- reinterpret_cast<const uint64_t * HH_RESTRICT>(packet_bytes);
- Update(LoadUnaligned<V4x64U>(packet));
- }
-
- HH_INLINE void UpdateRemainder(const char* bytes, const size_t size_mod32) {
- // 'Length padding' differentiates zero-valued inputs that have the same
- // size/32. mod32 is sufficient because each Update behaves as if a
- // counter were injected, because the state is large and mixed thoroughly.
- const V8x32U size256(
- _mm256_broadcastd_epi32(_mm_cvtsi64_si128(size_mod32)));
- // Equivalent to storing size_mod32 in packet.
- v0 += V4x64U(size256);
- // Boosts the avalanche effect of mod32.
- v1 = Rotate32By(v1, size256);
-
- const char* remainder = bytes + (size_mod32 & ~3);
- const size_t size_mod4 = size_mod32 & 3;
-
- const V4x32U size(_mm256_castsi256_si128(size256));
-
- // (Branching is faster than a single _mm256_maskload_epi32.)
- if (HH_UNLIKELY(size_mod32 & 16)) { // 16..31 bytes left
- const V4x32U packetL =
- LoadUnaligned<V4x32U>(reinterpret_cast<const uint32_t*>(bytes));
-
- const V4x32U int_mask = IntMask<16>()(size);
- const V4x32U int_lanes = MaskedLoadInt(bytes + 16, int_mask);
- const uint32_t last4 =
- Load3()(Load3::AllowReadBeforeAndReturn(), remainder, size_mod4);
-
- // The upper four bytes of packetH are zero, so insert there.
- const V4x32U packetH(_mm_insert_epi32(int_lanes, last4, 3));
- Update(packetH, packetL);
- } else { // size_mod32 < 16
- const V4x32U int_mask = IntMask<0>()(size);
- const V4x32U packetL = MaskedLoadInt(bytes, int_mask);
- const uint64_t last3 =
- Load3()(Load3::AllowUnordered(), remainder, size_mod4);
-
- // Rather than insert into packetL[3], it is faster to initialize
- // the otherwise empty packetH.
- const V4x32U packetH(_mm_cvtsi64_si128(last3));
- Update(packetH, packetL);
- }
- }
-
- HH_INLINE void Finalize(HHResult64* HH_RESTRICT result) {
- // Mix together all lanes. It is slightly better to permute v0 than v1;
- // it will be added to v1.
- Update(Permute(v0));
- Update(Permute(v0));
- Update(Permute(v0));
- Update(Permute(v0));
-
- const V2x64U sum0(_mm256_castsi256_si128(v0 + mul0));
- const V2x64U sum1(_mm256_castsi256_si128(v1 + mul1));
- const V2x64U hash = sum0 + sum1;
- // Each lane is sufficiently mixed, so just truncate to 64 bits.
- _mm_storel_epi64(reinterpret_cast<__m128i*>(result), hash);
- }
-
- HH_INLINE void Finalize(HHResult128* HH_RESTRICT result) {
- Update(Permute(v0));
- Update(Permute(v0));
- Update(Permute(v0));
- Update(Permute(v0));
-
- const V2x64U sum0(_mm256_castsi256_si128(v0 + mul0));
- const V2x64U sum1(_mm256_extracti128_si256(v1 + mul1, 1));
- const V2x64U hash = sum0 + sum1;
- _mm_storeu_si128(reinterpret_cast<__m128i*>(result), hash);
- }
-
- HH_INLINE void Finalize(HHResult256* HH_RESTRICT result) {
- Update(Permute(v0));
- Update(Permute(v0));
- Update(Permute(v0));
- Update(Permute(v0));
-
- const V4x64U sum0 = v0 + mul0;
- const V4x64U sum1 = v1 + mul1;
- const V4x64U hash = ModularReduction(sum1, sum0);
- StoreUnaligned(hash, &(*result)[0]);
- }
-
- // "buffer" must be 32-byte aligned.
- static HH_INLINE void ZeroInitialize(char* HH_RESTRICT buffer) {
- const __m256i zero = _mm256_setzero_si256();
- _mm256_store_si256(reinterpret_cast<__m256i*>(buffer), zero);
- }
-
- // "buffer" must be 32-byte aligned.
- static HH_INLINE void CopyPartial(const char* HH_RESTRICT from,
- const size_t size_mod32,
- char* HH_RESTRICT buffer) {
- const V4x32U size(size_mod32);
- const uint32_t* const HH_RESTRICT from_u32 =
- reinterpret_cast<const uint32_t * HH_RESTRICT>(from);
- uint32_t* const HH_RESTRICT buffer_u32 =
- reinterpret_cast<uint32_t * HH_RESTRICT>(buffer);
- if (HH_UNLIKELY(size_mod32 & 16)) { // Copying 16..31 bytes
- const V4x32U inL = LoadUnaligned<V4x32U>(from_u32);
- Store(inL, buffer_u32);
- const V4x32U inH = Load0To16<16, Load3::AllowReadBefore>(
- from + 16, size_mod32 - 16, size);
- Store(inH, buffer_u32 + V4x32U::N);
- } else { // Copying 0..15 bytes
- const V4x32U inL = Load0To16<>(from, size_mod32, size);
- Store(inL, buffer_u32);
- // No need to change upper 16 bytes of buffer.
- }
- }
-
- // "buffer" must be 32-byte aligned.
- static HH_INLINE void AppendPartial(const char* HH_RESTRICT from,
- const size_t size_mod32,
- char* HH_RESTRICT buffer,
- const size_t buffer_valid) {
- const V4x32U size(size_mod32);
- uint32_t* const HH_RESTRICT buffer_u32 =
- reinterpret_cast<uint32_t * HH_RESTRICT>(buffer);
- // buffer_valid + size <= 32 => appending 0..16 bytes inside upper 16 bytes.
- if (HH_UNLIKELY(buffer_valid & 16)) {
- const V4x32U suffix = Load0To16<>(from, size_mod32, size);
- const V4x32U bufferH = Load<V4x32U>(buffer_u32 + V4x32U::N);
- const V4x32U outH = Concatenate(bufferH, buffer_valid - 16, suffix);
- Store(outH, buffer_u32 + V4x32U::N);
- } else { // Appending 0..32 bytes starting at offset 0..15.
- const V4x32U bufferL = Load<V4x32U>(buffer_u32);
- const V4x32U suffixL = Load0To16<>(from, size_mod32, size);
- const V4x32U outL = Concatenate(bufferL, buffer_valid, suffixL);
- Store(outL, buffer_u32);
- const size_t offsetH = sizeof(V4x32U) - buffer_valid;
- // Do we have enough input to start filling the upper 16 buffer bytes?
- if (size_mod32 > offsetH) {
- const size_t sizeH = size_mod32 - offsetH;
- const V4x32U outH = Load0To16<>(from + offsetH, sizeH, V4x32U(sizeH));
- Store(outH, buffer_u32 + V4x32U::N);
- }
- }
- }
-
- // "buffer" must be 32-byte aligned.
- HH_INLINE void AppendAndUpdate(const char* HH_RESTRICT from,
- const size_t size_mod32,
- const char* HH_RESTRICT buffer,
- const size_t buffer_valid) {
- const V4x32U size(size_mod32);
- const uint32_t* const HH_RESTRICT buffer_u32 =
- reinterpret_cast<const uint32_t * HH_RESTRICT>(buffer);
- // buffer_valid + size <= 32 => appending 0..16 bytes inside upper 16 bytes.
- if (HH_UNLIKELY(buffer_valid & 16)) {
- const V4x32U suffix = Load0To16<>(from, size_mod32, size);
- const V4x32U packetL = Load<V4x32U>(buffer_u32);
- const V4x32U bufferH = Load<V4x32U>(buffer_u32 + V4x32U::N);
- const V4x32U packetH = Concatenate(bufferH, buffer_valid - 16, suffix);
- Update(packetH, packetL);
- } else { // Appending 0..32 bytes starting at offset 0..15.
- const V4x32U bufferL = Load<V4x32U>(buffer_u32);
- const V4x32U suffixL = Load0To16<>(from, size_mod32, size);
- const V4x32U packetL = Concatenate(bufferL, buffer_valid, suffixL);
- const size_t offsetH = sizeof(V4x32U) - buffer_valid;
- V4x32U packetH = packetL - packetL;
- // Do we have enough input to start filling the upper 16 packet bytes?
- if (size_mod32 > offsetH) {
- const size_t sizeH = size_mod32 - offsetH;
- packetH = Load0To16<>(from + offsetH, sizeH, V4x32U(sizeH));
- }
-
- Update(packetH, packetL);
- }
- }
-
- private:
- static HH_INLINE V4x32U MaskedLoadInt(const char* from,
- const V4x32U& int_mask) {
- // No faults will be raised when reading n=0..3 ints from "from" provided
- // int_mask[n] = 0.
- const int* HH_RESTRICT int_from = reinterpret_cast<const int*>(from);
- return V4x32U(_mm_maskload_epi32(int_from, int_mask));
- }
-
- // Loads <= 16 bytes without accessing any byte outside [from, from + size).
- // from[i] is loaded into lane i; from[i >= size] is undefined.
- template <uint32_t kSizeOffset = 0, class Load3Policy = Load3::AllowNone>
- static HH_INLINE V4x32U Load0To16(const char* from, const size_t size_mod32,
- const V4x32U& size) {
- const char* remainder = from + (size_mod32 & ~3);
- const uint64_t last3 = Load3()(Load3Policy(), remainder, size_mod32 & 3);
- const V4x32U int_mask = IntMask<kSizeOffset>()(size);
- const V4x32U int_lanes = MaskedLoadInt(from, int_mask);
- return Insert4AboveMask(last3, int_mask, int_lanes);
- }
-
- static HH_INLINE V4x64U Rotate64By32(const V4x64U& v) {
- return V4x64U(_mm256_shuffle_epi32(v, _MM_SHUFFLE(2, 3, 0, 1)));
- }
-
- // Rotates 32-bit lanes by "count" bits.
- static HH_INLINE V4x64U Rotate32By(const V4x64U& v, const V8x32U& count) {
- // Use variable shifts because sll_epi32 has 4 cycle latency (presumably
- // to broadcast the shift count).
- const V4x64U shifted_left(_mm256_sllv_epi32(v, count));
- const V4x64U shifted_right(_mm256_srlv_epi32(v, V8x32U(32) - count));
- return shifted_left | shifted_right;
- }
-
- static HH_INLINE V4x64U Permute(const V4x64U& v) {
- // For complete mixing, we need to swap the upper and lower 128-bit halves;
- // we also swap all 32-bit halves. This is faster than extracti128 plus
- // inserti128 followed by Rotate64By32.
- const V4x64U indices(0x0000000200000003ull, 0x0000000000000001ull,
- 0x0000000600000007ull, 0x0000000400000005ull);
- return V4x64U(_mm256_permutevar8x32_epi32(v, indices));
- }
-
- static HH_INLINE V4x64U MulLow32(const V4x64U& a, const V4x64U& b) {
- return V4x64U(_mm256_mul_epu32(a, b));
- }
-
- static HH_INLINE V4x64U ZipperMerge(const V4x64U& v) {
- // Multiplication mixes/scrambles bytes 0-7 of the 64-bit result to
- // varying degrees. In descending order of goodness, bytes
- // 3 4 2 5 1 6 0 7 have quality 228 224 164 160 100 96 36 32.
- // As expected, the upper and lower bytes are much worse.
- // For each 64-bit lane, our objectives are:
- // 1) maximizing and equalizing total goodness across the four lanes.
- // 2) mixing with bytes from the neighboring lane (AVX-2 makes it difficult
- // to cross the 128-bit wall, but PermuteAndUpdate takes care of that);
- // 3) placing the worst bytes in the upper 32 bits because those will not
- // be used in the next 32x32 multiplication.
- const uint64_t hi = 0x070806090D0A040Bull;
- const uint64_t lo = 0x000F010E05020C03ull;
- return V4x64U(_mm256_shuffle_epi8(v, V4x64U(hi, lo, hi, lo)));
- }
-
- // Updates four hash lanes in parallel by injecting four 64-bit packets.
- HH_INLINE void Update(const V4x64U& packet) {
- v1 += packet;
- v1 += mul0;
- mul0 ^= MulLow32(v1, v0 >> 32);
- HH_COMPILER_FENCE;
- v0 += mul1;
- mul1 ^= MulLow32(v0, v1 >> 32);
- HH_COMPILER_FENCE;
- v0 += ZipperMerge(v1);
- v1 += ZipperMerge(v0);
- }
-
- HH_INLINE void Update(const V4x32U& packetH, const V4x32U& packetL) {
- const __m256i packetL256 = _mm256_castsi128_si256(packetL);
- Update(V4x64U(_mm256_inserti128_si256(packetL256, packetH, 1)));
- }
-
- // XORs a << 1 and a << 2 into *out after clearing the upper two bits of a.
- // Also does the same for the upper 128 bit lane "b". Bit shifts are only
- // possible on independent 64-bit lanes. We therefore insert the upper bits
- // of a[0] that were lost into a[1]. Thanks to D. Lemire for helpful comments!
- static HH_INLINE void XorByShift128Left12(const V4x64U& ba,
- V4x64U* HH_RESTRICT out) {
- const V4x64U zero = ba ^ ba;
- const V4x64U top_bits2 = ba >> (64 - 2);
- const V4x64U ones = ba == ba; // FF .. FF
- const V4x64U shifted1_unmasked = ba + ba; // (avoids needing port0)
- HH_COMPILER_FENCE;
-
- // Only the lower halves of top_bits1's 128 bit lanes will be used, so we
- // can compute it before clearing the upper two bits of ba.
- const V4x64U top_bits1 = ba >> (64 - 1);
- const V4x64U upper_8bytes(_mm256_slli_si256(ones, 8)); // F 0 F 0
- const V4x64U shifted2 = shifted1_unmasked + shifted1_unmasked;
- HH_COMPILER_FENCE;
-
- const V4x64U upper_bit_of_128 = upper_8bytes << 63; // 80..00 80..00
- const V4x64U new_low_bits2(_mm256_unpacklo_epi64(zero, top_bits2));
- *out ^= shifted2;
- HH_COMPILER_FENCE;
-
- // The result must be as if the upper two bits of the input had been clear,
- // otherwise we're no longer computing a reduction.
- const V4x64U shifted1 = AndNot(upper_bit_of_128, shifted1_unmasked);
- *out ^= new_low_bits2;
- HH_COMPILER_FENCE;
-
- const V4x64U new_low_bits1(_mm256_unpacklo_epi64(zero, top_bits1));
- *out ^= shifted1;
-
- *out ^= new_low_bits1;
- }
-
- // Modular reduction by the irreducible polynomial (x^128 + x^2 + x).
- // Input: two 256-bit numbers a3210 and b3210, interleaved in 2 vectors.
- // The upper and lower 128-bit halves are processed independently.
- static HH_INLINE V4x64U ModularReduction(const V4x64U& b32a32,
- const V4x64U& b10a10) {
- // See Lemire, https://arxiv.org/pdf/1503.03465v8.pdf.
- V4x64U out = b10a10;
- XorByShift128Left12(b32a32, &out);
- return out;
- }
-
- V4x64U v0;
- V4x64U v1;
- V4x64U mul0;
- V4x64U mul1;
-};
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HH_DISABLE_TARGET_SPECIFIC
-#endif // HIGHWAYHASH_HH_AVX2_H_
+// Copyright 2015-2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HH_AVX2_H_
+#define HIGHWAYHASH_HH_AVX2_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/hh_buffer.h"
+#include "highwayhash/hh_types.h"
+#include "highwayhash/load3.h"
+#include "highwayhash/vector128.h"
+#include "highwayhash/vector256.h"
+
+// For auto-dependency generation, we need to include all headers but not their
+// contents (otherwise compilation fails because -mavx2 is not specified).
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+
+namespace highwayhash {
+// See vector128.h for why this namespace is necessary; matching it here makes
+// it easier use the vector128 symbols, but requires textual inclusion.
+namespace HH_TARGET_NAME {
+
+class HHStateAVX2 {
+ public:
+ explicit HH_INLINE HHStateAVX2(const HHKey key_lanes) { Reset(key_lanes); }
+
+ HH_INLINE void Reset(const HHKey key_lanes) {
+ // "Nothing up my sleeve" numbers, concatenated hex digits of Pi from
+ // http://www.numberworld.org/digits/Pi/, retrieved Feb 22, 2016.
+ //
+ // We use this python code to generate the fourth number to have
+ // more even mixture of bits:
+ /*
+def x(a,b,c):
+ retval = 0
+ for i in range(64):
+ count = ((a >> i) & 1) + ((b >> i) & 1) + ((c >> i) & 1)
+ if (count <= 1):
+ retval |= 1 << i
+ return retval
+ */
+ const V4x64U init0(0x243f6a8885a308d3ull, 0x13198a2e03707344ull,
+ 0xa4093822299f31d0ull, 0xdbe6d5d5fe4cce2full);
+ const V4x64U init1(0x452821e638d01377ull, 0xbe5466cf34e90c6cull,
+ 0xc0acf169b5f18a8cull, 0x3bd39e10cb0ef593ull);
+ const V4x64U key = LoadUnaligned<V4x64U>(key_lanes);
+ v0 = key ^ init0;
+ v1 = Rotate64By32(key) ^ init1;
+ mul0 = init0;
+ mul1 = init1;
+ }
+
+ HH_INLINE void Update(const HHPacket& packet_bytes) {
+ const uint64_t* HH_RESTRICT packet =
+ reinterpret_cast<const uint64_t * HH_RESTRICT>(packet_bytes);
+ Update(LoadUnaligned<V4x64U>(packet));
+ }
+
+ HH_INLINE void UpdateRemainder(const char* bytes, const size_t size_mod32) {
+ // 'Length padding' differentiates zero-valued inputs that have the same
+ // size/32. mod32 is sufficient because each Update behaves as if a
+ // counter were injected, because the state is large and mixed thoroughly.
+ const V8x32U size256(
+ _mm256_broadcastd_epi32(_mm_cvtsi64_si128(size_mod32)));
+ // Equivalent to storing size_mod32 in packet.
+ v0 += V4x64U(size256);
+ // Boosts the avalanche effect of mod32.
+ v1 = Rotate32By(v1, size256);
+
+ const char* remainder = bytes + (size_mod32 & ~3);
+ const size_t size_mod4 = size_mod32 & 3;
+
+ const V4x32U size(_mm256_castsi256_si128(size256));
+
+ // (Branching is faster than a single _mm256_maskload_epi32.)
+ if (HH_UNLIKELY(size_mod32 & 16)) { // 16..31 bytes left
+ const V4x32U packetL =
+ LoadUnaligned<V4x32U>(reinterpret_cast<const uint32_t*>(bytes));
+
+ const V4x32U int_mask = IntMask<16>()(size);
+ const V4x32U int_lanes = MaskedLoadInt(bytes + 16, int_mask);
+ const uint32_t last4 =
+ Load3()(Load3::AllowReadBeforeAndReturn(), remainder, size_mod4);
+
+ // The upper four bytes of packetH are zero, so insert there.
+ const V4x32U packetH(_mm_insert_epi32(int_lanes, last4, 3));
+ Update(packetH, packetL);
+ } else { // size_mod32 < 16
+ const V4x32U int_mask = IntMask<0>()(size);
+ const V4x32U packetL = MaskedLoadInt(bytes, int_mask);
+ const uint64_t last3 =
+ Load3()(Load3::AllowUnordered(), remainder, size_mod4);
+
+ // Rather than insert into packetL[3], it is faster to initialize
+ // the otherwise empty packetH.
+ const V4x32U packetH(_mm_cvtsi64_si128(last3));
+ Update(packetH, packetL);
+ }
+ }
+
+ HH_INLINE void Finalize(HHResult64* HH_RESTRICT result) {
+ // Mix together all lanes. It is slightly better to permute v0 than v1;
+ // it will be added to v1.
+ Update(Permute(v0));
+ Update(Permute(v0));
+ Update(Permute(v0));
+ Update(Permute(v0));
+
+ const V2x64U sum0(_mm256_castsi256_si128(v0 + mul0));
+ const V2x64U sum1(_mm256_castsi256_si128(v1 + mul1));
+ const V2x64U hash = sum0 + sum1;
+ // Each lane is sufficiently mixed, so just truncate to 64 bits.
+ _mm_storel_epi64(reinterpret_cast<__m128i*>(result), hash);
+ }
+
+ HH_INLINE void Finalize(HHResult128* HH_RESTRICT result) {
+ Update(Permute(v0));
+ Update(Permute(v0));
+ Update(Permute(v0));
+ Update(Permute(v0));
+
+ const V2x64U sum0(_mm256_castsi256_si128(v0 + mul0));
+ const V2x64U sum1(_mm256_extracti128_si256(v1 + mul1, 1));
+ const V2x64U hash = sum0 + sum1;
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(result), hash);
+ }
+
+ HH_INLINE void Finalize(HHResult256* HH_RESTRICT result) {
+ Update(Permute(v0));
+ Update(Permute(v0));
+ Update(Permute(v0));
+ Update(Permute(v0));
+
+ const V4x64U sum0 = v0 + mul0;
+ const V4x64U sum1 = v1 + mul1;
+ const V4x64U hash = ModularReduction(sum1, sum0);
+ StoreUnaligned(hash, &(*result)[0]);
+ }
+
+ // "buffer" must be 32-byte aligned.
+ static HH_INLINE void ZeroInitialize(char* HH_RESTRICT buffer) {
+ const __m256i zero = _mm256_setzero_si256();
+ _mm256_store_si256(reinterpret_cast<__m256i*>(buffer), zero);
+ }
+
+ // "buffer" must be 32-byte aligned.
+ static HH_INLINE void CopyPartial(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ char* HH_RESTRICT buffer) {
+ const V4x32U size(size_mod32);
+ const uint32_t* const HH_RESTRICT from_u32 =
+ reinterpret_cast<const uint32_t * HH_RESTRICT>(from);
+ uint32_t* const HH_RESTRICT buffer_u32 =
+ reinterpret_cast<uint32_t * HH_RESTRICT>(buffer);
+ if (HH_UNLIKELY(size_mod32 & 16)) { // Copying 16..31 bytes
+ const V4x32U inL = LoadUnaligned<V4x32U>(from_u32);
+ Store(inL, buffer_u32);
+ const V4x32U inH = Load0To16<16, Load3::AllowReadBefore>(
+ from + 16, size_mod32 - 16, size);
+ Store(inH, buffer_u32 + V4x32U::N);
+ } else { // Copying 0..15 bytes
+ const V4x32U inL = Load0To16<>(from, size_mod32, size);
+ Store(inL, buffer_u32);
+ // No need to change upper 16 bytes of buffer.
+ }
+ }
+
+ // "buffer" must be 32-byte aligned.
+ static HH_INLINE void AppendPartial(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ char* HH_RESTRICT buffer,
+ const size_t buffer_valid) {
+ const V4x32U size(size_mod32);
+ uint32_t* const HH_RESTRICT buffer_u32 =
+ reinterpret_cast<uint32_t * HH_RESTRICT>(buffer);
+ // buffer_valid + size <= 32 => appending 0..16 bytes inside upper 16 bytes.
+ if (HH_UNLIKELY(buffer_valid & 16)) {
+ const V4x32U suffix = Load0To16<>(from, size_mod32, size);
+ const V4x32U bufferH = Load<V4x32U>(buffer_u32 + V4x32U::N);
+ const V4x32U outH = Concatenate(bufferH, buffer_valid - 16, suffix);
+ Store(outH, buffer_u32 + V4x32U::N);
+ } else { // Appending 0..32 bytes starting at offset 0..15.
+ const V4x32U bufferL = Load<V4x32U>(buffer_u32);
+ const V4x32U suffixL = Load0To16<>(from, size_mod32, size);
+ const V4x32U outL = Concatenate(bufferL, buffer_valid, suffixL);
+ Store(outL, buffer_u32);
+ const size_t offsetH = sizeof(V4x32U) - buffer_valid;
+ // Do we have enough input to start filling the upper 16 buffer bytes?
+ if (size_mod32 > offsetH) {
+ const size_t sizeH = size_mod32 - offsetH;
+ const V4x32U outH = Load0To16<>(from + offsetH, sizeH, V4x32U(sizeH));
+ Store(outH, buffer_u32 + V4x32U::N);
+ }
+ }
+ }
+
+ // "buffer" must be 32-byte aligned.
+ HH_INLINE void AppendAndUpdate(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ const char* HH_RESTRICT buffer,
+ const size_t buffer_valid) {
+ const V4x32U size(size_mod32);
+ const uint32_t* const HH_RESTRICT buffer_u32 =
+ reinterpret_cast<const uint32_t * HH_RESTRICT>(buffer);
+ // buffer_valid + size <= 32 => appending 0..16 bytes inside upper 16 bytes.
+ if (HH_UNLIKELY(buffer_valid & 16)) {
+ const V4x32U suffix = Load0To16<>(from, size_mod32, size);
+ const V4x32U packetL = Load<V4x32U>(buffer_u32);
+ const V4x32U bufferH = Load<V4x32U>(buffer_u32 + V4x32U::N);
+ const V4x32U packetH = Concatenate(bufferH, buffer_valid - 16, suffix);
+ Update(packetH, packetL);
+ } else { // Appending 0..32 bytes starting at offset 0..15.
+ const V4x32U bufferL = Load<V4x32U>(buffer_u32);
+ const V4x32U suffixL = Load0To16<>(from, size_mod32, size);
+ const V4x32U packetL = Concatenate(bufferL, buffer_valid, suffixL);
+ const size_t offsetH = sizeof(V4x32U) - buffer_valid;
+ V4x32U packetH = packetL - packetL;
+ // Do we have enough input to start filling the upper 16 packet bytes?
+ if (size_mod32 > offsetH) {
+ const size_t sizeH = size_mod32 - offsetH;
+ packetH = Load0To16<>(from + offsetH, sizeH, V4x32U(sizeH));
+ }
+
+ Update(packetH, packetL);
+ }
+ }
+
+ private:
+ static HH_INLINE V4x32U MaskedLoadInt(const char* from,
+ const V4x32U& int_mask) {
+ // No faults will be raised when reading n=0..3 ints from "from" provided
+ // int_mask[n] = 0.
+ const int* HH_RESTRICT int_from = reinterpret_cast<const int*>(from);
+ return V4x32U(_mm_maskload_epi32(int_from, int_mask));
+ }
+
+ // Loads <= 16 bytes without accessing any byte outside [from, from + size).
+ // from[i] is loaded into lane i; from[i >= size] is undefined.
+ template <uint32_t kSizeOffset = 0, class Load3Policy = Load3::AllowNone>
+ static HH_INLINE V4x32U Load0To16(const char* from, const size_t size_mod32,
+ const V4x32U& size) {
+ const char* remainder = from + (size_mod32 & ~3);
+ const uint64_t last3 = Load3()(Load3Policy(), remainder, size_mod32 & 3);
+ const V4x32U int_mask = IntMask<kSizeOffset>()(size);
+ const V4x32U int_lanes = MaskedLoadInt(from, int_mask);
+ return Insert4AboveMask(last3, int_mask, int_lanes);
+ }
+
+ static HH_INLINE V4x64U Rotate64By32(const V4x64U& v) {
+ return V4x64U(_mm256_shuffle_epi32(v, _MM_SHUFFLE(2, 3, 0, 1)));
+ }
+
+ // Rotates 32-bit lanes by "count" bits.
+ static HH_INLINE V4x64U Rotate32By(const V4x64U& v, const V8x32U& count) {
+ // Use variable shifts because sll_epi32 has 4 cycle latency (presumably
+ // to broadcast the shift count).
+ const V4x64U shifted_left(_mm256_sllv_epi32(v, count));
+ const V4x64U shifted_right(_mm256_srlv_epi32(v, V8x32U(32) - count));
+ return shifted_left | shifted_right;
+ }
+
+ static HH_INLINE V4x64U Permute(const V4x64U& v) {
+ // For complete mixing, we need to swap the upper and lower 128-bit halves;
+ // we also swap all 32-bit halves. This is faster than extracti128 plus
+ // inserti128 followed by Rotate64By32.
+ const V4x64U indices(0x0000000200000003ull, 0x0000000000000001ull,
+ 0x0000000600000007ull, 0x0000000400000005ull);
+ return V4x64U(_mm256_permutevar8x32_epi32(v, indices));
+ }
+
+ static HH_INLINE V4x64U MulLow32(const V4x64U& a, const V4x64U& b) {
+ return V4x64U(_mm256_mul_epu32(a, b));
+ }
+
+ static HH_INLINE V4x64U ZipperMerge(const V4x64U& v) {
+ // Multiplication mixes/scrambles bytes 0-7 of the 64-bit result to
+ // varying degrees. In descending order of goodness, bytes
+ // 3 4 2 5 1 6 0 7 have quality 228 224 164 160 100 96 36 32.
+ // As expected, the upper and lower bytes are much worse.
+ // For each 64-bit lane, our objectives are:
+ // 1) maximizing and equalizing total goodness across the four lanes.
+ // 2) mixing with bytes from the neighboring lane (AVX-2 makes it difficult
+ // to cross the 128-bit wall, but PermuteAndUpdate takes care of that);
+ // 3) placing the worst bytes in the upper 32 bits because those will not
+ // be used in the next 32x32 multiplication.
+ const uint64_t hi = 0x070806090D0A040Bull;
+ const uint64_t lo = 0x000F010E05020C03ull;
+ return V4x64U(_mm256_shuffle_epi8(v, V4x64U(hi, lo, hi, lo)));
+ }
+
+ // Updates four hash lanes in parallel by injecting four 64-bit packets.
+ HH_INLINE void Update(const V4x64U& packet) {
+ v1 += packet;
+ v1 += mul0;
+ mul0 ^= MulLow32(v1, v0 >> 32);
+ HH_COMPILER_FENCE;
+ v0 += mul1;
+ mul1 ^= MulLow32(v0, v1 >> 32);
+ HH_COMPILER_FENCE;
+ v0 += ZipperMerge(v1);
+ v1 += ZipperMerge(v0);
+ }
+
+ HH_INLINE void Update(const V4x32U& packetH, const V4x32U& packetL) {
+ const __m256i packetL256 = _mm256_castsi128_si256(packetL);
+ Update(V4x64U(_mm256_inserti128_si256(packetL256, packetH, 1)));
+ }
+
+ // XORs a << 1 and a << 2 into *out after clearing the upper two bits of a.
+ // Also does the same for the upper 128 bit lane "b". Bit shifts are only
+ // possible on independent 64-bit lanes. We therefore insert the upper bits
+ // of a[0] that were lost into a[1]. Thanks to D. Lemire for helpful comments!
+ static HH_INLINE void XorByShift128Left12(const V4x64U& ba,
+ V4x64U* HH_RESTRICT out) {
+ const V4x64U zero = ba ^ ba;
+ const V4x64U top_bits2 = ba >> (64 - 2);
+ const V4x64U ones = ba == ba; // FF .. FF
+ const V4x64U shifted1_unmasked = ba + ba; // (avoids needing port0)
+ HH_COMPILER_FENCE;
+
+ // Only the lower halves of top_bits1's 128 bit lanes will be used, so we
+ // can compute it before clearing the upper two bits of ba.
+ const V4x64U top_bits1 = ba >> (64 - 1);
+ const V4x64U upper_8bytes(_mm256_slli_si256(ones, 8)); // F 0 F 0
+ const V4x64U shifted2 = shifted1_unmasked + shifted1_unmasked;
+ HH_COMPILER_FENCE;
+
+ const V4x64U upper_bit_of_128 = upper_8bytes << 63; // 80..00 80..00
+ const V4x64U new_low_bits2(_mm256_unpacklo_epi64(zero, top_bits2));
+ *out ^= shifted2;
+ HH_COMPILER_FENCE;
+
+ // The result must be as if the upper two bits of the input had been clear,
+ // otherwise we're no longer computing a reduction.
+ const V4x64U shifted1 = AndNot(upper_bit_of_128, shifted1_unmasked);
+ *out ^= new_low_bits2;
+ HH_COMPILER_FENCE;
+
+ const V4x64U new_low_bits1(_mm256_unpacklo_epi64(zero, top_bits1));
+ *out ^= shifted1;
+
+ *out ^= new_low_bits1;
+ }
+
+ // Modular reduction by the irreducible polynomial (x^128 + x^2 + x).
+ // Input: two 256-bit numbers a3210 and b3210, interleaved in 2 vectors.
+ // The upper and lower 128-bit halves are processed independently.
+ static HH_INLINE V4x64U ModularReduction(const V4x64U& b32a32,
+ const V4x64U& b10a10) {
+ // See Lemire, https://arxiv.org/pdf/1503.03465v8.pdf.
+ V4x64U out = b10a10;
+ XorByShift128Left12(b32a32, &out);
+ return out;
+ }
+
+ V4x64U v0;
+ V4x64U v1;
+ V4x64U mul0;
+ V4x64U mul1;
+};
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HH_DISABLE_TARGET_SPECIFIC
+#endif // HIGHWAYHASH_HH_AVX2_H_
diff --git a/contrib/libs/highwayhash/highwayhash/hh_buffer.h b/contrib/libs/highwayhash/highwayhash/hh_buffer.h
index 83b0fa6b8e..5b1c83f95b 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_buffer.h
+++ b/contrib/libs/highwayhash/highwayhash/hh_buffer.h
@@ -1,103 +1,103 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HH_BUFFER_H_
-#define HIGHWAYHASH_HH_BUFFER_H_
-
-// Helper functions used by hh_avx2 and hh_sse41.
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/vector128.h"
-
-// For auto-dependency generation, we need to include all headers but not their
-// contents (otherwise compilation fails because -msse4.1 is not specified).
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-
-namespace highwayhash {
-// To prevent ODR violations when including this from multiple translation
-// units (TU) that are compiled with different flags, the contents must reside
-// in a namespace whose name is unique to the TU. NOTE: this behavior is
-// incompatible with precompiled modules and requires textual inclusion instead.
-namespace HH_TARGET_NAME {
-
-template <uint32_t kSizeOffset>
-struct IntMask {}; // primary template
-
-template <>
-struct IntMask<0> {
- // Returns 32-bit lanes : ~0U if that lane can be loaded given "size" bytes.
- // Typical case: size = 0..16, nothing deducted.
- HH_INLINE V4x32U operator()(const V4x32U& size) const {
- // Lane n is valid if size >= (n + 1) * 4; subtract one because we only have
- // greater-than comparisons and don't want a negated mask.
- return V4x32U(_mm_cmpgt_epi32(size, V4x32U(15, 11, 7, 3)));
- }
-};
-
-template <>
-struct IntMask<16> {
- // "size" is 16..31; this is for loading the upper half of a packet, so
- // effectively deduct 16 from size by changing the comparands.
- HH_INLINE V4x32U operator()(const V4x32U& size) const {
- return V4x32U(_mm_cmpgt_epi32(size, V4x32U(31, 27, 23, 19)));
- }
-};
-
-// Inserts "bytes4" into "prev" at the lowest i such that mask[i] = 0.
-// Assumes prev[j] == 0 if mask[j] = 0.
-HH_INLINE V4x32U Insert4AboveMask(const uint32_t bytes4, const V4x32U& mask,
- const V4x32U& prev) {
- // There is no 128-bit shift by a variable count. Using shuffle_epi8 with a
- // control mask requires a table lookup. We know the shift count is a
- // multiple of 4 bytes, so we can broadcastd_epi32 and clear all lanes except
- // those where mask != 0. This works because any upper output lanes need not
- // be zero.
- return prev | AndNot(mask, V4x32U(bytes4));
-}
-
-// Shifts "suffix" left by "prefix_len" = 0..15 bytes, clears upper bytes of
-// "prefix", and returns the merged/concatenated bytes.
-HH_INLINE V4x32U Concatenate(const V4x32U& prefix, const size_t prefix_len,
- const V4x32U& suffix) {
- static const uint64_t table[V16x8U::N][V2x64U::N] = {
- {0x0706050403020100ull, 0x0F0E0D0C0B0A0908ull},
- {0x06050403020100FFull, 0x0E0D0C0B0A090807ull},
- {0x050403020100FFFFull, 0x0D0C0B0A09080706ull},
- {0x0403020100FFFFFFull, 0x0C0B0A0908070605ull},
- {0x03020100FFFFFFFFull, 0x0B0A090807060504ull},
- {0x020100FFFFFFFFFFull, 0x0A09080706050403ull},
- {0x0100FFFFFFFFFFFFull, 0x0908070605040302ull},
- {0x00FFFFFFFFFFFFFFull, 0x0807060504030201ull},
- {0xFFFFFFFFFFFFFFFFull, 0x0706050403020100ull},
- {0xFFFFFFFFFFFFFFFFull, 0x06050403020100FFull},
- {0xFFFFFFFFFFFFFFFFull, 0x050403020100FFFFull},
- {0xFFFFFFFFFFFFFFFFull, 0x0403020100FFFFFFull},
- {0xFFFFFFFFFFFFFFFFull, 0x03020100FFFFFFFFull},
- {0xFFFFFFFFFFFFFFFFull, 0x020100FFFFFFFFFFull},
- {0xFFFFFFFFFFFFFFFFull, 0x0100FFFFFFFFFFFFull},
- {0xFFFFFFFFFFFFFFFFull, 0x00FFFFFFFFFFFFFFull}};
- const V2x64U control = Load<V2x64U>(&table[prefix_len][0]);
- const V2x64U shifted_suffix(_mm_shuffle_epi8(suffix, control));
- return V4x32U(_mm_blendv_epi8(shifted_suffix, prefix, control));
-}
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HH_DISABLE_TARGET_SPECIFIC
-#endif // HIGHWAYHASH_HH_BUFFER_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HH_BUFFER_H_
+#define HIGHWAYHASH_HH_BUFFER_H_
+
+// Helper functions used by hh_avx2 and hh_sse41.
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/vector128.h"
+
+// For auto-dependency generation, we need to include all headers but not their
+// contents (otherwise compilation fails because -msse4.1 is not specified).
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+
+namespace highwayhash {
+// To prevent ODR violations when including this from multiple translation
+// units (TU) that are compiled with different flags, the contents must reside
+// in a namespace whose name is unique to the TU. NOTE: this behavior is
+// incompatible with precompiled modules and requires textual inclusion instead.
+namespace HH_TARGET_NAME {
+
+template <uint32_t kSizeOffset>
+struct IntMask {}; // primary template
+
+template <>
+struct IntMask<0> {
+ // Returns 32-bit lanes : ~0U if that lane can be loaded given "size" bytes.
+ // Typical case: size = 0..16, nothing deducted.
+ HH_INLINE V4x32U operator()(const V4x32U& size) const {
+ // Lane n is valid if size >= (n + 1) * 4; subtract one because we only have
+ // greater-than comparisons and don't want a negated mask.
+ return V4x32U(_mm_cmpgt_epi32(size, V4x32U(15, 11, 7, 3)));
+ }
+};
+
+template <>
+struct IntMask<16> {
+ // "size" is 16..31; this is for loading the upper half of a packet, so
+ // effectively deduct 16 from size by changing the comparands.
+ HH_INLINE V4x32U operator()(const V4x32U& size) const {
+ return V4x32U(_mm_cmpgt_epi32(size, V4x32U(31, 27, 23, 19)));
+ }
+};
+
+// Inserts "bytes4" into "prev" at the lowest i such that mask[i] = 0.
+// Assumes prev[j] == 0 if mask[j] = 0.
+HH_INLINE V4x32U Insert4AboveMask(const uint32_t bytes4, const V4x32U& mask,
+ const V4x32U& prev) {
+ // There is no 128-bit shift by a variable count. Using shuffle_epi8 with a
+ // control mask requires a table lookup. We know the shift count is a
+ // multiple of 4 bytes, so we can broadcastd_epi32 and clear all lanes except
+ // those where mask != 0. This works because any upper output lanes need not
+ // be zero.
+ return prev | AndNot(mask, V4x32U(bytes4));
+}
+
+// Shifts "suffix" left by "prefix_len" = 0..15 bytes, clears upper bytes of
+// "prefix", and returns the merged/concatenated bytes.
+HH_INLINE V4x32U Concatenate(const V4x32U& prefix, const size_t prefix_len,
+ const V4x32U& suffix) {
+ static const uint64_t table[V16x8U::N][V2x64U::N] = {
+ {0x0706050403020100ull, 0x0F0E0D0C0B0A0908ull},
+ {0x06050403020100FFull, 0x0E0D0C0B0A090807ull},
+ {0x050403020100FFFFull, 0x0D0C0B0A09080706ull},
+ {0x0403020100FFFFFFull, 0x0C0B0A0908070605ull},
+ {0x03020100FFFFFFFFull, 0x0B0A090807060504ull},
+ {0x020100FFFFFFFFFFull, 0x0A09080706050403ull},
+ {0x0100FFFFFFFFFFFFull, 0x0908070605040302ull},
+ {0x00FFFFFFFFFFFFFFull, 0x0807060504030201ull},
+ {0xFFFFFFFFFFFFFFFFull, 0x0706050403020100ull},
+ {0xFFFFFFFFFFFFFFFFull, 0x06050403020100FFull},
+ {0xFFFFFFFFFFFFFFFFull, 0x050403020100FFFFull},
+ {0xFFFFFFFFFFFFFFFFull, 0x0403020100FFFFFFull},
+ {0xFFFFFFFFFFFFFFFFull, 0x03020100FFFFFFFFull},
+ {0xFFFFFFFFFFFFFFFFull, 0x020100FFFFFFFFFFull},
+ {0xFFFFFFFFFFFFFFFFull, 0x0100FFFFFFFFFFFFull},
+ {0xFFFFFFFFFFFFFFFFull, 0x00FFFFFFFFFFFFFFull}};
+ const V2x64U control = Load<V2x64U>(&table[prefix_len][0]);
+ const V2x64U shifted_suffix(_mm_shuffle_epi8(suffix, control));
+ return V4x32U(_mm_blendv_epi8(shifted_suffix, prefix, control));
+}
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HH_DISABLE_TARGET_SPECIFIC
+#endif // HIGHWAYHASH_HH_BUFFER_H_
diff --git a/contrib/libs/highwayhash/highwayhash/hh_portable.cc b/contrib/libs/highwayhash/highwayhash/hh_portable.cc
index 1c8072aebe..3e0de9ed9c 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_portable.cc
+++ b/contrib/libs/highwayhash/highwayhash/hh_portable.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME Portable
-#include "highwayhash/highwayhash_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME Portable
+#include "highwayhash/highwayhash_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/hh_portable.h b/contrib/libs/highwayhash/highwayhash/hh_portable.h
index 150ecdee7c..11284deae8 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_portable.h
+++ b/contrib/libs/highwayhash/highwayhash/hh_portable.h
@@ -1,301 +1,301 @@
-// Copyright 2015-2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HH_PORTABLE_H_
-#define HIGHWAYHASH_HH_PORTABLE_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/endianess.h"
-#include "highwayhash/hh_types.h"
-#include "highwayhash/load3.h"
-
-namespace highwayhash {
-// See vector128.h for why this namespace is necessary; we match it here for
-// consistency. As a result, this header requires textual inclusion.
-namespace HH_TARGET_NAME {
-
-class HHStatePortable {
- public:
- static const int kNumLanes = 4;
- using Lanes = uint64_t[kNumLanes];
-
- explicit HH_INLINE HHStatePortable(const HHKey keys) { Reset(keys); }
-
- HH_INLINE void Reset(const HHKey keys) {
- static const Lanes init0 = {0xdbe6d5d5fe4cce2full, 0xa4093822299f31d0ull,
- 0x13198a2e03707344ull, 0x243f6a8885a308d3ull};
- static const Lanes init1 = {0x3bd39e10cb0ef593ull, 0xc0acf169b5f18a8cull,
- 0xbe5466cf34e90c6cull, 0x452821e638d01377ull};
- Lanes rotated_keys;
- Rotate64By32(keys, &rotated_keys);
- Copy(init0, &mul0);
- Copy(init1, &mul1);
- Xor(init0, keys, &v0);
- Xor(init1, rotated_keys, &v1);
- }
-
- HH_INLINE void Update(const HHPacket& packet) {
- Lanes packet_lanes;
- CopyPartial(&packet[0], sizeof(HHPacket),
- reinterpret_cast<char*>(&packet_lanes));
- for (int lane = 0; lane < kNumLanes; ++lane) {
- packet_lanes[lane] = host_from_le64(packet_lanes[lane]);
- }
- Update(packet_lanes);
- }
-
- HH_INLINE void UpdateRemainder(const char* bytes, const size_t size_mod32) {
- // 'Length padding' differentiates zero-valued inputs that have the same
- // size/32. mod32 is sufficient because each Update behaves as if a
- // counter were injected, because the state is large and mixed thoroughly.
- const uint64_t mod32_pair = (size_mod32 << 32) + size_mod32;
- for (int lane = 0; lane < kNumLanes; ++lane) {
- v0[lane] += mod32_pair;
- }
- Rotate32By(reinterpret_cast<uint32_t*>(&v1), size_mod32);
-
- const size_t size_mod4 = size_mod32 & 3;
- const char* remainder = bytes + (size_mod32 & ~3);
-
- HHPacket packet HH_ALIGNAS(32) = {0};
- CopyPartial(bytes, remainder - bytes, &packet[0]);
-
- if (size_mod32 & 16) { // 16..31 bytes left
- // Read the last 0..3 bytes and previous 1..4 into the upper bits.
- // Insert into the upper four bytes of packet, which are zero.
- uint32_t last4 =
- Load3()(Load3::AllowReadBeforeAndReturn(), remainder, size_mod4);
- CopyPartial(reinterpret_cast<const char*>(&last4), 4, &packet[28]);
- } else { // size_mod32 < 16
- uint64_t last4 = Load3()(Load3::AllowUnordered(), remainder, size_mod4);
-
- // Rather than insert at packet + 28, it is faster to initialize
- // the otherwise empty packet + 16 with up to 64 bits of padding.
- CopyPartial(reinterpret_cast<const char*>(&last4), sizeof(last4),
- &packet[16]);
- }
- Update(packet);
- }
-
- HH_INLINE void Finalize(HHResult64* HH_RESTRICT result) {
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
-
- *result = v0[0] + v1[0] + mul0[0] + mul1[0];
- }
-
- HH_INLINE void Finalize(HHResult128* HH_RESTRICT result) {
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
-
- (*result)[0] = v0[0] + mul0[0] + v1[2] + mul1[2];
- (*result)[1] = v0[1] + mul0[1] + v1[3] + mul1[3];
- }
-
- HH_INLINE void Finalize(HHResult256* HH_RESTRICT result) {
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
-
- ModularReduction(v1[1] + mul1[1], v1[0] + mul1[0], v0[1] + mul0[1],
- v0[0] + mul0[0], &(*result)[1], &(*result)[0]);
- ModularReduction(v1[3] + mul1[3], v1[2] + mul1[2], v0[3] + mul0[3],
- v0[2] + mul0[2], &(*result)[3], &(*result)[2]);
- }
-
- static HH_INLINE void ZeroInitialize(char* HH_RESTRICT buffer) {
- for (size_t i = 0; i < sizeof(HHPacket); ++i) {
- buffer[i] = 0;
- }
- }
-
- static HH_INLINE void CopyPartial(const char* HH_RESTRICT from,
- const size_t size_mod32,
- char* HH_RESTRICT buffer) {
- for (size_t i = 0; i < size_mod32; ++i) {
- buffer[i] = from[i];
- }
- }
-
- static HH_INLINE void AppendPartial(const char* HH_RESTRICT from,
- const size_t size_mod32,
- char* HH_RESTRICT buffer,
- const size_t buffer_valid) {
- for (size_t i = 0; i < size_mod32; ++i) {
- buffer[buffer_valid + i] = from[i];
- }
- }
-
- HH_INLINE void AppendAndUpdate(const char* HH_RESTRICT from,
- const size_t size_mod32,
- const char* HH_RESTRICT buffer,
- const size_t buffer_valid) {
- HHPacket tmp HH_ALIGNAS(32);
- for (size_t i = 0; i < buffer_valid; ++i) {
- tmp[i] = buffer[i];
- }
- for (size_t i = 0; i < size_mod32; ++i) {
- tmp[buffer_valid + i] = from[i];
- }
- Update(tmp);
- }
-
- private:
- static HH_INLINE void Copy(const Lanes& source, Lanes* HH_RESTRICT dest) {
- for (int lane = 0; lane < kNumLanes; ++lane) {
- (*dest)[lane] = source[lane];
- }
- }
-
- static HH_INLINE void Add(const Lanes& source, Lanes* HH_RESTRICT dest) {
- for (int lane = 0; lane < kNumLanes; ++lane) {
- (*dest)[lane] += source[lane];
- }
- }
-
- template <typename LanesOrPointer>
- static HH_INLINE void Xor(const Lanes& op1, const LanesOrPointer& op2,
- Lanes* HH_RESTRICT dest) {
- for (int lane = 0; lane < kNumLanes; ++lane) {
- (*dest)[lane] = op1[lane] ^ op2[lane];
- }
- }
-
-// Clears all bits except one byte at the given offset.
-#define MASK(v, bytes) ((v) & (0xFFull << ((bytes)*8)))
-
- // 16-byte permutation; shifting is about 10% faster than byte loads.
- // Adds zipper-merge result to add*.
- static HH_INLINE void ZipperMergeAndAdd(const uint64_t v1, const uint64_t v0,
- uint64_t* HH_RESTRICT add1,
- uint64_t* HH_RESTRICT add0) {
- *add0 += ((MASK(v0, 3) + MASK(v1, 4)) >> 24) +
- ((MASK(v0, 5) + MASK(v1, 6)) >> 16) + MASK(v0, 2) +
- (MASK(v0, 1) << 32) + (MASK(v1, 7) >> 8) + (v0 << 56);
-
- *add1 += ((MASK(v1, 3) + MASK(v0, 4)) >> 24) + MASK(v1, 2) +
- (MASK(v1, 5) >> 16) + (MASK(v1, 1) << 24) + (MASK(v0, 6) >> 8) +
- (MASK(v1, 0) << 48) + MASK(v0, 7);
- }
-
-#undef MASK
-
- // For inputs that are already in native byte order (e.g. PermuteAndAdd)
- HH_INLINE void Update(const Lanes& packet_lanes) {
- Add(packet_lanes, &v1);
- Add(mul0, &v1);
-
- // (Loop is faster than unrolling)
- for (int lane = 0; lane < kNumLanes; ++lane) {
- const uint32_t v1_32 = static_cast<uint32_t>(v1[lane]);
- mul0[lane] ^= v1_32 * (v0[lane] >> 32);
- v0[lane] += mul1[lane];
- const uint32_t v0_32 = static_cast<uint32_t>(v0[lane]);
- mul1[lane] ^= v0_32 * (v1[lane] >> 32);
- }
-
- ZipperMergeAndAdd(v1[1], v1[0], &v0[1], &v0[0]);
- ZipperMergeAndAdd(v1[3], v1[2], &v0[3], &v0[2]);
-
- ZipperMergeAndAdd(v0[1], v0[0], &v1[1], &v1[0]);
- ZipperMergeAndAdd(v0[3], v0[2], &v1[3], &v1[2]);
- }
-
- static HH_INLINE uint64_t Rotate64By32(const uint64_t x) {
- return (x >> 32) | (x << 32);
- }
-
- template <typename LanesOrPointer>
- static HH_INLINE void Rotate64By32(const LanesOrPointer& v,
- Lanes* HH_RESTRICT rotated) {
- for (int i = 0; i < kNumLanes; ++i) {
- (*rotated)[i] = Rotate64By32(v[i]);
- }
- }
-
- static HH_INLINE void Rotate32By(uint32_t* halves, const uint64_t count) {
- for (int i = 0; i < 2 * kNumLanes; ++i) {
- const uint32_t x = halves[i];
- halves[i] = (x << count) | (x >> (32 - count));
- }
- }
-
- static HH_INLINE void Permute(const Lanes& v, Lanes* HH_RESTRICT permuted) {
- (*permuted)[0] = Rotate64By32(v[2]);
- (*permuted)[1] = Rotate64By32(v[3]);
- (*permuted)[2] = Rotate64By32(v[0]);
- (*permuted)[3] = Rotate64By32(v[1]);
- }
-
- HH_INLINE void PermuteAndUpdate() {
- Lanes permuted;
- Permute(v0, &permuted);
- Update(permuted);
- }
-
- // Computes a << kBits for 128-bit a = (a1, a0).
- // Bit shifts are only possible on independent 64-bit lanes. We therefore
- // insert the upper bits of a0 that were lost into a1. This is slightly
- // shorter than Lemire's (a << 1) | (((a >> 8) << 1) << 8) approach.
- template <int kBits>
- static HH_INLINE void Shift128Left(uint64_t* HH_RESTRICT a1,
- uint64_t* HH_RESTRICT a0) {
- const uint64_t shifted1 = (*a1) << kBits;
- const uint64_t top_bits = (*a0) >> (64 - kBits);
- *a0 <<= kBits;
- *a1 = shifted1 | top_bits;
- }
-
- // Modular reduction by the irreducible polynomial (x^128 + x^2 + x).
- // Input: a 256-bit number a3210.
- static HH_INLINE void ModularReduction(const uint64_t a3_unmasked,
- const uint64_t a2, const uint64_t a1,
- const uint64_t a0,
- uint64_t* HH_RESTRICT m1,
- uint64_t* HH_RESTRICT m0) {
- // The upper two bits must be clear, otherwise a3 << 2 would lose bits,
- // in which case we're no longer computing a reduction.
- const uint64_t a3 = a3_unmasked & 0x3FFFFFFFFFFFFFFFull;
- // See Lemire, https://arxiv.org/pdf/1503.03465v8.pdf.
- uint64_t a3_shl1 = a3;
- uint64_t a2_shl1 = a2;
- uint64_t a3_shl2 = a3;
- uint64_t a2_shl2 = a2;
- Shift128Left<1>(&a3_shl1, &a2_shl1);
- Shift128Left<2>(&a3_shl2, &a2_shl2);
- *m1 = a1 ^ a3_shl1 ^ a3_shl2;
- *m0 = a0 ^ a2_shl1 ^ a2_shl2;
- }
-
- Lanes v0;
- Lanes v1;
- Lanes mul0;
- Lanes mul1;
-};
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_HH_PORTABLE_H_
+// Copyright 2015-2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HH_PORTABLE_H_
+#define HIGHWAYHASH_HH_PORTABLE_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/endianess.h"
+#include "highwayhash/hh_types.h"
+#include "highwayhash/load3.h"
+
+namespace highwayhash {
+// See vector128.h for why this namespace is necessary; we match it here for
+// consistency. As a result, this header requires textual inclusion.
+namespace HH_TARGET_NAME {
+
+class HHStatePortable {
+ public:
+ static const int kNumLanes = 4;
+ using Lanes = uint64_t[kNumLanes];
+
+ explicit HH_INLINE HHStatePortable(const HHKey keys) { Reset(keys); }
+
+ HH_INLINE void Reset(const HHKey keys) {
+ static const Lanes init0 = {0xdbe6d5d5fe4cce2full, 0xa4093822299f31d0ull,
+ 0x13198a2e03707344ull, 0x243f6a8885a308d3ull};
+ static const Lanes init1 = {0x3bd39e10cb0ef593ull, 0xc0acf169b5f18a8cull,
+ 0xbe5466cf34e90c6cull, 0x452821e638d01377ull};
+ Lanes rotated_keys;
+ Rotate64By32(keys, &rotated_keys);
+ Copy(init0, &mul0);
+ Copy(init1, &mul1);
+ Xor(init0, keys, &v0);
+ Xor(init1, rotated_keys, &v1);
+ }
+
+ HH_INLINE void Update(const HHPacket& packet) {
+ Lanes packet_lanes;
+ CopyPartial(&packet[0], sizeof(HHPacket),
+ reinterpret_cast<char*>(&packet_lanes));
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ packet_lanes[lane] = host_from_le64(packet_lanes[lane]);
+ }
+ Update(packet_lanes);
+ }
+
+ HH_INLINE void UpdateRemainder(const char* bytes, const size_t size_mod32) {
+ // 'Length padding' differentiates zero-valued inputs that have the same
+ // size/32. mod32 is sufficient because each Update behaves as if a
+ // counter were injected, because the state is large and mixed thoroughly.
+ const uint64_t mod32_pair = (size_mod32 << 32) + size_mod32;
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ v0[lane] += mod32_pair;
+ }
+ Rotate32By(reinterpret_cast<uint32_t*>(&v1), size_mod32);
+
+ const size_t size_mod4 = size_mod32 & 3;
+ const char* remainder = bytes + (size_mod32 & ~3);
+
+ HHPacket packet HH_ALIGNAS(32) = {0};
+ CopyPartial(bytes, remainder - bytes, &packet[0]);
+
+ if (size_mod32 & 16) { // 16..31 bytes left
+ // Read the last 0..3 bytes and previous 1..4 into the upper bits.
+ // Insert into the upper four bytes of packet, which are zero.
+ uint32_t last4 =
+ Load3()(Load3::AllowReadBeforeAndReturn(), remainder, size_mod4);
+ CopyPartial(reinterpret_cast<const char*>(&last4), 4, &packet[28]);
+ } else { // size_mod32 < 16
+ uint64_t last4 = Load3()(Load3::AllowUnordered(), remainder, size_mod4);
+
+ // Rather than insert at packet + 28, it is faster to initialize
+ // the otherwise empty packet + 16 with up to 64 bits of padding.
+ CopyPartial(reinterpret_cast<const char*>(&last4), sizeof(last4),
+ &packet[16]);
+ }
+ Update(packet);
+ }
+
+ HH_INLINE void Finalize(HHResult64* HH_RESTRICT result) {
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+
+ *result = v0[0] + v1[0] + mul0[0] + mul1[0];
+ }
+
+ HH_INLINE void Finalize(HHResult128* HH_RESTRICT result) {
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+
+ (*result)[0] = v0[0] + mul0[0] + v1[2] + mul1[2];
+ (*result)[1] = v0[1] + mul0[1] + v1[3] + mul1[3];
+ }
+
+ HH_INLINE void Finalize(HHResult256* HH_RESTRICT result) {
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+
+ ModularReduction(v1[1] + mul1[1], v1[0] + mul1[0], v0[1] + mul0[1],
+ v0[0] + mul0[0], &(*result)[1], &(*result)[0]);
+ ModularReduction(v1[3] + mul1[3], v1[2] + mul1[2], v0[3] + mul0[3],
+ v0[2] + mul0[2], &(*result)[3], &(*result)[2]);
+ }
+
+ static HH_INLINE void ZeroInitialize(char* HH_RESTRICT buffer) {
+ for (size_t i = 0; i < sizeof(HHPacket); ++i) {
+ buffer[i] = 0;
+ }
+ }
+
+ static HH_INLINE void CopyPartial(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ char* HH_RESTRICT buffer) {
+ for (size_t i = 0; i < size_mod32; ++i) {
+ buffer[i] = from[i];
+ }
+ }
+
+ static HH_INLINE void AppendPartial(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ char* HH_RESTRICT buffer,
+ const size_t buffer_valid) {
+ for (size_t i = 0; i < size_mod32; ++i) {
+ buffer[buffer_valid + i] = from[i];
+ }
+ }
+
+ HH_INLINE void AppendAndUpdate(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ const char* HH_RESTRICT buffer,
+ const size_t buffer_valid) {
+ HHPacket tmp HH_ALIGNAS(32);
+ for (size_t i = 0; i < buffer_valid; ++i) {
+ tmp[i] = buffer[i];
+ }
+ for (size_t i = 0; i < size_mod32; ++i) {
+ tmp[buffer_valid + i] = from[i];
+ }
+ Update(tmp);
+ }
+
+ private:
+ static HH_INLINE void Copy(const Lanes& source, Lanes* HH_RESTRICT dest) {
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ (*dest)[lane] = source[lane];
+ }
+ }
+
+ static HH_INLINE void Add(const Lanes& source, Lanes* HH_RESTRICT dest) {
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ (*dest)[lane] += source[lane];
+ }
+ }
+
+ template <typename LanesOrPointer>
+ static HH_INLINE void Xor(const Lanes& op1, const LanesOrPointer& op2,
+ Lanes* HH_RESTRICT dest) {
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ (*dest)[lane] = op1[lane] ^ op2[lane];
+ }
+ }
+
+// Clears all bits except one byte at the given offset.
+#define MASK(v, bytes) ((v) & (0xFFull << ((bytes)*8)))
+
+ // 16-byte permutation; shifting is about 10% faster than byte loads.
+ // Adds zipper-merge result to add*.
+ static HH_INLINE void ZipperMergeAndAdd(const uint64_t v1, const uint64_t v0,
+ uint64_t* HH_RESTRICT add1,
+ uint64_t* HH_RESTRICT add0) {
+ *add0 += ((MASK(v0, 3) + MASK(v1, 4)) >> 24) +
+ ((MASK(v0, 5) + MASK(v1, 6)) >> 16) + MASK(v0, 2) +
+ (MASK(v0, 1) << 32) + (MASK(v1, 7) >> 8) + (v0 << 56);
+
+ *add1 += ((MASK(v1, 3) + MASK(v0, 4)) >> 24) + MASK(v1, 2) +
+ (MASK(v1, 5) >> 16) + (MASK(v1, 1) << 24) + (MASK(v0, 6) >> 8) +
+ (MASK(v1, 0) << 48) + MASK(v0, 7);
+ }
+
+#undef MASK
+
+ // For inputs that are already in native byte order (e.g. PermuteAndAdd)
+ HH_INLINE void Update(const Lanes& packet_lanes) {
+ Add(packet_lanes, &v1);
+ Add(mul0, &v1);
+
+ // (Loop is faster than unrolling)
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ const uint32_t v1_32 = static_cast<uint32_t>(v1[lane]);
+ mul0[lane] ^= v1_32 * (v0[lane] >> 32);
+ v0[lane] += mul1[lane];
+ const uint32_t v0_32 = static_cast<uint32_t>(v0[lane]);
+ mul1[lane] ^= v0_32 * (v1[lane] >> 32);
+ }
+
+ ZipperMergeAndAdd(v1[1], v1[0], &v0[1], &v0[0]);
+ ZipperMergeAndAdd(v1[3], v1[2], &v0[3], &v0[2]);
+
+ ZipperMergeAndAdd(v0[1], v0[0], &v1[1], &v1[0]);
+ ZipperMergeAndAdd(v0[3], v0[2], &v1[3], &v1[2]);
+ }
+
+ static HH_INLINE uint64_t Rotate64By32(const uint64_t x) {
+ return (x >> 32) | (x << 32);
+ }
+
+ template <typename LanesOrPointer>
+ static HH_INLINE void Rotate64By32(const LanesOrPointer& v,
+ Lanes* HH_RESTRICT rotated) {
+ for (int i = 0; i < kNumLanes; ++i) {
+ (*rotated)[i] = Rotate64By32(v[i]);
+ }
+ }
+
+ static HH_INLINE void Rotate32By(uint32_t* halves, const uint64_t count) {
+ for (int i = 0; i < 2 * kNumLanes; ++i) {
+ const uint32_t x = halves[i];
+ halves[i] = (x << count) | (x >> (32 - count));
+ }
+ }
+
+ static HH_INLINE void Permute(const Lanes& v, Lanes* HH_RESTRICT permuted) {
+ (*permuted)[0] = Rotate64By32(v[2]);
+ (*permuted)[1] = Rotate64By32(v[3]);
+ (*permuted)[2] = Rotate64By32(v[0]);
+ (*permuted)[3] = Rotate64By32(v[1]);
+ }
+
+ HH_INLINE void PermuteAndUpdate() {
+ Lanes permuted;
+ Permute(v0, &permuted);
+ Update(permuted);
+ }
+
+ // Computes a << kBits for 128-bit a = (a1, a0).
+ // Bit shifts are only possible on independent 64-bit lanes. We therefore
+ // insert the upper bits of a0 that were lost into a1. This is slightly
+ // shorter than Lemire's (a << 1) | (((a >> 8) << 1) << 8) approach.
+ template <int kBits>
+ static HH_INLINE void Shift128Left(uint64_t* HH_RESTRICT a1,
+ uint64_t* HH_RESTRICT a0) {
+ const uint64_t shifted1 = (*a1) << kBits;
+ const uint64_t top_bits = (*a0) >> (64 - kBits);
+ *a0 <<= kBits;
+ *a1 = shifted1 | top_bits;
+ }
+
+ // Modular reduction by the irreducible polynomial (x^128 + x^2 + x).
+ // Input: a 256-bit number a3210.
+ static HH_INLINE void ModularReduction(const uint64_t a3_unmasked,
+ const uint64_t a2, const uint64_t a1,
+ const uint64_t a0,
+ uint64_t* HH_RESTRICT m1,
+ uint64_t* HH_RESTRICT m0) {
+ // The upper two bits must be clear, otherwise a3 << 2 would lose bits,
+ // in which case we're no longer computing a reduction.
+ const uint64_t a3 = a3_unmasked & 0x3FFFFFFFFFFFFFFFull;
+ // See Lemire, https://arxiv.org/pdf/1503.03465v8.pdf.
+ uint64_t a3_shl1 = a3;
+ uint64_t a2_shl1 = a2;
+ uint64_t a3_shl2 = a3;
+ uint64_t a2_shl2 = a2;
+ Shift128Left<1>(&a3_shl1, &a2_shl1);
+ Shift128Left<2>(&a3_shl2, &a2_shl2);
+ *m1 = a1 ^ a3_shl1 ^ a3_shl2;
+ *m0 = a0 ^ a2_shl1 ^ a2_shl2;
+ }
+
+ Lanes v0;
+ Lanes v1;
+ Lanes mul0;
+ Lanes mul1;
+};
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_HH_PORTABLE_H_
diff --git a/contrib/libs/highwayhash/highwayhash/hh_sse41.cc b/contrib/libs/highwayhash/highwayhash/hh_sse41.cc
index 0bf13ab4f5..9d6a0b968f 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_sse41.cc
+++ b/contrib/libs/highwayhash/highwayhash/hh_sse41.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME SSE41
-#include "highwayhash/highwayhash_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME SSE41
+#include "highwayhash/highwayhash_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/hh_sse41.h b/contrib/libs/highwayhash/highwayhash/hh_sse41.h
index c4d56697e2..a2a86da9b6 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_sse41.h
+++ b/contrib/libs/highwayhash/highwayhash/hh_sse41.h
@@ -1,330 +1,330 @@
-// Copyright 2015-2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HH_SSE41_H_
-#define HIGHWAYHASH_HH_SSE41_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/hh_buffer.h"
-#include "highwayhash/hh_types.h"
-#include "highwayhash/load3.h"
-#include "highwayhash/vector128.h"
-
-// For auto-dependency generation, we need to include all headers but not their
-// contents (otherwise compilation fails because -msse4.1 is not specified).
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-
-namespace highwayhash {
-// See vector128.h for why this namespace is necessary; matching it here makes
-// it easier use the vector128 symbols, but requires textual inclusion.
-namespace HH_TARGET_NAME {
-
-// J-lanes tree hashing: see http://dx.doi.org/10.4236/jis.2014.53010
-// Uses pairs of SSE4.1 instructions to emulate the AVX-2 algorithm.
-class HHStateSSE41 {
- public:
- explicit HH_INLINE HHStateSSE41(const HHKey key) { Reset(key); }
-
- HH_INLINE void Reset(const HHKey key) {
- // "Nothing up my sleeve numbers"; see HHStateTAVX2.
- const V2x64U init0L(0xa4093822299f31d0ull, 0xdbe6d5d5fe4cce2full);
- const V2x64U init0H(0x243f6a8885a308d3ull, 0x13198a2e03707344ull);
- const V2x64U init1L(0xc0acf169b5f18a8cull, 0x3bd39e10cb0ef593ull);
- const V2x64U init1H(0x452821e638d01377ull, 0xbe5466cf34e90c6cull);
- const V2x64U keyL = LoadUnaligned<V2x64U>(key + 0);
- const V2x64U keyH = LoadUnaligned<V2x64U>(key + 2);
- v0L = keyL ^ init0L;
- v0H = keyH ^ init0H;
- v1L = Rotate64By32(keyL) ^ init1L;
- v1H = Rotate64By32(keyH) ^ init1H;
- mul0L = init0L;
- mul0H = init0H;
- mul1L = init1L;
- mul1H = init1H;
- }
-
- HH_INLINE void Update(const HHPacket& packet_bytes) {
- const uint64_t* HH_RESTRICT packet =
- reinterpret_cast<const uint64_t * HH_RESTRICT>(packet_bytes);
- const V2x64U packetL = LoadUnaligned<V2x64U>(packet + 0);
- const V2x64U packetH = LoadUnaligned<V2x64U>(packet + 2);
- Update(packetH, packetL);
- }
-
- HH_INLINE void UpdateRemainder(const char* bytes, const size_t size_mod32) {
- // 'Length padding' differentiates zero-valued inputs that have the same
- // size/32. mod32 is sufficient because each Update behaves as if a
- // counter were injected, because the state is large and mixed thoroughly.
- const V4x32U vsize_mod32(static_cast<uint32_t>(size_mod32));
- // Equivalent to storing size_mod32 in packet.
- v0L += V2x64U(vsize_mod32);
- v0H += V2x64U(vsize_mod32);
- // Boosts the avalanche effect of mod32.
- Rotate32By(&v1H, &v1L, size_mod32);
-
- const size_t size_mod4 = size_mod32 & 3;
- const char* HH_RESTRICT remainder = bytes + (size_mod32 & ~3);
-
- if (HH_UNLIKELY(size_mod32 & 16)) { // 16..31 bytes left
- const V2x64U packetL =
- LoadUnaligned<V2x64U>(reinterpret_cast<const uint64_t*>(bytes));
-
- V2x64U packetH = LoadMultipleOfFour(bytes + 16, size_mod32);
-
- const uint32_t last4 =
- Load3()(Load3::AllowReadBeforeAndReturn(), remainder, size_mod4);
-
- // The upper four bytes of packetH are zero, so insert there.
- packetH = V2x64U(_mm_insert_epi32(packetH, last4, 3));
- Update(packetH, packetL);
- } else { // size_mod32 < 16
- const V2x64U packetL = LoadMultipleOfFour(bytes, size_mod32);
-
- const uint64_t last4 =
- Load3()(Load3::AllowUnordered(), remainder, size_mod4);
-
- // Rather than insert into packetL[3], it is faster to initialize
- // the otherwise empty packetH.
- const V2x64U packetH(_mm_cvtsi64_si128(last4));
- Update(packetH, packetL);
- }
- }
-
- HH_INLINE void Finalize(HHResult64* HH_RESTRICT result) {
- // Mix together all lanes.
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
-
- const V2x64U sum0 = v0L + mul0L;
- const V2x64U sum1 = v1L + mul1L;
- const V2x64U hash = sum0 + sum1;
- _mm_storel_epi64(reinterpret_cast<__m128i*>(result), hash);
- }
-
- HH_INLINE void Finalize(HHResult128* HH_RESTRICT result) {
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
-
- const V2x64U sum0 = v0L + mul0L;
- const V2x64U sum1 = v1H + mul1H;
- const V2x64U hash = sum0 + sum1;
- StoreUnaligned(hash, &(*result)[0]);
- }
-
- HH_INLINE void Finalize(HHResult256* HH_RESTRICT result) {
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
- PermuteAndUpdate();
-
- const V2x64U sum0L = v0L + mul0L;
- const V2x64U sum1L = v1L + mul1L;
- const V2x64U sum0H = v0H + mul0H;
- const V2x64U sum1H = v1H + mul1H;
- const V2x64U hashL = ModularReduction(sum1L, sum0L);
- const V2x64U hashH = ModularReduction(sum1H, sum0H);
- StoreUnaligned(hashL, &(*result)[0]);
- StoreUnaligned(hashH, &(*result)[2]);
- }
-
- static HH_INLINE void ZeroInitialize(char* HH_RESTRICT buffer_bytes) {
- __m128i* buffer = reinterpret_cast<__m128i*>(buffer_bytes);
- const __m128i zero = _mm_setzero_si128();
- _mm_store_si128(buffer + 0, zero);
- _mm_store_si128(buffer + 1, zero);
- }
-
- static HH_INLINE void CopyPartial(const char* HH_RESTRICT from,
- const size_t size_mod32,
- char* HH_RESTRICT buffer) {
- for (size_t i = 0; i < size_mod32; ++i) {
- buffer[i] = from[i];
- }
- }
-
- static HH_INLINE void AppendPartial(const char* HH_RESTRICT from,
- const size_t size_mod32,
- char* HH_RESTRICT buffer,
- const size_t buffer_valid) {
- for (size_t i = 0; i < size_mod32; ++i) {
- buffer[buffer_valid + i] = from[i];
- }
- }
-
- HH_INLINE void AppendAndUpdate(const char* HH_RESTRICT from,
- const size_t size_mod32,
- const char* HH_RESTRICT buffer,
- const size_t buffer_valid) {
- HHPacket tmp HH_ALIGNAS(32);
- for (size_t i = 0; i < buffer_valid; ++i) {
- tmp[i] = buffer[i];
- }
- for (size_t i = 0; i < size_mod32; ++i) {
- tmp[buffer_valid + i] = from[i];
- }
- Update(tmp);
- }
-
- private:
- // Swap 32-bit halves of each lane (caller swaps 128-bit halves)
- static HH_INLINE V2x64U Rotate64By32(const V2x64U& v) {
- return V2x64U(_mm_shuffle_epi32(v, _MM_SHUFFLE(2, 3, 0, 1)));
- }
-
- // Rotates 32-bit lanes by "count" bits.
- static HH_INLINE void Rotate32By(V2x64U* HH_RESTRICT vH,
- V2x64U* HH_RESTRICT vL,
- const uint64_t count) {
- // WARNING: the shift count is 64 bits, so we can't reuse vsize_mod32,
- // which is broadcast into 32-bit lanes.
- const __m128i count_left = _mm_cvtsi64_si128(count);
- const __m128i count_right = _mm_cvtsi64_si128(32 - count);
- const V2x64U shifted_leftL(_mm_sll_epi32(*vL, count_left));
- const V2x64U shifted_leftH(_mm_sll_epi32(*vH, count_left));
- const V2x64U shifted_rightL(_mm_srl_epi32(*vL, count_right));
- const V2x64U shifted_rightH(_mm_srl_epi32(*vH, count_right));
- *vL = shifted_leftL | shifted_rightL;
- *vH = shifted_leftH | shifted_rightH;
- }
-
- static HH_INLINE V2x64U ZipperMerge(const V2x64U& v) {
- // Multiplication mixes/scrambles bytes 0-7 of the 64-bit result to
- // varying degrees. In descending order of goodness, bytes
- // 3 4 2 5 1 6 0 7 have quality 228 224 164 160 100 96 36 32.
- // As expected, the upper and lower bytes are much worse.
- // For each 64-bit lane, our objectives are:
- // 1) maximizing and equalizing total goodness across each lane's bytes;
- // 2) mixing with bytes from the neighboring lane;
- // 3) placing the worst bytes in the upper 32 bits because those will not
- // be used in the next 32x32 multiplication.
- const uint64_t hi = 0x070806090D0A040Bull;
- const uint64_t lo = 0x000F010E05020C03ull;
- return V2x64U(_mm_shuffle_epi8(v, V2x64U(hi, lo)));
- }
-
- HH_INLINE void Update(const V2x64U& packetH, const V2x64U& packetL) {
- v1L += packetL;
- v1H += packetH;
- v1L += mul0L;
- v1H += mul0H;
- mul0L ^= V2x64U(_mm_mul_epu32(v1L, Rotate64By32(v0L)));
- mul0H ^= V2x64U(_mm_mul_epu32(v1H, v0H >> 32));
- v0L += mul1L;
- v0H += mul1H;
- mul1L ^= V2x64U(_mm_mul_epu32(v0L, Rotate64By32(v1L)));
- mul1H ^= V2x64U(_mm_mul_epu32(v0H, v1H >> 32));
- v0L += ZipperMerge(v1L);
- v0H += ZipperMerge(v1H);
- v1L += ZipperMerge(v0L);
- v1H += ZipperMerge(v0H);
- }
-
- HH_INLINE void PermuteAndUpdate() {
- // It is slightly better to permute v0 than v1; it will be added to v1.
- // AVX-2 Permute also swaps 128-bit halves, so swap input operands.
- Update(Rotate64By32(v0L), Rotate64By32(v0H));
- }
-
- // Returns zero-initialized vector with the lower "size" = 0, 4, 8 or 12
- // bytes loaded from "bytes". Serves as a replacement for AVX2 maskload_epi32.
- static HH_INLINE V2x64U LoadMultipleOfFour(const char* bytes,
- const size_t size) {
- const uint32_t* words = reinterpret_cast<const uint32_t*>(bytes);
- // Mask of 1-bits where the final 4 bytes should be inserted (replacement
- // for variable shift/insert using broadcast+blend).
- V2x64U mask4(_mm_cvtsi64_si128(0xFFFFFFFFULL)); // 'insert' into lane 0
- V2x64U ret(0);
- if (size & 8) {
- ret = V2x64U(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(words)));
- // mask4 = 0 ~0 0 0 ('insert' into lane 2)
- mask4 = V2x64U(_mm_slli_si128(mask4, 8));
- words += 2;
- }
- // Final 4 (possibly after the 8 above); 'insert' into lane 0 or 2 of ret.
- if (size & 4) {
- const __m128i word2 = _mm_cvtsi32_si128(words[0]);
- // = 0 word2 0 word2; mask4 will select which lane to keep.
- const V2x64U broadcast(_mm_shuffle_epi32(word2, 0x00));
- // (slightly faster than blendv_epi8)
- ret |= V2x64U(broadcast & mask4);
- }
- return ret;
- }
-
- // XORs x << 1 and x << 2 into *out after clearing the upper two bits of x.
- // Bit shifts are only possible on independent 64-bit lanes. We therefore
- // insert the upper bits of x[0] that were lost into x[1].
- // Thanks to D. Lemire for helpful comments!
- static HH_INLINE void XorByShift128Left12(const V2x64U& x,
- V2x64U* HH_RESTRICT out) {
- const V2x64U zero(_mm_setzero_si128());
- const V2x64U sign_bit128(_mm_insert_epi32(zero, 0x80000000u, 3));
- const V2x64U top_bits2 = x >> (64 - 2);
- HH_COMPILER_FENCE;
- const V2x64U shifted1_unmasked = x + x; // (avoids needing port0)
-
- // Only the lower half of top_bits1 will be used, so we
- // can compute it before clearing the upper two bits of x.
- const V2x64U top_bits1 = x >> (64 - 1);
- const V2x64U shifted2 = shifted1_unmasked + shifted1_unmasked;
- HH_COMPILER_FENCE;
-
- const V2x64U new_low_bits2(_mm_slli_si128(top_bits2, 8));
- *out ^= shifted2;
- // The result must be as if the upper two bits of the input had been clear,
- // otherwise we're no longer computing a reduction.
- const V2x64U shifted1 = AndNot(sign_bit128, shifted1_unmasked);
- HH_COMPILER_FENCE;
-
- const V2x64U new_low_bits1(_mm_slli_si128(top_bits1, 8));
- *out ^= new_low_bits2;
- *out ^= shifted1;
- *out ^= new_low_bits1;
- }
-
- // Modular reduction by the irreducible polynomial (x^128 + x^2 + x).
- // Input: a 256-bit number a3210.
- static HH_INLINE V2x64U ModularReduction(const V2x64U& a32_unmasked,
- const V2x64U& a10) {
- // See Lemire, https://arxiv.org/pdf/1503.03465v8.pdf.
- V2x64U out = a10;
- XorByShift128Left12(a32_unmasked, &out);
- return out;
- }
-
- V2x64U v0L;
- V2x64U v0H;
- V2x64U v1L;
- V2x64U v1H;
- V2x64U mul0L;
- V2x64U mul0H;
- V2x64U mul1L;
- V2x64U mul1H;
-};
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HH_DISABLE_TARGET_SPECIFIC
-#endif // HIGHWAYHASH_HH_SSE41_H_
+// Copyright 2015-2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HH_SSE41_H_
+#define HIGHWAYHASH_HH_SSE41_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/hh_buffer.h"
+#include "highwayhash/hh_types.h"
+#include "highwayhash/load3.h"
+#include "highwayhash/vector128.h"
+
+// For auto-dependency generation, we need to include all headers but not their
+// contents (otherwise compilation fails because -msse4.1 is not specified).
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+
+namespace highwayhash {
+// See vector128.h for why this namespace is necessary; matching it here makes
+// it easier use the vector128 symbols, but requires textual inclusion.
+namespace HH_TARGET_NAME {
+
+// J-lanes tree hashing: see http://dx.doi.org/10.4236/jis.2014.53010
+// Uses pairs of SSE4.1 instructions to emulate the AVX-2 algorithm.
+class HHStateSSE41 {
+ public:
+ explicit HH_INLINE HHStateSSE41(const HHKey key) { Reset(key); }
+
+ HH_INLINE void Reset(const HHKey key) {
+ // "Nothing up my sleeve numbers"; see HHStateTAVX2.
+ const V2x64U init0L(0xa4093822299f31d0ull, 0xdbe6d5d5fe4cce2full);
+ const V2x64U init0H(0x243f6a8885a308d3ull, 0x13198a2e03707344ull);
+ const V2x64U init1L(0xc0acf169b5f18a8cull, 0x3bd39e10cb0ef593ull);
+ const V2x64U init1H(0x452821e638d01377ull, 0xbe5466cf34e90c6cull);
+ const V2x64U keyL = LoadUnaligned<V2x64U>(key + 0);
+ const V2x64U keyH = LoadUnaligned<V2x64U>(key + 2);
+ v0L = keyL ^ init0L;
+ v0H = keyH ^ init0H;
+ v1L = Rotate64By32(keyL) ^ init1L;
+ v1H = Rotate64By32(keyH) ^ init1H;
+ mul0L = init0L;
+ mul0H = init0H;
+ mul1L = init1L;
+ mul1H = init1H;
+ }
+
+ HH_INLINE void Update(const HHPacket& packet_bytes) {
+ const uint64_t* HH_RESTRICT packet =
+ reinterpret_cast<const uint64_t * HH_RESTRICT>(packet_bytes);
+ const V2x64U packetL = LoadUnaligned<V2x64U>(packet + 0);
+ const V2x64U packetH = LoadUnaligned<V2x64U>(packet + 2);
+ Update(packetH, packetL);
+ }
+
+ HH_INLINE void UpdateRemainder(const char* bytes, const size_t size_mod32) {
+ // 'Length padding' differentiates zero-valued inputs that have the same
+ // size/32. mod32 is sufficient because each Update behaves as if a
+ // counter were injected, because the state is large and mixed thoroughly.
+ const V4x32U vsize_mod32(static_cast<uint32_t>(size_mod32));
+ // Equivalent to storing size_mod32 in packet.
+ v0L += V2x64U(vsize_mod32);
+ v0H += V2x64U(vsize_mod32);
+ // Boosts the avalanche effect of mod32.
+ Rotate32By(&v1H, &v1L, size_mod32);
+
+ const size_t size_mod4 = size_mod32 & 3;
+ const char* HH_RESTRICT remainder = bytes + (size_mod32 & ~3);
+
+ if (HH_UNLIKELY(size_mod32 & 16)) { // 16..31 bytes left
+ const V2x64U packetL =
+ LoadUnaligned<V2x64U>(reinterpret_cast<const uint64_t*>(bytes));
+
+ V2x64U packetH = LoadMultipleOfFour(bytes + 16, size_mod32);
+
+ const uint32_t last4 =
+ Load3()(Load3::AllowReadBeforeAndReturn(), remainder, size_mod4);
+
+ // The upper four bytes of packetH are zero, so insert there.
+ packetH = V2x64U(_mm_insert_epi32(packetH, last4, 3));
+ Update(packetH, packetL);
+ } else { // size_mod32 < 16
+ const V2x64U packetL = LoadMultipleOfFour(bytes, size_mod32);
+
+ const uint64_t last4 =
+ Load3()(Load3::AllowUnordered(), remainder, size_mod4);
+
+ // Rather than insert into packetL[3], it is faster to initialize
+ // the otherwise empty packetH.
+ const V2x64U packetH(_mm_cvtsi64_si128(last4));
+ Update(packetH, packetL);
+ }
+ }
+
+ HH_INLINE void Finalize(HHResult64* HH_RESTRICT result) {
+ // Mix together all lanes.
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+
+ const V2x64U sum0 = v0L + mul0L;
+ const V2x64U sum1 = v1L + mul1L;
+ const V2x64U hash = sum0 + sum1;
+ _mm_storel_epi64(reinterpret_cast<__m128i*>(result), hash);
+ }
+
+ HH_INLINE void Finalize(HHResult128* HH_RESTRICT result) {
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+
+ const V2x64U sum0 = v0L + mul0L;
+ const V2x64U sum1 = v1H + mul1H;
+ const V2x64U hash = sum0 + sum1;
+ StoreUnaligned(hash, &(*result)[0]);
+ }
+
+ HH_INLINE void Finalize(HHResult256* HH_RESTRICT result) {
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+ PermuteAndUpdate();
+
+ const V2x64U sum0L = v0L + mul0L;
+ const V2x64U sum1L = v1L + mul1L;
+ const V2x64U sum0H = v0H + mul0H;
+ const V2x64U sum1H = v1H + mul1H;
+ const V2x64U hashL = ModularReduction(sum1L, sum0L);
+ const V2x64U hashH = ModularReduction(sum1H, sum0H);
+ StoreUnaligned(hashL, &(*result)[0]);
+ StoreUnaligned(hashH, &(*result)[2]);
+ }
+
+ static HH_INLINE void ZeroInitialize(char* HH_RESTRICT buffer_bytes) {
+ __m128i* buffer = reinterpret_cast<__m128i*>(buffer_bytes);
+ const __m128i zero = _mm_setzero_si128();
+ _mm_store_si128(buffer + 0, zero);
+ _mm_store_si128(buffer + 1, zero);
+ }
+
+ static HH_INLINE void CopyPartial(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ char* HH_RESTRICT buffer) {
+ for (size_t i = 0; i < size_mod32; ++i) {
+ buffer[i] = from[i];
+ }
+ }
+
+ static HH_INLINE void AppendPartial(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ char* HH_RESTRICT buffer,
+ const size_t buffer_valid) {
+ for (size_t i = 0; i < size_mod32; ++i) {
+ buffer[buffer_valid + i] = from[i];
+ }
+ }
+
+ HH_INLINE void AppendAndUpdate(const char* HH_RESTRICT from,
+ const size_t size_mod32,
+ const char* HH_RESTRICT buffer,
+ const size_t buffer_valid) {
+ HHPacket tmp HH_ALIGNAS(32);
+ for (size_t i = 0; i < buffer_valid; ++i) {
+ tmp[i] = buffer[i];
+ }
+ for (size_t i = 0; i < size_mod32; ++i) {
+ tmp[buffer_valid + i] = from[i];
+ }
+ Update(tmp);
+ }
+
+ private:
+ // Swap 32-bit halves of each lane (caller swaps 128-bit halves)
+ static HH_INLINE V2x64U Rotate64By32(const V2x64U& v) {
+ return V2x64U(_mm_shuffle_epi32(v, _MM_SHUFFLE(2, 3, 0, 1)));
+ }
+
+ // Rotates 32-bit lanes by "count" bits.
+ static HH_INLINE void Rotate32By(V2x64U* HH_RESTRICT vH,
+ V2x64U* HH_RESTRICT vL,
+ const uint64_t count) {
+ // WARNING: the shift count is 64 bits, so we can't reuse vsize_mod32,
+ // which is broadcast into 32-bit lanes.
+ const __m128i count_left = _mm_cvtsi64_si128(count);
+ const __m128i count_right = _mm_cvtsi64_si128(32 - count);
+ const V2x64U shifted_leftL(_mm_sll_epi32(*vL, count_left));
+ const V2x64U shifted_leftH(_mm_sll_epi32(*vH, count_left));
+ const V2x64U shifted_rightL(_mm_srl_epi32(*vL, count_right));
+ const V2x64U shifted_rightH(_mm_srl_epi32(*vH, count_right));
+ *vL = shifted_leftL | shifted_rightL;
+ *vH = shifted_leftH | shifted_rightH;
+ }
+
+ static HH_INLINE V2x64U ZipperMerge(const V2x64U& v) {
+ // Multiplication mixes/scrambles bytes 0-7 of the 64-bit result to
+ // varying degrees. In descending order of goodness, bytes
+ // 3 4 2 5 1 6 0 7 have quality 228 224 164 160 100 96 36 32.
+ // As expected, the upper and lower bytes are much worse.
+ // For each 64-bit lane, our objectives are:
+ // 1) maximizing and equalizing total goodness across each lane's bytes;
+ // 2) mixing with bytes from the neighboring lane;
+ // 3) placing the worst bytes in the upper 32 bits because those will not
+ // be used in the next 32x32 multiplication.
+ const uint64_t hi = 0x070806090D0A040Bull;
+ const uint64_t lo = 0x000F010E05020C03ull;
+ return V2x64U(_mm_shuffle_epi8(v, V2x64U(hi, lo)));
+ }
+
+ HH_INLINE void Update(const V2x64U& packetH, const V2x64U& packetL) {
+ v1L += packetL;
+ v1H += packetH;
+ v1L += mul0L;
+ v1H += mul0H;
+ mul0L ^= V2x64U(_mm_mul_epu32(v1L, Rotate64By32(v0L)));
+ mul0H ^= V2x64U(_mm_mul_epu32(v1H, v0H >> 32));
+ v0L += mul1L;
+ v0H += mul1H;
+ mul1L ^= V2x64U(_mm_mul_epu32(v0L, Rotate64By32(v1L)));
+ mul1H ^= V2x64U(_mm_mul_epu32(v0H, v1H >> 32));
+ v0L += ZipperMerge(v1L);
+ v0H += ZipperMerge(v1H);
+ v1L += ZipperMerge(v0L);
+ v1H += ZipperMerge(v0H);
+ }
+
+ HH_INLINE void PermuteAndUpdate() {
+ // It is slightly better to permute v0 than v1; it will be added to v1.
+ // AVX-2 Permute also swaps 128-bit halves, so swap input operands.
+ Update(Rotate64By32(v0L), Rotate64By32(v0H));
+ }
+
+ // Returns zero-initialized vector with the lower "size" = 0, 4, 8 or 12
+ // bytes loaded from "bytes". Serves as a replacement for AVX2 maskload_epi32.
+ static HH_INLINE V2x64U LoadMultipleOfFour(const char* bytes,
+ const size_t size) {
+ const uint32_t* words = reinterpret_cast<const uint32_t*>(bytes);
+ // Mask of 1-bits where the final 4 bytes should be inserted (replacement
+ // for variable shift/insert using broadcast+blend).
+ V2x64U mask4(_mm_cvtsi64_si128(0xFFFFFFFFULL)); // 'insert' into lane 0
+ V2x64U ret(0);
+ if (size & 8) {
+ ret = V2x64U(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(words)));
+ // mask4 = 0 ~0 0 0 ('insert' into lane 2)
+ mask4 = V2x64U(_mm_slli_si128(mask4, 8));
+ words += 2;
+ }
+ // Final 4 (possibly after the 8 above); 'insert' into lane 0 or 2 of ret.
+ if (size & 4) {
+ const __m128i word2 = _mm_cvtsi32_si128(words[0]);
+ // = 0 word2 0 word2; mask4 will select which lane to keep.
+ const V2x64U broadcast(_mm_shuffle_epi32(word2, 0x00));
+ // (slightly faster than blendv_epi8)
+ ret |= V2x64U(broadcast & mask4);
+ }
+ return ret;
+ }
+
+ // XORs x << 1 and x << 2 into *out after clearing the upper two bits of x.
+ // Bit shifts are only possible on independent 64-bit lanes. We therefore
+ // insert the upper bits of x[0] that were lost into x[1].
+ // Thanks to D. Lemire for helpful comments!
+ static HH_INLINE void XorByShift128Left12(const V2x64U& x,
+ V2x64U* HH_RESTRICT out) {
+ const V2x64U zero(_mm_setzero_si128());
+ const V2x64U sign_bit128(_mm_insert_epi32(zero, 0x80000000u, 3));
+ const V2x64U top_bits2 = x >> (64 - 2);
+ HH_COMPILER_FENCE;
+ const V2x64U shifted1_unmasked = x + x; // (avoids needing port0)
+
+ // Only the lower half of top_bits1 will be used, so we
+ // can compute it before clearing the upper two bits of x.
+ const V2x64U top_bits1 = x >> (64 - 1);
+ const V2x64U shifted2 = shifted1_unmasked + shifted1_unmasked;
+ HH_COMPILER_FENCE;
+
+ const V2x64U new_low_bits2(_mm_slli_si128(top_bits2, 8));
+ *out ^= shifted2;
+ // The result must be as if the upper two bits of the input had been clear,
+ // otherwise we're no longer computing a reduction.
+ const V2x64U shifted1 = AndNot(sign_bit128, shifted1_unmasked);
+ HH_COMPILER_FENCE;
+
+ const V2x64U new_low_bits1(_mm_slli_si128(top_bits1, 8));
+ *out ^= new_low_bits2;
+ *out ^= shifted1;
+ *out ^= new_low_bits1;
+ }
+
+ // Modular reduction by the irreducible polynomial (x^128 + x^2 + x).
+ // Input: a 256-bit number a3210.
+ static HH_INLINE V2x64U ModularReduction(const V2x64U& a32_unmasked,
+ const V2x64U& a10) {
+ // See Lemire, https://arxiv.org/pdf/1503.03465v8.pdf.
+ V2x64U out = a10;
+ XorByShift128Left12(a32_unmasked, &out);
+ return out;
+ }
+
+ V2x64U v0L;
+ V2x64U v0H;
+ V2x64U v1L;
+ V2x64U v1H;
+ V2x64U mul0L;
+ V2x64U mul0H;
+ V2x64U mul1L;
+ V2x64U mul1H;
+};
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HH_DISABLE_TARGET_SPECIFIC
+#endif // HIGHWAYHASH_HH_SSE41_H_
diff --git a/contrib/libs/highwayhash/highwayhash/hh_types.h b/contrib/libs/highwayhash/highwayhash/hh_types.h
index e5b0430f17..f350d70f65 100644
--- a/contrib/libs/highwayhash/highwayhash/hh_types.h
+++ b/contrib/libs/highwayhash/highwayhash/hh_types.h
@@ -1,50 +1,50 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HH_TYPES_H_
-#define HIGHWAYHASH_HH_TYPES_H_
-
-// WARNING: included from c_bindings => must be C-compatible.
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stddef.h> // size_t
-#include <stdint.h>
-
-#ifdef __cplusplus
-namespace highwayhash {
-#endif
-
-// 256-bit secret key that should remain unknown to attackers.
-// We recommend initializing it to a random value.
-typedef uint64_t HHKey[4];
-
-// How much input is hashed by one call to HHStateT::Update.
-typedef char HHPacket[32];
-
-// Hash 'return' types.
-typedef uint64_t HHResult64; // returned directly
-typedef uint64_t HHResult128[2];
-typedef uint64_t HHResult256[4];
-
-// Called if a test fails, indicating which target and size.
-typedef void (*HHNotify)(const char*, size_t);
-
-#ifdef __cplusplus
-} // namespace highwayhash
-#endif
-
-#endif // HIGHWAYHASH_HH_TYPES_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HH_TYPES_H_
+#define HIGHWAYHASH_HH_TYPES_H_
+
+// WARNING: included from c_bindings => must be C-compatible.
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stddef.h> // size_t
+#include <stdint.h>
+
+#ifdef __cplusplus
+namespace highwayhash {
+#endif
+
+// 256-bit secret key that should remain unknown to attackers.
+// We recommend initializing it to a random value.
+typedef uint64_t HHKey[4];
+
+// How much input is hashed by one call to HHStateT::Update.
+typedef char HHPacket[32];
+
+// Hash 'return' types.
+typedef uint64_t HHResult64; // returned directly
+typedef uint64_t HHResult128[2];
+typedef uint64_t HHResult256[4];
+
+// Called if a test fails, indicating which target and size.
+typedef void (*HHNotify)(const char*, size_t);
+
+#ifdef __cplusplus
+} // namespace highwayhash
+#endif
+
+#endif // HIGHWAYHASH_HH_TYPES_H_
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash.h b/contrib/libs/highwayhash/highwayhash/highwayhash.h
index 0cebc841fe..cee1c31ba4 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash.h
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash.h
@@ -1,202 +1,202 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HIGHWAYHASH_H_
-#define HIGHWAYHASH_HIGHWAYHASH_H_
-
-// This header's templates are useful for inlining into other CPU-specific code:
-// template<TargetBits Target> CodeUsingHash() { HighwayHashT<Target>(...); },
-// and can also be instantiated with HH_TARGET when callers don't care about the
-// exact implementation. Otherwise, they are implementation details of the
-// highwayhash_target wrapper. Use that instead if you need to detect the best
-// available implementation at runtime.
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/hh_types.h"
-#include "highwayhash/iaca.h"
-
-// Include exactly one (see arch_specific.h) header, which defines a state
-// object in a target-specific namespace, e.g. AVX2::HHStateAVX2.
-// Attempts to use "computed includes" (#define MACRO "path/or_just_filename",
-// #include MACRO) fail with 'file not found', so we need an #if chain.
-#if HH_TARGET == HH_TARGET_AVX2
-#include "highwayhash/hh_avx2.h"
-#elif HH_TARGET == HH_TARGET_SSE41
-#include "highwayhash/hh_sse41.h"
-#elif HH_TARGET == HH_TARGET_Portable
-#include "highwayhash/hh_portable.h"
-#else
-#error "Unknown target, add its hh_*.h include here."
-#endif
-
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-namespace highwayhash {
-
-// Alias templates (HHStateT) cannot be specialized, so we need a helper struct.
-// Note that hh_*.h don't just specialize HHStateT directly because vector128.h
-// must reside in a distinct namespace (to allow including it from multiple
-// translation units), and it is easier if its users, i.e. the concrete HHState,
-// also reside in that same namespace, which precludes specialization.
-template <TargetBits Target>
-struct HHStateForTarget {};
-
-template <>
-struct HHStateForTarget<HH_TARGET> {
- // (The namespace is sufficient and the additional HH_TARGET_NAME suffix is
- // technically redundant, but it makes searching easier.)
- using type = HH_TARGET_NAME::HH_ADD_TARGET_SUFFIX(HHState);
-};
-
-// Typically used as HHStateT<HH_TARGET>. It would be easier to just have a
-// concrete type HH_STATE, but this alias template is required by the
-// templates in highwayhash_target.cc.
-template <TargetBits Target>
-using HHStateT = typename HHStateForTarget<Target>::type;
-
-// Computes HighwayHash of "bytes" using the implementation chosen by "State".
-//
-// "state" is a HHStateT<> initialized with a key.
-// "bytes" is the data to hash (possibly unaligned).
-// "size" is the number of bytes to hash; we do not read any additional bytes.
-// "hash" is a HHResult* (either 64, 128 or 256 bits).
-//
-// HighwayHash is a strong pseudorandom function with security claims
-// [https://arxiv.org/abs/1612.06257]. It is intended as a safer general-purpose
-// hash, about 4x faster than SipHash and 10x faster than BLAKE2.
-//
-// This template allows callers (e.g. tests) to invoke a specific
-// implementation. It must be compiled with the flags required by the desired
-// implementation. If the entire program cannot be built with these flags, use
-// the wrapper in highwayhash_target.h instead.
-//
-// Callers wanting to hash multiple pieces of data should duplicate this
-// function, calling HHStateT::Update for each input and only Finalizing once.
-template <class State, typename Result>
-HH_INLINE void HighwayHashT(State* HH_RESTRICT state,
- const char* HH_RESTRICT bytes, const size_t size,
- Result* HH_RESTRICT hash) {
- // BeginIACA();
- const size_t remainder = size & (sizeof(HHPacket) - 1);
- const size_t truncated = size & ~(sizeof(HHPacket) - 1);
- for (size_t offset = 0; offset < truncated; offset += sizeof(HHPacket)) {
- state->Update(*reinterpret_cast<const HHPacket*>(bytes + offset));
- }
-
- if (remainder != 0) {
- state->UpdateRemainder(bytes + truncated, remainder);
- }
-
- state->Finalize(hash);
- // EndIACA();
-}
-
-// Wrapper class for incrementally hashing a series of data ranges. The final
-// result is the same as HighwayHashT of the concatenation of all the ranges.
-// This is useful for computing the hash of cords, iovecs, and similar
-// data structures.
-template <TargetBits Target>
-class HighwayHashCatT {
- public:
- HH_INLINE HighwayHashCatT(const HHKey& key) : state_(key) {
- // Avoids msan uninitialized-memory warnings.
- HHStateT<Target>::ZeroInitialize(buffer_);
- }
-
- // Resets the state of the hasher so it can be used to hash a new string.
- HH_INLINE void Reset(const HHKey& key) {
- state_.Reset(key);
- buffer_usage_ = 0;
- }
-
- // Adds "bytes" to the internal buffer, feeding it to HHStateT::Update as
- // required. Call this as often as desired. Only reads bytes within the
- // interval [bytes, bytes + num_bytes). "num_bytes" == 0 has no effect.
- // There are no alignment requirements.
- HH_INLINE void Append(const char* HH_RESTRICT bytes, size_t num_bytes) {
- // BeginIACA();
- const size_t capacity = sizeof(HHPacket) - buffer_usage_;
- // New bytes fit within buffer, but still not enough to Update.
- if (HH_UNLIKELY(num_bytes < capacity)) {
- HHStateT<Target>::AppendPartial(bytes, num_bytes, buffer_, buffer_usage_);
- buffer_usage_ += num_bytes;
- return;
- }
-
- // HACK: ensures the state is kept in SIMD registers; otherwise, Update
- // constantly load/stores its operands, which is much slower.
- // Restrict-qualified pointers to external state or the state_ member are
- // not sufficient for keeping this in registers.
- HHStateT<Target> state_copy = state_;
-
- // Have prior bytes to flush.
- const size_t buffer_usage = buffer_usage_;
- if (HH_LIKELY(buffer_usage != 0)) {
- // Calls update with prior buffer contents plus new data. Does not modify
- // the buffer because some implementations can load into SIMD registers
- // and Append to them directly.
- state_copy.AppendAndUpdate(bytes, capacity, buffer_, buffer_usage);
- bytes += capacity;
- num_bytes -= capacity;
- }
-
- // Buffer currently empty => Update directly from the source.
- while (num_bytes >= sizeof(HHPacket)) {
- state_copy.Update(*reinterpret_cast<const HHPacket*>(bytes));
- bytes += sizeof(HHPacket);
- num_bytes -= sizeof(HHPacket);
- }
-
- // Unconditionally assign even if zero because we didn't reset to zero
- // after the AppendAndUpdate above.
- buffer_usage_ = num_bytes;
-
- state_ = state_copy;
-
- // Store any remainders in buffer, no-op if multiple of a packet.
- if (HH_LIKELY(num_bytes != 0)) {
- HHStateT<Target>::CopyPartial(bytes, num_bytes, buffer_);
- }
- // EndIACA();
- }
-
- // Stores the resulting 64, 128 or 256-bit hash of all data passed to Append.
- // Must be called exactly once, or after a prior Reset.
- template <typename Result> // HHResult*
- HH_INLINE void Finalize(Result* HH_RESTRICT hash) {
- // BeginIACA();
- HHStateT<Target> state_copy = state_;
- const size_t buffer_usage = buffer_usage_;
- if (HH_LIKELY(buffer_usage != 0)) {
- state_copy.UpdateRemainder(buffer_, buffer_usage);
- }
- state_copy.Finalize(hash);
- // EndIACA();
- }
-
- private:
- HHPacket buffer_ HH_ALIGNAS(64);
- HHStateT<Target> state_ HH_ALIGNAS(32);
- // How many bytes in buffer_ (starting with offset 0) are valid.
- size_t buffer_usage_ = 0;
-};
-
-} // namespace highwayhash
-#endif // HH_DISABLE_TARGET_SPECIFIC
-#endif // HIGHWAYHASH_HIGHWAYHASH_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HIGHWAYHASH_H_
+#define HIGHWAYHASH_HIGHWAYHASH_H_
+
+// This header's templates are useful for inlining into other CPU-specific code:
+// template<TargetBits Target> CodeUsingHash() { HighwayHashT<Target>(...); },
+// and can also be instantiated with HH_TARGET when callers don't care about the
+// exact implementation. Otherwise, they are implementation details of the
+// highwayhash_target wrapper. Use that instead if you need to detect the best
+// available implementation at runtime.
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/hh_types.h"
+#include "highwayhash/iaca.h"
+
+// Include exactly one (see arch_specific.h) header, which defines a state
+// object in a target-specific namespace, e.g. AVX2::HHStateAVX2.
+// Attempts to use "computed includes" (#define MACRO "path/or_just_filename",
+// #include MACRO) fail with 'file not found', so we need an #if chain.
+#if HH_TARGET == HH_TARGET_AVX2
+#include "highwayhash/hh_avx2.h"
+#elif HH_TARGET == HH_TARGET_SSE41
+#include "highwayhash/hh_sse41.h"
+#elif HH_TARGET == HH_TARGET_Portable
+#include "highwayhash/hh_portable.h"
+#else
+#error "Unknown target, add its hh_*.h include here."
+#endif
+
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+namespace highwayhash {
+
+// Alias templates (HHStateT) cannot be specialized, so we need a helper struct.
+// Note that hh_*.h don't just specialize HHStateT directly because vector128.h
+// must reside in a distinct namespace (to allow including it from multiple
+// translation units), and it is easier if its users, i.e. the concrete HHState,
+// also reside in that same namespace, which precludes specialization.
+template <TargetBits Target>
+struct HHStateForTarget {};
+
+template <>
+struct HHStateForTarget<HH_TARGET> {
+ // (The namespace is sufficient and the additional HH_TARGET_NAME suffix is
+ // technically redundant, but it makes searching easier.)
+ using type = HH_TARGET_NAME::HH_ADD_TARGET_SUFFIX(HHState);
+};
+
+// Typically used as HHStateT<HH_TARGET>. It would be easier to just have a
+// concrete type HH_STATE, but this alias template is required by the
+// templates in highwayhash_target.cc.
+template <TargetBits Target>
+using HHStateT = typename HHStateForTarget<Target>::type;
+
+// Computes HighwayHash of "bytes" using the implementation chosen by "State".
+//
+// "state" is a HHStateT<> initialized with a key.
+// "bytes" is the data to hash (possibly unaligned).
+// "size" is the number of bytes to hash; we do not read any additional bytes.
+// "hash" is a HHResult* (either 64, 128 or 256 bits).
+//
+// HighwayHash is a strong pseudorandom function with security claims
+// [https://arxiv.org/abs/1612.06257]. It is intended as a safer general-purpose
+// hash, about 4x faster than SipHash and 10x faster than BLAKE2.
+//
+// This template allows callers (e.g. tests) to invoke a specific
+// implementation. It must be compiled with the flags required by the desired
+// implementation. If the entire program cannot be built with these flags, use
+// the wrapper in highwayhash_target.h instead.
+//
+// Callers wanting to hash multiple pieces of data should duplicate this
+// function, calling HHStateT::Update for each input and only Finalizing once.
+template <class State, typename Result>
+HH_INLINE void HighwayHashT(State* HH_RESTRICT state,
+ const char* HH_RESTRICT bytes, const size_t size,
+ Result* HH_RESTRICT hash) {
+ // BeginIACA();
+ const size_t remainder = size & (sizeof(HHPacket) - 1);
+ const size_t truncated = size & ~(sizeof(HHPacket) - 1);
+ for (size_t offset = 0; offset < truncated; offset += sizeof(HHPacket)) {
+ state->Update(*reinterpret_cast<const HHPacket*>(bytes + offset));
+ }
+
+ if (remainder != 0) {
+ state->UpdateRemainder(bytes + truncated, remainder);
+ }
+
+ state->Finalize(hash);
+ // EndIACA();
+}
+
+// Wrapper class for incrementally hashing a series of data ranges. The final
+// result is the same as HighwayHashT of the concatenation of all the ranges.
+// This is useful for computing the hash of cords, iovecs, and similar
+// data structures.
+template <TargetBits Target>
+class HighwayHashCatT {
+ public:
+ HH_INLINE HighwayHashCatT(const HHKey& key) : state_(key) {
+ // Avoids msan uninitialized-memory warnings.
+ HHStateT<Target>::ZeroInitialize(buffer_);
+ }
+
+ // Resets the state of the hasher so it can be used to hash a new string.
+ HH_INLINE void Reset(const HHKey& key) {
+ state_.Reset(key);
+ buffer_usage_ = 0;
+ }
+
+ // Adds "bytes" to the internal buffer, feeding it to HHStateT::Update as
+ // required. Call this as often as desired. Only reads bytes within the
+ // interval [bytes, bytes + num_bytes). "num_bytes" == 0 has no effect.
+ // There are no alignment requirements.
+ HH_INLINE void Append(const char* HH_RESTRICT bytes, size_t num_bytes) {
+ // BeginIACA();
+ const size_t capacity = sizeof(HHPacket) - buffer_usage_;
+ // New bytes fit within buffer, but still not enough to Update.
+ if (HH_UNLIKELY(num_bytes < capacity)) {
+ HHStateT<Target>::AppendPartial(bytes, num_bytes, buffer_, buffer_usage_);
+ buffer_usage_ += num_bytes;
+ return;
+ }
+
+ // HACK: ensures the state is kept in SIMD registers; otherwise, Update
+ // constantly load/stores its operands, which is much slower.
+ // Restrict-qualified pointers to external state or the state_ member are
+ // not sufficient for keeping this in registers.
+ HHStateT<Target> state_copy = state_;
+
+ // Have prior bytes to flush.
+ const size_t buffer_usage = buffer_usage_;
+ if (HH_LIKELY(buffer_usage != 0)) {
+ // Calls update with prior buffer contents plus new data. Does not modify
+ // the buffer because some implementations can load into SIMD registers
+ // and Append to them directly.
+ state_copy.AppendAndUpdate(bytes, capacity, buffer_, buffer_usage);
+ bytes += capacity;
+ num_bytes -= capacity;
+ }
+
+ // Buffer currently empty => Update directly from the source.
+ while (num_bytes >= sizeof(HHPacket)) {
+ state_copy.Update(*reinterpret_cast<const HHPacket*>(bytes));
+ bytes += sizeof(HHPacket);
+ num_bytes -= sizeof(HHPacket);
+ }
+
+ // Unconditionally assign even if zero because we didn't reset to zero
+ // after the AppendAndUpdate above.
+ buffer_usage_ = num_bytes;
+
+ state_ = state_copy;
+
+ // Store any remainders in buffer, no-op if multiple of a packet.
+ if (HH_LIKELY(num_bytes != 0)) {
+ HHStateT<Target>::CopyPartial(bytes, num_bytes, buffer_);
+ }
+ // EndIACA();
+ }
+
+ // Stores the resulting 64, 128 or 256-bit hash of all data passed to Append.
+ // Must be called exactly once, or after a prior Reset.
+ template <typename Result> // HHResult*
+ HH_INLINE void Finalize(Result* HH_RESTRICT hash) {
+ // BeginIACA();
+ HHStateT<Target> state_copy = state_;
+ const size_t buffer_usage = buffer_usage_;
+ if (HH_LIKELY(buffer_usage != 0)) {
+ state_copy.UpdateRemainder(buffer_, buffer_usage);
+ }
+ state_copy.Finalize(hash);
+ // EndIACA();
+ }
+
+ private:
+ HHPacket buffer_ HH_ALIGNAS(64);
+ HHStateT<Target> state_ HH_ALIGNAS(32);
+ // How many bytes in buffer_ (starting with offset 0) are valid.
+ size_t buffer_usage_ = 0;
+};
+
+} // namespace highwayhash
+#endif // HH_DISABLE_TARGET_SPECIFIC
+#endif // HIGHWAYHASH_HIGHWAYHASH_H_
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_target.cc b/contrib/libs/highwayhash/highwayhash/highwayhash_target.cc
index f7dc4a0d54..74022f64bf 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_target.cc
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_target.cc
@@ -1,104 +1,104 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#include "highwayhash/highwayhash_target.h"
-
-#include "highwayhash/highwayhash.h"
-
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-namespace highwayhash {
-
-extern "C" {
-uint64_t HH_ADD_TARGET_SUFFIX(HighwayHash64_)(const HHKey key,
- const char* bytes,
- const uint64_t size) {
- HHStateT<HH_TARGET> state(key);
- HHResult64 result;
- HighwayHashT(&state, bytes, size, &result);
- return result;
-}
-} // extern "C"
-
-template <TargetBits Target>
-void HighwayHash<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const size_t size,
- HHResult64* HH_RESTRICT hash) const {
- HHStateT<Target> state(key);
- HighwayHashT(&state, bytes, size, hash);
-}
-
-template <TargetBits Target>
-void HighwayHash<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const size_t size,
- HHResult128* HH_RESTRICT hash) const {
- HHStateT<Target> state(key);
- HighwayHashT(&state, bytes, size, hash);
-}
-
-template <TargetBits Target>
-void HighwayHash<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const size_t size,
- HHResult256* HH_RESTRICT hash) const {
- HHStateT<Target> state(key);
- HighwayHashT(&state, bytes, size, hash);
-}
-
-template <TargetBits Target>
-void HighwayHashCat<Target>::operator()(const HHKey& key,
- const StringView* HH_RESTRICT fragments,
- const size_t num_fragments,
- HHResult64* HH_RESTRICT hash) const {
- HighwayHashCatT<Target> cat(key);
- for (size_t i = 0; i < num_fragments; ++i) {
- cat.Append(fragments[i].data, fragments[i].num_bytes);
- }
- cat.Finalize(hash);
-}
-
-template <TargetBits Target>
-void HighwayHashCat<Target>::operator()(const HHKey& key,
- const StringView* HH_RESTRICT fragments,
- const size_t num_fragments,
- HHResult128* HH_RESTRICT hash) const {
- HighwayHashCatT<Target> cat(key);
- for (size_t i = 0; i < num_fragments; ++i) {
- cat.Append(fragments[i].data, fragments[i].num_bytes);
- }
- cat.Finalize(hash);
-}
-
-template <TargetBits Target>
-void HighwayHashCat<Target>::operator()(const HHKey& key,
- const StringView* HH_RESTRICT fragments,
- const size_t num_fragments,
- HHResult256* HH_RESTRICT hash) const {
- HighwayHashCatT<Target> cat(key);
- for (size_t i = 0; i < num_fragments; ++i) {
- cat.Append(fragments[i].data, fragments[i].num_bytes);
- }
- cat.Finalize(hash);
-}
-
-// Instantiate for the current target.
-template struct HighwayHash<HH_TARGET>;
-template struct HighwayHashCat<HH_TARGET>;
-
-} // namespace highwayhash
-#endif // HH_DISABLE_TARGET_SPECIFIC
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#include "highwayhash/highwayhash_target.h"
+
+#include "highwayhash/highwayhash.h"
+
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+namespace highwayhash {
+
+extern "C" {
+uint64_t HH_ADD_TARGET_SUFFIX(HighwayHash64_)(const HHKey key,
+ const char* bytes,
+ const uint64_t size) {
+ HHStateT<HH_TARGET> state(key);
+ HHResult64 result;
+ HighwayHashT(&state, bytes, size, &result);
+ return result;
+}
+} // extern "C"
+
+template <TargetBits Target>
+void HighwayHash<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const size_t size,
+ HHResult64* HH_RESTRICT hash) const {
+ HHStateT<Target> state(key);
+ HighwayHashT(&state, bytes, size, hash);
+}
+
+template <TargetBits Target>
+void HighwayHash<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const size_t size,
+ HHResult128* HH_RESTRICT hash) const {
+ HHStateT<Target> state(key);
+ HighwayHashT(&state, bytes, size, hash);
+}
+
+template <TargetBits Target>
+void HighwayHash<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const size_t size,
+ HHResult256* HH_RESTRICT hash) const {
+ HHStateT<Target> state(key);
+ HighwayHashT(&state, bytes, size, hash);
+}
+
+template <TargetBits Target>
+void HighwayHashCat<Target>::operator()(const HHKey& key,
+ const StringView* HH_RESTRICT fragments,
+ const size_t num_fragments,
+ HHResult64* HH_RESTRICT hash) const {
+ HighwayHashCatT<Target> cat(key);
+ for (size_t i = 0; i < num_fragments; ++i) {
+ cat.Append(fragments[i].data, fragments[i].num_bytes);
+ }
+ cat.Finalize(hash);
+}
+
+template <TargetBits Target>
+void HighwayHashCat<Target>::operator()(const HHKey& key,
+ const StringView* HH_RESTRICT fragments,
+ const size_t num_fragments,
+ HHResult128* HH_RESTRICT hash) const {
+ HighwayHashCatT<Target> cat(key);
+ for (size_t i = 0; i < num_fragments; ++i) {
+ cat.Append(fragments[i].data, fragments[i].num_bytes);
+ }
+ cat.Finalize(hash);
+}
+
+template <TargetBits Target>
+void HighwayHashCat<Target>::operator()(const HHKey& key,
+ const StringView* HH_RESTRICT fragments,
+ const size_t num_fragments,
+ HHResult256* HH_RESTRICT hash) const {
+ HighwayHashCatT<Target> cat(key);
+ for (size_t i = 0; i < num_fragments; ++i) {
+ cat.Append(fragments[i].data, fragments[i].num_bytes);
+ }
+ cat.Finalize(hash);
+}
+
+// Instantiate for the current target.
+template struct HighwayHash<HH_TARGET>;
+template struct HighwayHashCat<HH_TARGET>;
+
+} // namespace highwayhash
+#endif // HH_DISABLE_TARGET_SPECIFIC
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_target.h b/contrib/libs/highwayhash/highwayhash/highwayhash_target.h
index 3d6f33f236..08b803f191 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_target.h
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_target.h
@@ -1,91 +1,91 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
-#define HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
-
-// Adapter for the InstructionSets::Run dispatcher, which invokes the best
-// implementations available on the current CPU.
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/hh_types.h"
-
-namespace highwayhash {
-
-// Usage: InstructionSets::Run<HighwayHash>(key, bytes, size, hash).
-// This incurs some small dispatch overhead. If the entire program is compiled
-// for the target CPU, you can instead call HighwayHashT directly to avoid any
-// overhead. This template is instantiated in the source file, which is
-// compiled once for every target with the required flags (e.g. -mavx2).
-template <TargetBits Target>
-struct HighwayHash {
- // Stores a 64/128/256 bit hash of "bytes" using the HighwayHashT
- // implementation for the "Target" CPU. The hash result is identical
- // regardless of which implementation is used.
- //
- // "key" is a (randomly generated or hard-coded) HHKey.
- // "bytes" is the data to hash (possibly unaligned).
- // "size" is the number of bytes to hash; we do not read any additional bytes.
- // "hash" is a HHResult* (either 64, 128 or 256 bits).
- //
- // HighwayHash is a strong pseudorandom function with security claims
- // [https://arxiv.org/abs/1612.06257]. It is intended as a safer
- // general-purpose hash, 5x faster than SipHash and 10x faster than BLAKE2.
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const size_t size, HHResult64* HH_RESTRICT hash) const;
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const size_t size, HHResult128* HH_RESTRICT hash) const;
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const size_t size, HHResult256* HH_RESTRICT hash) const;
-};
-
-// Replacement for C++17 std::string_view that avoids dependencies.
-// A struct requires fewer allocations when calling HighwayHashCat with
-// non-const "num_fragments".
-struct StringView {
- const char* data; // not necessarily aligned/padded
- size_t num_bytes; // possibly zero
-};
-
-// Note: this interface avoids dispatch overhead per fragment.
-template <TargetBits Target>
-struct HighwayHashCat {
- // Stores a 64/128/256 bit hash of all "num_fragments" "fragments" using the
- // HighwayHashCatT implementation for "Target". The hash result is identical
- // to HighwayHash of the flattened data, regardless of Target.
- //
- // "key" is a (randomly generated or hard-coded) HHKey.
- // "fragments" contain unaligned pointers and the number of valid bytes.
- // "num_fragments" indicates the number of entries in "fragments".
- // "hash" is a HHResult* (either 64, 128 or 256 bits).
- void operator()(const HHKey& key, const StringView* HH_RESTRICT fragments,
- const size_t num_fragments,
- HHResult64* HH_RESTRICT hash) const;
- void operator()(const HHKey& key, const StringView* HH_RESTRICT fragments,
- const size_t num_fragments,
- HHResult128* HH_RESTRICT hash) const;
- void operator()(const HHKey& key, const StringView* HH_RESTRICT fragments,
- const size_t num_fragments,
- HHResult256* HH_RESTRICT hash) const;
-};
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
+#define HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
+
+// Adapter for the InstructionSets::Run dispatcher, which invokes the best
+// implementations available on the current CPU.
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/hh_types.h"
+
+namespace highwayhash {
+
+// Usage: InstructionSets::Run<HighwayHash>(key, bytes, size, hash).
+// This incurs some small dispatch overhead. If the entire program is compiled
+// for the target CPU, you can instead call HighwayHashT directly to avoid any
+// overhead. This template is instantiated in the source file, which is
+// compiled once for every target with the required flags (e.g. -mavx2).
+template <TargetBits Target>
+struct HighwayHash {
+ // Stores a 64/128/256 bit hash of "bytes" using the HighwayHashT
+ // implementation for the "Target" CPU. The hash result is identical
+ // regardless of which implementation is used.
+ //
+ // "key" is a (randomly generated or hard-coded) HHKey.
+ // "bytes" is the data to hash (possibly unaligned).
+ // "size" is the number of bytes to hash; we do not read any additional bytes.
+ // "hash" is a HHResult* (either 64, 128 or 256 bits).
+ //
+ // HighwayHash is a strong pseudorandom function with security claims
+ // [https://arxiv.org/abs/1612.06257]. It is intended as a safer
+ // general-purpose hash, 5x faster than SipHash and 10x faster than BLAKE2.
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const size_t size, HHResult64* HH_RESTRICT hash) const;
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const size_t size, HHResult128* HH_RESTRICT hash) const;
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const size_t size, HHResult256* HH_RESTRICT hash) const;
+};
+
+// Replacement for C++17 std::string_view that avoids dependencies.
+// A struct requires fewer allocations when calling HighwayHashCat with
+// non-const "num_fragments".
+struct StringView {
+ const char* data; // not necessarily aligned/padded
+ size_t num_bytes; // possibly zero
+};
+
+// Note: this interface avoids dispatch overhead per fragment.
+template <TargetBits Target>
+struct HighwayHashCat {
+ // Stores a 64/128/256 bit hash of all "num_fragments" "fragments" using the
+ // HighwayHashCatT implementation for "Target". The hash result is identical
+ // to HighwayHash of the flattened data, regardless of Target.
+ //
+ // "key" is a (randomly generated or hard-coded) HHKey.
+ // "fragments" contain unaligned pointers and the number of valid bytes.
+ // "num_fragments" indicates the number of entries in "fragments".
+ // "hash" is a HHResult* (either 64, 128 or 256 bits).
+ void operator()(const HHKey& key, const StringView* HH_RESTRICT fragments,
+ const size_t num_fragments,
+ HHResult64* HH_RESTRICT hash) const;
+ void operator()(const HHKey& key, const StringView* HH_RESTRICT fragments,
+ const size_t num_fragments,
+ HHResult128* HH_RESTRICT hash) const;
+ void operator()(const HHKey& key, const StringView* HH_RESTRICT fragments,
+ const size_t num_fragments,
+ HHResult256* HH_RESTRICT hash) const;
+};
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_test.cc b/contrib/libs/highwayhash/highwayhash/highwayhash_test.cc
index d7f914af78..b0f8b88712 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_test.cc
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_test.cc
@@ -1,388 +1,388 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Ensures each implementation of HighwayHash returns consistent and unchanging
-// hash values.
-
-#include "highwayhash/highwayhash_test_target.h"
-
-#include <stddef.h>
-#include <atomic>
-#include <cstdio>
-#include <cstdlib>
-#include <vector>
-
-#ifdef HH_GOOGLETEST
-#include "testing/base/public/gunit.h"
-#endif
-
-#include "highwayhash/data_parallel.h"
-#include "highwayhash/instruction_sets.h"
-
-// Define to nonzero in order to print the (new) golden outputs.
-#define PRINT_RESULTS 0
-
-namespace highwayhash {
-namespace {
-
-// Known-good outputs are verified for all lengths in [0, 64].
-const size_t kMaxSize = 64;
-
-#if PRINT_RESULTS
-void Print(const HHResult64 result) { printf("0x%016lXull,\n", result); }
-
-// For HHResult128/256.
-template <int kNumLanes>
-void Print(const HHResult64 (&result)[kNumLanes]) {
- printf("{ ");
- for (int i = 0; i < kNumLanes; ++i) {
- if (i != 0) {
- printf(", ");
- }
- printf("0x%016lXull", result[i]);
- }
- printf("},\n");
-}
-#endif // PRINT_RESULTS
-
-// Called when any test fails; exits immediately because one mismatch usually
-// implies many others.
-void OnFailure(const char* target_name, const size_t size) {
- printf("Mismatch at size %zu\n", size);
-#ifdef HH_GOOGLETEST
- EXPECT_TRUE(false);
-#endif
- exit(1);
-}
-
-// Verifies every combination of implementation and input size. Returns which
-// targets were run/verified.
-template <typename Result>
-TargetBits VerifyImplementations(const Result (&known_good)[kMaxSize + 1]) {
- const HHKey key = {0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL,
- 0x1716151413121110ULL, 0x1F1E1D1C1B1A1918ULL};
-
- TargetBits targets = ~0U;
-
- // For each test input: empty string, 00, 00 01, ...
- char in[kMaxSize + 1] = {0};
- // Fast enough that we don't need a thread pool.
- for (uint64_t size = 0; size <= kMaxSize; ++size) {
- in[size] = static_cast<char>(size);
-#if PRINT_RESULTS
- Result actual;
- targets &= InstructionSets::Run<HighwayHash>(key, in, size, &actual);
- Print(actual);
-#else
- const Result* expected = &known_good[size];
- targets &= InstructionSets::RunAll<HighwayHashTest>(key, in, size, expected,
- &OnFailure);
-#endif
- }
- return targets;
-}
-
-// Cat
-
-void OnCatFailure(const char* target_name, const size_t size) {
- printf("Cat mismatch at size %zu\n", size);
-#ifdef HH_GOOGLETEST
- EXPECT_TRUE(false);
-#endif
- exit(1);
-}
-
-// Returns which targets were run/verified.
-template <typename Result>
-TargetBits VerifyCat(ThreadPool* pool) {
- // Reversed order vs prior test.
- const HHKey key = {0x1F1E1D1C1B1A1918ULL, 0x1716151413121110ULL,
- 0x0F0E0D0C0B0A0908ULL, 0x0706050403020100ULL};
-
- const size_t kMaxSize = 3 * 35;
- std::vector<char> flat;
- flat.reserve(kMaxSize);
- srand(129);
- for (size_t size = 0; size < kMaxSize; ++size) {
- flat.push_back(static_cast<char>(rand() & 0xFF));
- }
-
- std::atomic<TargetBits> targets{~0U};
-
- pool->Run(0, kMaxSize, [&key, &flat, &targets](const uint32_t i) {
- Result dummy;
- targets.fetch_and(InstructionSets::RunAll<HighwayHashCatTest>(
- key, flat.data(), i, &dummy, &OnCatFailure));
- });
- return targets.load();
-}
-
-const HHResult64 kExpected64[kMaxSize + 1] = {
- 0x907A56DE22C26E53ull, 0x7EAB43AAC7CDDD78ull, 0xB8D0569AB0B53D62ull,
- 0x5C6BEFAB8A463D80ull, 0xF205A46893007EDAull, 0x2B8A1668E4A94541ull,
- 0xBD4CCC325BEFCA6Full, 0x4D02AE1738F59482ull, 0xE1205108E55F3171ull,
- 0x32D2644EC77A1584ull, 0xF6E10ACDB103A90Bull, 0xC3BBF4615B415C15ull,
- 0x243CC2040063FA9Cull, 0xA89A58CE65E641FFull, 0x24B031A348455A23ull,
- 0x40793F86A449F33Bull, 0xCFAB3489F97EB832ull, 0x19FE67D2C8C5C0E2ull,
- 0x04DD90A69C565CC2ull, 0x75D9518E2371C504ull, 0x38AD9B1141D3DD16ull,
- 0x0264432CCD8A70E0ull, 0xA9DB5A6288683390ull, 0xD7B05492003F028Cull,
- 0x205F615AEA59E51Eull, 0xEEE0C89621052884ull, 0x1BFC1A93A7284F4Full,
- 0x512175B5B70DA91Dull, 0xF71F8976A0A2C639ull, 0xAE093FEF1F84E3E7ull,
- 0x22CA92B01161860Full, 0x9FC7007CCF035A68ull, 0xA0C964D9ECD580FCull,
- 0x2C90F73CA03181FCull, 0x185CF84E5691EB9Eull, 0x4FC1F5EF2752AA9Bull,
- 0xF5B7391A5E0A33EBull, 0xB9B84B83B4E96C9Cull, 0x5E42FE712A5CD9B4ull,
- 0xA150F2F90C3F97DCull, 0x7FA522D75E2D637Dull, 0x181AD0CC0DFFD32Bull,
- 0x3889ED981E854028ull, 0xFB4297E8C586EE2Dull, 0x6D064A45BB28059Cull,
- 0x90563609B3EC860Cull, 0x7AA4FCE94097C666ull, 0x1326BAC06B911E08ull,
- 0xB926168D2B154F34ull, 0x9919848945B1948Dull, 0xA2A98FC534825EBEull,
- 0xE9809095213EF0B6ull, 0x582E5483707BC0E9ull, 0x086E9414A88A6AF5ull,
- 0xEE86B98D20F6743Dull, 0xF89B7FF609B1C0A7ull, 0x4C7D9CC19E22C3E8ull,
- 0x9A97005024562A6Full, 0x5DD41CF423E6EBEFull, 0xDF13609C0468E227ull,
- 0x6E0DA4F64188155Aull, 0xB755BA4B50D7D4A1ull, 0x887A3484647479BDull,
- 0xAB8EEBE9BF2139A0ull, 0x75542C5D4CD2A6FFull};
-
-const HHResult128 kExpected128[kMaxSize + 1] = {
- {0x0679D1E884C28A7Cull, 0x2BCA2547F904748Dull},
- {0x7F3A39BCC2D897B9ull, 0x4A7E113CA064D91Full},
- {0x6AB34B92C5AB85BFull, 0xED7AC546689D76C2ull},
- {0xAC6AF8405A4A7DBEull, 0xD78FB7953256C3E1ull},
- {0x5A6E8CF789B86448ull, 0x834EF47C1BEDC218ull},
- {0x8EBFE0B573F425A3ull, 0xBCFCC410CB84325Aull},
- {0xA1E19717CAB8F1D6ull, 0x2AA50671881F877Dull},
- {0x0B595302950DA1ECull, 0x46932DE27204B388ull},
- {0x02FB033F200F89D4ull, 0xFEC3D7BB3B421F92ull},
- {0x0A5479D46CC1EADEull, 0x0C16A2D5A0F1C3DEull},
- {0xF759E41DDD621106ull, 0xB43D70116E004750ull},
- {0x980010BC36A4E98Full, 0x27479317AE00BBD1ull},
- {0x3BABF3B23761A379ull, 0xACCDC28E0256F326ull},
- {0x5780CD04269E142Eull, 0xBB70EE3F23BDEDA9ull},
- {0x4A401F1937E99EC3ull, 0x4B3D1385D6B4E214ull},
- {0x045C6EDE080E2CB0ull, 0x7327B45D2132DC89ull},
- {0x97E1624BEB1C1756ull, 0xB7137E1B69D45024ull},
- {0x31DBA8E3DB0BF012ull, 0x3E66E6A78A729B16ull},
- {0x34D6DF1B5D8AF2A7ull, 0x4F1A47FCBC39EB55ull},
- {0xE2C6BE2D47E5DCBCull, 0xD2FF85284E307C1Full},
- {0xDA681E06098EC892ull, 0x71AD98355019FED1ull},
- {0xC4FBD72B1F2FC30Bull, 0x327549B6C9FDEDD5ull},
- {0x14F429D1C20F0EB5ull, 0x228B40C92F3FA369ull},
- {0xF5C9535333206D01ull, 0xB6FC46FCCA65F9CCull},
- {0x3049FAD9DB729D2Dull, 0xB84C931C45F781EAull},
- {0x7C6FFE6F3706DC04ull, 0x4F94583806AE3C62ull},
- {0x9EF95EB28BE1CCE0ull, 0xAD9D5B96A0D15BFEull},
- {0x63D0ED54AF2985E6ull, 0xDFAFB1B6485C1B01ull},
- {0xA46C8A2FE498D46Cull, 0xF4DBAEC0FF03BAD6ull},
- {0xED978A0FBB3E5158ull, 0x060D144D57FBE6FDull},
- {0x53F1D80C8922E4E5ull, 0x1324880D932140C9ull},
- {0xDD363B03563870CEull, 0x0DFDB79F4F34184Bull},
- {0x4E702701AE65DB38ull, 0x1B67E0A2E2DBFB04ull},
- {0x240DA388551D0822ull, 0x2FF1BB584AC4BD61ull},
- {0x3FAFB8B7C26499ABull, 0x072516308E889132ull},
- {0x0AB452339406AB22ull, 0x751DBB7FF9472D42ull},
- {0x83BA782DB6EB1186ull, 0x4391544D9318DC29ull},
- {0x25077ECDAAB201E8ull, 0x695E0E95446D63A2ull},
- {0x1AF0BF12F91F17D4ull, 0x5BB8FF299368D22Cull},
- {0x338C09CBAF701E38ull, 0xA7D24D5E7C06DC78ull},
- {0x5AB58D6555D28B56ull, 0xE781413A9AE1310Full},
- {0xB0281CD10BCA7B89ull, 0xF49873B45C0F7274ull},
- {0x67EEBD6D71E57B06ull, 0x9421CB1DB54EEDDFull},
- {0x00DAB867E37EDA65ull, 0x6477E454191E213Full},
- {0x9AF9C4817C24C82Eull, 0xAE3A73522F311EEBull},
- {0xD8A334E30D23C6E6ull, 0xAF57EF86CCCF12FFull},
- {0x0353A48FC9E139DDull, 0x27D5626170A7DD0Full},
- {0x0DA12E888EB61876ull, 0x67B17DF10CB365CDull},
- {0x967CD764883A5E85ull, 0x570D7C9A774A6AB4ull},
- {0xA8DF13980C81E533ull, 0x9C33FE4797F87F1Aull},
- {0xCABB59F53AE75FF2ull, 0x6D25512E77172E7Aull},
- {0xB24E7F0C7DA62BE7ull, 0x2442F94890F57D89ull},
- {0x7DCBA0A5B9689BBDull, 0x700FC8D13DA4CC60ull},
- {0x1E8E014B97A9F828ull, 0xF858EFCA33E8A502ull},
- {0x4DAF4E31F34D10C7ull, 0x47E382D0A5A8C613ull},
- {0x577CAB4EF626BB28ull, 0xF6ED27E594C5795Full},
- {0x989188C958586C96ull, 0x8B3A2CB0D5B48FD9ull},
- {0x13CC58F5A076C088ull, 0x932A0FD21D4B422Cull},
- {0xD067380DAD885647ull, 0xC1020E396B31BB4Aull},
- {0x47D05A73072758D0ull, 0x5CF6075A0AEB5D78ull},
- {0x54441D7AE94E2D4Eull, 0x3B4F67953ABD3EA4ull},
- {0xEDD4250C3733EEBCull, 0x26E365AA1167C723ull},
- {0x92D02D2A641DA598ull, 0x3DAF5EB24A0C2A94ull},
- {0xAE6CF7FE2D76CA56ull, 0xC7918532A42D2F5Dull},
- {0xAD24762A08D96F1Bull, 0x729083EC59FA8DF7ull}};
-
-const HHResult256 kExpected256[kMaxSize + 1] = {
- {0xC6DC0C823434863Full, 0x6A42CCB644CBFAD9ull, 0x18DEF6A60EA5D873ull,
- 0x3596F663D00D1225ull},
- {0x00518B3D2BD22424ull, 0xE5791619BF612E97ull, 0xF4DAF07017FAF99Dull,
- 0xE36AE62C5509B5D6ull},
- {0x81021CC5067D8526ull, 0xBEEFC1BC87A6911Aull, 0xE2AEC605F80657FEull,
- 0x3C6576B5DF982327ull},
- {0x118D72C0B5DB2C70ull, 0x0BE2E64BF538CA74ull, 0x667B33FE41DDAA74ull,
- 0xB6199539303E13E1ull},
- {0x4AC9B8B2E4FD873Bull, 0xDE0FE265A45FFC97ull, 0x1FC1476F896ADA3Bull,
- 0x7680B4AE30B371E7ull},
- {0x518ABC6B5E88214Full, 0xFD62A05B2B06026Bull, 0x9C978E8B38DBE795ull,
- 0x41412401886FF054ull},
- {0x2DEDEF0832BEA7D9ull, 0x44EFE0AEAB7944FCull, 0x09AA7C9374A1E980ull,
- 0x714DB8B507C507FBull},
- {0x6FA2135DE3D3D3AAull, 0xC0EEA9A890E36156ull, 0xFAC1DB8C817DB095ull,
- 0x7B42789096836327ull},
- {0x27257C518B1FFC5Cull, 0x26CC8E669DA1AB0Full, 0xCD7B17C661A0A680ull,
- 0x31D0A7EC0AA3B9BFull},
- {0xB91869900A1AF26Cull, 0x95B0D74B7FF20B43ull, 0x2A6CABF6F931B575ull,
- 0x69734DC9E66A1965ull},
- {0xDD7DA31F5C4DD30Full, 0x08940D249A0A7B69ull, 0xAE7D3AD1C5EA81F2ull,
- 0x96701DB5C6602B21ull},
- {0x2E4A230847E64687ull, 0xF96176C38E48B038ull, 0x9ED0B88A3026E1BCull,
- 0x9AAB5DCA46FCFE19ull},
- {0x3E5CF04BFBAC2642ull, 0x591A3581001709DFull, 0xA0288F5FA63C10A2ull,
- 0x85B94D3641A2C108ull},
- {0x454A95FAD8901350ull, 0x5546E8E75D2AC833ull, 0xCF5FF2ACB4B5F2C1ull,
- 0x14F314318028D62Eull},
- {0x0DED251FB81F34A9ull, 0xC42111DB31618AA6ull, 0xC1C3352B70B00C5Dull,
- 0xDC8947DBC398F0C2ull},
- {0xC591A100AB4E9E72ull, 0x4CCFD2A7B0D8D911ull, 0x6FEDFDDE1BA3F770ull,
- 0x03E5C5A2F6E708A1ull},
- {0x537C42CC5E7B448Aull, 0xA7343E04249B2231ull, 0x2CB51D697EFE9B6Dull,
- 0x589D83141A699A97ull},
- {0x3F7E6EA60343B870ull, 0x4E27E907E296D4D7ull, 0x87525BF1AABBF794ull,
- 0x6B03C4DC206EC628ull},
- {0x741BA4D7A856E03Cull, 0x3798422CB64C9AFAull, 0xB1D89C9720D33FDDull,
- 0x08DE607FC4E3B5C3ull},
- {0x77D77342C85BA466ull, 0xA01C603C58F6D97Eull, 0x342AF0A7309EA4EAull,
- 0x9C958EB3F6A64B94ull},
- {0x9EDCADDD1FFC763Full, 0xBD9BAA6E9BE936EFull, 0xAAB0F78F1A4A94F7ull,
- 0xE71D9CA601DA4C02ull},
- {0xE3AA0D0A422BF888ull, 0x07734C8173411035ull, 0x8A085019DE545AF6ull,
- 0xBC3C520B1221A779ull},
- {0x16170C02C5E5439Dull, 0x45C6004513BFC174ull, 0x35CF3AD65D225EC8ull,
- 0xE10BAA702D37C90Eull},
- {0x6BD63B47EA43ABC6ull, 0xCC08BE8A651E24C0ull, 0xB564F0FC6FF8998Aull,
- 0x3EE409A34232E589ull},
- {0xD6CEE5574355BB81ull, 0x8E31FF40B271A16Dull, 0xC3ECEDBEEACCCAE9ull,
- 0x19386CD3A23B92E9ull},
- {0x32475E05D248DBB1ull, 0xF2396A122830E72Cull, 0xB88395678C0DB899ull,
- 0x8BD410A22A247066ull},
- {0x0BFA3B3C4775EB43ull, 0x496596C36FB2A200ull, 0xA00F533EF150D7DDull,
- 0xB5D70BBCABB572C4ull},
- {0x932B0ED33ED691B1ull, 0xB58394EDCEA3C53Dull, 0xB935E0786B132755ull,
- 0x3E0998322B3F74BAull},
- {0xE21F2CE1BDD156A7ull, 0x764518A56E1363B5ull, 0x461251D3EC39B93Full,
- 0x33C1FE46C9664CC4ull},
- {0x8ABD3F6184C9CD7Dull, 0x8195816637017FC0ull, 0x284B3E93524765DEull,
- 0x56147BDBA9362D0Eull},
- {0x1F050672342807B6ull, 0x9B0AD1091A83910Dull, 0xF23AD4A58C3B1E21ull,
- 0xCC986EC0BEA16781ull},
- {0x053164DEF96B10CEull, 0x1D5ADA15E36D8F6Cull, 0x06FB43534C0472EFull,
- 0x021C0ED1FDEA0948ull},
- {0xF62BA4C5A665E602ull, 0x490D89FD89430C56ull, 0x18F423BE8A9B7E3Cull,
- 0x769E5DDA4DCAC619ull},
- {0xDABD25FAF07A6684ull, 0xACA85CD21536B927ull, 0xAC05E050B4E3D3D1ull,
- 0xBE427B2475CCD981ull},
- {0x89A2B35A34F89F8Cull, 0x1A0E51B2875D34E6ull, 0xBA573CF45E123919ull,
- 0x1C50815B08F1138Aull},
- {0x3390CCBE60F2AFF7ull, 0xD9E2D245643E79C2ull, 0x1104A78F85D3CDF5ull,
- 0x7E55F38F9C53A58Full},
- {0xC189AE1A9D456C0Eull, 0x06AA4C3D4204A40Full, 0x4B383405A9D451A9ull,
- 0x7EA34CBCAEF0C31Eull},
- {0xB45FA7CC19AE4DDFull, 0x306C418E9BA67420ull, 0xDF16D80D4D48C096ull,
- 0xD3169E50BC8D75CCull},
- {0x5894367013710C89ull, 0xD39EE6D584E76AF3ull, 0x5C55A414BCDDE505ull,
- 0x8FA97D561CB174BFull},
- {0x87355749D59F39DDull, 0x26B8B311E72C50F4ull, 0x1911A8CBCE53E37Bull,
- 0x5C256452C39B95F6ull},
- {0x8B9E87C9ABC82821ull, 0x12A5FC06B69CDC2Dull, 0xF95104FF805E5E1Dull,
- 0xE5D4D2257AD5592Eull},
- {0x5A89242B02E1E048ull, 0x771602AAD1880A7Eull, 0x0F34507608387843ull,
- 0x7AFB45F3EA4F0F24ull},
- {0x3BE3800150FDDE00ull, 0x7871908FF91AD81Aull, 0xA00E07F351BB15C1ull,
- 0x429658E7FD10D11Aull},
- {0x2B2B1A6CD1BA454Cull, 0xF19E8CA5C022308Aull, 0xAEFA0EB6F7C3CF74ull,
- 0x21F4330A5258E7C7ull},
- {0xD1C806622910A9BEull, 0xFE224EF598F541B1ull, 0xB95A435AEC4DD849ull,
- 0xD942A277AB57E68Eull},
- {0x16BF7116E8D2B328ull, 0xB37DC98EA931FC13ull, 0x18E8859A592C8C11ull,
- 0x11590F16C4C61716ull},
- {0xD046122D4C7B24AEull, 0xBD0899DFD7345611ull, 0x91AAECB50DE6DFF9ull,
- 0x6EDC4896BAA90FFAull},
- {0x2FE97B8135EA956Dull, 0xFBA50900FB4EF23Cull, 0x0BC907363F7EA368ull,
- 0xA5C982D3094BCEE2ull},
- {0x247BFB5BA3A0F245ull, 0x6ACBDD4AFFDB03EBull, 0xA4237427D373B619ull,
- 0xFA9C041D302B728Cull},
- {0xF93109909D6B80EFull, 0xD1321A6BEE302794ull, 0xD63E1E7985C458D3ull,
- 0x644CD44F6C6FDE95ull},
- {0xD0522C663FBE65B0ull, 0x78F366F302EA33F5ull, 0xB9ED66D1CB87C891ull,
- 0x0CEB2298BA9D1C1Aull},
- {0x60D60E9B569264E8ull, 0xE34447A5741417EAull, 0x04522108BDF3AFC3ull,
- 0x90F4FE2D585B25FAull},
- {0xAF411662AAB81B12ull, 0x3AD58EBBA1BA2F39ull, 0x73E0E8EB5879E37Dull,
- 0xCE0E8F8F613D3FC5ull},
- {0xCA756CB9E1FDF1C6ull, 0x89731D81712D34BDull, 0xBF520B2D830959C2ull,
- 0xD35ED12BB24CE9EFull},
- {0x5FB2B65ABF038045ull, 0x3F2D32F8532E14D6ull, 0x06443CC95CDD58C8ull,
- 0x30FC6FBE8CCE8EB8ull},
- {0x94A9774F02848D73ull, 0x83F9AFC4C0B48768ull, 0xDB7BF5FBD9B25A26ull,
- 0x7F7D50266FFA639Bull},
- {0x352A775C646259DDull, 0xB2B532B472539832ull, 0x9981AE050A2FB38Cull,
- 0xE13641E804F6DC00ull},
- {0x080E005A04E73352ull, 0x0314F6EA196A210Cull, 0x29EA80869CE307A4ull,
- 0x4FABEB9ADE04BE00ull},
- {0x5674A4A533335ADFull, 0x3C7C0650FF6C585Bull, 0x384E4F8246446812ull,
- 0xAE2DADA5E0EB6D81ull},
- {0xB6CE794A89B0A1F7ull, 0x0DC2B87EC9473CDDull, 0x349A006CA2899C88ull,
- 0x4B411CB7DF6BF33Cull},
- {0xD79BB5606CE6BDAFull, 0x4040EA447818A5C1ull, 0x53D58C5710475284ull,
- 0x3DA8730E092608BAull},
- {0x5900A2DAA12E085Cull, 0x80D490C510C493DDull, 0x4BDF17B0247C8D1Bull,
- 0xA8649490D6CFCE67ull},
- {0xFBDAB07B10180D47ull, 0xED6C196BDC43E292ull, 0xE7D494077FA2791Dull,
- 0xC7108D4FD01BBF85ull},
- {0x4365D6236E6AE467ull, 0xB3D540909D4308A5ull, 0xE38207ABD4588D68ull,
- 0xBBD42849A8C92313ull},
- {0x064DB5FE415126F5ull, 0x248AF8FB29A9C595ull, 0x508633A742B3FFF7ull,
- 0x24CFDCA800C34770ull}};
-
-void RunTests() {
- // TODO(janwas): detect number of cores.
- ThreadPool pool(4);
-
- TargetBits tested = ~0U;
- tested &= VerifyImplementations(kExpected64);
- tested &= VerifyImplementations(kExpected128);
- tested &= VerifyImplementations(kExpected256);
- // Any failure causes immediate exit, so apparently all succeeded.
- HH_TARGET_NAME::ForeachTarget(tested, [](const TargetBits target) {
- printf("%10s: OK\n", TargetName(target));
- });
-
- tested = ~0U;
- tested &= VerifyCat<HHResult64>(&pool);
- tested &= VerifyCat<HHResult128>(&pool);
- tested &= VerifyCat<HHResult256>(&pool);
- HH_TARGET_NAME::ForeachTarget(tested, [](const TargetBits target) {
- printf("%10sCat: OK\n", TargetName(target));
- });
-}
-
-#ifdef HH_GOOGLETEST
-TEST(HighwayhashTest, OutputMatchesExpectations) { RunTests(); }
-#endif
-
-} // namespace
-} // namespace highwayhash
-
-#ifndef HH_GOOGLETEST
-int main(int argc, char* argv[]) {
- highwayhash::RunTests();
- return 0;
-}
-#endif
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Ensures each implementation of HighwayHash returns consistent and unchanging
+// hash values.
+
+#include "highwayhash/highwayhash_test_target.h"
+
+#include <stddef.h>
+#include <atomic>
+#include <cstdio>
+#include <cstdlib>
+#include <vector>
+
+#ifdef HH_GOOGLETEST
+#include "testing/base/public/gunit.h"
+#endif
+
+#include "highwayhash/data_parallel.h"
+#include "highwayhash/instruction_sets.h"
+
+// Define to nonzero in order to print the (new) golden outputs.
+#define PRINT_RESULTS 0
+
+namespace highwayhash {
+namespace {
+
+// Known-good outputs are verified for all lengths in [0, 64].
+const size_t kMaxSize = 64;
+
+#if PRINT_RESULTS
+void Print(const HHResult64 result) { printf("0x%016lXull,\n", result); }
+
+// For HHResult128/256.
+template <int kNumLanes>
+void Print(const HHResult64 (&result)[kNumLanes]) {
+ printf("{ ");
+ for (int i = 0; i < kNumLanes; ++i) {
+ if (i != 0) {
+ printf(", ");
+ }
+ printf("0x%016lXull", result[i]);
+ }
+ printf("},\n");
+}
+#endif // PRINT_RESULTS
+
+// Called when any test fails; exits immediately because one mismatch usually
+// implies many others.
+void OnFailure(const char* target_name, const size_t size) {
+ printf("Mismatch at size %zu\n", size);
+#ifdef HH_GOOGLETEST
+ EXPECT_TRUE(false);
+#endif
+ exit(1);
+}
+
+// Verifies every combination of implementation and input size. Returns which
+// targets were run/verified.
+template <typename Result>
+TargetBits VerifyImplementations(const Result (&known_good)[kMaxSize + 1]) {
+ const HHKey key = {0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL,
+ 0x1716151413121110ULL, 0x1F1E1D1C1B1A1918ULL};
+
+ TargetBits targets = ~0U;
+
+ // For each test input: empty string, 00, 00 01, ...
+ char in[kMaxSize + 1] = {0};
+ // Fast enough that we don't need a thread pool.
+ for (uint64_t size = 0; size <= kMaxSize; ++size) {
+ in[size] = static_cast<char>(size);
+#if PRINT_RESULTS
+ Result actual;
+ targets &= InstructionSets::Run<HighwayHash>(key, in, size, &actual);
+ Print(actual);
+#else
+ const Result* expected = &known_good[size];
+ targets &= InstructionSets::RunAll<HighwayHashTest>(key, in, size, expected,
+ &OnFailure);
+#endif
+ }
+ return targets;
+}
+
+// Cat
+
+void OnCatFailure(const char* target_name, const size_t size) {
+ printf("Cat mismatch at size %zu\n", size);
+#ifdef HH_GOOGLETEST
+ EXPECT_TRUE(false);
+#endif
+ exit(1);
+}
+
+// Returns which targets were run/verified.
+template <typename Result>
+TargetBits VerifyCat(ThreadPool* pool) {
+ // Reversed order vs prior test.
+ const HHKey key = {0x1F1E1D1C1B1A1918ULL, 0x1716151413121110ULL,
+ 0x0F0E0D0C0B0A0908ULL, 0x0706050403020100ULL};
+
+ const size_t kMaxSize = 3 * 35;
+ std::vector<char> flat;
+ flat.reserve(kMaxSize);
+ srand(129);
+ for (size_t size = 0; size < kMaxSize; ++size) {
+ flat.push_back(static_cast<char>(rand() & 0xFF));
+ }
+
+ std::atomic<TargetBits> targets{~0U};
+
+ pool->Run(0, kMaxSize, [&key, &flat, &targets](const uint32_t i) {
+ Result dummy;
+ targets.fetch_and(InstructionSets::RunAll<HighwayHashCatTest>(
+ key, flat.data(), i, &dummy, &OnCatFailure));
+ });
+ return targets.load();
+}
+
+const HHResult64 kExpected64[kMaxSize + 1] = {
+ 0x907A56DE22C26E53ull, 0x7EAB43AAC7CDDD78ull, 0xB8D0569AB0B53D62ull,
+ 0x5C6BEFAB8A463D80ull, 0xF205A46893007EDAull, 0x2B8A1668E4A94541ull,
+ 0xBD4CCC325BEFCA6Full, 0x4D02AE1738F59482ull, 0xE1205108E55F3171ull,
+ 0x32D2644EC77A1584ull, 0xF6E10ACDB103A90Bull, 0xC3BBF4615B415C15ull,
+ 0x243CC2040063FA9Cull, 0xA89A58CE65E641FFull, 0x24B031A348455A23ull,
+ 0x40793F86A449F33Bull, 0xCFAB3489F97EB832ull, 0x19FE67D2C8C5C0E2ull,
+ 0x04DD90A69C565CC2ull, 0x75D9518E2371C504ull, 0x38AD9B1141D3DD16ull,
+ 0x0264432CCD8A70E0ull, 0xA9DB5A6288683390ull, 0xD7B05492003F028Cull,
+ 0x205F615AEA59E51Eull, 0xEEE0C89621052884ull, 0x1BFC1A93A7284F4Full,
+ 0x512175B5B70DA91Dull, 0xF71F8976A0A2C639ull, 0xAE093FEF1F84E3E7ull,
+ 0x22CA92B01161860Full, 0x9FC7007CCF035A68ull, 0xA0C964D9ECD580FCull,
+ 0x2C90F73CA03181FCull, 0x185CF84E5691EB9Eull, 0x4FC1F5EF2752AA9Bull,
+ 0xF5B7391A5E0A33EBull, 0xB9B84B83B4E96C9Cull, 0x5E42FE712A5CD9B4ull,
+ 0xA150F2F90C3F97DCull, 0x7FA522D75E2D637Dull, 0x181AD0CC0DFFD32Bull,
+ 0x3889ED981E854028ull, 0xFB4297E8C586EE2Dull, 0x6D064A45BB28059Cull,
+ 0x90563609B3EC860Cull, 0x7AA4FCE94097C666ull, 0x1326BAC06B911E08ull,
+ 0xB926168D2B154F34ull, 0x9919848945B1948Dull, 0xA2A98FC534825EBEull,
+ 0xE9809095213EF0B6ull, 0x582E5483707BC0E9ull, 0x086E9414A88A6AF5ull,
+ 0xEE86B98D20F6743Dull, 0xF89B7FF609B1C0A7ull, 0x4C7D9CC19E22C3E8ull,
+ 0x9A97005024562A6Full, 0x5DD41CF423E6EBEFull, 0xDF13609C0468E227ull,
+ 0x6E0DA4F64188155Aull, 0xB755BA4B50D7D4A1ull, 0x887A3484647479BDull,
+ 0xAB8EEBE9BF2139A0ull, 0x75542C5D4CD2A6FFull};
+
+const HHResult128 kExpected128[kMaxSize + 1] = {
+ {0x0679D1E884C28A7Cull, 0x2BCA2547F904748Dull},
+ {0x7F3A39BCC2D897B9ull, 0x4A7E113CA064D91Full},
+ {0x6AB34B92C5AB85BFull, 0xED7AC546689D76C2ull},
+ {0xAC6AF8405A4A7DBEull, 0xD78FB7953256C3E1ull},
+ {0x5A6E8CF789B86448ull, 0x834EF47C1BEDC218ull},
+ {0x8EBFE0B573F425A3ull, 0xBCFCC410CB84325Aull},
+ {0xA1E19717CAB8F1D6ull, 0x2AA50671881F877Dull},
+ {0x0B595302950DA1ECull, 0x46932DE27204B388ull},
+ {0x02FB033F200F89D4ull, 0xFEC3D7BB3B421F92ull},
+ {0x0A5479D46CC1EADEull, 0x0C16A2D5A0F1C3DEull},
+ {0xF759E41DDD621106ull, 0xB43D70116E004750ull},
+ {0x980010BC36A4E98Full, 0x27479317AE00BBD1ull},
+ {0x3BABF3B23761A379ull, 0xACCDC28E0256F326ull},
+ {0x5780CD04269E142Eull, 0xBB70EE3F23BDEDA9ull},
+ {0x4A401F1937E99EC3ull, 0x4B3D1385D6B4E214ull},
+ {0x045C6EDE080E2CB0ull, 0x7327B45D2132DC89ull},
+ {0x97E1624BEB1C1756ull, 0xB7137E1B69D45024ull},
+ {0x31DBA8E3DB0BF012ull, 0x3E66E6A78A729B16ull},
+ {0x34D6DF1B5D8AF2A7ull, 0x4F1A47FCBC39EB55ull},
+ {0xE2C6BE2D47E5DCBCull, 0xD2FF85284E307C1Full},
+ {0xDA681E06098EC892ull, 0x71AD98355019FED1ull},
+ {0xC4FBD72B1F2FC30Bull, 0x327549B6C9FDEDD5ull},
+ {0x14F429D1C20F0EB5ull, 0x228B40C92F3FA369ull},
+ {0xF5C9535333206D01ull, 0xB6FC46FCCA65F9CCull},
+ {0x3049FAD9DB729D2Dull, 0xB84C931C45F781EAull},
+ {0x7C6FFE6F3706DC04ull, 0x4F94583806AE3C62ull},
+ {0x9EF95EB28BE1CCE0ull, 0xAD9D5B96A0D15BFEull},
+ {0x63D0ED54AF2985E6ull, 0xDFAFB1B6485C1B01ull},
+ {0xA46C8A2FE498D46Cull, 0xF4DBAEC0FF03BAD6ull},
+ {0xED978A0FBB3E5158ull, 0x060D144D57FBE6FDull},
+ {0x53F1D80C8922E4E5ull, 0x1324880D932140C9ull},
+ {0xDD363B03563870CEull, 0x0DFDB79F4F34184Bull},
+ {0x4E702701AE65DB38ull, 0x1B67E0A2E2DBFB04ull},
+ {0x240DA388551D0822ull, 0x2FF1BB584AC4BD61ull},
+ {0x3FAFB8B7C26499ABull, 0x072516308E889132ull},
+ {0x0AB452339406AB22ull, 0x751DBB7FF9472D42ull},
+ {0x83BA782DB6EB1186ull, 0x4391544D9318DC29ull},
+ {0x25077ECDAAB201E8ull, 0x695E0E95446D63A2ull},
+ {0x1AF0BF12F91F17D4ull, 0x5BB8FF299368D22Cull},
+ {0x338C09CBAF701E38ull, 0xA7D24D5E7C06DC78ull},
+ {0x5AB58D6555D28B56ull, 0xE781413A9AE1310Full},
+ {0xB0281CD10BCA7B89ull, 0xF49873B45C0F7274ull},
+ {0x67EEBD6D71E57B06ull, 0x9421CB1DB54EEDDFull},
+ {0x00DAB867E37EDA65ull, 0x6477E454191E213Full},
+ {0x9AF9C4817C24C82Eull, 0xAE3A73522F311EEBull},
+ {0xD8A334E30D23C6E6ull, 0xAF57EF86CCCF12FFull},
+ {0x0353A48FC9E139DDull, 0x27D5626170A7DD0Full},
+ {0x0DA12E888EB61876ull, 0x67B17DF10CB365CDull},
+ {0x967CD764883A5E85ull, 0x570D7C9A774A6AB4ull},
+ {0xA8DF13980C81E533ull, 0x9C33FE4797F87F1Aull},
+ {0xCABB59F53AE75FF2ull, 0x6D25512E77172E7Aull},
+ {0xB24E7F0C7DA62BE7ull, 0x2442F94890F57D89ull},
+ {0x7DCBA0A5B9689BBDull, 0x700FC8D13DA4CC60ull},
+ {0x1E8E014B97A9F828ull, 0xF858EFCA33E8A502ull},
+ {0x4DAF4E31F34D10C7ull, 0x47E382D0A5A8C613ull},
+ {0x577CAB4EF626BB28ull, 0xF6ED27E594C5795Full},
+ {0x989188C958586C96ull, 0x8B3A2CB0D5B48FD9ull},
+ {0x13CC58F5A076C088ull, 0x932A0FD21D4B422Cull},
+ {0xD067380DAD885647ull, 0xC1020E396B31BB4Aull},
+ {0x47D05A73072758D0ull, 0x5CF6075A0AEB5D78ull},
+ {0x54441D7AE94E2D4Eull, 0x3B4F67953ABD3EA4ull},
+ {0xEDD4250C3733EEBCull, 0x26E365AA1167C723ull},
+ {0x92D02D2A641DA598ull, 0x3DAF5EB24A0C2A94ull},
+ {0xAE6CF7FE2D76CA56ull, 0xC7918532A42D2F5Dull},
+ {0xAD24762A08D96F1Bull, 0x729083EC59FA8DF7ull}};
+
+const HHResult256 kExpected256[kMaxSize + 1] = {
+ {0xC6DC0C823434863Full, 0x6A42CCB644CBFAD9ull, 0x18DEF6A60EA5D873ull,
+ 0x3596F663D00D1225ull},
+ {0x00518B3D2BD22424ull, 0xE5791619BF612E97ull, 0xF4DAF07017FAF99Dull,
+ 0xE36AE62C5509B5D6ull},
+ {0x81021CC5067D8526ull, 0xBEEFC1BC87A6911Aull, 0xE2AEC605F80657FEull,
+ 0x3C6576B5DF982327ull},
+ {0x118D72C0B5DB2C70ull, 0x0BE2E64BF538CA74ull, 0x667B33FE41DDAA74ull,
+ 0xB6199539303E13E1ull},
+ {0x4AC9B8B2E4FD873Bull, 0xDE0FE265A45FFC97ull, 0x1FC1476F896ADA3Bull,
+ 0x7680B4AE30B371E7ull},
+ {0x518ABC6B5E88214Full, 0xFD62A05B2B06026Bull, 0x9C978E8B38DBE795ull,
+ 0x41412401886FF054ull},
+ {0x2DEDEF0832BEA7D9ull, 0x44EFE0AEAB7944FCull, 0x09AA7C9374A1E980ull,
+ 0x714DB8B507C507FBull},
+ {0x6FA2135DE3D3D3AAull, 0xC0EEA9A890E36156ull, 0xFAC1DB8C817DB095ull,
+ 0x7B42789096836327ull},
+ {0x27257C518B1FFC5Cull, 0x26CC8E669DA1AB0Full, 0xCD7B17C661A0A680ull,
+ 0x31D0A7EC0AA3B9BFull},
+ {0xB91869900A1AF26Cull, 0x95B0D74B7FF20B43ull, 0x2A6CABF6F931B575ull,
+ 0x69734DC9E66A1965ull},
+ {0xDD7DA31F5C4DD30Full, 0x08940D249A0A7B69ull, 0xAE7D3AD1C5EA81F2ull,
+ 0x96701DB5C6602B21ull},
+ {0x2E4A230847E64687ull, 0xF96176C38E48B038ull, 0x9ED0B88A3026E1BCull,
+ 0x9AAB5DCA46FCFE19ull},
+ {0x3E5CF04BFBAC2642ull, 0x591A3581001709DFull, 0xA0288F5FA63C10A2ull,
+ 0x85B94D3641A2C108ull},
+ {0x454A95FAD8901350ull, 0x5546E8E75D2AC833ull, 0xCF5FF2ACB4B5F2C1ull,
+ 0x14F314318028D62Eull},
+ {0x0DED251FB81F34A9ull, 0xC42111DB31618AA6ull, 0xC1C3352B70B00C5Dull,
+ 0xDC8947DBC398F0C2ull},
+ {0xC591A100AB4E9E72ull, 0x4CCFD2A7B0D8D911ull, 0x6FEDFDDE1BA3F770ull,
+ 0x03E5C5A2F6E708A1ull},
+ {0x537C42CC5E7B448Aull, 0xA7343E04249B2231ull, 0x2CB51D697EFE9B6Dull,
+ 0x589D83141A699A97ull},
+ {0x3F7E6EA60343B870ull, 0x4E27E907E296D4D7ull, 0x87525BF1AABBF794ull,
+ 0x6B03C4DC206EC628ull},
+ {0x741BA4D7A856E03Cull, 0x3798422CB64C9AFAull, 0xB1D89C9720D33FDDull,
+ 0x08DE607FC4E3B5C3ull},
+ {0x77D77342C85BA466ull, 0xA01C603C58F6D97Eull, 0x342AF0A7309EA4EAull,
+ 0x9C958EB3F6A64B94ull},
+ {0x9EDCADDD1FFC763Full, 0xBD9BAA6E9BE936EFull, 0xAAB0F78F1A4A94F7ull,
+ 0xE71D9CA601DA4C02ull},
+ {0xE3AA0D0A422BF888ull, 0x07734C8173411035ull, 0x8A085019DE545AF6ull,
+ 0xBC3C520B1221A779ull},
+ {0x16170C02C5E5439Dull, 0x45C6004513BFC174ull, 0x35CF3AD65D225EC8ull,
+ 0xE10BAA702D37C90Eull},
+ {0x6BD63B47EA43ABC6ull, 0xCC08BE8A651E24C0ull, 0xB564F0FC6FF8998Aull,
+ 0x3EE409A34232E589ull},
+ {0xD6CEE5574355BB81ull, 0x8E31FF40B271A16Dull, 0xC3ECEDBEEACCCAE9ull,
+ 0x19386CD3A23B92E9ull},
+ {0x32475E05D248DBB1ull, 0xF2396A122830E72Cull, 0xB88395678C0DB899ull,
+ 0x8BD410A22A247066ull},
+ {0x0BFA3B3C4775EB43ull, 0x496596C36FB2A200ull, 0xA00F533EF150D7DDull,
+ 0xB5D70BBCABB572C4ull},
+ {0x932B0ED33ED691B1ull, 0xB58394EDCEA3C53Dull, 0xB935E0786B132755ull,
+ 0x3E0998322B3F74BAull},
+ {0xE21F2CE1BDD156A7ull, 0x764518A56E1363B5ull, 0x461251D3EC39B93Full,
+ 0x33C1FE46C9664CC4ull},
+ {0x8ABD3F6184C9CD7Dull, 0x8195816637017FC0ull, 0x284B3E93524765DEull,
+ 0x56147BDBA9362D0Eull},
+ {0x1F050672342807B6ull, 0x9B0AD1091A83910Dull, 0xF23AD4A58C3B1E21ull,
+ 0xCC986EC0BEA16781ull},
+ {0x053164DEF96B10CEull, 0x1D5ADA15E36D8F6Cull, 0x06FB43534C0472EFull,
+ 0x021C0ED1FDEA0948ull},
+ {0xF62BA4C5A665E602ull, 0x490D89FD89430C56ull, 0x18F423BE8A9B7E3Cull,
+ 0x769E5DDA4DCAC619ull},
+ {0xDABD25FAF07A6684ull, 0xACA85CD21536B927ull, 0xAC05E050B4E3D3D1ull,
+ 0xBE427B2475CCD981ull},
+ {0x89A2B35A34F89F8Cull, 0x1A0E51B2875D34E6ull, 0xBA573CF45E123919ull,
+ 0x1C50815B08F1138Aull},
+ {0x3390CCBE60F2AFF7ull, 0xD9E2D245643E79C2ull, 0x1104A78F85D3CDF5ull,
+ 0x7E55F38F9C53A58Full},
+ {0xC189AE1A9D456C0Eull, 0x06AA4C3D4204A40Full, 0x4B383405A9D451A9ull,
+ 0x7EA34CBCAEF0C31Eull},
+ {0xB45FA7CC19AE4DDFull, 0x306C418E9BA67420ull, 0xDF16D80D4D48C096ull,
+ 0xD3169E50BC8D75CCull},
+ {0x5894367013710C89ull, 0xD39EE6D584E76AF3ull, 0x5C55A414BCDDE505ull,
+ 0x8FA97D561CB174BFull},
+ {0x87355749D59F39DDull, 0x26B8B311E72C50F4ull, 0x1911A8CBCE53E37Bull,
+ 0x5C256452C39B95F6ull},
+ {0x8B9E87C9ABC82821ull, 0x12A5FC06B69CDC2Dull, 0xF95104FF805E5E1Dull,
+ 0xE5D4D2257AD5592Eull},
+ {0x5A89242B02E1E048ull, 0x771602AAD1880A7Eull, 0x0F34507608387843ull,
+ 0x7AFB45F3EA4F0F24ull},
+ {0x3BE3800150FDDE00ull, 0x7871908FF91AD81Aull, 0xA00E07F351BB15C1ull,
+ 0x429658E7FD10D11Aull},
+ {0x2B2B1A6CD1BA454Cull, 0xF19E8CA5C022308Aull, 0xAEFA0EB6F7C3CF74ull,
+ 0x21F4330A5258E7C7ull},
+ {0xD1C806622910A9BEull, 0xFE224EF598F541B1ull, 0xB95A435AEC4DD849ull,
+ 0xD942A277AB57E68Eull},
+ {0x16BF7116E8D2B328ull, 0xB37DC98EA931FC13ull, 0x18E8859A592C8C11ull,
+ 0x11590F16C4C61716ull},
+ {0xD046122D4C7B24AEull, 0xBD0899DFD7345611ull, 0x91AAECB50DE6DFF9ull,
+ 0x6EDC4896BAA90FFAull},
+ {0x2FE97B8135EA956Dull, 0xFBA50900FB4EF23Cull, 0x0BC907363F7EA368ull,
+ 0xA5C982D3094BCEE2ull},
+ {0x247BFB5BA3A0F245ull, 0x6ACBDD4AFFDB03EBull, 0xA4237427D373B619ull,
+ 0xFA9C041D302B728Cull},
+ {0xF93109909D6B80EFull, 0xD1321A6BEE302794ull, 0xD63E1E7985C458D3ull,
+ 0x644CD44F6C6FDE95ull},
+ {0xD0522C663FBE65B0ull, 0x78F366F302EA33F5ull, 0xB9ED66D1CB87C891ull,
+ 0x0CEB2298BA9D1C1Aull},
+ {0x60D60E9B569264E8ull, 0xE34447A5741417EAull, 0x04522108BDF3AFC3ull,
+ 0x90F4FE2D585B25FAull},
+ {0xAF411662AAB81B12ull, 0x3AD58EBBA1BA2F39ull, 0x73E0E8EB5879E37Dull,
+ 0xCE0E8F8F613D3FC5ull},
+ {0xCA756CB9E1FDF1C6ull, 0x89731D81712D34BDull, 0xBF520B2D830959C2ull,
+ 0xD35ED12BB24CE9EFull},
+ {0x5FB2B65ABF038045ull, 0x3F2D32F8532E14D6ull, 0x06443CC95CDD58C8ull,
+ 0x30FC6FBE8CCE8EB8ull},
+ {0x94A9774F02848D73ull, 0x83F9AFC4C0B48768ull, 0xDB7BF5FBD9B25A26ull,
+ 0x7F7D50266FFA639Bull},
+ {0x352A775C646259DDull, 0xB2B532B472539832ull, 0x9981AE050A2FB38Cull,
+ 0xE13641E804F6DC00ull},
+ {0x080E005A04E73352ull, 0x0314F6EA196A210Cull, 0x29EA80869CE307A4ull,
+ 0x4FABEB9ADE04BE00ull},
+ {0x5674A4A533335ADFull, 0x3C7C0650FF6C585Bull, 0x384E4F8246446812ull,
+ 0xAE2DADA5E0EB6D81ull},
+ {0xB6CE794A89B0A1F7ull, 0x0DC2B87EC9473CDDull, 0x349A006CA2899C88ull,
+ 0x4B411CB7DF6BF33Cull},
+ {0xD79BB5606CE6BDAFull, 0x4040EA447818A5C1ull, 0x53D58C5710475284ull,
+ 0x3DA8730E092608BAull},
+ {0x5900A2DAA12E085Cull, 0x80D490C510C493DDull, 0x4BDF17B0247C8D1Bull,
+ 0xA8649490D6CFCE67ull},
+ {0xFBDAB07B10180D47ull, 0xED6C196BDC43E292ull, 0xE7D494077FA2791Dull,
+ 0xC7108D4FD01BBF85ull},
+ {0x4365D6236E6AE467ull, 0xB3D540909D4308A5ull, 0xE38207ABD4588D68ull,
+ 0xBBD42849A8C92313ull},
+ {0x064DB5FE415126F5ull, 0x248AF8FB29A9C595ull, 0x508633A742B3FFF7ull,
+ 0x24CFDCA800C34770ull}};
+
+void RunTests() {
+ // TODO(janwas): detect number of cores.
+ ThreadPool pool(4);
+
+ TargetBits tested = ~0U;
+ tested &= VerifyImplementations(kExpected64);
+ tested &= VerifyImplementations(kExpected128);
+ tested &= VerifyImplementations(kExpected256);
+ // Any failure causes immediate exit, so apparently all succeeded.
+ HH_TARGET_NAME::ForeachTarget(tested, [](const TargetBits target) {
+ printf("%10s: OK\n", TargetName(target));
+ });
+
+ tested = ~0U;
+ tested &= VerifyCat<HHResult64>(&pool);
+ tested &= VerifyCat<HHResult128>(&pool);
+ tested &= VerifyCat<HHResult256>(&pool);
+ HH_TARGET_NAME::ForeachTarget(tested, [](const TargetBits target) {
+ printf("%10sCat: OK\n", TargetName(target));
+ });
+}
+
+#ifdef HH_GOOGLETEST
+TEST(HighwayhashTest, OutputMatchesExpectations) { RunTests(); }
+#endif
+
+} // namespace
+} // namespace highwayhash
+
+#ifndef HH_GOOGLETEST
+int main(int argc, char* argv[]) {
+ highwayhash::RunTests();
+ return 0;
+}
+#endif
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_test_avx2.cc b/contrib/libs/highwayhash/highwayhash/highwayhash_test_avx2.cc
index 6e12132e8c..f1efe0b5f0 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_test_avx2.cc
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_test_avx2.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME AVX2
-#include "highwayhash/highwayhash_test_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME AVX2
+#include "highwayhash/highwayhash_test_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_test_portable.cc b/contrib/libs/highwayhash/highwayhash/highwayhash_test_portable.cc
index e5bee564a7..04930a7e12 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_test_portable.cc
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_test_portable.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME Portable
-#include "highwayhash/highwayhash_test_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME Portable
+#include "highwayhash/highwayhash_test_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_test_sse41.cc b/contrib/libs/highwayhash/highwayhash/highwayhash_test_sse41.cc
index 1ae43bcca9..2d6e83d66f 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_test_sse41.cc
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_test_sse41.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME SSE41
-#include "highwayhash/highwayhash_test_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME SSE41
+#include "highwayhash/highwayhash_test_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.cc b/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.cc
index b00704b83c..701c14b927 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.cc
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.cc
@@ -1,211 +1,211 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#include "highwayhash/highwayhash_test_target.h"
-
-#include "highwayhash/highwayhash.h"
-
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-namespace highwayhash {
-namespace {
-
-void NotifyIfUnequal(const size_t size, const HHResult64& expected,
- const HHResult64& actual, const HHNotify notify) {
- if (expected != actual) {
- (*notify)(TargetName(HH_TARGET), size);
- }
-}
-
-// Overload for HHResult128 or HHResult256 (arrays).
-template <size_t kNumLanes>
-void NotifyIfUnequal(const size_t size, const uint64_t (&expected)[kNumLanes],
- const uint64_t (&actual)[kNumLanes],
- const HHNotify notify) {
- for (size_t i = 0; i < kNumLanes; ++i) {
- if (expected[i] != actual[i]) {
- (*notify)(TargetName(HH_TARGET), size);
- return;
- }
- }
-}
-
-// Shared logic for all HighwayHashTest::operator() overloads.
-template <typename Result>
-void TestHighwayHash(HHStateT<HH_TARGET>* HH_RESTRICT state,
- const char* HH_RESTRICT bytes, const size_t size,
- const Result* expected, const HHNotify notify) {
- Result actual;
- HighwayHashT(state, bytes, size, &actual);
- NotifyIfUnequal(size, *expected, actual, notify);
-}
-
-// Shared logic for all HighwayHashCatTest::operator() overloads.
-template <typename Result>
-void TestHighwayHashCat(const HHKey& key, const char* HH_RESTRICT bytes,
- const size_t size, const Result* expected,
- const HHNotify notify) {
- // Slightly faster to compute the expected prefix hashes only once.
- // Use new instead of vector to avoid headers with inline functions.
- Result* results = new Result[size + 1];
- for (size_t i = 0; i <= size; ++i) {
- HHStateT<HH_TARGET> state_flat(key);
- HighwayHashT(&state_flat, bytes, i, &results[i]);
- }
-
- // Splitting into three fragments/Append should cover all codepaths.
- const size_t max_fragment_size = size / 3;
- for (size_t size1 = 0; size1 < max_fragment_size; ++size1) {
- for (size_t size2 = 0; size2 < max_fragment_size; ++size2) {
- for (size_t size3 = 0; size3 < max_fragment_size; ++size3) {
- HighwayHashCatT<HH_TARGET> cat(key);
- const char* pos = bytes;
- cat.Append(pos, size1);
- pos += size1;
- cat.Append(pos, size2);
- pos += size2;
- cat.Append(pos, size3);
- pos += size3;
-
- Result result_cat;
- cat.Finalize(&result_cat);
-
- const size_t total_size = pos - bytes;
- NotifyIfUnequal(total_size, results[total_size], result_cat, notify);
- }
- }
- }
-
- delete[] results;
-}
-
-} // namespace
-
-template <TargetBits Target>
-void HighwayHashTest<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const size_t size,
- const HHResult64* expected,
- const HHNotify notify) const {
- HHStateT<Target> state(key);
- TestHighwayHash(&state, bytes, size, expected, notify);
-}
-
-template <TargetBits Target>
-void HighwayHashTest<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const size_t size,
- const HHResult128* expected,
- const HHNotify notify) const {
- HHStateT<Target> state(key);
- TestHighwayHash(&state, bytes, size, expected, notify);
-}
-
-template <TargetBits Target>
-void HighwayHashTest<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const size_t size,
- const HHResult256* expected,
- const HHNotify notify) const {
- HHStateT<Target> state(key);
- TestHighwayHash(&state, bytes, size, expected, notify);
-}
-
-template <TargetBits Target>
-void HighwayHashCatTest<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const uint64_t size,
- const HHResult64* expected,
- const HHNotify notify) const {
- TestHighwayHashCat(key, bytes, size, expected, notify);
-}
-
-template <TargetBits Target>
-void HighwayHashCatTest<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const uint64_t size,
- const HHResult128* expected,
- const HHNotify notify) const {
- TestHighwayHashCat(key, bytes, size, expected, notify);
-}
-
-template <TargetBits Target>
-void HighwayHashCatTest<Target>::operator()(const HHKey& key,
- const char* HH_RESTRICT bytes,
- const uint64_t size,
- const HHResult256* expected,
- const HHNotify notify) const {
- TestHighwayHashCat(key, bytes, size, expected, notify);
-}
-
-// Instantiate for the current target.
-template struct HighwayHashTest<HH_TARGET>;
-template struct HighwayHashCatTest<HH_TARGET>;
-
-//-----------------------------------------------------------------------------
-// benchmark
-
-namespace {
-
-template <TargetBits Target>
-uint64_t RunHighway(const size_t size) {
- static const HHKey key HH_ALIGNAS(32) = {0, 1, 2, 3};
- char in[kMaxBenchmarkInputSize];
- in[0] = static_cast<char>(size & 0xFF);
- HHResult64 result;
- HHStateT<Target> state(key);
- HighwayHashT(&state, in, size, &result);
- return result;
-}
-
-template <TargetBits Target>
-uint64_t RunHighwayCat(const size_t size) {
- static const HHKey key HH_ALIGNAS(32) = {0, 1, 2, 3};
- HH_ALIGNAS(64) HighwayHashCatT<Target> cat(key);
- char in[kMaxBenchmarkInputSize];
- in[0] = static_cast<char>(size & 0xFF);
- const size_t half_size = size / 2;
- cat.Append(in, half_size);
- cat.Append(in + half_size, size - half_size);
- HHResult64 result;
- cat.Finalize(&result);
- return result;
-}
-
-} // namespace
-
-template <TargetBits Target>
-void HighwayHashBenchmark<Target>::operator()(DurationsForInputs* input_map,
- NotifyBenchmark notify,
- void* context) const {
- MeasureDurations(&RunHighway<Target>, input_map);
- notify("HighwayHash", TargetName(Target), input_map, context);
-}
-
-template <TargetBits Target>
-void HighwayHashCatBenchmark<Target>::operator()(DurationsForInputs* input_map,
- NotifyBenchmark notify,
- void* context) const {
- MeasureDurations(&RunHighwayCat<Target>, input_map);
- notify("HighwayHashCat", TargetName(Target), input_map, context);
-}
-
-// Instantiate for the current target.
-template struct HighwayHashBenchmark<HH_TARGET>;
-template struct HighwayHashCatBenchmark<HH_TARGET>;
-
-} // namespace highwayhash
-#endif // HH_DISABLE_TARGET_SPECIFIC
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#include "highwayhash/highwayhash_test_target.h"
+
+#include "highwayhash/highwayhash.h"
+
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+namespace highwayhash {
+namespace {
+
+void NotifyIfUnequal(const size_t size, const HHResult64& expected,
+ const HHResult64& actual, const HHNotify notify) {
+ if (expected != actual) {
+ (*notify)(TargetName(HH_TARGET), size);
+ }
+}
+
+// Overload for HHResult128 or HHResult256 (arrays).
+template <size_t kNumLanes>
+void NotifyIfUnequal(const size_t size, const uint64_t (&expected)[kNumLanes],
+ const uint64_t (&actual)[kNumLanes],
+ const HHNotify notify) {
+ for (size_t i = 0; i < kNumLanes; ++i) {
+ if (expected[i] != actual[i]) {
+ (*notify)(TargetName(HH_TARGET), size);
+ return;
+ }
+ }
+}
+
+// Shared logic for all HighwayHashTest::operator() overloads.
+template <typename Result>
+void TestHighwayHash(HHStateT<HH_TARGET>* HH_RESTRICT state,
+ const char* HH_RESTRICT bytes, const size_t size,
+ const Result* expected, const HHNotify notify) {
+ Result actual;
+ HighwayHashT(state, bytes, size, &actual);
+ NotifyIfUnequal(size, *expected, actual, notify);
+}
+
+// Shared logic for all HighwayHashCatTest::operator() overloads.
+template <typename Result>
+void TestHighwayHashCat(const HHKey& key, const char* HH_RESTRICT bytes,
+ const size_t size, const Result* expected,
+ const HHNotify notify) {
+ // Slightly faster to compute the expected prefix hashes only once.
+ // Use new instead of vector to avoid headers with inline functions.
+ Result* results = new Result[size + 1];
+ for (size_t i = 0; i <= size; ++i) {
+ HHStateT<HH_TARGET> state_flat(key);
+ HighwayHashT(&state_flat, bytes, i, &results[i]);
+ }
+
+ // Splitting into three fragments/Append should cover all codepaths.
+ const size_t max_fragment_size = size / 3;
+ for (size_t size1 = 0; size1 < max_fragment_size; ++size1) {
+ for (size_t size2 = 0; size2 < max_fragment_size; ++size2) {
+ for (size_t size3 = 0; size3 < max_fragment_size; ++size3) {
+ HighwayHashCatT<HH_TARGET> cat(key);
+ const char* pos = bytes;
+ cat.Append(pos, size1);
+ pos += size1;
+ cat.Append(pos, size2);
+ pos += size2;
+ cat.Append(pos, size3);
+ pos += size3;
+
+ Result result_cat;
+ cat.Finalize(&result_cat);
+
+ const size_t total_size = pos - bytes;
+ NotifyIfUnequal(total_size, results[total_size], result_cat, notify);
+ }
+ }
+ }
+
+ delete[] results;
+}
+
+} // namespace
+
+template <TargetBits Target>
+void HighwayHashTest<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const size_t size,
+ const HHResult64* expected,
+ const HHNotify notify) const {
+ HHStateT<Target> state(key);
+ TestHighwayHash(&state, bytes, size, expected, notify);
+}
+
+template <TargetBits Target>
+void HighwayHashTest<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const size_t size,
+ const HHResult128* expected,
+ const HHNotify notify) const {
+ HHStateT<Target> state(key);
+ TestHighwayHash(&state, bytes, size, expected, notify);
+}
+
+template <TargetBits Target>
+void HighwayHashTest<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const size_t size,
+ const HHResult256* expected,
+ const HHNotify notify) const {
+ HHStateT<Target> state(key);
+ TestHighwayHash(&state, bytes, size, expected, notify);
+}
+
+template <TargetBits Target>
+void HighwayHashCatTest<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const uint64_t size,
+ const HHResult64* expected,
+ const HHNotify notify) const {
+ TestHighwayHashCat(key, bytes, size, expected, notify);
+}
+
+template <TargetBits Target>
+void HighwayHashCatTest<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const uint64_t size,
+ const HHResult128* expected,
+ const HHNotify notify) const {
+ TestHighwayHashCat(key, bytes, size, expected, notify);
+}
+
+template <TargetBits Target>
+void HighwayHashCatTest<Target>::operator()(const HHKey& key,
+ const char* HH_RESTRICT bytes,
+ const uint64_t size,
+ const HHResult256* expected,
+ const HHNotify notify) const {
+ TestHighwayHashCat(key, bytes, size, expected, notify);
+}
+
+// Instantiate for the current target.
+template struct HighwayHashTest<HH_TARGET>;
+template struct HighwayHashCatTest<HH_TARGET>;
+
+//-----------------------------------------------------------------------------
+// benchmark
+
+namespace {
+
+template <TargetBits Target>
+uint64_t RunHighway(const size_t size) {
+ static const HHKey key HH_ALIGNAS(32) = {0, 1, 2, 3};
+ char in[kMaxBenchmarkInputSize];
+ in[0] = static_cast<char>(size & 0xFF);
+ HHResult64 result;
+ HHStateT<Target> state(key);
+ HighwayHashT(&state, in, size, &result);
+ return result;
+}
+
+template <TargetBits Target>
+uint64_t RunHighwayCat(const size_t size) {
+ static const HHKey key HH_ALIGNAS(32) = {0, 1, 2, 3};
+ HH_ALIGNAS(64) HighwayHashCatT<Target> cat(key);
+ char in[kMaxBenchmarkInputSize];
+ in[0] = static_cast<char>(size & 0xFF);
+ const size_t half_size = size / 2;
+ cat.Append(in, half_size);
+ cat.Append(in + half_size, size - half_size);
+ HHResult64 result;
+ cat.Finalize(&result);
+ return result;
+}
+
+} // namespace
+
+template <TargetBits Target>
+void HighwayHashBenchmark<Target>::operator()(DurationsForInputs* input_map,
+ NotifyBenchmark notify,
+ void* context) const {
+ MeasureDurations(&RunHighway<Target>, input_map);
+ notify("HighwayHash", TargetName(Target), input_map, context);
+}
+
+template <TargetBits Target>
+void HighwayHashCatBenchmark<Target>::operator()(DurationsForInputs* input_map,
+ NotifyBenchmark notify,
+ void* context) const {
+ MeasureDurations(&RunHighwayCat<Target>, input_map);
+ notify("HighwayHashCat", TargetName(Target), input_map, context);
+}
+
+// Instantiate for the current target.
+template struct HighwayHashBenchmark<HH_TARGET>;
+template struct HighwayHashCatBenchmark<HH_TARGET>;
+
+} // namespace highwayhash
+#endif // HH_DISABLE_TARGET_SPECIFIC
diff --git a/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.h b/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.h
index 88cca8c168..b89695d346 100644
--- a/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.h
+++ b/contrib/libs/highwayhash/highwayhash/highwayhash_test_target.h
@@ -1,89 +1,89 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
-#define HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
-
-// Tests called by InstructionSets::RunAll, so we can verify all
-// implementations supported by the current CPU.
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stddef.h>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/hh_types.h"
-#include "highwayhash/nanobenchmark.h"
-
-namespace highwayhash {
-
-// Verifies the hash result matches "expected" and calls "notify" if not.
-template <TargetBits Target>
-struct HighwayHashTest {
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const size_t size, const HHResult64* expected,
- const HHNotify notify) const;
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const size_t size, const HHResult128* expected,
- const HHNotify notify) const;
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const size_t size, const HHResult256* expected,
- const HHNotify notify) const;
-};
-
-// For every possible partition of "bytes" into zero to three fragments,
-// verifies HighwayHashCat returns the same result as HighwayHashT of the
-// concatenated fragments, and calls "notify" if not. The value of "expected"
-// is ignored; it is only used for overloading.
-template <TargetBits Target>
-struct HighwayHashCatTest {
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const uint64_t size, const HHResult64* expected,
- const HHNotify notify) const;
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const uint64_t size, const HHResult128* expected,
- const HHNotify notify) const;
- void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
- const uint64_t size, const HHResult256* expected,
- const HHNotify notify) const;
-};
-
-// Called by benchmark with prefix, target_name, input_map, context.
-// This function must set input_map->num_items to 0.
-using NotifyBenchmark = void (*)(const char*, const char*, DurationsForInputs*,
- void*);
-
-constexpr size_t kMaxBenchmarkInputSize = 1024;
-
-// Calls "notify" with benchmark results for the input sizes specified by
-// "input_map" (<= kMaxBenchmarkInputSize) plus a "context" parameter.
-template <TargetBits Target>
-struct HighwayHashBenchmark {
- void operator()(DurationsForInputs* input_map, NotifyBenchmark notify,
- void* context) const;
-};
-
-template <TargetBits Target>
-struct HighwayHashCatBenchmark {
- void operator()(DurationsForInputs* input_map, NotifyBenchmark notify,
- void* context) const;
-};
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
+#define HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
+
+// Tests called by InstructionSets::RunAll, so we can verify all
+// implementations supported by the current CPU.
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stddef.h>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/hh_types.h"
+#include "highwayhash/nanobenchmark.h"
+
+namespace highwayhash {
+
+// Verifies the hash result matches "expected" and calls "notify" if not.
+template <TargetBits Target>
+struct HighwayHashTest {
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const size_t size, const HHResult64* expected,
+ const HHNotify notify) const;
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const size_t size, const HHResult128* expected,
+ const HHNotify notify) const;
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const size_t size, const HHResult256* expected,
+ const HHNotify notify) const;
+};
+
+// For every possible partition of "bytes" into zero to three fragments,
+// verifies HighwayHashCat returns the same result as HighwayHashT of the
+// concatenated fragments, and calls "notify" if not. The value of "expected"
+// is ignored; it is only used for overloading.
+template <TargetBits Target>
+struct HighwayHashCatTest {
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const uint64_t size, const HHResult64* expected,
+ const HHNotify notify) const;
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const uint64_t size, const HHResult128* expected,
+ const HHNotify notify) const;
+ void operator()(const HHKey& key, const char* HH_RESTRICT bytes,
+ const uint64_t size, const HHResult256* expected,
+ const HHNotify notify) const;
+};
+
+// Called by benchmark with prefix, target_name, input_map, context.
+// This function must set input_map->num_items to 0.
+using NotifyBenchmark = void (*)(const char*, const char*, DurationsForInputs*,
+ void*);
+
+constexpr size_t kMaxBenchmarkInputSize = 1024;
+
+// Calls "notify" with benchmark results for the input sizes specified by
+// "input_map" (<= kMaxBenchmarkInputSize) plus a "context" parameter.
+template <TargetBits Target>
+struct HighwayHashBenchmark {
+ void operator()(DurationsForInputs* input_map, NotifyBenchmark notify,
+ void* context) const;
+};
+
+template <TargetBits Target>
+struct HighwayHashCatBenchmark {
+ void operator()(DurationsForInputs* input_map, NotifyBenchmark notify,
+ void* context) const;
+};
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_HIGHWAYHASH_TARGET_H_
diff --git a/contrib/libs/highwayhash/highwayhash/iaca.h b/contrib/libs/highwayhash/highwayhash/iaca.h
index 3a075544d4..80e1013ae0 100644
--- a/contrib/libs/highwayhash/highwayhash/iaca.h
+++ b/contrib/libs/highwayhash/highwayhash/iaca.h
@@ -1,63 +1,63 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_IACA_H_
-#define HIGHWAYHASH_IACA_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/compiler_specific.h"
-
-// IACA (Intel's Code Analyzer, go/intel-iaca) analyzes instruction latencies,
-// but only for code between special markers. These functions embed such markers
-// in an executable, but only for reading via IACA - they deliberately trigger
-// a crash if executed to ensure they are removed in normal builds.
-
-// Default off; callers must `#define HH_ENABLE_IACA 1` before including this.
-#ifndef HH_ENABLE_IACA
-#define HH_ENABLE_IACA 0
-#endif
-
-namespace highwayhash {
-
-#if HH_ENABLE_IACA && (HH_GCC_VERSION || HH_CLANG_VERSION)
-
-// Call before the region of interest. Fences hopefully prevent reordering.
-static HH_INLINE void BeginIACA() {
- HH_COMPILER_FENCE;
- asm volatile(
- ".byte 0x0F, 0x0B\n\t" // UD2
- "movl $111, %ebx\n\t"
- ".byte 0x64, 0x67, 0x90\n\t");
- HH_COMPILER_FENCE;
-}
-
-// Call after the region of interest. Fences hopefully prevent reordering.
-static HH_INLINE void EndIACA() {
- HH_COMPILER_FENCE;
- asm volatile(
- "movl $222, %ebx\n\t"
- ".byte 0x64, 0x67, 0x90\n\t"
- ".byte 0x0F, 0x0B\n\t"); // UD2
- HH_COMPILER_FENCE;
-}
-
-#endif
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_IACA_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_IACA_H_
+#define HIGHWAYHASH_IACA_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/compiler_specific.h"
+
+// IACA (Intel's Code Analyzer, go/intel-iaca) analyzes instruction latencies,
+// but only for code between special markers. These functions embed such markers
+// in an executable, but only for reading via IACA - they deliberately trigger
+// a crash if executed to ensure they are removed in normal builds.
+
+// Default off; callers must `#define HH_ENABLE_IACA 1` before including this.
+#ifndef HH_ENABLE_IACA
+#define HH_ENABLE_IACA 0
+#endif
+
+namespace highwayhash {
+
+#if HH_ENABLE_IACA && (HH_GCC_VERSION || HH_CLANG_VERSION)
+
+// Call before the region of interest. Fences hopefully prevent reordering.
+static HH_INLINE void BeginIACA() {
+ HH_COMPILER_FENCE;
+ asm volatile(
+ ".byte 0x0F, 0x0B\n\t" // UD2
+ "movl $111, %ebx\n\t"
+ ".byte 0x64, 0x67, 0x90\n\t");
+ HH_COMPILER_FENCE;
+}
+
+// Call after the region of interest. Fences hopefully prevent reordering.
+static HH_INLINE void EndIACA() {
+ HH_COMPILER_FENCE;
+ asm volatile(
+ "movl $222, %ebx\n\t"
+ ".byte 0x64, 0x67, 0x90\n\t"
+ ".byte 0x0F, 0x0B\n\t"); // UD2
+ HH_COMPILER_FENCE;
+}
+
+#endif
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_IACA_H_
diff --git a/contrib/libs/highwayhash/highwayhash/instruction_sets.cc b/contrib/libs/highwayhash/highwayhash/instruction_sets.cc
index 5760cd6303..a02e1f81d9 100644
--- a/contrib/libs/highwayhash/highwayhash/instruction_sets.cc
+++ b/contrib/libs/highwayhash/highwayhash/instruction_sets.cc
@@ -1,141 +1,141 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/instruction_sets.h"
-#include "highwayhash/arch_specific.h"
-
-// Currently there are only specialized targets for X64; other architectures
-// only use HH_TARGET_Portable, in which case Supported() just returns that.
-#if HH_ARCH_X64
-
-#include <atomic>
-
-namespace highwayhash {
-
-namespace {
-
-bool IsBitSet(const uint32_t reg, const int index) {
- return (reg & (1U << index)) != 0;
-}
-
-// Returns the lower 32 bits of extended control register 0.
-// Requires CPU support for "OSXSAVE" (see below).
-uint32_t ReadXCR0() {
-#if HH_MSC_VERSION
- return static_cast<uint32_t>(_xgetbv(0));
-#else
- uint32_t xcr0, xcr0_high;
- const uint32_t index = 0;
- asm volatile(".byte 0x0F, 0x01, 0xD0"
- : "=a"(xcr0), "=d"(xcr0_high)
- : "c"(index));
- return xcr0;
-#endif
-}
-
-// 0 iff not yet initialized by Supported().
-// Not function-local => no compiler-generated locking.
-std::atomic<TargetBits> supported_{0};
-
-// Bits indicating which instruction set extensions are supported.
-enum {
- kBitSSE = 1 << 0,
- kBitSSE2 = 1 << 1,
- kBitSSE3 = 1 << 2,
- kBitSSSE3 = 1 << 3,
- kBitSSE41 = 1 << 4,
- kBitSSE42 = 1 << 5,
- kBitAVX = 1 << 6,
- kBitAVX2 = 1 << 7,
- kBitFMA = 1 << 8,
- kBitLZCNT = 1 << 9,
- kBitBMI = 1 << 10,
- kBitBMI2 = 1 << 11,
-
- kGroupAVX2 = kBitAVX | kBitAVX2 | kBitFMA | kBitLZCNT | kBitBMI | kBitBMI2,
- kGroupSSE41 = kBitSSE | kBitSSE2 | kBitSSE3 | kBitSSSE3 | kBitSSE41
-};
-
-} // namespace
-
-TargetBits InstructionSets::Supported() {
- TargetBits supported = supported_.load(std::memory_order_acquire);
- // Already initialized, return that.
- if (HH_LIKELY(supported)) {
- return supported;
- }
-
- uint32_t flags = 0;
- uint32_t abcd[4];
-
- Cpuid(0, 0, abcd);
- const uint32_t max_level = abcd[0];
-
- // Standard feature flags
- Cpuid(1, 0, abcd);
- flags |= IsBitSet(abcd[3], 25) ? kBitSSE : 0;
- flags |= IsBitSet(abcd[3], 26) ? kBitSSE2 : 0;
- flags |= IsBitSet(abcd[2], 0) ? kBitSSE3 : 0;
- flags |= IsBitSet(abcd[2], 9) ? kBitSSSE3 : 0;
- flags |= IsBitSet(abcd[2], 19) ? kBitSSE41 : 0;
- flags |= IsBitSet(abcd[2], 20) ? kBitSSE42 : 0;
- flags |= IsBitSet(abcd[2], 12) ? kBitFMA : 0;
- flags |= IsBitSet(abcd[2], 28) ? kBitAVX : 0;
- const bool has_osxsave = IsBitSet(abcd[2], 27);
-
- // Extended feature flags
- Cpuid(0x80000001U, 0, abcd);
- flags |= IsBitSet(abcd[2], 5) ? kBitLZCNT : 0;
-
- // Extended features
- if (max_level >= 7) {
- Cpuid(7, 0, abcd);
- flags |= IsBitSet(abcd[1], 3) ? kBitBMI : 0;
- flags |= IsBitSet(abcd[1], 5) ? kBitAVX2 : 0;
- flags |= IsBitSet(abcd[1], 8) ? kBitBMI2 : 0;
- }
-
- // Verify OS support for XSAVE, without which XMM/YMM registers are not
- // preserved across context switches and are not safe to use.
- if (has_osxsave) {
- const uint32_t xcr0 = ReadXCR0();
- // XMM
- if ((xcr0 & 2) == 0) {
- flags &= ~(kBitSSE | kBitSSE2 | kBitSSE3 | kBitSSSE3 | kBitSSE41 |
- kBitSSE42 | kBitAVX | kBitAVX2 | kBitFMA);
- }
- // YMM
- if ((xcr0 & 4) == 0) {
- flags &= ~(kBitAVX | kBitAVX2);
- }
- }
-
- // Also indicates "supported" has been initialized.
- supported = HH_TARGET_Portable;
-
- // Set target bit(s) if all their group's flags are all set.
- if ((flags & kGroupAVX2) == kGroupAVX2) {
- supported |= HH_TARGET_AVX2;
- }
- if ((flags & kGroupSSE41) == kGroupSSE41) {
- supported |= HH_TARGET_SSE41;
- }
-
- supported_.store(supported, std::memory_order_release);
- return supported;
-}
-
-} // namespace highwayhash
-
-#endif // HH_ARCH_X64
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/instruction_sets.h"
+#include "highwayhash/arch_specific.h"
+
+// Currently there are only specialized targets for X64; other architectures
+// only use HH_TARGET_Portable, in which case Supported() just returns that.
+#if HH_ARCH_X64
+
+#include <atomic>
+
+namespace highwayhash {
+
+namespace {
+
+bool IsBitSet(const uint32_t reg, const int index) {
+ return (reg & (1U << index)) != 0;
+}
+
+// Returns the lower 32 bits of extended control register 0.
+// Requires CPU support for "OSXSAVE" (see below).
+uint32_t ReadXCR0() {
+#if HH_MSC_VERSION
+ return static_cast<uint32_t>(_xgetbv(0));
+#else
+ uint32_t xcr0, xcr0_high;
+ const uint32_t index = 0;
+ asm volatile(".byte 0x0F, 0x01, 0xD0"
+ : "=a"(xcr0), "=d"(xcr0_high)
+ : "c"(index));
+ return xcr0;
+#endif
+}
+
+// 0 iff not yet initialized by Supported().
+// Not function-local => no compiler-generated locking.
+std::atomic<TargetBits> supported_{0};
+
+// Bits indicating which instruction set extensions are supported.
+enum {
+ kBitSSE = 1 << 0,
+ kBitSSE2 = 1 << 1,
+ kBitSSE3 = 1 << 2,
+ kBitSSSE3 = 1 << 3,
+ kBitSSE41 = 1 << 4,
+ kBitSSE42 = 1 << 5,
+ kBitAVX = 1 << 6,
+ kBitAVX2 = 1 << 7,
+ kBitFMA = 1 << 8,
+ kBitLZCNT = 1 << 9,
+ kBitBMI = 1 << 10,
+ kBitBMI2 = 1 << 11,
+
+ kGroupAVX2 = kBitAVX | kBitAVX2 | kBitFMA | kBitLZCNT | kBitBMI | kBitBMI2,
+ kGroupSSE41 = kBitSSE | kBitSSE2 | kBitSSE3 | kBitSSSE3 | kBitSSE41
+};
+
+} // namespace
+
+TargetBits InstructionSets::Supported() {
+ TargetBits supported = supported_.load(std::memory_order_acquire);
+ // Already initialized, return that.
+ if (HH_LIKELY(supported)) {
+ return supported;
+ }
+
+ uint32_t flags = 0;
+ uint32_t abcd[4];
+
+ Cpuid(0, 0, abcd);
+ const uint32_t max_level = abcd[0];
+
+ // Standard feature flags
+ Cpuid(1, 0, abcd);
+ flags |= IsBitSet(abcd[3], 25) ? kBitSSE : 0;
+ flags |= IsBitSet(abcd[3], 26) ? kBitSSE2 : 0;
+ flags |= IsBitSet(abcd[2], 0) ? kBitSSE3 : 0;
+ flags |= IsBitSet(abcd[2], 9) ? kBitSSSE3 : 0;
+ flags |= IsBitSet(abcd[2], 19) ? kBitSSE41 : 0;
+ flags |= IsBitSet(abcd[2], 20) ? kBitSSE42 : 0;
+ flags |= IsBitSet(abcd[2], 12) ? kBitFMA : 0;
+ flags |= IsBitSet(abcd[2], 28) ? kBitAVX : 0;
+ const bool has_osxsave = IsBitSet(abcd[2], 27);
+
+ // Extended feature flags
+ Cpuid(0x80000001U, 0, abcd);
+ flags |= IsBitSet(abcd[2], 5) ? kBitLZCNT : 0;
+
+ // Extended features
+ if (max_level >= 7) {
+ Cpuid(7, 0, abcd);
+ flags |= IsBitSet(abcd[1], 3) ? kBitBMI : 0;
+ flags |= IsBitSet(abcd[1], 5) ? kBitAVX2 : 0;
+ flags |= IsBitSet(abcd[1], 8) ? kBitBMI2 : 0;
+ }
+
+ // Verify OS support for XSAVE, without which XMM/YMM registers are not
+ // preserved across context switches and are not safe to use.
+ if (has_osxsave) {
+ const uint32_t xcr0 = ReadXCR0();
+ // XMM
+ if ((xcr0 & 2) == 0) {
+ flags &= ~(kBitSSE | kBitSSE2 | kBitSSE3 | kBitSSSE3 | kBitSSE41 |
+ kBitSSE42 | kBitAVX | kBitAVX2 | kBitFMA);
+ }
+ // YMM
+ if ((xcr0 & 4) == 0) {
+ flags &= ~(kBitAVX | kBitAVX2);
+ }
+ }
+
+ // Also indicates "supported" has been initialized.
+ supported = HH_TARGET_Portable;
+
+ // Set target bit(s) if all their group's flags are all set.
+ if ((flags & kGroupAVX2) == kGroupAVX2) {
+ supported |= HH_TARGET_AVX2;
+ }
+ if ((flags & kGroupSSE41) == kGroupSSE41) {
+ supported |= HH_TARGET_SSE41;
+ }
+
+ supported_.store(supported, std::memory_order_release);
+ return supported;
+}
+
+} // namespace highwayhash
+
+#endif // HH_ARCH_X64
diff --git a/contrib/libs/highwayhash/highwayhash/instruction_sets.h b/contrib/libs/highwayhash/highwayhash/instruction_sets.h
index 5d2251b654..88bc1bc374 100644
--- a/contrib/libs/highwayhash/highwayhash/instruction_sets.h
+++ b/contrib/libs/highwayhash/highwayhash/instruction_sets.h
@@ -1,88 +1,88 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_INSTRUCTION_SETS_H_
-#define HIGHWAYHASH_INSTRUCTION_SETS_H_
-
-// Calls the best specialization of a template supported by the current CPU.
-//
-// Usage: for each dispatch site, declare a Functor template with a 'Target'
-// argument, add a source file defining its operator() and instantiating
-// Functor<HH_TARGET>, add a cc_library_for_targets rule for that source file,
-// and call InstructionSets::Run<Functor>(/*args*/).
-
-#include <utility> // std::forward
-
-#include "highwayhash/arch_specific.h" // HH_TARGET_*
-#include "highwayhash/compiler_specific.h"
-
-namespace highwayhash {
-
-// Detects TargetBits and calls specializations of a user-defined functor.
-class InstructionSets {
- public:
-// Returns bit array of HH_TARGET_* supported by the current CPU.
-// The HH_TARGET_Portable bit is guaranteed to be set.
-#if HH_ARCH_X64
- static TargetBits Supported();
-#else
- static HH_INLINE TargetBits Supported() { return HH_TARGET_Portable; }
-#endif
-
- // Chooses the best available "Target" for the current CPU, runs the
- // corresponding Func<Target>::operator()(args) and returns that Target
- // (a single bit). The overhead of dispatching is low, about 4 cycles, but
- // this should only be called infrequently (e.g. hoisting it out of loops).
- template <template <TargetBits> class Func, typename... Args>
- static HH_INLINE TargetBits Run(Args&&... args) {
-#if HH_ARCH_X64
- const TargetBits supported = Supported();
- if (supported & HH_TARGET_AVX2) {
- Func<HH_TARGET_AVX2>()(std::forward<Args>(args)...);
- return HH_TARGET_AVX2;
- }
- if (supported & HH_TARGET_SSE41) {
- Func<HH_TARGET_SSE41>()(std::forward<Args>(args)...);
- return HH_TARGET_SSE41;
- }
-#endif // HH_ARCH_X64
-
- Func<HH_TARGET_Portable>()(std::forward<Args>(args)...);
- return HH_TARGET_Portable;
- }
-
- // Calls Func<Target>::operator()(args) for all Target supported by the
- // current CPU, and returns their HH_TARGET_* bits.
- template <template <TargetBits> class Func, typename... Args>
- static HH_INLINE TargetBits RunAll(Args&&... args) {
-#if HH_ARCH_X64
- const TargetBits supported = Supported();
- if (supported & HH_TARGET_AVX2) {
- Func<HH_TARGET_AVX2>()(std::forward<Args>(args)...);
- }
- if (supported & HH_TARGET_SSE41) {
- Func<HH_TARGET_SSE41>()(std::forward<Args>(args)...);
- }
-#else
- const TargetBits supported = HH_TARGET_Portable;
-#endif // HH_ARCH_X64
-
- Func<HH_TARGET_Portable>()(std::forward<Args>(args)...);
- return supported; // i.e. all that were run
- }
-};
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_INSTRUCTION_SETS_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_INSTRUCTION_SETS_H_
+#define HIGHWAYHASH_INSTRUCTION_SETS_H_
+
+// Calls the best specialization of a template supported by the current CPU.
+//
+// Usage: for each dispatch site, declare a Functor template with a 'Target'
+// argument, add a source file defining its operator() and instantiating
+// Functor<HH_TARGET>, add a cc_library_for_targets rule for that source file,
+// and call InstructionSets::Run<Functor>(/*args*/).
+
+#include <utility> // std::forward
+
+#include "highwayhash/arch_specific.h" // HH_TARGET_*
+#include "highwayhash/compiler_specific.h"
+
+namespace highwayhash {
+
+// Detects TargetBits and calls specializations of a user-defined functor.
+class InstructionSets {
+ public:
+// Returns bit array of HH_TARGET_* supported by the current CPU.
+// The HH_TARGET_Portable bit is guaranteed to be set.
+#if HH_ARCH_X64
+ static TargetBits Supported();
+#else
+ static HH_INLINE TargetBits Supported() { return HH_TARGET_Portable; }
+#endif
+
+ // Chooses the best available "Target" for the current CPU, runs the
+ // corresponding Func<Target>::operator()(args) and returns that Target
+ // (a single bit). The overhead of dispatching is low, about 4 cycles, but
+ // this should only be called infrequently (e.g. hoisting it out of loops).
+ template <template <TargetBits> class Func, typename... Args>
+ static HH_INLINE TargetBits Run(Args&&... args) {
+#if HH_ARCH_X64
+ const TargetBits supported = Supported();
+ if (supported & HH_TARGET_AVX2) {
+ Func<HH_TARGET_AVX2>()(std::forward<Args>(args)...);
+ return HH_TARGET_AVX2;
+ }
+ if (supported & HH_TARGET_SSE41) {
+ Func<HH_TARGET_SSE41>()(std::forward<Args>(args)...);
+ return HH_TARGET_SSE41;
+ }
+#endif // HH_ARCH_X64
+
+ Func<HH_TARGET_Portable>()(std::forward<Args>(args)...);
+ return HH_TARGET_Portable;
+ }
+
+ // Calls Func<Target>::operator()(args) for all Target supported by the
+ // current CPU, and returns their HH_TARGET_* bits.
+ template <template <TargetBits> class Func, typename... Args>
+ static HH_INLINE TargetBits RunAll(Args&&... args) {
+#if HH_ARCH_X64
+ const TargetBits supported = Supported();
+ if (supported & HH_TARGET_AVX2) {
+ Func<HH_TARGET_AVX2>()(std::forward<Args>(args)...);
+ }
+ if (supported & HH_TARGET_SSE41) {
+ Func<HH_TARGET_SSE41>()(std::forward<Args>(args)...);
+ }
+#else
+ const TargetBits supported = HH_TARGET_Portable;
+#endif // HH_ARCH_X64
+
+ Func<HH_TARGET_Portable>()(std::forward<Args>(args)...);
+ return supported; // i.e. all that were run
+ }
+};
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_INSTRUCTION_SETS_H_
diff --git a/contrib/libs/highwayhash/highwayhash/load3.h b/contrib/libs/highwayhash/highwayhash/load3.h
index 0bf0da9c4d..e226b19520 100644
--- a/contrib/libs/highwayhash/highwayhash/load3.h
+++ b/contrib/libs/highwayhash/highwayhash/load3.h
@@ -1,144 +1,144 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_HH_LOAD3_H_
-#define HIGHWAYHASH_HH_LOAD3_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/endianess.h"
-
-namespace highwayhash {
-// To prevent ODR violations when including this from multiple translation
-// units (TU) that are compiled with different flags, the contents must reside
-// in a namespace whose name is unique to the TU. NOTE: this behavior is
-// incompatible with precompiled modules and requires textual inclusion instead.
-namespace HH_TARGET_NAME {
-
-// Loads 0 to 3 bytes from a given location using one of several policies.
-// These are potentially faster than 8-bit loads, but require certain additional
-// promises by the caller: that 'out of bounds' memory accesses are allowed,
-// and/or that the bytes may be permuted or duplicated.
-class Load3 {
- public:
- // In increasing order of complexity:
- struct AllowReadBeforeAndReturn {};
- struct AllowReadBefore {};
- struct AllowUnordered {};
- struct AllowNone {};
-
- // Up to 4 preceding bytes may be read and returned along with the 0..3
- // valid bytes. The valid bytes are in little-endian order, except that the
- // preceding bytes occupy the least-significant bytes.
- HH_INLINE uint32_t operator()(AllowReadBeforeAndReturn, const char* from,
- const size_t size_mod4) {
- // It's safe to read before "from", so we can load 32 bits, which is faster
- // than individual byte loads. We assume little-endian byte order, so
- // big-endian platforms will need to swap. Type punning can generate
- // incorrect code if compiled with strict aliasing; the only safe
- // alternatives are memcpy and reading through char*. We must avoid memcpy
- // because string.h must not be included per the warning above. On GCC and
- // Clang, we can use a builtin instead.
- uint32_t last4;
- Copy(from + size_mod4 - 4, 4, reinterpret_cast<char*>(&last4));
- return host_from_le32(last4);
- }
-
- // As above, but preceding bytes are removed and upper byte(s) are zero.
- HH_INLINE uint64_t operator()(AllowReadBefore, const char* from,
- const size_t size_mod4) {
- // Shift 0..3 valid bytes into LSB as if loaded in little-endian order.
- // 64-bit type enables 32-bit shift when size_mod4 == 0.
- uint64_t last3 = operator()(AllowReadBeforeAndReturn(), from, size_mod4);
- last3 >>= 32 - (size_mod4 * 8);
- return last3;
- }
-
- // The bytes need not be loaded in little-endian order. This particular order
- // (and the duplication of some bytes depending on "size_mod4") was chosen for
- // computational convenience and can no longer be changed because it is part
- // of the HighwayHash length padding definition.
- HH_INLINE uint64_t operator()(AllowUnordered, const char* from,
- const size_t size_mod4) {
- uint64_t last3 = 0;
- // Not allowed to read any bytes; early-out is faster than reading from a
- // constant array of zeros.
- if (size_mod4 == 0) {
- return last3;
- }
-
- // These indices are chosen as an easy-to-compute sequence containing the
- // same elements as [0, size), but repeated and/or reordered. This enables
- // unconditional loads, which outperform conditional 8 or 16+8 bit loads.
- const uint64_t idx0 = 0;
- const uint64_t idx1 = size_mod4 >> 1;
- const uint64_t idx2 = size_mod4 - 1;
- // Store into least significant bytes (avoids one shift).
- last3 = static_cast<uint64_t>(from[idx0]);
- last3 += static_cast<uint64_t>(from[idx1]) << 8;
- last3 += static_cast<uint64_t>(from[idx2]) << 16;
- return last3;
- }
-
- // Must read exactly [0, size) bytes in little-endian order.
- HH_INLINE uint64_t operator()(AllowNone, const char* from,
- const size_t size_mod4) {
- // We need to load in little-endian order without accessing anything outside
- // [from, from + size_mod4). Unrolling is faster than looping backwards.
- uint64_t last3 = 0;
- if (size_mod4 >= 1) {
- last3 += U64FromChar(from[0]);
- }
- if (size_mod4 >= 2) {
- last3 += U64FromChar(from[1]) << 8;
- }
- if (size_mod4 == 3) {
- last3 += U64FromChar(from[2]) << 16;
- }
- return last3;
- }
-
- private:
- static HH_INLINE uint32_t U32FromChar(const char c) {
- return static_cast<uint32_t>(static_cast<unsigned char>(c));
- }
-
- static HH_INLINE uint64_t U64FromChar(const char c) {
- return static_cast<uint64_t>(static_cast<unsigned char>(c));
- }
-
- static HH_INLINE void Copy(const char* HH_RESTRICT from, const size_t size,
- char* HH_RESTRICT to) {
-#if HH_MSC_VERSION
- for (size_t i = 0; i < size; ++i) {
- to[i] = from[i];
- }
-#else
- __builtin_memcpy(to, from, size);
-#endif
- }
-};
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_LOAD3_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_HH_LOAD3_H_
+#define HIGHWAYHASH_HH_LOAD3_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/endianess.h"
+
+namespace highwayhash {
+// To prevent ODR violations when including this from multiple translation
+// units (TU) that are compiled with different flags, the contents must reside
+// in a namespace whose name is unique to the TU. NOTE: this behavior is
+// incompatible with precompiled modules and requires textual inclusion instead.
+namespace HH_TARGET_NAME {
+
+// Loads 0 to 3 bytes from a given location using one of several policies.
+// These are potentially faster than 8-bit loads, but require certain additional
+// promises by the caller: that 'out of bounds' memory accesses are allowed,
+// and/or that the bytes may be permuted or duplicated.
+class Load3 {
+ public:
+ // In increasing order of complexity:
+ struct AllowReadBeforeAndReturn {};
+ struct AllowReadBefore {};
+ struct AllowUnordered {};
+ struct AllowNone {};
+
+ // Up to 4 preceding bytes may be read and returned along with the 0..3
+ // valid bytes. The valid bytes are in little-endian order, except that the
+ // preceding bytes occupy the least-significant bytes.
+ HH_INLINE uint32_t operator()(AllowReadBeforeAndReturn, const char* from,
+ const size_t size_mod4) {
+ // It's safe to read before "from", so we can load 32 bits, which is faster
+ // than individual byte loads. We assume little-endian byte order, so
+ // big-endian platforms will need to swap. Type punning can generate
+ // incorrect code if compiled with strict aliasing; the only safe
+ // alternatives are memcpy and reading through char*. We must avoid memcpy
+ // because string.h must not be included per the warning above. On GCC and
+ // Clang, we can use a builtin instead.
+ uint32_t last4;
+ Copy(from + size_mod4 - 4, 4, reinterpret_cast<char*>(&last4));
+ return host_from_le32(last4);
+ }
+
+ // As above, but preceding bytes are removed and upper byte(s) are zero.
+ HH_INLINE uint64_t operator()(AllowReadBefore, const char* from,
+ const size_t size_mod4) {
+ // Shift 0..3 valid bytes into LSB as if loaded in little-endian order.
+ // 64-bit type enables 32-bit shift when size_mod4 == 0.
+ uint64_t last3 = operator()(AllowReadBeforeAndReturn(), from, size_mod4);
+ last3 >>= 32 - (size_mod4 * 8);
+ return last3;
+ }
+
+ // The bytes need not be loaded in little-endian order. This particular order
+ // (and the duplication of some bytes depending on "size_mod4") was chosen for
+ // computational convenience and can no longer be changed because it is part
+ // of the HighwayHash length padding definition.
+ HH_INLINE uint64_t operator()(AllowUnordered, const char* from,
+ const size_t size_mod4) {
+ uint64_t last3 = 0;
+ // Not allowed to read any bytes; early-out is faster than reading from a
+ // constant array of zeros.
+ if (size_mod4 == 0) {
+ return last3;
+ }
+
+ // These indices are chosen as an easy-to-compute sequence containing the
+ // same elements as [0, size), but repeated and/or reordered. This enables
+ // unconditional loads, which outperform conditional 8 or 16+8 bit loads.
+ const uint64_t idx0 = 0;
+ const uint64_t idx1 = size_mod4 >> 1;
+ const uint64_t idx2 = size_mod4 - 1;
+ // Store into least significant bytes (avoids one shift).
+ last3 = static_cast<uint64_t>(from[idx0]);
+ last3 += static_cast<uint64_t>(from[idx1]) << 8;
+ last3 += static_cast<uint64_t>(from[idx2]) << 16;
+ return last3;
+ }
+
+ // Must read exactly [0, size) bytes in little-endian order.
+ HH_INLINE uint64_t operator()(AllowNone, const char* from,
+ const size_t size_mod4) {
+ // We need to load in little-endian order without accessing anything outside
+ // [from, from + size_mod4). Unrolling is faster than looping backwards.
+ uint64_t last3 = 0;
+ if (size_mod4 >= 1) {
+ last3 += U64FromChar(from[0]);
+ }
+ if (size_mod4 >= 2) {
+ last3 += U64FromChar(from[1]) << 8;
+ }
+ if (size_mod4 == 3) {
+ last3 += U64FromChar(from[2]) << 16;
+ }
+ return last3;
+ }
+
+ private:
+ static HH_INLINE uint32_t U32FromChar(const char c) {
+ return static_cast<uint32_t>(static_cast<unsigned char>(c));
+ }
+
+ static HH_INLINE uint64_t U64FromChar(const char c) {
+ return static_cast<uint64_t>(static_cast<unsigned char>(c));
+ }
+
+ static HH_INLINE void Copy(const char* HH_RESTRICT from, const size_t size,
+ char* HH_RESTRICT to) {
+#if HH_MSC_VERSION
+ for (size_t i = 0; i < size; ++i) {
+ to[i] = from[i];
+ }
+#else
+ __builtin_memcpy(to, from, size);
+#endif
+ }
+};
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_LOAD3_H_
diff --git a/contrib/libs/highwayhash/highwayhash/nanobenchmark.cc b/contrib/libs/highwayhash/highwayhash/nanobenchmark.cc
index 5929016f6f..f0ba6ad35b 100644
--- a/contrib/libs/highwayhash/highwayhash/nanobenchmark.cc
+++ b/contrib/libs/highwayhash/highwayhash/nanobenchmark.cc
@@ -1,437 +1,437 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/nanobenchmark.h"
-
-#include <algorithm>
-#include <cmath>
-#include <cstdio>
-#include <map>
-#include <random>
-#include <vector>
-
-#include <stddef.h>
-
-#include "highwayhash/os_specific.h"
-#include "highwayhash/robust_statistics.h"
-#include "highwayhash/tsc_timer.h"
-
-namespace highwayhash {
-namespace {
-
-// Enables sanity checks that verify correct operation at the cost of
-// longer benchmark runs.
-#ifndef NANOBENCHMARK_ENABLE_CHECKS
-#define NANOBENCHMARK_ENABLE_CHECKS 0
-#endif
-
-#define NANOBENCHMARK_CHECK_ALWAYS(condition) \
- while (!(condition)) { \
- printf("Nanobenchmark check failed at line %d\n", __LINE__); \
- abort(); \
- }
-
-#if NANOBENCHMARK_ENABLE_CHECKS
-#define NANOBENCHMARK_CHECK(condition) NANOBENCHMARK_CHECK_ALWAYS(condition)
-#else
-#define NANOBENCHMARK_CHECK(condition)
-#endif
-
-#if HH_MSC_VERSION
-
-// MSVC does not support inline assembly anymore (and never supported GCC's
-// RTL constraints used below).
-#pragma optimize("", off)
-// Self-assignment with #pragma optimize("off") might be expected to prevent
-// elision, but it does not with MSVC 2015.
-void UseCharPointer(volatile const char*) {}
-#pragma optimize("", on)
-
-template <class T>
-inline void PreventElision(T&& output) {
- UseCharPointer(reinterpret_cast<volatile const char*>(&output));
-}
-
-#else
-
-// Prevents the compiler from eliding the computations that led to "output".
-// Works by indicating to the compiler that "output" is being read and modified.
-// The +r constraint avoids unnecessary writes to memory, but only works for
-// FuncOutput.
-template <class T>
-inline void PreventElision(T&& output) {
- asm volatile("" : "+r"(output) : : "memory");
-}
-
-#endif
-
-HH_NOINLINE FuncOutput Func1(const FuncInput input) { return input + 1; }
-HH_NOINLINE FuncOutput Func2(const FuncInput input) { return input + 2; }
-
-// Cycles elapsed = difference between two cycle counts. Must be unsigned to
-// ensure wraparound on overflow.
-using Duration = uint32_t;
-
-// Even with high-priority pinned threads and frequency throttling disabled,
-// elapsed times are noisy due to interrupts or SMM operations. It might help
-// to detect such events via transactions and omit affected measurements.
-// Unfortunately, TSX is currently unavailable due to a bug. We achieve
-// repeatable results with a robust measure of the central tendency ("mode").
-
-// Returns time elapsed between timer Start/Stop.
-Duration EstimateResolutionOnCurrentCPU(const Func func) {
- // Even 128K samples are not enough to achieve repeatable results when
- // throttling is enabled; the caller must perform additional aggregation.
- const size_t kNumSamples = 512;
- Duration samples[kNumSamples];
- for (size_t i = 0; i < kNumSamples; ++i) {
- const volatile Duration t0 = Start<Duration>();
- PreventElision(func(i));
- const volatile Duration t1 = Stop<Duration>();
- NANOBENCHMARK_CHECK(t0 <= t1);
- samples[i] = t1 - t0;
- }
- CountingSort(samples, samples + kNumSamples);
- const Duration resolution = Mode(samples, kNumSamples);
- NANOBENCHMARK_CHECK(resolution != 0);
- return resolution;
-}
-
-// Returns mode of EstimateResolutionOnCurrentCPU across all CPUs. This
-// increases repeatability because some CPUs may be throttled or slowed down by
-// interrupts.
-Duration EstimateResolution(const Func func_to_measure) {
- Func func = (func_to_measure == &Func2) ? &Func1 : &Func2;
-
- const size_t kNumSamples = 512;
- std::vector<Duration> resolutions;
- resolutions.reserve(kNumSamples);
-
- const auto cpus = AvailableCPUs();
- const size_t repetitions_per_cpu = kNumSamples / cpus.size();
-
- auto affinity = GetThreadAffinity();
- for (const int cpu : cpus) {
- PinThreadToCPU(cpu);
- for (size_t i = 0; i < repetitions_per_cpu; ++i) {
- resolutions.push_back(EstimateResolutionOnCurrentCPU(func));
- }
- }
- SetThreadAffinity(affinity);
- free(affinity);
-
- Duration* const begin = resolutions.data();
- CountingSort(begin, begin + resolutions.size());
- const Duration resolution = Mode(begin, resolutions.size());
- printf("Resolution %lu\n", long(resolution));
- return resolution;
-}
-
-// Returns cycles elapsed when running an empty region, i.e. the timer
-// resolution/overhead, which will be deducted from other measurements and
-// also used by InitReplicas.
-Duration Resolution(const Func func) {
- // Initialization is expensive and should only happen once.
- static const Duration resolution = EstimateResolution(func);
- return resolution;
-}
-
-// Returns cycles elapsed when passing each of "inputs" (after in-place
-// shuffling) to "func", which must return something it has computed
-// so the compiler does not optimize it away.
-Duration CyclesElapsed(const Duration resolution, const Func func,
- std::vector<FuncInput>* inputs) {
- // This benchmark attempts to measure the performance of "func" when
- // called with realistic inputs, which we assume are randomly drawn
- // from the given "inputs" distribution, so we shuffle those values.
- std::random_shuffle(inputs->begin(), inputs->end());
-
- const Duration t0 = Start<Duration>();
- for (const FuncInput input : *inputs) {
- PreventElision(func(input));
- }
- const Duration t1 = Stop<Duration>();
- const Duration elapsed = t1 - t0;
- NANOBENCHMARK_CHECK(elapsed > resolution);
- return elapsed - resolution;
-}
-
-// Stores input values for a series of calls to the function to measure.
-// We assume inputs are drawn from a known discrete probability distribution,
-// modeled as a vector<FuncInput> v. The probability of a value X
-// in v is count(v.begin(), v.end(), X) / v.size().
-class Inputs {
- Inputs(const Inputs&) = delete;
- Inputs& operator=(const Inputs&) = delete;
-
- public:
- Inputs(const Duration resolution, const std::vector<FuncInput>& distribution,
- const Func func)
- : unique_(InitUnique(distribution)),
- replicas_(InitReplicas(distribution, resolution, func)),
- num_replicas_(replicas_.size() / distribution.size()) {
- printf("NumReplicas %zu\n", num_replicas_);
- }
-
- // Returns vector of the unique values from the input distribution.
- const std::vector<FuncInput>& Unique() const { return unique_; }
-
- // Returns how many instances of "distribution" are in "replicas_", i.e.
- // the number of occurrences of an input value that occurred only once
- // in the distribution. This is the divisor for computing the duration
- // of a single call.
- size_t NumReplicas() const { return num_replicas_; }
-
- // Returns the (replicated) input distribution. Modified by caller
- // (shuffled in-place) => not thread-safe.
- std::vector<FuncInput>& Replicas() { return replicas_; }
-
- // Returns a copy of Replicas() with NumReplicas() occurrences of "input"
- // removed. Used for the leave-one-out measurement.
- std::vector<FuncInput> Without(const FuncInput input_to_remove) const {
- // "input_to_remove" should be in the original distribution.
- NANOBENCHMARK_CHECK(std::find(unique_.begin(), unique_.end(),
- input_to_remove) != unique_.end());
-
- std::vector<FuncInput> copy = replicas_;
- auto pos = std::partition(copy.begin(), copy.end(),
- [input_to_remove](const FuncInput input) {
- return input_to_remove != input;
- });
- // Must occur at least num_replicas_ times.
- NANOBENCHMARK_CHECK(copy.end() - pos >= num_replicas_);
- // (Avoids unused-variable warning.)
- PreventElision(&*pos);
- copy.resize(copy.size() - num_replicas_);
- return copy;
- }
-
- private:
- // Returns a copy with any duplicate values removed. Initializing unique_
- // through this function allows it to be const.
- static std::vector<FuncInput> InitUnique(
- const std::vector<FuncInput>& distribution) {
- std::vector<FuncInput> unique = distribution;
- std::sort(unique.begin(), unique.end());
- unique.erase(std::unique(unique.begin(), unique.end()), unique.end());
- // Our leave-one-out measurement technique only makes sense when
- // there are multiple input values.
- NANOBENCHMARK_CHECK(unique.size() >= 2);
- return unique;
- }
-
- // Returns how many replicas of "distribution" are required before
- // CyclesElapsed is large enough compared to the timer resolution.
- static std::vector<FuncInput> InitReplicas(
- const std::vector<FuncInput>& distribution, const Duration resolution,
- const Func func) {
- // We compute the difference in duration for inputs = Replicas() vs.
- // Without(). Dividing this by num_replicas must yield a value where the
- // quantization error (from the timer resolution) is sufficiently small.
- const uint64_t min_elapsed = distribution.size() * resolution * 400;
-
- std::vector<FuncInput> replicas;
- for (;;) {
- AppendReplica(distribution, &replicas);
-
-#if NANOBENCHMARK_ENABLE_CHECKS
- const uint64_t t0 = Start64();
-#endif
- const Duration elapsed = CyclesElapsed(resolution, func, &replicas);
-#if NANOBENCHMARK_ENABLE_CHECKS
- const uint64_t t1 = Stop64();
-#endif
- // Ensure the 32-bit timer didn't and won't overflow.
- NANOBENCHMARK_CHECK((t1 - t0) < (1ULL << 30));
-
- if (elapsed >= min_elapsed) {
- return replicas;
- }
- }
- }
-
- // Appends all values in "distribution" to "replicas".
- static void AppendReplica(const std::vector<FuncInput>& distribution,
- std::vector<FuncInput>* replicas) {
- replicas->reserve(replicas->size() + distribution.size());
- for (const FuncInput input : distribution) {
- replicas->push_back(input);
- }
- }
-
- const std::vector<FuncInput> unique_;
-
- // Modified by caller (shuffled in-place) => non-const.
- std::vector<FuncInput> replicas_;
-
- // Initialized from replicas_.
- const size_t num_replicas_;
-};
-
-// Holds samples of measured durations, and (robustly) reduces them to a
-// single result for each unique input value.
-class DurationSamples {
- public:
- DurationSamples(const std::vector<FuncInput>& unique_inputs,
- const size_t num_samples)
- : num_samples_(num_samples) {
- // Preallocate storage.
- for (const FuncInput input : unique_inputs) {
- samples_for_input_[input].reserve(num_samples);
- }
- }
-
- void Add(const FuncInput input, const Duration sample) {
- // "input" should be one of the values passed to the ctor.
- NANOBENCHMARK_CHECK(samples_for_input_.find(input) !=
- samples_for_input_.end());
-
- samples_for_input_[input].push_back(sample);
- }
-
- // Invokes "lambda" for each (input, duration) pair. The per-call duration
- // is the central tendency (the mode) of the samples.
- template <class Lambda>
- void Reduce(const Lambda& lambda) {
- for (auto& input_and_samples : samples_for_input_) {
- const FuncInput input = input_and_samples.first;
- std::vector<Duration>& samples = input_and_samples.second;
-
- NANOBENCHMARK_CHECK(samples.size() <= num_samples_);
- std::sort(samples.begin(), samples.end());
- const Duration duration = Mode(samples.data(), samples.size());
- lambda(input, duration);
- }
- }
-
- private:
- const size_t num_samples_;
- std::map<FuncInput, std::vector<Duration>> samples_for_input_;
-};
-
-// Gathers "num_samples" durations via repeated leave-one-out measurements.
-DurationSamples GatherDurationSamples(const Duration resolution, Inputs& inputs,
- const Func func,
- const size_t num_samples) {
- DurationSamples samples(inputs.Unique(), num_samples);
- for (size_t i = 0; i < num_samples; ++i) {
- // Total duration for all shuffled input values. This may change over time,
- // so recompute it for each sample.
- const Duration total = CyclesElapsed(resolution, func, &inputs.Replicas());
-
- for (const FuncInput input : inputs.Unique()) {
- // To isolate the durations of the calls with this input value,
- // we measure the duration without those values and subtract that
- // from the total, and later divide by NumReplicas.
- std::vector<FuncInput> without = inputs.Without(input);
- for (int rep = 0; rep < 3; ++rep) {
- const Duration elapsed = CyclesElapsed(resolution, func, &without);
- if (elapsed < total) {
- samples.Add(input, total - elapsed);
- break;
- }
- }
- }
- }
- return samples;
-}
-
-} // namespace
-
-DurationsForInputs::DurationsForInputs(const FuncInput* inputs,
- const size_t num_inputs,
- const size_t max_durations)
- : num_items(0),
- inputs_(inputs),
- num_inputs_(num_inputs),
- max_durations_(max_durations),
- all_durations_(new float[num_inputs * max_durations]) {
- NANOBENCHMARK_CHECK(num_inputs != 0);
- NANOBENCHMARK_CHECK(max_durations != 0);
-
- items = new Item[num_inputs];
- for (size_t i = 0; i < num_inputs_; ++i) {
- items[i].input = 0; // initialized later
- items[i].num_durations = 0;
- items[i].durations = all_durations_ + i * max_durations;
- }
-}
-
-DurationsForInputs::~DurationsForInputs() {
- delete[] all_durations_;
- delete[] items;
-}
-
-void DurationsForInputs::AddItem(const FuncInput input, const float sample) {
- for (size_t i = 0; i < num_items; ++i) {
- NANOBENCHMARK_CHECK(items[i].input != input);
- }
- Item& item = items[num_items];
- item.input = input;
- item.num_durations = 1;
- item.durations[0] = sample;
- ++num_items;
-}
-
-void DurationsForInputs::AddSample(const FuncInput input, const float sample) {
- for (size_t i = 0; i < num_items; ++i) {
- Item& item = items[i];
- if (item.input == input) {
- item.durations[item.num_durations] = sample;
- ++item.num_durations;
- return;
- }
- }
- NANOBENCHMARK_CHECK(!"Item not found");
-}
-
-void DurationsForInputs::Item::PrintMedianAndVariability() {
- // Copy so that Median can modify.
- std::vector<float> duration_vec(durations, durations + num_durations);
- const float median = Median(&duration_vec);
- const float variability = MedianAbsoluteDeviation(duration_vec, median);
- printf("%5zu: median=%5.1f cycles; median abs. deviation=%4.1f cycles\n",
- input, median, variability);
-}
-
-void MeasureDurations(const Func func, DurationsForInputs* input_map) {
- const Duration resolution = Resolution(func);
-
- // Adds enough 'replicas' of the distribution to measure "func" given
- // the timer resolution.
- const std::vector<FuncInput> distribution(
- input_map->inputs_, input_map->inputs_ + input_map->num_inputs_);
- Inputs inputs(resolution, distribution, func);
- const double per_call = 1.0 / static_cast<int>(inputs.NumReplicas());
-
- // First iteration: populate input_map items.
- auto samples = GatherDurationSamples(resolution, inputs, func, 512);
- samples.Reduce(
- [per_call, input_map](const FuncInput input, const Duration duration) {
- const float sample = static_cast<float>(duration * per_call);
- input_map->AddItem(input, sample);
- });
-
- // Subsequent iteration(s): append to input_map items' array.
- for (size_t rep = 1; rep < input_map->max_durations_; ++rep) {
- auto samples = GatherDurationSamples(resolution, inputs, func, 512);
- samples.Reduce(
- [per_call, input_map](const FuncInput input, const Duration duration) {
- const float sample = static_cast<float>(duration * per_call);
- input_map->AddSample(input, sample);
- });
- }
-}
-
-} // namespace highwayhash
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/nanobenchmark.h"
+
+#include <algorithm>
+#include <cmath>
+#include <cstdio>
+#include <map>
+#include <random>
+#include <vector>
+
+#include <stddef.h>
+
+#include "highwayhash/os_specific.h"
+#include "highwayhash/robust_statistics.h"
+#include "highwayhash/tsc_timer.h"
+
+namespace highwayhash {
+namespace {
+
+// Enables sanity checks that verify correct operation at the cost of
+// longer benchmark runs.
+#ifndef NANOBENCHMARK_ENABLE_CHECKS
+#define NANOBENCHMARK_ENABLE_CHECKS 0
+#endif
+
+#define NANOBENCHMARK_CHECK_ALWAYS(condition) \
+ while (!(condition)) { \
+ printf("Nanobenchmark check failed at line %d\n", __LINE__); \
+ abort(); \
+ }
+
+#if NANOBENCHMARK_ENABLE_CHECKS
+#define NANOBENCHMARK_CHECK(condition) NANOBENCHMARK_CHECK_ALWAYS(condition)
+#else
+#define NANOBENCHMARK_CHECK(condition)
+#endif
+
+#if HH_MSC_VERSION
+
+// MSVC does not support inline assembly anymore (and never supported GCC's
+// RTL constraints used below).
+#pragma optimize("", off)
+// Self-assignment with #pragma optimize("off") might be expected to prevent
+// elision, but it does not with MSVC 2015.
+void UseCharPointer(volatile const char*) {}
+#pragma optimize("", on)
+
+template <class T>
+inline void PreventElision(T&& output) {
+ UseCharPointer(reinterpret_cast<volatile const char*>(&output));
+}
+
+#else
+
+// Prevents the compiler from eliding the computations that led to "output".
+// Works by indicating to the compiler that "output" is being read and modified.
+// The +r constraint avoids unnecessary writes to memory, but only works for
+// FuncOutput.
+template <class T>
+inline void PreventElision(T&& output) {
+ asm volatile("" : "+r"(output) : : "memory");
+}
+
+#endif
+
+HH_NOINLINE FuncOutput Func1(const FuncInput input) { return input + 1; }
+HH_NOINLINE FuncOutput Func2(const FuncInput input) { return input + 2; }
+
+// Cycles elapsed = difference between two cycle counts. Must be unsigned to
+// ensure wraparound on overflow.
+using Duration = uint32_t;
+
+// Even with high-priority pinned threads and frequency throttling disabled,
+// elapsed times are noisy due to interrupts or SMM operations. It might help
+// to detect such events via transactions and omit affected measurements.
+// Unfortunately, TSX is currently unavailable due to a bug. We achieve
+// repeatable results with a robust measure of the central tendency ("mode").
+
+// Returns time elapsed between timer Start/Stop.
+Duration EstimateResolutionOnCurrentCPU(const Func func) {
+ // Even 128K samples are not enough to achieve repeatable results when
+ // throttling is enabled; the caller must perform additional aggregation.
+ const size_t kNumSamples = 512;
+ Duration samples[kNumSamples];
+ for (size_t i = 0; i < kNumSamples; ++i) {
+ const volatile Duration t0 = Start<Duration>();
+ PreventElision(func(i));
+ const volatile Duration t1 = Stop<Duration>();
+ NANOBENCHMARK_CHECK(t0 <= t1);
+ samples[i] = t1 - t0;
+ }
+ CountingSort(samples, samples + kNumSamples);
+ const Duration resolution = Mode(samples, kNumSamples);
+ NANOBENCHMARK_CHECK(resolution != 0);
+ return resolution;
+}
+
+// Returns mode of EstimateResolutionOnCurrentCPU across all CPUs. This
+// increases repeatability because some CPUs may be throttled or slowed down by
+// interrupts.
+Duration EstimateResolution(const Func func_to_measure) {
+ Func func = (func_to_measure == &Func2) ? &Func1 : &Func2;
+
+ const size_t kNumSamples = 512;
+ std::vector<Duration> resolutions;
+ resolutions.reserve(kNumSamples);
+
+ const auto cpus = AvailableCPUs();
+ const size_t repetitions_per_cpu = kNumSamples / cpus.size();
+
+ auto affinity = GetThreadAffinity();
+ for (const int cpu : cpus) {
+ PinThreadToCPU(cpu);
+ for (size_t i = 0; i < repetitions_per_cpu; ++i) {
+ resolutions.push_back(EstimateResolutionOnCurrentCPU(func));
+ }
+ }
+ SetThreadAffinity(affinity);
+ free(affinity);
+
+ Duration* const begin = resolutions.data();
+ CountingSort(begin, begin + resolutions.size());
+ const Duration resolution = Mode(begin, resolutions.size());
+ printf("Resolution %lu\n", long(resolution));
+ return resolution;
+}
+
+// Returns cycles elapsed when running an empty region, i.e. the timer
+// resolution/overhead, which will be deducted from other measurements and
+// also used by InitReplicas.
+Duration Resolution(const Func func) {
+ // Initialization is expensive and should only happen once.
+ static const Duration resolution = EstimateResolution(func);
+ return resolution;
+}
+
+// Returns cycles elapsed when passing each of "inputs" (after in-place
+// shuffling) to "func", which must return something it has computed
+// so the compiler does not optimize it away.
+Duration CyclesElapsed(const Duration resolution, const Func func,
+ std::vector<FuncInput>* inputs) {
+ // This benchmark attempts to measure the performance of "func" when
+ // called with realistic inputs, which we assume are randomly drawn
+ // from the given "inputs" distribution, so we shuffle those values.
+ std::random_shuffle(inputs->begin(), inputs->end());
+
+ const Duration t0 = Start<Duration>();
+ for (const FuncInput input : *inputs) {
+ PreventElision(func(input));
+ }
+ const Duration t1 = Stop<Duration>();
+ const Duration elapsed = t1 - t0;
+ NANOBENCHMARK_CHECK(elapsed > resolution);
+ return elapsed - resolution;
+}
+
+// Stores input values for a series of calls to the function to measure.
+// We assume inputs are drawn from a known discrete probability distribution,
+// modeled as a vector<FuncInput> v. The probability of a value X
+// in v is count(v.begin(), v.end(), X) / v.size().
+class Inputs {
+ Inputs(const Inputs&) = delete;
+ Inputs& operator=(const Inputs&) = delete;
+
+ public:
+ Inputs(const Duration resolution, const std::vector<FuncInput>& distribution,
+ const Func func)
+ : unique_(InitUnique(distribution)),
+ replicas_(InitReplicas(distribution, resolution, func)),
+ num_replicas_(replicas_.size() / distribution.size()) {
+ printf("NumReplicas %zu\n", num_replicas_);
+ }
+
+ // Returns vector of the unique values from the input distribution.
+ const std::vector<FuncInput>& Unique() const { return unique_; }
+
+ // Returns how many instances of "distribution" are in "replicas_", i.e.
+ // the number of occurrences of an input value that occurred only once
+ // in the distribution. This is the divisor for computing the duration
+ // of a single call.
+ size_t NumReplicas() const { return num_replicas_; }
+
+ // Returns the (replicated) input distribution. Modified by caller
+ // (shuffled in-place) => not thread-safe.
+ std::vector<FuncInput>& Replicas() { return replicas_; }
+
+ // Returns a copy of Replicas() with NumReplicas() occurrences of "input"
+ // removed. Used for the leave-one-out measurement.
+ std::vector<FuncInput> Without(const FuncInput input_to_remove) const {
+ // "input_to_remove" should be in the original distribution.
+ NANOBENCHMARK_CHECK(std::find(unique_.begin(), unique_.end(),
+ input_to_remove) != unique_.end());
+
+ std::vector<FuncInput> copy = replicas_;
+ auto pos = std::partition(copy.begin(), copy.end(),
+ [input_to_remove](const FuncInput input) {
+ return input_to_remove != input;
+ });
+ // Must occur at least num_replicas_ times.
+ NANOBENCHMARK_CHECK(copy.end() - pos >= num_replicas_);
+ // (Avoids unused-variable warning.)
+ PreventElision(&*pos);
+ copy.resize(copy.size() - num_replicas_);
+ return copy;
+ }
+
+ private:
+ // Returns a copy with any duplicate values removed. Initializing unique_
+ // through this function allows it to be const.
+ static std::vector<FuncInput> InitUnique(
+ const std::vector<FuncInput>& distribution) {
+ std::vector<FuncInput> unique = distribution;
+ std::sort(unique.begin(), unique.end());
+ unique.erase(std::unique(unique.begin(), unique.end()), unique.end());
+ // Our leave-one-out measurement technique only makes sense when
+ // there are multiple input values.
+ NANOBENCHMARK_CHECK(unique.size() >= 2);
+ return unique;
+ }
+
+ // Returns how many replicas of "distribution" are required before
+ // CyclesElapsed is large enough compared to the timer resolution.
+ static std::vector<FuncInput> InitReplicas(
+ const std::vector<FuncInput>& distribution, const Duration resolution,
+ const Func func) {
+ // We compute the difference in duration for inputs = Replicas() vs.
+ // Without(). Dividing this by num_replicas must yield a value where the
+ // quantization error (from the timer resolution) is sufficiently small.
+ const uint64_t min_elapsed = distribution.size() * resolution * 400;
+
+ std::vector<FuncInput> replicas;
+ for (;;) {
+ AppendReplica(distribution, &replicas);
+
+#if NANOBENCHMARK_ENABLE_CHECKS
+ const uint64_t t0 = Start64();
+#endif
+ const Duration elapsed = CyclesElapsed(resolution, func, &replicas);
+#if NANOBENCHMARK_ENABLE_CHECKS
+ const uint64_t t1 = Stop64();
+#endif
+ // Ensure the 32-bit timer didn't and won't overflow.
+ NANOBENCHMARK_CHECK((t1 - t0) < (1ULL << 30));
+
+ if (elapsed >= min_elapsed) {
+ return replicas;
+ }
+ }
+ }
+
+ // Appends all values in "distribution" to "replicas".
+ static void AppendReplica(const std::vector<FuncInput>& distribution,
+ std::vector<FuncInput>* replicas) {
+ replicas->reserve(replicas->size() + distribution.size());
+ for (const FuncInput input : distribution) {
+ replicas->push_back(input);
+ }
+ }
+
+ const std::vector<FuncInput> unique_;
+
+ // Modified by caller (shuffled in-place) => non-const.
+ std::vector<FuncInput> replicas_;
+
+ // Initialized from replicas_.
+ const size_t num_replicas_;
+};
+
+// Holds samples of measured durations, and (robustly) reduces them to a
+// single result for each unique input value.
+class DurationSamples {
+ public:
+ DurationSamples(const std::vector<FuncInput>& unique_inputs,
+ const size_t num_samples)
+ : num_samples_(num_samples) {
+ // Preallocate storage.
+ for (const FuncInput input : unique_inputs) {
+ samples_for_input_[input].reserve(num_samples);
+ }
+ }
+
+ void Add(const FuncInput input, const Duration sample) {
+ // "input" should be one of the values passed to the ctor.
+ NANOBENCHMARK_CHECK(samples_for_input_.find(input) !=
+ samples_for_input_.end());
+
+ samples_for_input_[input].push_back(sample);
+ }
+
+ // Invokes "lambda" for each (input, duration) pair. The per-call duration
+ // is the central tendency (the mode) of the samples.
+ template <class Lambda>
+ void Reduce(const Lambda& lambda) {
+ for (auto& input_and_samples : samples_for_input_) {
+ const FuncInput input = input_and_samples.first;
+ std::vector<Duration>& samples = input_and_samples.second;
+
+ NANOBENCHMARK_CHECK(samples.size() <= num_samples_);
+ std::sort(samples.begin(), samples.end());
+ const Duration duration = Mode(samples.data(), samples.size());
+ lambda(input, duration);
+ }
+ }
+
+ private:
+ const size_t num_samples_;
+ std::map<FuncInput, std::vector<Duration>> samples_for_input_;
+};
+
+// Gathers "num_samples" durations via repeated leave-one-out measurements.
+DurationSamples GatherDurationSamples(const Duration resolution, Inputs& inputs,
+ const Func func,
+ const size_t num_samples) {
+ DurationSamples samples(inputs.Unique(), num_samples);
+ for (size_t i = 0; i < num_samples; ++i) {
+ // Total duration for all shuffled input values. This may change over time,
+ // so recompute it for each sample.
+ const Duration total = CyclesElapsed(resolution, func, &inputs.Replicas());
+
+ for (const FuncInput input : inputs.Unique()) {
+ // To isolate the durations of the calls with this input value,
+ // we measure the duration without those values and subtract that
+ // from the total, and later divide by NumReplicas.
+ std::vector<FuncInput> without = inputs.Without(input);
+ for (int rep = 0; rep < 3; ++rep) {
+ const Duration elapsed = CyclesElapsed(resolution, func, &without);
+ if (elapsed < total) {
+ samples.Add(input, total - elapsed);
+ break;
+ }
+ }
+ }
+ }
+ return samples;
+}
+
+} // namespace
+
+DurationsForInputs::DurationsForInputs(const FuncInput* inputs,
+ const size_t num_inputs,
+ const size_t max_durations)
+ : num_items(0),
+ inputs_(inputs),
+ num_inputs_(num_inputs),
+ max_durations_(max_durations),
+ all_durations_(new float[num_inputs * max_durations]) {
+ NANOBENCHMARK_CHECK(num_inputs != 0);
+ NANOBENCHMARK_CHECK(max_durations != 0);
+
+ items = new Item[num_inputs];
+ for (size_t i = 0; i < num_inputs_; ++i) {
+ items[i].input = 0; // initialized later
+ items[i].num_durations = 0;
+ items[i].durations = all_durations_ + i * max_durations;
+ }
+}
+
+DurationsForInputs::~DurationsForInputs() {
+ delete[] all_durations_;
+ delete[] items;
+}
+
+void DurationsForInputs::AddItem(const FuncInput input, const float sample) {
+ for (size_t i = 0; i < num_items; ++i) {
+ NANOBENCHMARK_CHECK(items[i].input != input);
+ }
+ Item& item = items[num_items];
+ item.input = input;
+ item.num_durations = 1;
+ item.durations[0] = sample;
+ ++num_items;
+}
+
+void DurationsForInputs::AddSample(const FuncInput input, const float sample) {
+ for (size_t i = 0; i < num_items; ++i) {
+ Item& item = items[i];
+ if (item.input == input) {
+ item.durations[item.num_durations] = sample;
+ ++item.num_durations;
+ return;
+ }
+ }
+ NANOBENCHMARK_CHECK(!"Item not found");
+}
+
+void DurationsForInputs::Item::PrintMedianAndVariability() {
+ // Copy so that Median can modify.
+ std::vector<float> duration_vec(durations, durations + num_durations);
+ const float median = Median(&duration_vec);
+ const float variability = MedianAbsoluteDeviation(duration_vec, median);
+ printf("%5zu: median=%5.1f cycles; median abs. deviation=%4.1f cycles\n",
+ input, median, variability);
+}
+
+void MeasureDurations(const Func func, DurationsForInputs* input_map) {
+ const Duration resolution = Resolution(func);
+
+ // Adds enough 'replicas' of the distribution to measure "func" given
+ // the timer resolution.
+ const std::vector<FuncInput> distribution(
+ input_map->inputs_, input_map->inputs_ + input_map->num_inputs_);
+ Inputs inputs(resolution, distribution, func);
+ const double per_call = 1.0 / static_cast<int>(inputs.NumReplicas());
+
+ // First iteration: populate input_map items.
+ auto samples = GatherDurationSamples(resolution, inputs, func, 512);
+ samples.Reduce(
+ [per_call, input_map](const FuncInput input, const Duration duration) {
+ const float sample = static_cast<float>(duration * per_call);
+ input_map->AddItem(input, sample);
+ });
+
+ // Subsequent iteration(s): append to input_map items' array.
+ for (size_t rep = 1; rep < input_map->max_durations_; ++rep) {
+ auto samples = GatherDurationSamples(resolution, inputs, func, 512);
+ samples.Reduce(
+ [per_call, input_map](const FuncInput input, const Duration duration) {
+ const float sample = static_cast<float>(duration * per_call);
+ input_map->AddSample(input, sample);
+ });
+ }
+}
+
+} // namespace highwayhash
diff --git a/contrib/libs/highwayhash/highwayhash/nanobenchmark.h b/contrib/libs/highwayhash/highwayhash/nanobenchmark.h
index ba4ca5a9bb..1cf6426e0f 100644
--- a/contrib/libs/highwayhash/highwayhash/nanobenchmark.h
+++ b/contrib/libs/highwayhash/highwayhash/nanobenchmark.h
@@ -1,158 +1,158 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_NANOBENCHMARK_H_
-#define HIGHWAYHASH_NANOBENCHMARK_H_
-
-// Benchmarks functions of a single integer argument with realistic branch
-// prediction hit rates. Uses a robust estimator to summarize the measurements.
-// Measurements are precise to about 0.2 cycles.
-//
-// Example:
-// #include "highwayhash/nanobenchmark.h"
-// using namespace highwayhash;
-//
-// uint64_t RegionToMeasure(size_t size) {
-// char from[8] = {static_cast<char>(size)};
-// char to[8];
-// memcpy(to, from, size);
-// return to[0];
-// }
-//
-// PinThreadToRandomCPU();
-//
-// static const size_t distribution[] = {3, 3, 4, 4, 7, 7, 8, 8};
-// DurationsForInputs input_map = MakeDurationsForInputs(distribution, 10);
-// MeasureDurations(&RegionToMeasure, &input_map);
-// for (size_t i = 0; i < input_map.num_items; ++i) {
-// input_map.items[i].PrintMedianAndVariability();
-// }
-//
-// Output:
-// 3: median= 25.2 cycles; median abs. deviation= 0.1 cycles
-// 4: median= 13.5 cycles; median abs. deviation= 0.1 cycles
-// 7: median= 13.5 cycles; median abs. deviation= 0.1 cycles
-// 8: median= 27.5 cycles; median abs. deviation= 0.2 cycles
-// (7 is presumably faster because it can use two unaligned 32-bit load/stores.)
-//
-// Background: Microbenchmarks such as http://github.com/google/benchmark
-// can measure elapsed times on the order of a microsecond. Shorter functions
-// are typically measured by repeating them thousands of times and dividing
-// the total elapsed time by this count. Unfortunately, repetition (especially
-// with the same input parameter!) influences the runtime. In time-critical
-// code, it is reasonable to expect warm instruction/data caches and TLBs,
-// but a perfect record of which branches will be taken is unrealistic.
-// Unless the application also repeatedly invokes the measured function with
-// the same parameter, the benchmark is measuring something very different -
-// a best-case result, almost as if the parameter were made a compile-time
-// constant. This may lead to erroneous conclusions about branch-heavy
-// algorithms outperforming branch-free alternatives.
-//
-// Our approach differs in three ways. Adding fences to the timer functions
-// reduces variability due to instruction reordering, improving the timer
-// resolution to about 10 nanoseconds. However, shorter functions must still
-// be invoked repeatedly. For more realistic branch prediction performance,
-// we vary the input parameter according to a user-specified distribution.
-// Thus, instead of VaryInputs(Measure(Repeat(func))), we change the
-// loop nesting to Measure(Repeat(VaryInputs(func))). We also estimate the
-// central tendency of the measurement samples with the "half sample mode",
-// which is more robust to outliers and skewed data than the mean or median.
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stddef.h>
-#include <stdint.h>
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-
-namespace highwayhash {
-
-// Argument to the function being measured (e.g. number of bytes to copy).
-using FuncInput = size_t;
-
-// "Proof of work" returned by the function to ensure it is not elided.
-using FuncOutput = uint64_t;
-
-// Function to measure (cannot use std::function in a restricted header).
-using Func = FuncOutput (*)(FuncInput);
-
-// Flat map of input -> durations[].
-class DurationsForInputs {
- public:
- struct Item {
- void PrintMedianAndVariability();
-
- FuncInput input; // read-only (set by AddItem).
- size_t num_durations; // written so far: [0, max_durations).
- float* durations; // max_durations entries; points into all_durations.
- };
-
- // "inputs" is an array of "num_inputs" (not necessarily unique) arguments to
- // "func". The values are chosen to maximize coverage of "func". The pointer
- // must remain valid until after MeasureDurations. This represents a
- // distribution, so a value's frequency should reflect its probability in the
- // real application. Order does not matter; for example, a uniform
- // distribution over [0, 4) could be represented as {3,0,2,1}. Repeating each
- // value at least once ensures the leave-one-out distribution is closer to the
- // original distribution, leading to more realistic results.
- //
- // "max_durations" is the number of duration samples to measure for each
- // unique input value. Larger values decrease variability.
- //
- // Runtime is proportional to "num_inputs" * #unique * "max_durations".
- DurationsForInputs(const FuncInput* inputs, const size_t num_inputs,
- const size_t max_durations);
- ~DurationsForInputs();
-
- // Adds an item with the given "input" and "sample". Must only be called once
- // per unique "input" value.
- void AddItem(const FuncInput input, const float sample);
-
- // Adds "sample" to an already existing Item with the given "input".
- void AddSample(const FuncInput input, const float sample);
-
- // Allow direct inspection of items[0..num_items-1] because accessor or
- // ForeachItem functions are unsafe in a restricted header.
- Item* items; // owned by this class, do not allocate/free.
- size_t num_items; // safe to reset to zero.
-
- private:
- friend void MeasureDurations(Func, DurationsForInputs*);
-
- const FuncInput* const inputs_;
- const size_t num_inputs_;
- const size_t max_durations_;
- float* const all_durations_;
-};
-
-// Helper function to detect num_inputs from arrays.
-template <size_t N>
-static HH_INLINE DurationsForInputs MakeDurationsForInputs(
- const FuncInput (&inputs)[N], const size_t max_durations) {
- return DurationsForInputs(&inputs[0], N, max_durations);
-}
-
-// Returns precise measurements of the cycles elapsed when calling "func" with
-// each unique input value in "input_map", taking special care to maintain
-// realistic branch prediction hit rates.
-//
-// "func" returns a 'proof of work' to ensure its computations are not elided.
-void MeasureDurations(const Func func, DurationsForInputs* input_map);
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_NANOBENCHMARK_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_NANOBENCHMARK_H_
+#define HIGHWAYHASH_NANOBENCHMARK_H_
+
+// Benchmarks functions of a single integer argument with realistic branch
+// prediction hit rates. Uses a robust estimator to summarize the measurements.
+// Measurements are precise to about 0.2 cycles.
+//
+// Example:
+// #include "highwayhash/nanobenchmark.h"
+// using namespace highwayhash;
+//
+// uint64_t RegionToMeasure(size_t size) {
+// char from[8] = {static_cast<char>(size)};
+// char to[8];
+// memcpy(to, from, size);
+// return to[0];
+// }
+//
+// PinThreadToRandomCPU();
+//
+// static const size_t distribution[] = {3, 3, 4, 4, 7, 7, 8, 8};
+// DurationsForInputs input_map = MakeDurationsForInputs(distribution, 10);
+// MeasureDurations(&RegionToMeasure, &input_map);
+// for (size_t i = 0; i < input_map.num_items; ++i) {
+// input_map.items[i].PrintMedianAndVariability();
+// }
+//
+// Output:
+// 3: median= 25.2 cycles; median abs. deviation= 0.1 cycles
+// 4: median= 13.5 cycles; median abs. deviation= 0.1 cycles
+// 7: median= 13.5 cycles; median abs. deviation= 0.1 cycles
+// 8: median= 27.5 cycles; median abs. deviation= 0.2 cycles
+// (7 is presumably faster because it can use two unaligned 32-bit load/stores.)
+//
+// Background: Microbenchmarks such as http://github.com/google/benchmark
+// can measure elapsed times on the order of a microsecond. Shorter functions
+// are typically measured by repeating them thousands of times and dividing
+// the total elapsed time by this count. Unfortunately, repetition (especially
+// with the same input parameter!) influences the runtime. In time-critical
+// code, it is reasonable to expect warm instruction/data caches and TLBs,
+// but a perfect record of which branches will be taken is unrealistic.
+// Unless the application also repeatedly invokes the measured function with
+// the same parameter, the benchmark is measuring something very different -
+// a best-case result, almost as if the parameter were made a compile-time
+// constant. This may lead to erroneous conclusions about branch-heavy
+// algorithms outperforming branch-free alternatives.
+//
+// Our approach differs in three ways. Adding fences to the timer functions
+// reduces variability due to instruction reordering, improving the timer
+// resolution to about 10 nanoseconds. However, shorter functions must still
+// be invoked repeatedly. For more realistic branch prediction performance,
+// we vary the input parameter according to a user-specified distribution.
+// Thus, instead of VaryInputs(Measure(Repeat(func))), we change the
+// loop nesting to Measure(Repeat(VaryInputs(func))). We also estimate the
+// central tendency of the measurement samples with the "half sample mode",
+// which is more robust to outliers and skewed data than the mean or median.
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stddef.h>
+#include <stdint.h>
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+
+namespace highwayhash {
+
+// Argument to the function being measured (e.g. number of bytes to copy).
+using FuncInput = size_t;
+
+// "Proof of work" returned by the function to ensure it is not elided.
+using FuncOutput = uint64_t;
+
+// Function to measure (cannot use std::function in a restricted header).
+using Func = FuncOutput (*)(FuncInput);
+
+// Flat map of input -> durations[].
+class DurationsForInputs {
+ public:
+ struct Item {
+ void PrintMedianAndVariability();
+
+ FuncInput input; // read-only (set by AddItem).
+ size_t num_durations; // written so far: [0, max_durations).
+ float* durations; // max_durations entries; points into all_durations.
+ };
+
+ // "inputs" is an array of "num_inputs" (not necessarily unique) arguments to
+ // "func". The values are chosen to maximize coverage of "func". The pointer
+ // must remain valid until after MeasureDurations. This represents a
+ // distribution, so a value's frequency should reflect its probability in the
+ // real application. Order does not matter; for example, a uniform
+ // distribution over [0, 4) could be represented as {3,0,2,1}. Repeating each
+ // value at least once ensures the leave-one-out distribution is closer to the
+ // original distribution, leading to more realistic results.
+ //
+ // "max_durations" is the number of duration samples to measure for each
+ // unique input value. Larger values decrease variability.
+ //
+ // Runtime is proportional to "num_inputs" * #unique * "max_durations".
+ DurationsForInputs(const FuncInput* inputs, const size_t num_inputs,
+ const size_t max_durations);
+ ~DurationsForInputs();
+
+ // Adds an item with the given "input" and "sample". Must only be called once
+ // per unique "input" value.
+ void AddItem(const FuncInput input, const float sample);
+
+ // Adds "sample" to an already existing Item with the given "input".
+ void AddSample(const FuncInput input, const float sample);
+
+ // Allow direct inspection of items[0..num_items-1] because accessor or
+ // ForeachItem functions are unsafe in a restricted header.
+ Item* items; // owned by this class, do not allocate/free.
+ size_t num_items; // safe to reset to zero.
+
+ private:
+ friend void MeasureDurations(Func, DurationsForInputs*);
+
+ const FuncInput* const inputs_;
+ const size_t num_inputs_;
+ const size_t max_durations_;
+ float* const all_durations_;
+};
+
+// Helper function to detect num_inputs from arrays.
+template <size_t N>
+static HH_INLINE DurationsForInputs MakeDurationsForInputs(
+ const FuncInput (&inputs)[N], const size_t max_durations) {
+ return DurationsForInputs(&inputs[0], N, max_durations);
+}
+
+// Returns precise measurements of the cycles elapsed when calling "func" with
+// each unique input value in "input_map", taking special care to maintain
+// realistic branch prediction hit rates.
+//
+// "func" returns a 'proof of work' to ensure its computations are not elided.
+void MeasureDurations(const Func func, DurationsForInputs* input_map);
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_NANOBENCHMARK_H_
diff --git a/contrib/libs/highwayhash/highwayhash/nanobenchmark_example.cc b/contrib/libs/highwayhash/highwayhash/nanobenchmark_example.cc
index f7b2269311..d95acf144a 100644
--- a/contrib/libs/highwayhash/highwayhash/nanobenchmark_example.cc
+++ b/contrib/libs/highwayhash/highwayhash/nanobenchmark_example.cc
@@ -1,48 +1,48 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <cstddef>
-#include <cstring>
-#include <vector>
-
-#include "highwayhash/nanobenchmark.h"
-#include "highwayhash/os_specific.h"
-
-namespace highwayhash {
-namespace {
-
-uint64_t RegionToMeasure(FuncInput size) {
- char from[8] = {static_cast<char>(size)};
- char to[8];
- memcpy(to, from, size);
- return to[0];
-}
-
-void TestMemcpy() {
- PinThreadToRandomCPU();
- static const size_t distribution[] = {3, 3, 4, 4, 7, 7, 8, 8};
- DurationsForInputs input_map = MakeDurationsForInputs(distribution, 10);
- MeasureDurations(&RegionToMeasure, &input_map);
- for (size_t i = 0; i < input_map.num_items; ++i) {
- input_map.items[i].PrintMedianAndVariability();
- }
-}
-
-} // namespace
-} // namespace highwayhash
-
-int main(int argc, char* argv[]) {
- highwayhash::TestMemcpy();
- return 0;
-}
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstddef>
+#include <cstring>
+#include <vector>
+
+#include "highwayhash/nanobenchmark.h"
+#include "highwayhash/os_specific.h"
+
+namespace highwayhash {
+namespace {
+
+uint64_t RegionToMeasure(FuncInput size) {
+ char from[8] = {static_cast<char>(size)};
+ char to[8];
+ memcpy(to, from, size);
+ return to[0];
+}
+
+void TestMemcpy() {
+ PinThreadToRandomCPU();
+ static const size_t distribution[] = {3, 3, 4, 4, 7, 7, 8, 8};
+ DurationsForInputs input_map = MakeDurationsForInputs(distribution, 10);
+ MeasureDurations(&RegionToMeasure, &input_map);
+ for (size_t i = 0; i < input_map.num_items; ++i) {
+ input_map.items[i].PrintMedianAndVariability();
+ }
+}
+
+} // namespace
+} // namespace highwayhash
+
+int main(int argc, char* argv[]) {
+ highwayhash::TestMemcpy();
+ return 0;
+}
diff --git a/contrib/libs/highwayhash/highwayhash/os_specific.cc b/contrib/libs/highwayhash/highwayhash/os_specific.cc
index 5c877bc709..c28b2c1ae3 100644
--- a/contrib/libs/highwayhash/highwayhash/os_specific.cc
+++ b/contrib/libs/highwayhash/highwayhash/os_specific.cc
@@ -1,244 +1,244 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/os_specific.h"
-
-#include <algorithm>
-#include <cstddef>
-#include <cstdint>
-#include <cstdio>
-#include <cstdlib>
-#include <ctime>
-#include <random>
-
-#include "highwayhash/arch_specific.h"
-
-#if defined(_WIN32) || defined(_WIN64)
-#define OS_WIN 1
-#define NOMINMAX
-#include <windows.h>
-#else
-#define OS_WIN 0
-#endif
-
-#ifdef __linux__
-#define OS_LINUX 1
-#include <sched.h>
-#include <sys/time.h>
-#else
-#define OS_LINUX 0
-#endif
-
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/os_specific.h"
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
+#include <random>
+
+#include "highwayhash/arch_specific.h"
+
+#if defined(_WIN32) || defined(_WIN64)
+#define OS_WIN 1
+#define NOMINMAX
+#include <windows.h>
+#else
+#define OS_WIN 0
+#endif
+
+#ifdef __linux__
+#define OS_LINUX 1
+#include <sched.h>
+#include <sys/time.h>
+#else
+#define OS_LINUX 0
+#endif
+
#if defined(__MACH__) || defined(__APPLE__)
-#define OS_MAC 1
-#include <mach/mach.h>
-#include <mach/mach_time.h>
-#else
-#define OS_MAC 0
-#endif
-
-#ifdef __FreeBSD__
-#define OS_FREEBSD 1
-#include <sys/cpuset.h>
-#include <sys/param.h>
-#include <unistd.h>
-#else
-#define OS_FREEBSD 0
-#endif
-
-namespace highwayhash {
-
-#define CHECK(condition) \
- while (!(condition)) { \
- printf("os_specific CHECK failed at line %d\n", __LINE__); \
- abort(); \
- }
-
-double Now() {
-#if OS_WIN
- LARGE_INTEGER counter;
- (void)QueryPerformanceCounter(&counter);
- static const double rcp_freq = []() {
- LARGE_INTEGER freq;
- (void)QueryPerformanceFrequency(&freq);
- return 1.0 / freq.QuadPart;
- }();
- return counter.QuadPart * rcp_freq;
-#elif OS_MAC
- const auto t = mach_absolute_time();
- // On OSX/iOS platform the elapsed time is cpu time unit
- // We have to query the time base information to convert it back
- // See https://developer.apple.com/library/mac/qa/qa1398/_index.html
- static mach_timebase_info_data_t timebase;
- if (timebase.denom == 0) {
- (void)mach_timebase_info(&timebase);
- }
- return double(t) * timebase.numer / timebase.denom * 1E-9;
-#else
- timespec t;
- clock_gettime(CLOCK_REALTIME, &t);
- return t.tv_sec + t.tv_nsec * 1E-9;
-#endif
-}
-
-void RaiseThreadPriority() {
-#if OS_WIN
- BOOL ok = SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
- CHECK(ok);
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
- CHECK(ok);
-#elif OS_LINUX
- // omit: SCHED_RR and SCHED_FIFO with sched_priority max, max-1 and max/2
- // lead to 2-3x runtime and higher variability!
-#elif OS_FREEBSD
+#define OS_MAC 1
+#include <mach/mach.h>
+#include <mach/mach_time.h>
+#else
+#define OS_MAC 0
+#endif
+
+#ifdef __FreeBSD__
+#define OS_FREEBSD 1
+#include <sys/cpuset.h>
+#include <sys/param.h>
+#include <unistd.h>
+#else
+#define OS_FREEBSD 0
+#endif
+
+namespace highwayhash {
+
+#define CHECK(condition) \
+ while (!(condition)) { \
+ printf("os_specific CHECK failed at line %d\n", __LINE__); \
+ abort(); \
+ }
+
+double Now() {
+#if OS_WIN
+ LARGE_INTEGER counter;
+ (void)QueryPerformanceCounter(&counter);
+ static const double rcp_freq = []() {
+ LARGE_INTEGER freq;
+ (void)QueryPerformanceFrequency(&freq);
+ return 1.0 / freq.QuadPart;
+ }();
+ return counter.QuadPart * rcp_freq;
#elif OS_MAC
-#else
-#error "port"
-#endif
-}
-
-struct ThreadAffinity {
-#if OS_WIN
- DWORD_PTR mask;
-#elif OS_LINUX
- cpu_set_t set;
-#elif OS_FREEBSD
- cpuset_t set;
-#endif
-};
-
-ThreadAffinity* GetThreadAffinity() {
- ThreadAffinity* affinity =
- static_cast<ThreadAffinity*>(malloc(sizeof(ThreadAffinity)));
-#if OS_WIN
- DWORD_PTR system_affinity;
- const BOOL ok = GetProcessAffinityMask(GetCurrentProcess(), &affinity->mask,
- &system_affinity);
- CHECK(ok);
-#elif OS_LINUX
- const pid_t pid = 0; // current thread
- const int err = sched_getaffinity(pid, sizeof(cpu_set_t), &affinity->set);
- CHECK(err == 0);
-#elif OS_FREEBSD
- const pid_t pid = getpid(); // current thread
- const int err = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
- sizeof(cpuset_t), &affinity->set);
- CHECK(err == 0);
-#endif
- return affinity;
-}
-
-namespace {
-
-ThreadAffinity* OriginalThreadAffinity() {
- static ThreadAffinity* original = GetThreadAffinity();
- return original;
-}
-
-} // namespace
-
-void SetThreadAffinity(ThreadAffinity* affinity) {
- // Ensure original is initialized before changing.
- const ThreadAffinity* const original = OriginalThreadAffinity();
- CHECK(original != nullptr);
-
-#if OS_WIN
- const HANDLE hThread = GetCurrentThread();
- const DWORD_PTR prev = SetThreadAffinityMask(hThread, affinity->mask);
- CHECK(prev != 0);
-#elif OS_LINUX
- const pid_t pid = 0; // current thread
- const int err = sched_setaffinity(pid, sizeof(cpu_set_t), &affinity->set);
- CHECK(err == 0);
-#elif OS_FREEBSD
- const pid_t pid = getpid(); // current thread
- const int err = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
- sizeof(cpuset_t), &affinity->set);
- CHECK(err == 0);
+ const auto t = mach_absolute_time();
+ // On OSX/iOS platform the elapsed time is cpu time unit
+ // We have to query the time base information to convert it back
+ // See https://developer.apple.com/library/mac/qa/qa1398/_index.html
+ static mach_timebase_info_data_t timebase;
+ if (timebase.denom == 0) {
+ (void)mach_timebase_info(&timebase);
+ }
+ return double(t) * timebase.numer / timebase.denom * 1E-9;
+#else
+ timespec t;
+ clock_gettime(CLOCK_REALTIME, &t);
+ return t.tv_sec + t.tv_nsec * 1E-9;
+#endif
+}
+
+void RaiseThreadPriority() {
+#if OS_WIN
+ BOOL ok = SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+ CHECK(ok);
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
+ CHECK(ok);
+#elif OS_LINUX
+ // omit: SCHED_RR and SCHED_FIFO with sched_priority max, max-1 and max/2
+ // lead to 2-3x runtime and higher variability!
+#elif OS_FREEBSD
#elif OS_MAC
-#else
-#error "port"
-#endif
-}
-
-std::vector<int> AvailableCPUs() {
- std::vector<int> cpus;
- cpus.reserve(64);
- const ThreadAffinity* const affinity = OriginalThreadAffinity();
-#if OS_WIN
- for (int cpu = 0; cpu < 64; ++cpu) {
- if (affinity->mask & (1ULL << cpu)) {
- cpus.push_back(cpu);
- }
- }
-#elif OS_LINUX
- for (size_t cpu = 0; cpu < sizeof(cpu_set_t) * 8; ++cpu) {
- if (CPU_ISSET(cpu, &affinity->set)) {
- cpus.push_back(cpu);
- }
- }
-#elif OS_FREEBSD
- for (size_t cpu = 0; cpu < sizeof(cpuset_t) * 8; ++cpu) {
- if (CPU_ISSET(cpu, &affinity->set)) {
- cpus.push_back(cpu);
- }
- }
+#else
+#error "port"
+#endif
+}
+
+struct ThreadAffinity {
+#if OS_WIN
+ DWORD_PTR mask;
+#elif OS_LINUX
+ cpu_set_t set;
+#elif OS_FREEBSD
+ cpuset_t set;
+#endif
+};
+
+ThreadAffinity* GetThreadAffinity() {
+ ThreadAffinity* affinity =
+ static_cast<ThreadAffinity*>(malloc(sizeof(ThreadAffinity)));
+#if OS_WIN
+ DWORD_PTR system_affinity;
+ const BOOL ok = GetProcessAffinityMask(GetCurrentProcess(), &affinity->mask,
+ &system_affinity);
+ CHECK(ok);
+#elif OS_LINUX
+ const pid_t pid = 0; // current thread
+ const int err = sched_getaffinity(pid, sizeof(cpu_set_t), &affinity->set);
+ CHECK(err == 0);
+#elif OS_FREEBSD
+ const pid_t pid = getpid(); // current thread
+ const int err = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
+ sizeof(cpuset_t), &affinity->set);
+ CHECK(err == 0);
+#endif
+ return affinity;
+}
+
+namespace {
+
+ThreadAffinity* OriginalThreadAffinity() {
+ static ThreadAffinity* original = GetThreadAffinity();
+ return original;
+}
+
+} // namespace
+
+void SetThreadAffinity(ThreadAffinity* affinity) {
+ // Ensure original is initialized before changing.
+ const ThreadAffinity* const original = OriginalThreadAffinity();
+ CHECK(original != nullptr);
+
+#if OS_WIN
+ const HANDLE hThread = GetCurrentThread();
+ const DWORD_PTR prev = SetThreadAffinityMask(hThread, affinity->mask);
+ CHECK(prev != 0);
+#elif OS_LINUX
+ const pid_t pid = 0; // current thread
+ const int err = sched_setaffinity(pid, sizeof(cpu_set_t), &affinity->set);
+ CHECK(err == 0);
+#elif OS_FREEBSD
+ const pid_t pid = getpid(); // current thread
+ const int err = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
+ sizeof(cpuset_t), &affinity->set);
+ CHECK(err == 0);
#elif OS_MAC
-#else
-#error "port"
-#endif
- return cpus;
-}
-
-void PinThreadToCPU(const int cpu) {
- ThreadAffinity affinity;
-#if OS_WIN
- affinity.mask = 1ULL << cpu;
-#elif OS_LINUX
- CPU_ZERO(&affinity.set);
- CPU_SET(cpu, &affinity.set);
-#elif OS_FREEBSD
- CPU_ZERO(&affinity.set);
- CPU_SET(cpu, &affinity.set);
+#else
+#error "port"
+#endif
+}
+
+std::vector<int> AvailableCPUs() {
+ std::vector<int> cpus;
+ cpus.reserve(64);
+ const ThreadAffinity* const affinity = OriginalThreadAffinity();
+#if OS_WIN
+ for (int cpu = 0; cpu < 64; ++cpu) {
+ if (affinity->mask & (1ULL << cpu)) {
+ cpus.push_back(cpu);
+ }
+ }
+#elif OS_LINUX
+ for (size_t cpu = 0; cpu < sizeof(cpu_set_t) * 8; ++cpu) {
+ if (CPU_ISSET(cpu, &affinity->set)) {
+ cpus.push_back(cpu);
+ }
+ }
+#elif OS_FREEBSD
+ for (size_t cpu = 0; cpu < sizeof(cpuset_t) * 8; ++cpu) {
+ if (CPU_ISSET(cpu, &affinity->set)) {
+ cpus.push_back(cpu);
+ }
+ }
#elif OS_MAC
-#else
-#error "port"
-#endif
- SetThreadAffinity(&affinity);
-}
-
-void PinThreadToRandomCPU() {
- std::vector<int> cpus = AvailableCPUs();
-
- // Remove first two CPUs because interrupts are often pinned to them.
- CHECK(cpus.size() > 2);
- cpus.erase(cpus.begin(), cpus.begin() + 2);
-
- // Random choice to prevent burning up the same core.
- std::random_device device;
- std::ranlux48 generator(device());
- std::shuffle(cpus.begin(), cpus.end(), generator);
- const int cpu = cpus.front();
-
- PinThreadToCPU(cpu);
-
-#if HH_ARCH_X64
- // After setting affinity, we should be running on the desired CPU.
- printf("Running on CPU #%d, APIC ID %02x\n", cpu, ApicId());
-#else
- printf("Running on CPU #%d\n", cpu);
-#endif
-}
-
-} // namespace highwayhash
+#else
+#error "port"
+#endif
+ return cpus;
+}
+
+void PinThreadToCPU(const int cpu) {
+ ThreadAffinity affinity;
+#if OS_WIN
+ affinity.mask = 1ULL << cpu;
+#elif OS_LINUX
+ CPU_ZERO(&affinity.set);
+ CPU_SET(cpu, &affinity.set);
+#elif OS_FREEBSD
+ CPU_ZERO(&affinity.set);
+ CPU_SET(cpu, &affinity.set);
+#elif OS_MAC
+#else
+#error "port"
+#endif
+ SetThreadAffinity(&affinity);
+}
+
+void PinThreadToRandomCPU() {
+ std::vector<int> cpus = AvailableCPUs();
+
+ // Remove first two CPUs because interrupts are often pinned to them.
+ CHECK(cpus.size() > 2);
+ cpus.erase(cpus.begin(), cpus.begin() + 2);
+
+ // Random choice to prevent burning up the same core.
+ std::random_device device;
+ std::ranlux48 generator(device());
+ std::shuffle(cpus.begin(), cpus.end(), generator);
+ const int cpu = cpus.front();
+
+ PinThreadToCPU(cpu);
+
+#if HH_ARCH_X64
+ // After setting affinity, we should be running on the desired CPU.
+ printf("Running on CPU #%d, APIC ID %02x\n", cpu, ApicId());
+#else
+ printf("Running on CPU #%d\n", cpu);
+#endif
+}
+
+} // namespace highwayhash
diff --git a/contrib/libs/highwayhash/highwayhash/os_specific.h b/contrib/libs/highwayhash/highwayhash/os_specific.h
index cefd3628e4..46f3c3e3ef 100644
--- a/contrib/libs/highwayhash/highwayhash/os_specific.h
+++ b/contrib/libs/highwayhash/highwayhash/os_specific.h
@@ -1,54 +1,54 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_OS_SPECIFIC_H_
-#define HIGHWAYHASH_OS_SPECIFIC_H_
-
-#include <vector>
-
-namespace highwayhash {
-
-// Returns current wall-clock time [seconds].
-double Now();
-
-// Sets this thread's priority to the maximum. This should not be called on
-// single-core systems. Requires elevated permissions. No effect on Linux
-// because it increases runtime and variability (issue #19).
-void RaiseThreadPriority();
-
-// Returns CPU numbers in [0, N), where N is the number of bits in the
-// thread's initial affinity (unaffected by any SetThreadAffinity).
-std::vector<int> AvailableCPUs();
-
-// Opaque.
-struct ThreadAffinity;
-
-// Caller must free() the return value.
-ThreadAffinity* GetThreadAffinity();
-
-// Restores a previous affinity returned by GetThreadAffinity.
-void SetThreadAffinity(ThreadAffinity* affinity);
-
-// Ensures the thread is running on the specified cpu, and no others.
-// Useful for reducing nanobenchmark variability (fewer context switches).
-// Uses SetThreadAffinity.
-void PinThreadToCPU(const int cpu);
-
-// Random choice of CPU avoids overloading any one core.
-// Uses SetThreadAffinity.
-void PinThreadToRandomCPU();
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_OS_SPECIFIC_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_OS_SPECIFIC_H_
+#define HIGHWAYHASH_OS_SPECIFIC_H_
+
+#include <vector>
+
+namespace highwayhash {
+
+// Returns current wall-clock time [seconds].
+double Now();
+
+// Sets this thread's priority to the maximum. This should not be called on
+// single-core systems. Requires elevated permissions. No effect on Linux
+// because it increases runtime and variability (issue #19).
+void RaiseThreadPriority();
+
+// Returns CPU numbers in [0, N), where N is the number of bits in the
+// thread's initial affinity (unaffected by any SetThreadAffinity).
+std::vector<int> AvailableCPUs();
+
+// Opaque.
+struct ThreadAffinity;
+
+// Caller must free() the return value.
+ThreadAffinity* GetThreadAffinity();
+
+// Restores a previous affinity returned by GetThreadAffinity.
+void SetThreadAffinity(ThreadAffinity* affinity);
+
+// Ensures the thread is running on the specified cpu, and no others.
+// Useful for reducing nanobenchmark variability (fewer context switches).
+// Uses SetThreadAffinity.
+void PinThreadToCPU(const int cpu);
+
+// Random choice of CPU avoids overloading any one core.
+// Uses SetThreadAffinity.
+void PinThreadToRandomCPU();
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_OS_SPECIFIC_H_
diff --git a/contrib/libs/highwayhash/highwayhash/profiler.h b/contrib/libs/highwayhash/highwayhash/profiler.h
index 9e8f5f6958..09da7e71a5 100644
--- a/contrib/libs/highwayhash/highwayhash/profiler.h
+++ b/contrib/libs/highwayhash/highwayhash/profiler.h
@@ -1,754 +1,754 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_PROFILER_H_
-#define HIGHWAYHASH_PROFILER_H_
-
-// High precision, low overhead time measurements. Returns exact call counts and
-// total elapsed time for user-defined 'zones' (code regions, i.e. C++ scopes).
-//
-// Usage: add this header to BUILD srcs; instrument regions of interest:
-// { PROFILER_ZONE("name"); /*code*/ } or
-// void FuncToMeasure() { PROFILER_FUNC; /*code*/ }.
-// After all threads have exited any zones, invoke PROFILER_PRINT_RESULTS() to
-// print call counts and average durations [CPU cycles] to stdout, sorted in
-// descending order of total duration.
-
-// Configuration settings:
-
-// If zero, this file has no effect and no measurements will be recorded.
-#ifndef PROFILER_ENABLED
-#define PROFILER_ENABLED 1
-#endif
-
-// How many mebibytes to allocate (if PROFILER_ENABLED) per thread that
-// enters at least one zone. Once this buffer is full, the thread will analyze
-// and discard packets, thus temporarily adding some observer overhead.
-// Each zone occupies 16 bytes.
-#ifndef PROFILER_THREAD_STORAGE
-#define PROFILER_THREAD_STORAGE 200ULL
-#endif
-
-#if PROFILER_ENABLED
-
-#include <algorithm> // min/max
-#include <atomic>
-#include <cassert>
-#include <cstddef> // ptrdiff_t
-#include <cstdint>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring> // memcpy
-#include <new>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-
-// Non-portable aspects:
-// - SSE2 128-bit load/store (write-combining, UpdateOrAdd)
-// - RDTSCP timestamps (serializing, high-resolution)
-// - assumes string literals are stored within an 8 MiB range
-// - compiler-specific annotations (restrict, alignment, fences)
-#if HH_ARCH_X64
-#include <emmintrin.h>
-#if HH_MSC_VERSION
-#include <intrin.h>
-#else
-#include <x86intrin.h>
-#endif
-#endif
-
-#include "highwayhash/robust_statistics.h"
-#include "highwayhash/tsc_timer.h"
-
-#define PROFILER_CHECK(condition) \
- while (!(condition)) { \
- printf("Profiler check failed at line %d\n", __LINE__); \
- abort(); \
- }
-
-namespace highwayhash {
-
-// Upper bounds for various fixed-size data structures (guarded via assert):
-
-// How many threads can actually enter a zone (those that don't do not count).
-// Memory use is about kMaxThreads * PROFILER_THREAD_STORAGE MiB.
-// WARNING: a fiber library can spawn hundreds of threads.
-static constexpr size_t kMaxThreads = 128;
-
-// Maximum nesting of zones.
-static constexpr size_t kMaxDepth = 64;
-
-// Total number of zones.
-static constexpr size_t kMaxZones = 256;
-
-// Functions that depend on the cache line size.
-class CacheAligned {
- public:
- static constexpr size_t kPointerSize = sizeof(void*);
- static constexpr size_t kCacheLineSize = 64;
-
- static void* Allocate(const size_t bytes) {
- char* const allocated = static_cast<char*>(malloc(bytes + kCacheLineSize));
- if (allocated == nullptr) {
- return nullptr;
- }
- const uintptr_t misalignment =
- reinterpret_cast<uintptr_t>(allocated) & (kCacheLineSize - 1);
- // malloc is at least kPointerSize aligned, so we can store the "allocated"
- // pointer immediately before the aligned memory.
- assert(misalignment % kPointerSize == 0);
- char* const aligned = allocated + kCacheLineSize - misalignment;
- memcpy(aligned - kPointerSize, &allocated, kPointerSize);
- return aligned;
- }
-
- // Template allows freeing pointer-to-const.
- template <typename T>
- static void Free(T* aligned_pointer) {
- if (aligned_pointer == nullptr) {
- return;
- }
- const char* const aligned = reinterpret_cast<const char*>(aligned_pointer);
- assert(reinterpret_cast<uintptr_t>(aligned) % kCacheLineSize == 0);
- char* allocated;
- memcpy(&allocated, aligned - kPointerSize, kPointerSize);
- assert(allocated <= aligned - kPointerSize);
- assert(allocated >= aligned - kCacheLineSize);
- free(allocated);
- }
-
-#if HH_ARCH_X64
- // Overwrites "to" without loading it into the cache (read-for-ownership).
- template <typename T>
- static void StreamCacheLine(const T* from_items, T* to_items) {
- const __m128i* const from = reinterpret_cast<const __m128i*>(from_items);
- __m128i* const to = reinterpret_cast<__m128i*>(to_items);
- HH_COMPILER_FENCE;
- const __m128i v0 = _mm_load_si128(from + 0);
- const __m128i v1 = _mm_load_si128(from + 1);
- const __m128i v2 = _mm_load_si128(from + 2);
- const __m128i v3 = _mm_load_si128(from + 3);
- // Fences prevent the compiler from reordering loads/stores, which may
- // interfere with write-combining.
- HH_COMPILER_FENCE;
- _mm_stream_si128(to + 0, v0);
- _mm_stream_si128(to + 1, v1);
- _mm_stream_si128(to + 2, v2);
- _mm_stream_si128(to + 3, v3);
- HH_COMPILER_FENCE;
- }
-#endif
-};
-
-// Represents zone entry/exit events. Stores a full-resolution timestamp plus
-// an offset (representing zone name or identifying exit packets). POD.
-class Packet {
- public:
- // If offsets do not fit, UpdateOrAdd will overrun our heap allocation
- // (governed by kMaxZones). We have seen multi-megabyte offsets.
- static constexpr size_t kOffsetBits = 25;
- static constexpr uint64_t kOffsetBias = 1ULL << (kOffsetBits - 1);
-
- // We need full-resolution timestamps; at an effective rate of 4 GHz,
- // this permits 1 minute zone durations (for longer durations, split into
- // multiple zones). Wraparound is handled by masking.
- static constexpr size_t kTimestampBits = 64 - kOffsetBits;
- static constexpr uint64_t kTimestampMask = (1ULL << kTimestampBits) - 1;
-
- static Packet Make(const size_t biased_offset, const uint64_t timestamp) {
- assert(biased_offset < (1ULL << kOffsetBits));
-
- Packet packet;
- packet.bits_ =
- (biased_offset << kTimestampBits) + (timestamp & kTimestampMask);
- return packet;
- }
-
- uint64_t Timestamp() const { return bits_ & kTimestampMask; }
-
- size_t BiasedOffset() const { return (bits_ >> kTimestampBits); }
-
- private:
- uint64_t bits_;
-};
-static_assert(sizeof(Packet) == 8, "Wrong Packet size");
-
-// Returns the address of a string literal. Assuming zone names are also
-// literals and stored nearby, we can represent them as offsets, which are
-// faster to compute than hashes or even a static index.
-//
-// This function must not be static - each call (even from other translation
-// units) must return the same value.
-inline const char* StringOrigin() {
- // Chosen such that no zone name is a prefix nor suffix of this string
- // to ensure they aren't merged (offset 0 identifies zone-exit packets).
- static const char* string_origin = "__#__";
- return string_origin - Packet::kOffsetBias;
-}
-
-// Representation of an active zone, stored in a stack. Used to deduct
-// child duration from the parent's self time. POD.
-struct Node {
- Packet packet;
- uint64_t child_total;
-};
-
-// Holds statistics for all zones with the same name. POD.
-struct Accumulator {
- static constexpr size_t kNumCallBits = 64 - Packet::kOffsetBits;
-
- uint64_t BiasedOffset() const { return num_calls >> kNumCallBits; }
- uint64_t NumCalls() const { return num_calls & ((1ULL << kNumCallBits) - 1); }
-
- // UpdateOrAdd relies upon this layout.
- uint64_t num_calls = 0; // upper bits = biased_offset.
- uint64_t total_duration = 0;
-};
-#if HH_ARCH_X64
-static_assert(sizeof(Accumulator) == sizeof(__m128i), "Wrong Accumulator size");
-#endif
-
-template <typename T>
-inline T ClampedSubtract(const T minuend, const T subtrahend) {
- if (subtrahend > minuend) {
- return 0;
- }
- return minuend - subtrahend;
-}
-
-// Per-thread call graph (stack) and Accumulator for each zone.
-class Results {
- public:
- Results() {
- // Zero-initialize first accumulator to avoid a check for num_zones_ == 0.
- memset(zones_, 0, sizeof(Accumulator));
- }
-
- // Used for computing overhead when this thread encounters its first Zone.
- // This has no observable effect apart from increasing "analyze_elapsed_".
- uint64_t ZoneDuration(const Packet* packets) {
- PROFILER_CHECK(depth_ == 0);
- PROFILER_CHECK(num_zones_ == 0);
- AnalyzePackets(packets, 2);
- const uint64_t duration = zones_[0].total_duration;
- zones_[0].num_calls = 0;
- zones_[0].total_duration = 0;
- PROFILER_CHECK(depth_ == 0);
- num_zones_ = 0;
- return duration;
- }
-
- void SetSelfOverhead(const uint64_t self_overhead) {
- self_overhead_ = self_overhead;
- }
-
- void SetChildOverhead(const uint64_t child_overhead) {
- child_overhead_ = child_overhead;
- }
-
- // Draw all required information from the packets, which can be discarded
- // afterwards. Called whenever this thread's storage is full.
- void AnalyzePackets(const Packet* packets, const size_t num_packets) {
- const uint64_t t0 = Start<uint64_t>();
-
- for (size_t i = 0; i < num_packets; ++i) {
- const Packet p = packets[i];
- // Entering a zone
- if (p.BiasedOffset() != Packet::kOffsetBias) {
- assert(depth_ < kMaxDepth);
- nodes_[depth_].packet = p;
- nodes_[depth_].child_total = 0;
- ++depth_;
- continue;
- }
-
- assert(depth_ != 0);
- const Node& node = nodes_[depth_ - 1];
- // Masking correctly handles unsigned wraparound.
- const uint64_t duration =
- (p.Timestamp() - node.packet.Timestamp()) & Packet::kTimestampMask;
- const uint64_t self_duration = ClampedSubtract(
- duration, self_overhead_ + child_overhead_ + node.child_total);
-
- UpdateOrAdd(node.packet.BiasedOffset(), self_duration);
- --depth_;
-
- // Deduct this nested node's time from its parent's self_duration.
- if (depth_ != 0) {
- nodes_[depth_ - 1].child_total += duration + child_overhead_;
- }
- }
-
- const uint64_t t1 = Stop<uint64_t>();
- analyze_elapsed_ += t1 - t0;
- }
-
- // Incorporates results from another thread. Call after all threads have
- // exited any zones.
- void Assimilate(const Results& other) {
- const uint64_t t0 = Start<uint64_t>();
- assert(depth_ == 0);
- assert(other.depth_ == 0);
-
- for (size_t i = 0; i < other.num_zones_; ++i) {
- const Accumulator& zone = other.zones_[i];
- UpdateOrAdd(zone.BiasedOffset(), zone.total_duration);
- }
- const uint64_t t1 = Stop<uint64_t>();
- analyze_elapsed_ += t1 - t0 + other.analyze_elapsed_;
- }
-
- // Single-threaded.
- void Print() {
- const uint64_t t0 = Start<uint64_t>();
- MergeDuplicates();
-
- // Sort by decreasing total (self) cost.
- std::sort(zones_, zones_ + num_zones_,
- [](const Accumulator& r1, const Accumulator& r2) {
- return r1.total_duration > r2.total_duration;
- });
-
- const char* string_origin = StringOrigin();
- for (size_t i = 0; i < num_zones_; ++i) {
- const Accumulator& r = zones_[i];
- const uint64_t num_calls = r.NumCalls();
- printf("%40s: %10zu x %15zu = %15zu\n", string_origin + r.BiasedOffset(),
- num_calls, r.total_duration / num_calls, r.total_duration);
- }
-
- const uint64_t t1 = Stop<uint64_t>();
- analyze_elapsed_ += t1 - t0;
- printf("Total clocks during analysis: %zu\n", analyze_elapsed_);
- }
-
- private:
-#if HH_ARCH_X64
- static bool SameOffset(const __m128i& zone, const size_t biased_offset) {
- const uint64_t num_calls = _mm_cvtsi128_si64(zone);
- return (num_calls >> Accumulator::kNumCallBits) == biased_offset;
- }
-#endif
-
- // Updates an existing Accumulator (uniquely identified by biased_offset) or
- // adds one if this is the first time this thread analyzed that zone.
- // Uses a self-organizing list data structure, which avoids dynamic memory
- // allocations and is far faster than unordered_map. Loads, updates and
- // stores the entire Accumulator with vector instructions.
- void UpdateOrAdd(const size_t biased_offset, const uint64_t duration) {
- assert(biased_offset < (1ULL << Packet::kOffsetBits));
-
-#if HH_ARCH_X64
- const __m128i one_64 = _mm_set1_epi64x(1);
- const __m128i duration_64 = _mm_cvtsi64_si128(duration);
- const __m128i add_duration_call = _mm_unpacklo_epi64(one_64, duration_64);
-
- __m128i* const HH_RESTRICT zones = reinterpret_cast<__m128i*>(zones_);
-
- // Special case for first zone: (maybe) update, without swapping.
- __m128i prev = _mm_load_si128(zones);
- if (SameOffset(prev, biased_offset)) {
- prev = _mm_add_epi64(prev, add_duration_call);
- assert(SameOffset(prev, biased_offset));
- _mm_store_si128(zones, prev);
- return;
- }
-
- // Look for a zone with the same offset.
- for (size_t i = 1; i < num_zones_; ++i) {
- __m128i zone = _mm_load_si128(zones + i);
- if (SameOffset(zone, biased_offset)) {
- zone = _mm_add_epi64(zone, add_duration_call);
- assert(SameOffset(zone, biased_offset));
- // Swap with predecessor (more conservative than move to front,
- // but at least as successful).
- _mm_store_si128(zones + i - 1, zone);
- _mm_store_si128(zones + i, prev);
- return;
- }
- prev = zone;
- }
-
- // Not found; create a new Accumulator.
- const __m128i biased_offset_64 = _mm_slli_epi64(
- _mm_cvtsi64_si128(biased_offset), Accumulator::kNumCallBits);
- const __m128i zone = _mm_add_epi64(biased_offset_64, add_duration_call);
- assert(SameOffset(zone, biased_offset));
-
- assert(num_zones_ < kMaxZones);
- _mm_store_si128(zones + num_zones_, zone);
- ++num_zones_;
-#else
- // Special case for first zone: (maybe) update, without swapping.
- if (zones_[0].BiasedOffset() == biased_offset) {
- zones_[0].total_duration += duration;
- zones_[0].num_calls += 1;
- assert(zones_[0].BiasedOffset() == biased_offset);
- return;
- }
-
- // Look for a zone with the same offset.
- for (size_t i = 1; i < num_zones_; ++i) {
- if (zones_[i].BiasedOffset() == biased_offset) {
- zones_[i].total_duration += duration;
- zones_[i].num_calls += 1;
- assert(zones_[i].BiasedOffset() == biased_offset);
- // Swap with predecessor (more conservative than move to front,
- // but at least as successful).
- const Accumulator prev = zones_[i - 1];
- zones_[i - 1] = zones_[i];
- zones_[i] = prev;
- return;
- }
- }
-
- // Not found; create a new Accumulator.
- assert(num_zones_ < kMaxZones);
- Accumulator* HH_RESTRICT zone = zones_ + num_zones_;
- zone->num_calls = (biased_offset << Accumulator::kNumCallBits) + 1;
- zone->total_duration = duration;
- assert(zone->BiasedOffset() == biased_offset);
- ++num_zones_;
-#endif
- }
-
- // Each instantiation of a function template seems to get its own copy of
- // __func__ and GCC doesn't merge them. An N^2 search for duplicates is
- // acceptable because we only expect a few dozen zones.
- void MergeDuplicates() {
- const char* string_origin = StringOrigin();
- for (size_t i = 0; i < num_zones_; ++i) {
- const size_t biased_offset = zones_[i].BiasedOffset();
- const char* name = string_origin + biased_offset;
- // Separate num_calls from biased_offset so we can add them together.
- uint64_t num_calls = zones_[i].NumCalls();
-
- // Add any subsequent duplicates to num_calls and total_duration.
- for (size_t j = i + 1; j < num_zones_;) {
- if (!strcmp(name, string_origin + zones_[j].BiasedOffset())) {
- num_calls += zones_[j].NumCalls();
- zones_[i].total_duration += zones_[j].total_duration;
- // Fill hole with last item.
- zones_[j] = zones_[--num_zones_];
- } else { // Name differed, try next Accumulator.
- ++j;
- }
- }
-
- assert(num_calls < (1ULL << Accumulator::kNumCallBits));
-
- // Re-pack regardless of whether any duplicates were found.
- zones_[i].num_calls =
- (biased_offset << Accumulator::kNumCallBits) + num_calls;
- }
- }
-
- uint64_t analyze_elapsed_ = 0;
- uint64_t self_overhead_ = 0;
- uint64_t child_overhead_ = 0;
-
- size_t depth_ = 0; // Number of active zones.
- size_t num_zones_ = 0; // Number of retired zones.
-
- HH_ALIGNAS(64) Node nodes_[kMaxDepth]; // Stack
- HH_ALIGNAS(64) Accumulator zones_[kMaxZones]; // Self-organizing list
-};
-
-// Per-thread packet storage, allocated via CacheAligned.
-class ThreadSpecific {
- static constexpr size_t kBufferCapacity =
- CacheAligned::kCacheLineSize / sizeof(Packet);
-
- public:
- // "name" is used to sanity-check offsets fit in kOffsetBits.
- explicit ThreadSpecific(const char* name)
- : packets_(static_cast<Packet*>(
- CacheAligned::Allocate(PROFILER_THREAD_STORAGE << 20))),
- num_packets_(0),
- max_packets_(PROFILER_THREAD_STORAGE << 17),
- string_origin_(StringOrigin()) {
- // Even in optimized builds (with NDEBUG), verify that this zone's name
- // offset fits within the allotted space. If not, UpdateOrAdd is likely to
- // overrun zones_[]. We also assert(), but users often do not run debug
- // builds. Checking here on the cold path (only reached once per thread)
- // is cheap, but it only covers one zone.
- const size_t biased_offset = name - string_origin_;
- PROFILER_CHECK(biased_offset <= (1ULL << Packet::kOffsetBits));
- }
-
- ~ThreadSpecific() { CacheAligned::Free(packets_); }
-
- // Depends on Zone => defined below.
- void ComputeOverhead();
-
- void WriteEntry(const char* name, const uint64_t timestamp) {
- const size_t biased_offset = name - string_origin_;
- Write(Packet::Make(biased_offset, timestamp));
- }
-
- void WriteExit(const uint64_t timestamp) {
- const size_t biased_offset = Packet::kOffsetBias;
- Write(Packet::Make(biased_offset, timestamp));
- }
-
- void AnalyzeRemainingPackets() {
-#if HH_ARCH_X64
- // Ensures prior weakly-ordered streaming stores are globally visible.
- _mm_sfence();
-
- // Storage full => empty it.
- if (num_packets_ + buffer_size_ > max_packets_) {
- results_.AnalyzePackets(packets_, num_packets_);
- num_packets_ = 0;
- }
- memcpy(packets_ + num_packets_, buffer_, buffer_size_ * sizeof(Packet));
- num_packets_ += buffer_size_;
-#endif
-
- results_.AnalyzePackets(packets_, num_packets_);
- num_packets_ = 0;
- }
-
- Results& GetResults() { return results_; }
-
- private:
- // Write packet to buffer/storage, emptying them as needed.
- void Write(const Packet packet) {
-#if HH_ARCH_X64
- // Buffer full => copy to storage.
- if (buffer_size_ == kBufferCapacity) {
- // Storage full => empty it.
- if (num_packets_ + kBufferCapacity > max_packets_) {
- results_.AnalyzePackets(packets_, num_packets_);
- num_packets_ = 0;
- }
- // This buffering halves observer overhead and decreases the overall
- // runtime by about 3%.
- CacheAligned::StreamCacheLine(buffer_, packets_ + num_packets_);
- num_packets_ += kBufferCapacity;
- buffer_size_ = 0;
- }
- buffer_[buffer_size_] = packet;
- ++buffer_size_;
-#else
- // Write directly to storage.
- if (num_packets_ >= max_packets_) {
- results_.AnalyzePackets(packets_, num_packets_);
- num_packets_ = 0;
- }
- packets_[num_packets_] = packet;
- ++num_packets_;
-#endif
- }
-
- // Write-combining buffer to avoid cache pollution. Must be the first
- // non-static member to ensure cache-line alignment.
-#if HH_ARCH_X64
- Packet buffer_[kBufferCapacity];
- size_t buffer_size_ = 0;
-#endif
-
- // Contiguous storage for zone enter/exit packets.
- Packet* const HH_RESTRICT packets_;
- size_t num_packets_;
- const size_t max_packets_;
- // Cached here because we already read this cache line on zone entry/exit.
- const char* HH_RESTRICT string_origin_;
- Results results_;
-};
-
-class ThreadList {
- public:
- // Thread-safe.
- void Add(ThreadSpecific* const ts) {
- const uint32_t index = num_threads_.fetch_add(1);
- PROFILER_CHECK(index < kMaxThreads);
- threads_[index] = ts;
- }
-
- // Single-threaded.
- void PrintResults() {
- const uint32_t num_threads = num_threads_.load();
- for (uint32_t i = 0; i < num_threads; ++i) {
- threads_[i]->AnalyzeRemainingPackets();
- }
-
- // Combine all threads into a single Result.
- for (uint32_t i = 1; i < num_threads; ++i) {
- threads_[0]->GetResults().Assimilate(threads_[i]->GetResults());
- }
-
- if (num_threads != 0) {
- threads_[0]->GetResults().Print();
- }
- }
-
- private:
- // Owning pointers.
- HH_ALIGNAS(64) ThreadSpecific* threads_[kMaxThreads];
- std::atomic<uint32_t> num_threads_{0};
-};
-
-// RAII zone enter/exit recorder constructed by the ZONE macro; also
-// responsible for initializing ThreadSpecific.
-class Zone {
- public:
- // "name" must be a string literal (see StringOrigin).
- HH_NOINLINE explicit Zone(const char* name) {
- HH_COMPILER_FENCE;
- ThreadSpecific* HH_RESTRICT thread_specific = StaticThreadSpecific();
- if (HH_UNLIKELY(thread_specific == nullptr)) {
- void* mem = CacheAligned::Allocate(sizeof(ThreadSpecific));
- thread_specific = new (mem) ThreadSpecific(name);
- // Must happen before ComputeOverhead, which re-enters this ctor.
- Threads().Add(thread_specific);
- StaticThreadSpecific() = thread_specific;
- thread_specific->ComputeOverhead();
- }
-
- // (Capture timestamp ASAP, not inside WriteEntry.)
- HH_COMPILER_FENCE;
- const uint64_t timestamp = Start<uint64_t>();
- thread_specific->WriteEntry(name, timestamp);
- }
-
- HH_NOINLINE ~Zone() {
- HH_COMPILER_FENCE;
- const uint64_t timestamp = Stop<uint64_t>();
- StaticThreadSpecific()->WriteExit(timestamp);
- HH_COMPILER_FENCE;
- }
-
- // Call exactly once after all threads have exited all zones.
- static void PrintResults() { Threads().PrintResults(); }
-
- private:
- // Returns reference to the thread's ThreadSpecific pointer (initially null).
- // Function-local static avoids needing a separate definition.
- static ThreadSpecific*& StaticThreadSpecific() {
- static thread_local ThreadSpecific* thread_specific;
- return thread_specific;
- }
-
- // Returns the singleton ThreadList. Non time-critical.
- static ThreadList& Threads() {
- static ThreadList threads_;
- return threads_;
- }
-};
-
-// Creates a zone starting from here until the end of the current scope.
-// Timestamps will be recorded when entering and exiting the zone.
-// "name" must be a string literal, which is ensured by merging with "".
-#define PROFILER_ZONE(name) \
- HH_COMPILER_FENCE; \
- const Zone zone("" name); \
- HH_COMPILER_FENCE
-
-// Creates a zone for an entire function (when placed at its beginning).
-// Shorter/more convenient than ZONE.
-#define PROFILER_FUNC \
- HH_COMPILER_FENCE; \
- const Zone zone(__func__); \
- HH_COMPILER_FENCE
-
-#define PROFILER_PRINT_RESULTS Zone::PrintResults
-
-inline void ThreadSpecific::ComputeOverhead() {
- // Delay after capturing timestamps before/after the actual zone runs. Even
- // with frequency throttling disabled, this has a multimodal distribution,
- // including 32, 34, 48, 52, 59, 62.
- uint64_t self_overhead;
- {
- const size_t kNumSamples = 32;
- uint32_t samples[kNumSamples];
- for (size_t idx_sample = 0; idx_sample < kNumSamples; ++idx_sample) {
- const size_t kNumDurations = 1024;
- uint32_t durations[kNumDurations];
-
- for (size_t idx_duration = 0; idx_duration < kNumDurations;
- ++idx_duration) {
- { PROFILER_ZONE("Dummy Zone (never shown)"); }
-#if HH_ARCH_X64
- const uint64_t duration = results_.ZoneDuration(buffer_);
- buffer_size_ = 0;
-#else
- const uint64_t duration = results_.ZoneDuration(packets_);
- num_packets_ = 0;
-#endif
- durations[idx_duration] = static_cast<uint32_t>(duration);
- PROFILER_CHECK(num_packets_ == 0);
- }
- CountingSort(durations, durations + kNumDurations);
- samples[idx_sample] = Mode(durations, kNumDurations);
- }
- // Median.
- CountingSort(samples, samples + kNumSamples);
- self_overhead = samples[kNumSamples / 2];
- printf("Overhead: %zu\n", self_overhead);
- results_.SetSelfOverhead(self_overhead);
- }
-
- // Delay before capturing start timestamp / after end timestamp.
- const size_t kNumSamples = 32;
- uint32_t samples[kNumSamples];
- for (size_t idx_sample = 0; idx_sample < kNumSamples; ++idx_sample) {
- const size_t kNumDurations = 16;
- uint32_t durations[kNumDurations];
- for (size_t idx_duration = 0; idx_duration < kNumDurations;
- ++idx_duration) {
- const size_t kReps = 10000;
- // Analysis time should not be included => must fit within buffer.
- PROFILER_CHECK(kReps * 2 < max_packets_);
-#if HH_ARCH_X64
- _mm_mfence();
-#endif
- const uint64_t t0 = Start<uint64_t>();
- for (size_t i = 0; i < kReps; ++i) {
- PROFILER_ZONE("Dummy");
- }
-#if HH_ARCH_X64
- _mm_sfence();
-#endif
- const uint64_t t1 = Stop<uint64_t>();
-#if HH_ARCH_X64
- PROFILER_CHECK(num_packets_ + buffer_size_ == kReps * 2);
- buffer_size_ = 0;
-#else
- PROFILER_CHECK(num_packets_ == kReps * 2);
-#endif
- num_packets_ = 0;
- const uint64_t avg_duration = (t1 - t0 + kReps / 2) / kReps;
- durations[idx_duration] =
- static_cast<uint32_t>(ClampedSubtract(avg_duration, self_overhead));
- }
- CountingSort(durations, durations + kNumDurations);
- samples[idx_sample] = Mode(durations, kNumDurations);
- }
- CountingSort(samples, samples + kNumSamples);
- const uint64_t child_overhead = samples[9 * kNumSamples / 10];
- printf("Child overhead: %zu\n", child_overhead);
- results_.SetChildOverhead(child_overhead);
-}
-
-} // namespace highwayhash
-
-#else // !PROFILER_ENABLED
-#define PROFILER_ZONE(name)
-#define PROFILER_FUNC
-#define PROFILER_PRINT_RESULTS()
-#endif
-
-#endif // HIGHWAYHASH_PROFILER_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_PROFILER_H_
+#define HIGHWAYHASH_PROFILER_H_
+
+// High precision, low overhead time measurements. Returns exact call counts and
+// total elapsed time for user-defined 'zones' (code regions, i.e. C++ scopes).
+//
+// Usage: add this header to BUILD srcs; instrument regions of interest:
+// { PROFILER_ZONE("name"); /*code*/ } or
+// void FuncToMeasure() { PROFILER_FUNC; /*code*/ }.
+// After all threads have exited any zones, invoke PROFILER_PRINT_RESULTS() to
+// print call counts and average durations [CPU cycles] to stdout, sorted in
+// descending order of total duration.
+
+// Configuration settings:
+
+// If zero, this file has no effect and no measurements will be recorded.
+#ifndef PROFILER_ENABLED
+#define PROFILER_ENABLED 1
+#endif
+
+// How many mebibytes to allocate (if PROFILER_ENABLED) per thread that
+// enters at least one zone. Once this buffer is full, the thread will analyze
+// and discard packets, thus temporarily adding some observer overhead.
+// Each zone occupies 16 bytes.
+#ifndef PROFILER_THREAD_STORAGE
+#define PROFILER_THREAD_STORAGE 200ULL
+#endif
+
+#if PROFILER_ENABLED
+
+#include <algorithm> // min/max
+#include <atomic>
+#include <cassert>
+#include <cstddef> // ptrdiff_t
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring> // memcpy
+#include <new>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+
+// Non-portable aspects:
+// - SSE2 128-bit load/store (write-combining, UpdateOrAdd)
+// - RDTSCP timestamps (serializing, high-resolution)
+// - assumes string literals are stored within an 8 MiB range
+// - compiler-specific annotations (restrict, alignment, fences)
+#if HH_ARCH_X64
+#include <emmintrin.h>
+#if HH_MSC_VERSION
+#include <intrin.h>
+#else
+#include <x86intrin.h>
+#endif
+#endif
+
+#include "highwayhash/robust_statistics.h"
+#include "highwayhash/tsc_timer.h"
+
+#define PROFILER_CHECK(condition) \
+ while (!(condition)) { \
+ printf("Profiler check failed at line %d\n", __LINE__); \
+ abort(); \
+ }
+
+namespace highwayhash {
+
+// Upper bounds for various fixed-size data structures (guarded via assert):
+
+// How many threads can actually enter a zone (those that don't do not count).
+// Memory use is about kMaxThreads * PROFILER_THREAD_STORAGE MiB.
+// WARNING: a fiber library can spawn hundreds of threads.
+static constexpr size_t kMaxThreads = 128;
+
+// Maximum nesting of zones.
+static constexpr size_t kMaxDepth = 64;
+
+// Total number of zones.
+static constexpr size_t kMaxZones = 256;
+
+// Functions that depend on the cache line size.
+class CacheAligned {
+ public:
+ static constexpr size_t kPointerSize = sizeof(void*);
+ static constexpr size_t kCacheLineSize = 64;
+
+ static void* Allocate(const size_t bytes) {
+ char* const allocated = static_cast<char*>(malloc(bytes + kCacheLineSize));
+ if (allocated == nullptr) {
+ return nullptr;
+ }
+ const uintptr_t misalignment =
+ reinterpret_cast<uintptr_t>(allocated) & (kCacheLineSize - 1);
+ // malloc is at least kPointerSize aligned, so we can store the "allocated"
+ // pointer immediately before the aligned memory.
+ assert(misalignment % kPointerSize == 0);
+ char* const aligned = allocated + kCacheLineSize - misalignment;
+ memcpy(aligned - kPointerSize, &allocated, kPointerSize);
+ return aligned;
+ }
+
+ // Template allows freeing pointer-to-const.
+ template <typename T>
+ static void Free(T* aligned_pointer) {
+ if (aligned_pointer == nullptr) {
+ return;
+ }
+ const char* const aligned = reinterpret_cast<const char*>(aligned_pointer);
+ assert(reinterpret_cast<uintptr_t>(aligned) % kCacheLineSize == 0);
+ char* allocated;
+ memcpy(&allocated, aligned - kPointerSize, kPointerSize);
+ assert(allocated <= aligned - kPointerSize);
+ assert(allocated >= aligned - kCacheLineSize);
+ free(allocated);
+ }
+
+#if HH_ARCH_X64
+ // Overwrites "to" without loading it into the cache (read-for-ownership).
+ template <typename T>
+ static void StreamCacheLine(const T* from_items, T* to_items) {
+ const __m128i* const from = reinterpret_cast<const __m128i*>(from_items);
+ __m128i* const to = reinterpret_cast<__m128i*>(to_items);
+ HH_COMPILER_FENCE;
+ const __m128i v0 = _mm_load_si128(from + 0);
+ const __m128i v1 = _mm_load_si128(from + 1);
+ const __m128i v2 = _mm_load_si128(from + 2);
+ const __m128i v3 = _mm_load_si128(from + 3);
+ // Fences prevent the compiler from reordering loads/stores, which may
+ // interfere with write-combining.
+ HH_COMPILER_FENCE;
+ _mm_stream_si128(to + 0, v0);
+ _mm_stream_si128(to + 1, v1);
+ _mm_stream_si128(to + 2, v2);
+ _mm_stream_si128(to + 3, v3);
+ HH_COMPILER_FENCE;
+ }
+#endif
+};
+
+// Represents zone entry/exit events. Stores a full-resolution timestamp plus
+// an offset (representing zone name or identifying exit packets). POD.
+class Packet {
+ public:
+ // If offsets do not fit, UpdateOrAdd will overrun our heap allocation
+ // (governed by kMaxZones). We have seen multi-megabyte offsets.
+ static constexpr size_t kOffsetBits = 25;
+ static constexpr uint64_t kOffsetBias = 1ULL << (kOffsetBits - 1);
+
+ // We need full-resolution timestamps; at an effective rate of 4 GHz,
+ // this permits 1 minute zone durations (for longer durations, split into
+ // multiple zones). Wraparound is handled by masking.
+ static constexpr size_t kTimestampBits = 64 - kOffsetBits;
+ static constexpr uint64_t kTimestampMask = (1ULL << kTimestampBits) - 1;
+
+ static Packet Make(const size_t biased_offset, const uint64_t timestamp) {
+ assert(biased_offset < (1ULL << kOffsetBits));
+
+ Packet packet;
+ packet.bits_ =
+ (biased_offset << kTimestampBits) + (timestamp & kTimestampMask);
+ return packet;
+ }
+
+ uint64_t Timestamp() const { return bits_ & kTimestampMask; }
+
+ size_t BiasedOffset() const { return (bits_ >> kTimestampBits); }
+
+ private:
+ uint64_t bits_;
+};
+static_assert(sizeof(Packet) == 8, "Wrong Packet size");
+
+// Returns the address of a string literal. Assuming zone names are also
+// literals and stored nearby, we can represent them as offsets, which are
+// faster to compute than hashes or even a static index.
+//
+// This function must not be static - each call (even from other translation
+// units) must return the same value.
+inline const char* StringOrigin() {
+ // Chosen such that no zone name is a prefix nor suffix of this string
+ // to ensure they aren't merged (offset 0 identifies zone-exit packets).
+ static const char* string_origin = "__#__";
+ return string_origin - Packet::kOffsetBias;
+}
+
+// Representation of an active zone, stored in a stack. Used to deduct
+// child duration from the parent's self time. POD.
+struct Node {
+ Packet packet;
+ uint64_t child_total;
+};
+
+// Holds statistics for all zones with the same name. POD.
+struct Accumulator {
+ static constexpr size_t kNumCallBits = 64 - Packet::kOffsetBits;
+
+ uint64_t BiasedOffset() const { return num_calls >> kNumCallBits; }
+ uint64_t NumCalls() const { return num_calls & ((1ULL << kNumCallBits) - 1); }
+
+ // UpdateOrAdd relies upon this layout.
+ uint64_t num_calls = 0; // upper bits = biased_offset.
+ uint64_t total_duration = 0;
+};
+#if HH_ARCH_X64
+static_assert(sizeof(Accumulator) == sizeof(__m128i), "Wrong Accumulator size");
+#endif
+
+template <typename T>
+inline T ClampedSubtract(const T minuend, const T subtrahend) {
+ if (subtrahend > minuend) {
+ return 0;
+ }
+ return minuend - subtrahend;
+}
+
+// Per-thread call graph (stack) and Accumulator for each zone.
+class Results {
+ public:
+ Results() {
+ // Zero-initialize first accumulator to avoid a check for num_zones_ == 0.
+ memset(zones_, 0, sizeof(Accumulator));
+ }
+
+ // Used for computing overhead when this thread encounters its first Zone.
+ // This has no observable effect apart from increasing "analyze_elapsed_".
+ uint64_t ZoneDuration(const Packet* packets) {
+ PROFILER_CHECK(depth_ == 0);
+ PROFILER_CHECK(num_zones_ == 0);
+ AnalyzePackets(packets, 2);
+ const uint64_t duration = zones_[0].total_duration;
+ zones_[0].num_calls = 0;
+ zones_[0].total_duration = 0;
+ PROFILER_CHECK(depth_ == 0);
+ num_zones_ = 0;
+ return duration;
+ }
+
+ void SetSelfOverhead(const uint64_t self_overhead) {
+ self_overhead_ = self_overhead;
+ }
+
+ void SetChildOverhead(const uint64_t child_overhead) {
+ child_overhead_ = child_overhead;
+ }
+
+ // Draw all required information from the packets, which can be discarded
+ // afterwards. Called whenever this thread's storage is full.
+ void AnalyzePackets(const Packet* packets, const size_t num_packets) {
+ const uint64_t t0 = Start<uint64_t>();
+
+ for (size_t i = 0; i < num_packets; ++i) {
+ const Packet p = packets[i];
+ // Entering a zone
+ if (p.BiasedOffset() != Packet::kOffsetBias) {
+ assert(depth_ < kMaxDepth);
+ nodes_[depth_].packet = p;
+ nodes_[depth_].child_total = 0;
+ ++depth_;
+ continue;
+ }
+
+ assert(depth_ != 0);
+ const Node& node = nodes_[depth_ - 1];
+ // Masking correctly handles unsigned wraparound.
+ const uint64_t duration =
+ (p.Timestamp() - node.packet.Timestamp()) & Packet::kTimestampMask;
+ const uint64_t self_duration = ClampedSubtract(
+ duration, self_overhead_ + child_overhead_ + node.child_total);
+
+ UpdateOrAdd(node.packet.BiasedOffset(), self_duration);
+ --depth_;
+
+ // Deduct this nested node's time from its parent's self_duration.
+ if (depth_ != 0) {
+ nodes_[depth_ - 1].child_total += duration + child_overhead_;
+ }
+ }
+
+ const uint64_t t1 = Stop<uint64_t>();
+ analyze_elapsed_ += t1 - t0;
+ }
+
+ // Incorporates results from another thread. Call after all threads have
+ // exited any zones.
+ void Assimilate(const Results& other) {
+ const uint64_t t0 = Start<uint64_t>();
+ assert(depth_ == 0);
+ assert(other.depth_ == 0);
+
+ for (size_t i = 0; i < other.num_zones_; ++i) {
+ const Accumulator& zone = other.zones_[i];
+ UpdateOrAdd(zone.BiasedOffset(), zone.total_duration);
+ }
+ const uint64_t t1 = Stop<uint64_t>();
+ analyze_elapsed_ += t1 - t0 + other.analyze_elapsed_;
+ }
+
+ // Single-threaded.
+ void Print() {
+ const uint64_t t0 = Start<uint64_t>();
+ MergeDuplicates();
+
+ // Sort by decreasing total (self) cost.
+ std::sort(zones_, zones_ + num_zones_,
+ [](const Accumulator& r1, const Accumulator& r2) {
+ return r1.total_duration > r2.total_duration;
+ });
+
+ const char* string_origin = StringOrigin();
+ for (size_t i = 0; i < num_zones_; ++i) {
+ const Accumulator& r = zones_[i];
+ const uint64_t num_calls = r.NumCalls();
+ printf("%40s: %10zu x %15zu = %15zu\n", string_origin + r.BiasedOffset(),
+ num_calls, r.total_duration / num_calls, r.total_duration);
+ }
+
+ const uint64_t t1 = Stop<uint64_t>();
+ analyze_elapsed_ += t1 - t0;
+ printf("Total clocks during analysis: %zu\n", analyze_elapsed_);
+ }
+
+ private:
+#if HH_ARCH_X64
+ static bool SameOffset(const __m128i& zone, const size_t biased_offset) {
+ const uint64_t num_calls = _mm_cvtsi128_si64(zone);
+ return (num_calls >> Accumulator::kNumCallBits) == biased_offset;
+ }
+#endif
+
+ // Updates an existing Accumulator (uniquely identified by biased_offset) or
+ // adds one if this is the first time this thread analyzed that zone.
+ // Uses a self-organizing list data structure, which avoids dynamic memory
+ // allocations and is far faster than unordered_map. Loads, updates and
+ // stores the entire Accumulator with vector instructions.
+ void UpdateOrAdd(const size_t biased_offset, const uint64_t duration) {
+ assert(biased_offset < (1ULL << Packet::kOffsetBits));
+
+#if HH_ARCH_X64
+ const __m128i one_64 = _mm_set1_epi64x(1);
+ const __m128i duration_64 = _mm_cvtsi64_si128(duration);
+ const __m128i add_duration_call = _mm_unpacklo_epi64(one_64, duration_64);
+
+ __m128i* const HH_RESTRICT zones = reinterpret_cast<__m128i*>(zones_);
+
+ // Special case for first zone: (maybe) update, without swapping.
+ __m128i prev = _mm_load_si128(zones);
+ if (SameOffset(prev, biased_offset)) {
+ prev = _mm_add_epi64(prev, add_duration_call);
+ assert(SameOffset(prev, biased_offset));
+ _mm_store_si128(zones, prev);
+ return;
+ }
+
+ // Look for a zone with the same offset.
+ for (size_t i = 1; i < num_zones_; ++i) {
+ __m128i zone = _mm_load_si128(zones + i);
+ if (SameOffset(zone, biased_offset)) {
+ zone = _mm_add_epi64(zone, add_duration_call);
+ assert(SameOffset(zone, biased_offset));
+ // Swap with predecessor (more conservative than move to front,
+ // but at least as successful).
+ _mm_store_si128(zones + i - 1, zone);
+ _mm_store_si128(zones + i, prev);
+ return;
+ }
+ prev = zone;
+ }
+
+ // Not found; create a new Accumulator.
+ const __m128i biased_offset_64 = _mm_slli_epi64(
+ _mm_cvtsi64_si128(biased_offset), Accumulator::kNumCallBits);
+ const __m128i zone = _mm_add_epi64(biased_offset_64, add_duration_call);
+ assert(SameOffset(zone, biased_offset));
+
+ assert(num_zones_ < kMaxZones);
+ _mm_store_si128(zones + num_zones_, zone);
+ ++num_zones_;
+#else
+ // Special case for first zone: (maybe) update, without swapping.
+ if (zones_[0].BiasedOffset() == biased_offset) {
+ zones_[0].total_duration += duration;
+ zones_[0].num_calls += 1;
+ assert(zones_[0].BiasedOffset() == biased_offset);
+ return;
+ }
+
+ // Look for a zone with the same offset.
+ for (size_t i = 1; i < num_zones_; ++i) {
+ if (zones_[i].BiasedOffset() == biased_offset) {
+ zones_[i].total_duration += duration;
+ zones_[i].num_calls += 1;
+ assert(zones_[i].BiasedOffset() == biased_offset);
+ // Swap with predecessor (more conservative than move to front,
+ // but at least as successful).
+ const Accumulator prev = zones_[i - 1];
+ zones_[i - 1] = zones_[i];
+ zones_[i] = prev;
+ return;
+ }
+ }
+
+ // Not found; create a new Accumulator.
+ assert(num_zones_ < kMaxZones);
+ Accumulator* HH_RESTRICT zone = zones_ + num_zones_;
+ zone->num_calls = (biased_offset << Accumulator::kNumCallBits) + 1;
+ zone->total_duration = duration;
+ assert(zone->BiasedOffset() == biased_offset);
+ ++num_zones_;
+#endif
+ }
+
+ // Each instantiation of a function template seems to get its own copy of
+ // __func__ and GCC doesn't merge them. An N^2 search for duplicates is
+ // acceptable because we only expect a few dozen zones.
+ void MergeDuplicates() {
+ const char* string_origin = StringOrigin();
+ for (size_t i = 0; i < num_zones_; ++i) {
+ const size_t biased_offset = zones_[i].BiasedOffset();
+ const char* name = string_origin + biased_offset;
+ // Separate num_calls from biased_offset so we can add them together.
+ uint64_t num_calls = zones_[i].NumCalls();
+
+ // Add any subsequent duplicates to num_calls and total_duration.
+ for (size_t j = i + 1; j < num_zones_;) {
+ if (!strcmp(name, string_origin + zones_[j].BiasedOffset())) {
+ num_calls += zones_[j].NumCalls();
+ zones_[i].total_duration += zones_[j].total_duration;
+ // Fill hole with last item.
+ zones_[j] = zones_[--num_zones_];
+ } else { // Name differed, try next Accumulator.
+ ++j;
+ }
+ }
+
+ assert(num_calls < (1ULL << Accumulator::kNumCallBits));
+
+ // Re-pack regardless of whether any duplicates were found.
+ zones_[i].num_calls =
+ (biased_offset << Accumulator::kNumCallBits) + num_calls;
+ }
+ }
+
+ uint64_t analyze_elapsed_ = 0;
+ uint64_t self_overhead_ = 0;
+ uint64_t child_overhead_ = 0;
+
+ size_t depth_ = 0; // Number of active zones.
+ size_t num_zones_ = 0; // Number of retired zones.
+
+ HH_ALIGNAS(64) Node nodes_[kMaxDepth]; // Stack
+ HH_ALIGNAS(64) Accumulator zones_[kMaxZones]; // Self-organizing list
+};
+
+// Per-thread packet storage, allocated via CacheAligned.
+class ThreadSpecific {
+ static constexpr size_t kBufferCapacity =
+ CacheAligned::kCacheLineSize / sizeof(Packet);
+
+ public:
+ // "name" is used to sanity-check offsets fit in kOffsetBits.
+ explicit ThreadSpecific(const char* name)
+ : packets_(static_cast<Packet*>(
+ CacheAligned::Allocate(PROFILER_THREAD_STORAGE << 20))),
+ num_packets_(0),
+ max_packets_(PROFILER_THREAD_STORAGE << 17),
+ string_origin_(StringOrigin()) {
+ // Even in optimized builds (with NDEBUG), verify that this zone's name
+ // offset fits within the allotted space. If not, UpdateOrAdd is likely to
+ // overrun zones_[]. We also assert(), but users often do not run debug
+ // builds. Checking here on the cold path (only reached once per thread)
+ // is cheap, but it only covers one zone.
+ const size_t biased_offset = name - string_origin_;
+ PROFILER_CHECK(biased_offset <= (1ULL << Packet::kOffsetBits));
+ }
+
+ ~ThreadSpecific() { CacheAligned::Free(packets_); }
+
+ // Depends on Zone => defined below.
+ void ComputeOverhead();
+
+ void WriteEntry(const char* name, const uint64_t timestamp) {
+ const size_t biased_offset = name - string_origin_;
+ Write(Packet::Make(biased_offset, timestamp));
+ }
+
+ void WriteExit(const uint64_t timestamp) {
+ const size_t biased_offset = Packet::kOffsetBias;
+ Write(Packet::Make(biased_offset, timestamp));
+ }
+
+ void AnalyzeRemainingPackets() {
+#if HH_ARCH_X64
+ // Ensures prior weakly-ordered streaming stores are globally visible.
+ _mm_sfence();
+
+ // Storage full => empty it.
+ if (num_packets_ + buffer_size_ > max_packets_) {
+ results_.AnalyzePackets(packets_, num_packets_);
+ num_packets_ = 0;
+ }
+ memcpy(packets_ + num_packets_, buffer_, buffer_size_ * sizeof(Packet));
+ num_packets_ += buffer_size_;
+#endif
+
+ results_.AnalyzePackets(packets_, num_packets_);
+ num_packets_ = 0;
+ }
+
+ Results& GetResults() { return results_; }
+
+ private:
+ // Write packet to buffer/storage, emptying them as needed.
+ void Write(const Packet packet) {
+#if HH_ARCH_X64
+ // Buffer full => copy to storage.
+ if (buffer_size_ == kBufferCapacity) {
+ // Storage full => empty it.
+ if (num_packets_ + kBufferCapacity > max_packets_) {
+ results_.AnalyzePackets(packets_, num_packets_);
+ num_packets_ = 0;
+ }
+ // This buffering halves observer overhead and decreases the overall
+ // runtime by about 3%.
+ CacheAligned::StreamCacheLine(buffer_, packets_ + num_packets_);
+ num_packets_ += kBufferCapacity;
+ buffer_size_ = 0;
+ }
+ buffer_[buffer_size_] = packet;
+ ++buffer_size_;
+#else
+ // Write directly to storage.
+ if (num_packets_ >= max_packets_) {
+ results_.AnalyzePackets(packets_, num_packets_);
+ num_packets_ = 0;
+ }
+ packets_[num_packets_] = packet;
+ ++num_packets_;
+#endif
+ }
+
+ // Write-combining buffer to avoid cache pollution. Must be the first
+ // non-static member to ensure cache-line alignment.
+#if HH_ARCH_X64
+ Packet buffer_[kBufferCapacity];
+ size_t buffer_size_ = 0;
+#endif
+
+ // Contiguous storage for zone enter/exit packets.
+ Packet* const HH_RESTRICT packets_;
+ size_t num_packets_;
+ const size_t max_packets_;
+ // Cached here because we already read this cache line on zone entry/exit.
+ const char* HH_RESTRICT string_origin_;
+ Results results_;
+};
+
+class ThreadList {
+ public:
+ // Thread-safe.
+ void Add(ThreadSpecific* const ts) {
+ const uint32_t index = num_threads_.fetch_add(1);
+ PROFILER_CHECK(index < kMaxThreads);
+ threads_[index] = ts;
+ }
+
+ // Single-threaded.
+ void PrintResults() {
+ const uint32_t num_threads = num_threads_.load();
+ for (uint32_t i = 0; i < num_threads; ++i) {
+ threads_[i]->AnalyzeRemainingPackets();
+ }
+
+ // Combine all threads into a single Result.
+ for (uint32_t i = 1; i < num_threads; ++i) {
+ threads_[0]->GetResults().Assimilate(threads_[i]->GetResults());
+ }
+
+ if (num_threads != 0) {
+ threads_[0]->GetResults().Print();
+ }
+ }
+
+ private:
+ // Owning pointers.
+ HH_ALIGNAS(64) ThreadSpecific* threads_[kMaxThreads];
+ std::atomic<uint32_t> num_threads_{0};
+};
+
+// RAII zone enter/exit recorder constructed by the ZONE macro; also
+// responsible for initializing ThreadSpecific.
+class Zone {
+ public:
+ // "name" must be a string literal (see StringOrigin).
+ HH_NOINLINE explicit Zone(const char* name) {
+ HH_COMPILER_FENCE;
+ ThreadSpecific* HH_RESTRICT thread_specific = StaticThreadSpecific();
+ if (HH_UNLIKELY(thread_specific == nullptr)) {
+ void* mem = CacheAligned::Allocate(sizeof(ThreadSpecific));
+ thread_specific = new (mem) ThreadSpecific(name);
+ // Must happen before ComputeOverhead, which re-enters this ctor.
+ Threads().Add(thread_specific);
+ StaticThreadSpecific() = thread_specific;
+ thread_specific->ComputeOverhead();
+ }
+
+ // (Capture timestamp ASAP, not inside WriteEntry.)
+ HH_COMPILER_FENCE;
+ const uint64_t timestamp = Start<uint64_t>();
+ thread_specific->WriteEntry(name, timestamp);
+ }
+
+ HH_NOINLINE ~Zone() {
+ HH_COMPILER_FENCE;
+ const uint64_t timestamp = Stop<uint64_t>();
+ StaticThreadSpecific()->WriteExit(timestamp);
+ HH_COMPILER_FENCE;
+ }
+
+ // Call exactly once after all threads have exited all zones.
+ static void PrintResults() { Threads().PrintResults(); }
+
+ private:
+ // Returns reference to the thread's ThreadSpecific pointer (initially null).
+ // Function-local static avoids needing a separate definition.
+ static ThreadSpecific*& StaticThreadSpecific() {
+ static thread_local ThreadSpecific* thread_specific;
+ return thread_specific;
+ }
+
+ // Returns the singleton ThreadList. Non time-critical.
+ static ThreadList& Threads() {
+ static ThreadList threads_;
+ return threads_;
+ }
+};
+
+// Creates a zone starting from here until the end of the current scope.
+// Timestamps will be recorded when entering and exiting the zone.
+// "name" must be a string literal, which is ensured by merging with "".
+#define PROFILER_ZONE(name) \
+ HH_COMPILER_FENCE; \
+ const Zone zone("" name); \
+ HH_COMPILER_FENCE
+
+// Creates a zone for an entire function (when placed at its beginning).
+// Shorter/more convenient than ZONE.
+#define PROFILER_FUNC \
+ HH_COMPILER_FENCE; \
+ const Zone zone(__func__); \
+ HH_COMPILER_FENCE
+
+#define PROFILER_PRINT_RESULTS Zone::PrintResults
+
+inline void ThreadSpecific::ComputeOverhead() {
+ // Delay after capturing timestamps before/after the actual zone runs. Even
+ // with frequency throttling disabled, this has a multimodal distribution,
+ // including 32, 34, 48, 52, 59, 62.
+ uint64_t self_overhead;
+ {
+ const size_t kNumSamples = 32;
+ uint32_t samples[kNumSamples];
+ for (size_t idx_sample = 0; idx_sample < kNumSamples; ++idx_sample) {
+ const size_t kNumDurations = 1024;
+ uint32_t durations[kNumDurations];
+
+ for (size_t idx_duration = 0; idx_duration < kNumDurations;
+ ++idx_duration) {
+ { PROFILER_ZONE("Dummy Zone (never shown)"); }
+#if HH_ARCH_X64
+ const uint64_t duration = results_.ZoneDuration(buffer_);
+ buffer_size_ = 0;
+#else
+ const uint64_t duration = results_.ZoneDuration(packets_);
+ num_packets_ = 0;
+#endif
+ durations[idx_duration] = static_cast<uint32_t>(duration);
+ PROFILER_CHECK(num_packets_ == 0);
+ }
+ CountingSort(durations, durations + kNumDurations);
+ samples[idx_sample] = Mode(durations, kNumDurations);
+ }
+ // Median.
+ CountingSort(samples, samples + kNumSamples);
+ self_overhead = samples[kNumSamples / 2];
+ printf("Overhead: %zu\n", self_overhead);
+ results_.SetSelfOverhead(self_overhead);
+ }
+
+ // Delay before capturing start timestamp / after end timestamp.
+ const size_t kNumSamples = 32;
+ uint32_t samples[kNumSamples];
+ for (size_t idx_sample = 0; idx_sample < kNumSamples; ++idx_sample) {
+ const size_t kNumDurations = 16;
+ uint32_t durations[kNumDurations];
+ for (size_t idx_duration = 0; idx_duration < kNumDurations;
+ ++idx_duration) {
+ const size_t kReps = 10000;
+ // Analysis time should not be included => must fit within buffer.
+ PROFILER_CHECK(kReps * 2 < max_packets_);
+#if HH_ARCH_X64
+ _mm_mfence();
+#endif
+ const uint64_t t0 = Start<uint64_t>();
+ for (size_t i = 0; i < kReps; ++i) {
+ PROFILER_ZONE("Dummy");
+ }
+#if HH_ARCH_X64
+ _mm_sfence();
+#endif
+ const uint64_t t1 = Stop<uint64_t>();
+#if HH_ARCH_X64
+ PROFILER_CHECK(num_packets_ + buffer_size_ == kReps * 2);
+ buffer_size_ = 0;
+#else
+ PROFILER_CHECK(num_packets_ == kReps * 2);
+#endif
+ num_packets_ = 0;
+ const uint64_t avg_duration = (t1 - t0 + kReps / 2) / kReps;
+ durations[idx_duration] =
+ static_cast<uint32_t>(ClampedSubtract(avg_duration, self_overhead));
+ }
+ CountingSort(durations, durations + kNumDurations);
+ samples[idx_sample] = Mode(durations, kNumDurations);
+ }
+ CountingSort(samples, samples + kNumSamples);
+ const uint64_t child_overhead = samples[9 * kNumSamples / 10];
+ printf("Child overhead: %zu\n", child_overhead);
+ results_.SetChildOverhead(child_overhead);
+}
+
+} // namespace highwayhash
+
+#else // !PROFILER_ENABLED
+#define PROFILER_ZONE(name)
+#define PROFILER_FUNC
+#define PROFILER_PRINT_RESULTS()
+#endif
+
+#endif // HIGHWAYHASH_PROFILER_H_
diff --git a/contrib/libs/highwayhash/highwayhash/profiler_example.cc b/contrib/libs/highwayhash/highwayhash/profiler_example.cc
index 9d97066ec9..999cc4581f 100644
--- a/contrib/libs/highwayhash/highwayhash/profiler_example.cc
+++ b/contrib/libs/highwayhash/highwayhash/profiler_example.cc
@@ -1,97 +1,97 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <cassert>
-#include <cmath>
-#include <cstdlib>
-
-#include "highwayhash/os_specific.h"
-#include "highwayhash/profiler.h"
-
-namespace highwayhash {
-namespace {
-
-void Spin(const double min_time) {
- const double t0 = Now();
- for (;;) {
- const double elapsed = Now() - t0;
- if (elapsed > min_time) {
- break;
- }
- }
-}
-
-void Spin10() {
- PROFILER_FUNC;
- Spin(10E-6);
-}
-
-void Spin20() {
- PROFILER_FUNC;
- Spin(20E-6);
-}
-
-void Spin3060() {
- {
- PROFILER_ZONE("spin30");
- Spin(30E-6);
- }
- {
- PROFILER_ZONE("spin60");
- Spin(60E-6);
- }
-}
-
-void Level3() {
- PROFILER_FUNC;
- for (int rep = 0; rep < 10; ++rep) {
- double total = 0.0;
- for (int i = 0; i < 100 - rep; ++i) {
- total += pow(0.9, i);
- }
- if (std::abs(total - 9.999) > 1E-2) {
- abort();
- }
- }
-}
-
-void Level2() {
- PROFILER_FUNC;
- Level3();
-}
-
-void Level1() {
- PROFILER_FUNC;
- Level2();
-}
-
-void ProfilerExample() {
- PinThreadToRandomCPU();
- {
- PROFILER_FUNC;
- Spin10();
- Spin20();
- Spin3060();
- Level1();
- }
- PROFILER_PRINT_RESULTS();
-}
-
-} // namespace
-} // namespace highwayhash
-
-int main(int argc, char* argv[]) {
- highwayhash::ProfilerExample();
- return 0;
-}
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cassert>
+#include <cmath>
+#include <cstdlib>
+
+#include "highwayhash/os_specific.h"
+#include "highwayhash/profiler.h"
+
+namespace highwayhash {
+namespace {
+
+void Spin(const double min_time) {
+ const double t0 = Now();
+ for (;;) {
+ const double elapsed = Now() - t0;
+ if (elapsed > min_time) {
+ break;
+ }
+ }
+}
+
+void Spin10() {
+ PROFILER_FUNC;
+ Spin(10E-6);
+}
+
+void Spin20() {
+ PROFILER_FUNC;
+ Spin(20E-6);
+}
+
+void Spin3060() {
+ {
+ PROFILER_ZONE("spin30");
+ Spin(30E-6);
+ }
+ {
+ PROFILER_ZONE("spin60");
+ Spin(60E-6);
+ }
+}
+
+void Level3() {
+ PROFILER_FUNC;
+ for (int rep = 0; rep < 10; ++rep) {
+ double total = 0.0;
+ for (int i = 0; i < 100 - rep; ++i) {
+ total += pow(0.9, i);
+ }
+ if (std::abs(total - 9.999) > 1E-2) {
+ abort();
+ }
+ }
+}
+
+void Level2() {
+ PROFILER_FUNC;
+ Level3();
+}
+
+void Level1() {
+ PROFILER_FUNC;
+ Level2();
+}
+
+void ProfilerExample() {
+ PinThreadToRandomCPU();
+ {
+ PROFILER_FUNC;
+ Spin10();
+ Spin20();
+ Spin3060();
+ Level1();
+ }
+ PROFILER_PRINT_RESULTS();
+}
+
+} // namespace
+} // namespace highwayhash
+
+int main(int argc, char* argv[]) {
+ highwayhash::ProfilerExample();
+ return 0;
+}
diff --git a/contrib/libs/highwayhash/highwayhash/robust_statistics.h b/contrib/libs/highwayhash/highwayhash/robust_statistics.h
index 9c4a0b4cd5..4e45494f9b 100644
--- a/contrib/libs/highwayhash/highwayhash/robust_statistics.h
+++ b/contrib/libs/highwayhash/highwayhash/robust_statistics.h
@@ -1,135 +1,135 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_ROBUST_STATISTICS_H_
-#define HIGHWAYHASH_ROBUST_STATISTICS_H_
-
-// Robust statistics: Mode, Median, MedianAbsoluteDeviation.
-
-#include <stddef.h>
-#include <algorithm>
-#include <cassert>
-#include <cmath>
-#include <limits>
-#include <vector>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-
-namespace highwayhash {
-
-// @return i in [idx_begin, idx_begin + half_count) that minimizes
-// sorted[i + half_count] - sorted[i].
-template <typename T>
-size_t MinRange(const T* const HH_RESTRICT sorted, const size_t idx_begin,
- const size_t half_count) {
- T min_range = std::numeric_limits<T>::max();
- size_t min_idx = 0;
-
- for (size_t idx = idx_begin; idx < idx_begin + half_count; ++idx) {
- assert(sorted[idx] <= sorted[idx + half_count]);
- const T range = sorted[idx + half_count] - sorted[idx];
- if (range < min_range) {
- min_range = range;
- min_idx = idx;
- }
- }
-
- return min_idx;
-}
-
-// Returns an estimate of the mode by calling MinRange on successively
-// halved intervals. "sorted" must be in ascending order. This is the
-// Half Sample Mode estimator proposed by Bickel in "On a fast, robust
-// estimator of the mode", with complexity O(N log N). The mode is less
-// affected by outliers in highly-skewed distributions than the median.
-// The averaging operation below assumes "T" is an unsigned integer type.
-template <typename T>
-T Mode(const T* const HH_RESTRICT sorted, const size_t num_values) {
- size_t idx_begin = 0;
- size_t half_count = num_values / 2;
- while (half_count > 1) {
- idx_begin = MinRange(sorted, idx_begin, half_count);
- half_count >>= 1;
- }
-
- const T x = sorted[idx_begin + 0];
- if (half_count == 0) {
- return x;
- }
- assert(half_count == 1);
- const T average = (x + sorted[idx_begin + 1] + 1) / 2;
- return average;
-}
-
-// Sorts integral values in ascending order. About 3x faster than std::sort for
-// input distributions with very few unique values.
-template <class T>
-void CountingSort(T* begin, T* end) {
- // Unique values and their frequency (similar to flat_map).
- using Unique = std::pair<T, int>;
- std::vector<Unique> unique;
- for (const T* p = begin; p != end; ++p) {
- const T value = *p;
- const auto pos =
- std::find_if(unique.begin(), unique.end(),
- [value](const Unique& u) { return u.first == value; });
- if (pos == unique.end()) {
- unique.push_back(std::make_pair(*p, 1));
- } else {
- ++pos->second;
- }
- }
-
- // Sort in ascending order of value (pair.first).
- std::sort(unique.begin(), unique.end());
-
- // Write that many copies of each unique value to the array.
- T* HH_RESTRICT p = begin;
- for (const auto& value_count : unique) {
- std::fill(p, p + value_count.second, value_count.first);
- p += value_count.second;
- }
- assert(p == end);
-}
-
-// Returns the median value. Side effect: sorts "samples".
-template <typename T>
-T Median(std::vector<T>* samples) {
- assert(!samples->empty());
- std::sort(samples->begin(), samples->end());
- const size_t half = samples->size() / 2;
- // Odd count: return middle
- if (samples->size() % 2) {
- return (*samples)[half];
- }
- // Even count: return average of middle two.
- return ((*samples)[half] + (*samples)[half - 1]) / 2;
-}
-
-// Returns a robust measure of variability.
-template <typename T>
-T MedianAbsoluteDeviation(const std::vector<T>& samples, const T median) {
- assert(!samples.empty());
- std::vector<T> abs_deviations;
- abs_deviations.reserve(samples.size());
- for (const T sample : samples) {
- abs_deviations.push_back(std::abs(sample - median));
- }
- return Median(&abs_deviations);
-}
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_ROBUST_STATISTICS_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_ROBUST_STATISTICS_H_
+#define HIGHWAYHASH_ROBUST_STATISTICS_H_
+
+// Robust statistics: Mode, Median, MedianAbsoluteDeviation.
+
+#include <stddef.h>
+#include <algorithm>
+#include <cassert>
+#include <cmath>
+#include <limits>
+#include <vector>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+
+namespace highwayhash {
+
+// @return i in [idx_begin, idx_begin + half_count) that minimizes
+// sorted[i + half_count] - sorted[i].
+template <typename T>
+size_t MinRange(const T* const HH_RESTRICT sorted, const size_t idx_begin,
+ const size_t half_count) {
+ T min_range = std::numeric_limits<T>::max();
+ size_t min_idx = 0;
+
+ for (size_t idx = idx_begin; idx < idx_begin + half_count; ++idx) {
+ assert(sorted[idx] <= sorted[idx + half_count]);
+ const T range = sorted[idx + half_count] - sorted[idx];
+ if (range < min_range) {
+ min_range = range;
+ min_idx = idx;
+ }
+ }
+
+ return min_idx;
+}
+
+// Returns an estimate of the mode by calling MinRange on successively
+// halved intervals. "sorted" must be in ascending order. This is the
+// Half Sample Mode estimator proposed by Bickel in "On a fast, robust
+// estimator of the mode", with complexity O(N log N). The mode is less
+// affected by outliers in highly-skewed distributions than the median.
+// The averaging operation below assumes "T" is an unsigned integer type.
+template <typename T>
+T Mode(const T* const HH_RESTRICT sorted, const size_t num_values) {
+ size_t idx_begin = 0;
+ size_t half_count = num_values / 2;
+ while (half_count > 1) {
+ idx_begin = MinRange(sorted, idx_begin, half_count);
+ half_count >>= 1;
+ }
+
+ const T x = sorted[idx_begin + 0];
+ if (half_count == 0) {
+ return x;
+ }
+ assert(half_count == 1);
+ const T average = (x + sorted[idx_begin + 1] + 1) / 2;
+ return average;
+}
+
+// Sorts integral values in ascending order. About 3x faster than std::sort for
+// input distributions with very few unique values.
+template <class T>
+void CountingSort(T* begin, T* end) {
+ // Unique values and their frequency (similar to flat_map).
+ using Unique = std::pair<T, int>;
+ std::vector<Unique> unique;
+ for (const T* p = begin; p != end; ++p) {
+ const T value = *p;
+ const auto pos =
+ std::find_if(unique.begin(), unique.end(),
+ [value](const Unique& u) { return u.first == value; });
+ if (pos == unique.end()) {
+ unique.push_back(std::make_pair(*p, 1));
+ } else {
+ ++pos->second;
+ }
+ }
+
+ // Sort in ascending order of value (pair.first).
+ std::sort(unique.begin(), unique.end());
+
+ // Write that many copies of each unique value to the array.
+ T* HH_RESTRICT p = begin;
+ for (const auto& value_count : unique) {
+ std::fill(p, p + value_count.second, value_count.first);
+ p += value_count.second;
+ }
+ assert(p == end);
+}
+
+// Returns the median value. Side effect: sorts "samples".
+template <typename T>
+T Median(std::vector<T>* samples) {
+ assert(!samples->empty());
+ std::sort(samples->begin(), samples->end());
+ const size_t half = samples->size() / 2;
+ // Odd count: return middle
+ if (samples->size() % 2) {
+ return (*samples)[half];
+ }
+ // Even count: return average of middle two.
+ return ((*samples)[half] + (*samples)[half - 1]) / 2;
+}
+
+// Returns a robust measure of variability.
+template <typename T>
+T MedianAbsoluteDeviation(const std::vector<T>& samples, const T median) {
+ assert(!samples.empty());
+ std::vector<T> abs_deviations;
+ abs_deviations.reserve(samples.size());
+ for (const T sample : samples) {
+ abs_deviations.push_back(std::abs(sample - median));
+ }
+ return Median(&abs_deviations);
+}
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_ROBUST_STATISTICS_H_
diff --git a/contrib/libs/highwayhash/highwayhash/scalar.h b/contrib/libs/highwayhash/highwayhash/scalar.h
index eb7bac9c1d..72ccae727e 100644
--- a/contrib/libs/highwayhash/highwayhash/scalar.h
+++ b/contrib/libs/highwayhash/highwayhash/scalar.h
@@ -1,352 +1,352 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_SCALAR_H_
-#define HIGHWAYHASH_SCALAR_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stddef.h> // size_t
-#include <stdint.h>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-
-namespace highwayhash {
-// To prevent ODR violations when including this from multiple translation
-// units (TU) that are compiled with different flags, the contents must reside
-// in a namespace whose name is unique to the TU. NOTE: this behavior is
-// incompatible with precompiled modules and requires textual inclusion instead.
-namespace HH_TARGET_NAME {
-
-// Single-lane "vector" type with the same interface as V128/Scalar. Allows the
-// same client template to generate both SIMD and portable code.
-template <typename Type>
-class Scalar {
- public:
- struct Intrinsic {
- Type t;
- };
-
- using T = Type;
- static constexpr size_t N = 1;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE Scalar() {}
-
- HH_INLINE explicit Scalar(const T t) : v_(t) {}
-
- HH_INLINE Scalar(const Scalar<T>& other) : v_(other.v_) {}
-
- HH_INLINE Scalar& operator=(const Scalar<T>& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE Scalar(const Intrinsic& v) : v_(v.t) {}
- HH_INLINE Scalar& operator=(const Intrinsic& v) {
- v_ = v.t;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return {v_}; }
-
- HH_INLINE Scalar operator==(const Scalar& other) const {
- Scalar eq;
- eq.FillWithByte(v_ == other.v_ ? 0xFF : 0x00);
- return eq;
- }
- HH_INLINE Scalar operator<(const Scalar& other) const {
- Scalar lt;
- lt.FillWithByte(v_ < other.v_ ? 0xFF : 0x00);
- return lt;
- }
- HH_INLINE Scalar operator>(const Scalar& other) const {
- Scalar gt;
- gt.FillWithByte(v_ > other.v_ ? 0xFF : 0x00);
- return gt;
- }
-
- HH_INLINE Scalar& operator*=(const Scalar& other) {
- v_ *= other.v_;
- return *this;
- }
- HH_INLINE Scalar& operator/=(const Scalar& other) {
- v_ /= other.v_;
- return *this;
- }
- HH_INLINE Scalar& operator+=(const Scalar& other) {
- v_ += other.v_;
- return *this;
- }
- HH_INLINE Scalar& operator-=(const Scalar& other) {
- v_ -= other.v_;
- return *this;
- }
-
- HH_INLINE Scalar& operator&=(const Scalar& other) {
- v_ &= other.v_;
- return *this;
- }
- HH_INLINE Scalar& operator|=(const Scalar& other) {
- v_ |= other.v_;
- return *this;
- }
- HH_INLINE Scalar& operator^=(const Scalar& other) {
- v_ ^= other.v_;
- return *this;
- }
-
- HH_INLINE Scalar& operator<<=(const int count) {
- // In C, int64_t << 64 is undefined, but we want to match the sensible
- // behavior of SSE2 (zeroing).
- if (count >= sizeof(T) * 8) {
- v_ = 0;
- } else {
- v_ <<= count;
- }
- return *this;
- }
-
- HH_INLINE Scalar& operator>>=(const int count) {
- if (count >= sizeof(T) * 8) {
- v_ = 0;
- } else {
- v_ >>= count;
- }
- return *this;
- }
-
- // For internal use only. We need to avoid memcpy/memset because this is a
- // restricted header.
- void FillWithByte(const unsigned char value) {
- unsigned char* bytes = reinterpret_cast<unsigned char*>(&v_);
- for (size_t i = 0; i < sizeof(T); ++i) {
- bytes[i] = value;
- }
- }
-
- void CopyTo(unsigned char* HH_RESTRICT to_bytes) const {
- const unsigned char* from_bytes =
- reinterpret_cast<const unsigned char*>(&v_);
- for (size_t i = 0; i < sizeof(T); ++i) {
- to_bytes[i] = from_bytes[i];
- }
- }
-
- private:
- T v_;
-};
-
-// Non-member operators.
-
-template <typename T>
-HH_INLINE Scalar<T> operator*(const Scalar<T>& left, const Scalar<T>& right) {
- Scalar<T> t(left);
- return t *= right;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator/(const Scalar<T>& left, const Scalar<T>& right) {
- Scalar<T> t(left);
- return t /= right;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator+(const Scalar<T>& left, const Scalar<T>& right) {
- Scalar<T> t(left);
- return t += right;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator-(const Scalar<T>& left, const Scalar<T>& right) {
- Scalar<T> t(left);
- return t -= right;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator&(const Scalar<T>& left, const Scalar<T>& right) {
- Scalar<T> t(left);
- return t &= right;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator|(const Scalar<T> left, const Scalar<T>& right) {
- Scalar<T> t(left);
- return t |= right;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator^(const Scalar<T>& left, const Scalar<T>& right) {
- Scalar<T> t(left);
- return t ^= right;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator<<(const Scalar<T>& v, const int count) {
- Scalar<T> t(v);
- return t <<= count;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> operator>>(const Scalar<T>& v, const int count) {
- Scalar<T> t(v);
- return t >>= count;
-}
-
-using V1x8U = Scalar<uint8_t>;
-using V1x16U = Scalar<uint16_t>;
-using V1x16I = Scalar<int16_t>;
-using V1x32U = Scalar<uint32_t>;
-using V1x32I = Scalar<int32_t>;
-using V1x64U = Scalar<uint64_t>;
-using V1x32F = Scalar<float>;
-using V1x64F = Scalar<double>;
-
-// Load/Store.
-
-// We differentiate between targets' vector types via template specialization.
-// Calling Load<V>(floats) is more natural than Load(V8x32F(), floats) and may
-// generate better code in unoptimized builds. Only declare the primary
-// templates to avoid needing mutual exclusion with vector128/256.
-template <class V>
-HH_INLINE V Load(const typename V::T* const HH_RESTRICT from);
-template <class V>
-HH_INLINE V LoadUnaligned(const typename V::T* const HH_RESTRICT from);
-
-template <>
-HH_INLINE V1x8U Load<V1x8U>(const V1x8U::T* const HH_RESTRICT from) {
- return V1x8U(*from);
-}
-template <>
-HH_INLINE V1x16U Load<V1x16U>(const V1x16U::T* const HH_RESTRICT from) {
- return V1x16U(*from);
-}
-template <>
-HH_INLINE V1x16I Load<V1x16I>(const V1x16I::T* const HH_RESTRICT from) {
- return V1x16I(*from);
-}
-template <>
-HH_INLINE V1x32U Load<V1x32U>(const V1x32U::T* const HH_RESTRICT from) {
- return V1x32U(*from);
-}
-template <>
-HH_INLINE V1x32I Load<V1x32I>(const V1x32I::T* const HH_RESTRICT from) {
- return V1x32I(*from);
-}
-template <>
-HH_INLINE V1x64U Load<V1x64U>(const V1x64U::T* const HH_RESTRICT from) {
- return V1x64U(*from);
-}
-template <>
-HH_INLINE V1x32F Load<V1x32F>(const V1x32F::T* const HH_RESTRICT from) {
- return V1x32F(*from);
-}
-template <>
-HH_INLINE V1x64F Load<V1x64F>(const V1x64F::T* const HH_RESTRICT from) {
- return V1x64F(*from);
-}
-
-template <>
-HH_INLINE V1x8U LoadUnaligned<V1x8U>(const V1x8U::T* const HH_RESTRICT from) {
- return V1x8U(*from);
-}
-template <>
-HH_INLINE V1x16U
-LoadUnaligned<V1x16U>(const V1x16U::T* const HH_RESTRICT from) {
- return V1x16U(*from);
-}
-template <>
-HH_INLINE V1x16I
-LoadUnaligned<V1x16I>(const V1x16I::T* const HH_RESTRICT from) {
- return V1x16I(*from);
-}
-template <>
-HH_INLINE V1x32U
-LoadUnaligned<V1x32U>(const V1x32U::T* const HH_RESTRICT from) {
- return V1x32U(*from);
-}
-template <>
-HH_INLINE V1x32I
-LoadUnaligned<V1x32I>(const V1x32I::T* const HH_RESTRICT from) {
- return V1x32I(*from);
-}
-template <>
-HH_INLINE V1x64U
-LoadUnaligned<V1x64U>(const V1x64U::T* const HH_RESTRICT from) {
- return V1x64U(*from);
-}
-template <>
-HH_INLINE V1x32F
-LoadUnaligned<V1x32F>(const V1x32F::T* const HH_RESTRICT from) {
- return V1x32F(*from);
-}
-template <>
-HH_INLINE V1x64F
-LoadUnaligned<V1x64F>(const V1x64F::T* const HH_RESTRICT from) {
- return V1x64F(*from);
-}
-
-template <typename T>
-HH_INLINE void Store(const Scalar<T>& v, T* const HH_RESTRICT to) {
- v.CopyTo(reinterpret_cast<unsigned char*>(to));
-}
-
-template <typename T>
-HH_INLINE void StoreUnaligned(const Scalar<T>& v, T* const HH_RESTRICT to) {
- v.CopyTo(reinterpret_cast<unsigned char*>(to));
-}
-
-template <typename T>
-HH_INLINE void Stream(const Scalar<T>& v, T* const HH_RESTRICT to) {
- v.CopyTo(reinterpret_cast<unsigned char*>(to));
-}
-
-// Miscellaneous functions.
-
-template <typename T>
-HH_INLINE Scalar<T> RotateLeft(const Scalar<T>& v, const int count) {
- constexpr size_t num_bits = sizeof(T) * 8;
- return (v << count) | (v >> (num_bits - count));
-}
-
-template <typename T>
-HH_INLINE Scalar<T> AndNot(const Scalar<T>& neg_mask, const Scalar<T>& values) {
- return values & ~neg_mask;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> Select(const Scalar<T>& a, const Scalar<T>& b,
- const Scalar<T>& mask) {
- const char* mask_bytes = reinterpret_cast<const char*>(&mask);
- return (mask_bytes[sizeof(T) - 1] & 0x80) ? b : a;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> Min(const Scalar<T>& v0, const Scalar<T>& v1) {
- return (v0 < v1) ? v0 : v1;
-}
-
-template <typename T>
-HH_INLINE Scalar<T> Max(const Scalar<T>& v0, const Scalar<T>& v1) {
- return (v0 < v1) ? v1 : v0;
-}
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_SCALAR_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_SCALAR_H_
+#define HIGHWAYHASH_SCALAR_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stddef.h> // size_t
+#include <stdint.h>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+
+namespace highwayhash {
+// To prevent ODR violations when including this from multiple translation
+// units (TU) that are compiled with different flags, the contents must reside
+// in a namespace whose name is unique to the TU. NOTE: this behavior is
+// incompatible with precompiled modules and requires textual inclusion instead.
+namespace HH_TARGET_NAME {
+
+// Single-lane "vector" type with the same interface as V128/Scalar. Allows the
+// same client template to generate both SIMD and portable code.
+template <typename Type>
+class Scalar {
+ public:
+ struct Intrinsic {
+ Type t;
+ };
+
+ using T = Type;
+ static constexpr size_t N = 1;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE Scalar() {}
+
+ HH_INLINE explicit Scalar(const T t) : v_(t) {}
+
+ HH_INLINE Scalar(const Scalar<T>& other) : v_(other.v_) {}
+
+ HH_INLINE Scalar& operator=(const Scalar<T>& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE Scalar(const Intrinsic& v) : v_(v.t) {}
+ HH_INLINE Scalar& operator=(const Intrinsic& v) {
+ v_ = v.t;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return {v_}; }
+
+ HH_INLINE Scalar operator==(const Scalar& other) const {
+ Scalar eq;
+ eq.FillWithByte(v_ == other.v_ ? 0xFF : 0x00);
+ return eq;
+ }
+ HH_INLINE Scalar operator<(const Scalar& other) const {
+ Scalar lt;
+ lt.FillWithByte(v_ < other.v_ ? 0xFF : 0x00);
+ return lt;
+ }
+ HH_INLINE Scalar operator>(const Scalar& other) const {
+ Scalar gt;
+ gt.FillWithByte(v_ > other.v_ ? 0xFF : 0x00);
+ return gt;
+ }
+
+ HH_INLINE Scalar& operator*=(const Scalar& other) {
+ v_ *= other.v_;
+ return *this;
+ }
+ HH_INLINE Scalar& operator/=(const Scalar& other) {
+ v_ /= other.v_;
+ return *this;
+ }
+ HH_INLINE Scalar& operator+=(const Scalar& other) {
+ v_ += other.v_;
+ return *this;
+ }
+ HH_INLINE Scalar& operator-=(const Scalar& other) {
+ v_ -= other.v_;
+ return *this;
+ }
+
+ HH_INLINE Scalar& operator&=(const Scalar& other) {
+ v_ &= other.v_;
+ return *this;
+ }
+ HH_INLINE Scalar& operator|=(const Scalar& other) {
+ v_ |= other.v_;
+ return *this;
+ }
+ HH_INLINE Scalar& operator^=(const Scalar& other) {
+ v_ ^= other.v_;
+ return *this;
+ }
+
+ HH_INLINE Scalar& operator<<=(const int count) {
+ // In C, int64_t << 64 is undefined, but we want to match the sensible
+ // behavior of SSE2 (zeroing).
+ if (count >= sizeof(T) * 8) {
+ v_ = 0;
+ } else {
+ v_ <<= count;
+ }
+ return *this;
+ }
+
+ HH_INLINE Scalar& operator>>=(const int count) {
+ if (count >= sizeof(T) * 8) {
+ v_ = 0;
+ } else {
+ v_ >>= count;
+ }
+ return *this;
+ }
+
+ // For internal use only. We need to avoid memcpy/memset because this is a
+ // restricted header.
+ void FillWithByte(const unsigned char value) {
+ unsigned char* bytes = reinterpret_cast<unsigned char*>(&v_);
+ for (size_t i = 0; i < sizeof(T); ++i) {
+ bytes[i] = value;
+ }
+ }
+
+ void CopyTo(unsigned char* HH_RESTRICT to_bytes) const {
+ const unsigned char* from_bytes =
+ reinterpret_cast<const unsigned char*>(&v_);
+ for (size_t i = 0; i < sizeof(T); ++i) {
+ to_bytes[i] = from_bytes[i];
+ }
+ }
+
+ private:
+ T v_;
+};
+
+// Non-member operators.
+
+template <typename T>
+HH_INLINE Scalar<T> operator*(const Scalar<T>& left, const Scalar<T>& right) {
+ Scalar<T> t(left);
+ return t *= right;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator/(const Scalar<T>& left, const Scalar<T>& right) {
+ Scalar<T> t(left);
+ return t /= right;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator+(const Scalar<T>& left, const Scalar<T>& right) {
+ Scalar<T> t(left);
+ return t += right;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator-(const Scalar<T>& left, const Scalar<T>& right) {
+ Scalar<T> t(left);
+ return t -= right;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator&(const Scalar<T>& left, const Scalar<T>& right) {
+ Scalar<T> t(left);
+ return t &= right;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator|(const Scalar<T> left, const Scalar<T>& right) {
+ Scalar<T> t(left);
+ return t |= right;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator^(const Scalar<T>& left, const Scalar<T>& right) {
+ Scalar<T> t(left);
+ return t ^= right;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator<<(const Scalar<T>& v, const int count) {
+ Scalar<T> t(v);
+ return t <<= count;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> operator>>(const Scalar<T>& v, const int count) {
+ Scalar<T> t(v);
+ return t >>= count;
+}
+
+using V1x8U = Scalar<uint8_t>;
+using V1x16U = Scalar<uint16_t>;
+using V1x16I = Scalar<int16_t>;
+using V1x32U = Scalar<uint32_t>;
+using V1x32I = Scalar<int32_t>;
+using V1x64U = Scalar<uint64_t>;
+using V1x32F = Scalar<float>;
+using V1x64F = Scalar<double>;
+
+// Load/Store.
+
+// We differentiate between targets' vector types via template specialization.
+// Calling Load<V>(floats) is more natural than Load(V8x32F(), floats) and may
+// generate better code in unoptimized builds. Only declare the primary
+// templates to avoid needing mutual exclusion with vector128/256.
+template <class V>
+HH_INLINE V Load(const typename V::T* const HH_RESTRICT from);
+template <class V>
+HH_INLINE V LoadUnaligned(const typename V::T* const HH_RESTRICT from);
+
+template <>
+HH_INLINE V1x8U Load<V1x8U>(const V1x8U::T* const HH_RESTRICT from) {
+ return V1x8U(*from);
+}
+template <>
+HH_INLINE V1x16U Load<V1x16U>(const V1x16U::T* const HH_RESTRICT from) {
+ return V1x16U(*from);
+}
+template <>
+HH_INLINE V1x16I Load<V1x16I>(const V1x16I::T* const HH_RESTRICT from) {
+ return V1x16I(*from);
+}
+template <>
+HH_INLINE V1x32U Load<V1x32U>(const V1x32U::T* const HH_RESTRICT from) {
+ return V1x32U(*from);
+}
+template <>
+HH_INLINE V1x32I Load<V1x32I>(const V1x32I::T* const HH_RESTRICT from) {
+ return V1x32I(*from);
+}
+template <>
+HH_INLINE V1x64U Load<V1x64U>(const V1x64U::T* const HH_RESTRICT from) {
+ return V1x64U(*from);
+}
+template <>
+HH_INLINE V1x32F Load<V1x32F>(const V1x32F::T* const HH_RESTRICT from) {
+ return V1x32F(*from);
+}
+template <>
+HH_INLINE V1x64F Load<V1x64F>(const V1x64F::T* const HH_RESTRICT from) {
+ return V1x64F(*from);
+}
+
+template <>
+HH_INLINE V1x8U LoadUnaligned<V1x8U>(const V1x8U::T* const HH_RESTRICT from) {
+ return V1x8U(*from);
+}
+template <>
+HH_INLINE V1x16U
+LoadUnaligned<V1x16U>(const V1x16U::T* const HH_RESTRICT from) {
+ return V1x16U(*from);
+}
+template <>
+HH_INLINE V1x16I
+LoadUnaligned<V1x16I>(const V1x16I::T* const HH_RESTRICT from) {
+ return V1x16I(*from);
+}
+template <>
+HH_INLINE V1x32U
+LoadUnaligned<V1x32U>(const V1x32U::T* const HH_RESTRICT from) {
+ return V1x32U(*from);
+}
+template <>
+HH_INLINE V1x32I
+LoadUnaligned<V1x32I>(const V1x32I::T* const HH_RESTRICT from) {
+ return V1x32I(*from);
+}
+template <>
+HH_INLINE V1x64U
+LoadUnaligned<V1x64U>(const V1x64U::T* const HH_RESTRICT from) {
+ return V1x64U(*from);
+}
+template <>
+HH_INLINE V1x32F
+LoadUnaligned<V1x32F>(const V1x32F::T* const HH_RESTRICT from) {
+ return V1x32F(*from);
+}
+template <>
+HH_INLINE V1x64F
+LoadUnaligned<V1x64F>(const V1x64F::T* const HH_RESTRICT from) {
+ return V1x64F(*from);
+}
+
+template <typename T>
+HH_INLINE void Store(const Scalar<T>& v, T* const HH_RESTRICT to) {
+ v.CopyTo(reinterpret_cast<unsigned char*>(to));
+}
+
+template <typename T>
+HH_INLINE void StoreUnaligned(const Scalar<T>& v, T* const HH_RESTRICT to) {
+ v.CopyTo(reinterpret_cast<unsigned char*>(to));
+}
+
+template <typename T>
+HH_INLINE void Stream(const Scalar<T>& v, T* const HH_RESTRICT to) {
+ v.CopyTo(reinterpret_cast<unsigned char*>(to));
+}
+
+// Miscellaneous functions.
+
+template <typename T>
+HH_INLINE Scalar<T> RotateLeft(const Scalar<T>& v, const int count) {
+ constexpr size_t num_bits = sizeof(T) * 8;
+ return (v << count) | (v >> (num_bits - count));
+}
+
+template <typename T>
+HH_INLINE Scalar<T> AndNot(const Scalar<T>& neg_mask, const Scalar<T>& values) {
+ return values & ~neg_mask;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> Select(const Scalar<T>& a, const Scalar<T>& b,
+ const Scalar<T>& mask) {
+ const char* mask_bytes = reinterpret_cast<const char*>(&mask);
+ return (mask_bytes[sizeof(T) - 1] & 0x80) ? b : a;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> Min(const Scalar<T>& v0, const Scalar<T>& v1) {
+ return (v0 < v1) ? v0 : v1;
+}
+
+template <typename T>
+HH_INLINE Scalar<T> Max(const Scalar<T>& v0, const Scalar<T>& v1) {
+ return (v0 < v1) ? v1 : v0;
+}
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_SCALAR_H_
diff --git a/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.cc b/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.cc
index 136f2769a1..9ddeca64e6 100644
--- a/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.cc
+++ b/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.cc
@@ -1,183 +1,183 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/scalar_sip_tree_hash.h"
-
-#include <cstddef>
-#include <cstring> // memcpy
-
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/sip_hash.h"
-
-namespace highwayhash {
-namespace {
-
-// Paper: https://www.131002.net/siphash/siphash.pdf
-// SSE41 implementation: https://goo.gl/80GBSD
-// Tree hash extension: http://dx.doi.org/10.4236/jis.2014.53010
-
-// The hash state is updated by injecting 4x8-byte packets;
-// XORing together all state vectors yields 32 bytes that are
-// reduced to 64 bits via 8-byte SipHash.
-
-const int kNumLanes = 4;
-using Lanes = HH_U64[kNumLanes];
-const int kPacketSize = sizeof(Lanes);
-
-template <int kUpdateRounds, int kFinalizeRounds>
-class ScalarSipTreeHashState {
- public:
- HH_INLINE ScalarSipTreeHashState(const Lanes& keys, const int lane) {
- const HH_U64 key = keys[lane] ^ (kNumLanes | lane);
- v0 = 0x736f6d6570736575ull ^ key;
- v1 = 0x646f72616e646f6dull ^ key;
- v2 = 0x6c7967656e657261ull ^ key;
- v3 = 0x7465646279746573ull ^ key;
- }
-
- HH_INLINE void Update(const HH_U64& packet) {
- v3 ^= packet;
-
- Compress<kUpdateRounds>();
-
- v0 ^= packet;
- }
-
- HH_INLINE HH_U64 Finalize() {
- // Mix in bits to avoid leaking the key if all packets were zero.
- v2 ^= 0xFF;
-
- Compress<kFinalizeRounds>();
-
- return (v0 ^ v1) ^ (v2 ^ v3);
- }
-
- private:
- // Rotate a 64-bit value "v" left by N bits.
- template <HH_U64 bits>
- static HH_INLINE HH_U64 RotateLeft(const HH_U64 v) {
- const HH_U64 left = v << bits;
- const HH_U64 right = v >> (64 - bits);
- return left | right;
- }
-
- template <int kRounds>
- HH_INLINE void Compress() {
- for (int i = 0; i < kRounds; ++i) {
- // ARX network: add, rotate, exclusive-or.
- v0 += v1;
- v2 += v3;
- v1 = RotateLeft<13>(v1);
- v3 = RotateLeft<16>(v3);
- v1 ^= v0;
- v3 ^= v2;
-
- v0 = RotateLeft<32>(v0);
-
- v2 += v1;
- v0 += v3;
- v1 = RotateLeft<17>(v1);
- v3 = RotateLeft<21>(v3);
- v1 ^= v2;
- v3 ^= v0;
-
- v2 = RotateLeft<32>(v2);
- }
- }
-
- HH_U64 v0;
- HH_U64 v1;
- HH_U64 v2;
- HH_U64 v3;
-};
-
-} // namespace
-
-template <size_t kUpdateRounds, size_t kFinalizeRounds>
-HH_U64 ScalarSipTreeHashT(const Lanes& key, const char* bytes,
- const HH_U64 size) {
- // "j-lanes" tree hashing interleaves 8-byte input packets.
- using State = ScalarSipTreeHashState<kUpdateRounds, kFinalizeRounds>;
- State state[kNumLanes] = {State(key, 0), State(key, 1), State(key, 2),
- State(key, 3)};
-
- // Hash entire 32-byte packets.
- const size_t remainder = size & (kPacketSize - 1);
- const size_t truncated_size = size - remainder;
- const HH_U64* packets = reinterpret_cast<const HH_U64*>(bytes);
- for (size_t i = 0; i < truncated_size / kPacketSize; ++i) {
- for (int lane = 0; lane < kNumLanes; ++lane) {
- const HH_U64 packet = *packets++;
- state[lane].Update(packet);
- }
- }
-
- // Update with final 32-byte packet.
- const size_t remainder_mod4 = remainder & 3;
- uint32_t packet4 = static_cast<uint32_t>(remainder << 24);
- const char* final_bytes = bytes + size - remainder_mod4;
- for (size_t i = 0; i < remainder_mod4; ++i) {
- const uint32_t byte = static_cast<unsigned char>(final_bytes[i]);
- packet4 += byte << (i * 8);
- }
-
- char final_packet[kPacketSize] = {0};
- memcpy(final_packet, bytes + truncated_size, remainder - remainder_mod4);
- memcpy(final_packet + kPacketSize - 4, &packet4, sizeof(packet4));
- packets = reinterpret_cast<const HH_U64*>(final_packet);
- for (int lane = 0; lane < kNumLanes; ++lane) {
- state[lane].Update(packets[lane]);
- }
-
- // Store the resulting hashes.
- uint64_t hashes[4];
- for (int lane = 0; lane < kNumLanes; ++lane) {
- hashes[lane] = state[lane].Finalize();
- }
-
- typename SipHashStateT<kUpdateRounds, kFinalizeRounds>::Key reduce_key;
- memcpy(&reduce_key, &key, sizeof(reduce_key));
- return ReduceSipTreeHash<kNumLanes, kUpdateRounds, kFinalizeRounds>(
- reduce_key, hashes);
-}
-
-HH_U64 ScalarSipTreeHash(const Lanes& key, const char* bytes,
- const HH_U64 size) {
- return ScalarSipTreeHashT<2, 4>(key, bytes, size);
-}
-
-HH_U64 ScalarSipTreeHash13(const Lanes& key, const char* bytes,
- const HH_U64 size) {
- return ScalarSipTreeHashT<1, 3>(key, bytes, size);
-}
-} // namespace highwayhash
-
-using highwayhash::HH_U64;
-using highwayhash::ScalarSipTreeHash;
-using highwayhash::ScalarSipTreeHash13;
-using Key = HH_U64[4];
-
-extern "C" {
-
-HH_U64 ScalarSipTreeHashC(const HH_U64* key, const char* bytes,
- const HH_U64 size) {
- return ScalarSipTreeHash(*reinterpret_cast<const Key*>(key), bytes, size);
-}
-
-HH_U64 ScalarSipTreeHash13C(const HH_U64* key, const char* bytes,
- const HH_U64 size) {
- return ScalarSipTreeHash13(*reinterpret_cast<const Key*>(key), bytes, size);
-}
-
-} // extern "C"
+// Copyright 2015 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/scalar_sip_tree_hash.h"
+
+#include <cstddef>
+#include <cstring> // memcpy
+
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/sip_hash.h"
+
+namespace highwayhash {
+namespace {
+
+// Paper: https://www.131002.net/siphash/siphash.pdf
+// SSE41 implementation: https://goo.gl/80GBSD
+// Tree hash extension: http://dx.doi.org/10.4236/jis.2014.53010
+
+// The hash state is updated by injecting 4x8-byte packets;
+// XORing together all state vectors yields 32 bytes that are
+// reduced to 64 bits via 8-byte SipHash.
+
+const int kNumLanes = 4;
+using Lanes = HH_U64[kNumLanes];
+const int kPacketSize = sizeof(Lanes);
+
+template <int kUpdateRounds, int kFinalizeRounds>
+class ScalarSipTreeHashState {
+ public:
+ HH_INLINE ScalarSipTreeHashState(const Lanes& keys, const int lane) {
+ const HH_U64 key = keys[lane] ^ (kNumLanes | lane);
+ v0 = 0x736f6d6570736575ull ^ key;
+ v1 = 0x646f72616e646f6dull ^ key;
+ v2 = 0x6c7967656e657261ull ^ key;
+ v3 = 0x7465646279746573ull ^ key;
+ }
+
+ HH_INLINE void Update(const HH_U64& packet) {
+ v3 ^= packet;
+
+ Compress<kUpdateRounds>();
+
+ v0 ^= packet;
+ }
+
+ HH_INLINE HH_U64 Finalize() {
+ // Mix in bits to avoid leaking the key if all packets were zero.
+ v2 ^= 0xFF;
+
+ Compress<kFinalizeRounds>();
+
+ return (v0 ^ v1) ^ (v2 ^ v3);
+ }
+
+ private:
+ // Rotate a 64-bit value "v" left by N bits.
+ template <HH_U64 bits>
+ static HH_INLINE HH_U64 RotateLeft(const HH_U64 v) {
+ const HH_U64 left = v << bits;
+ const HH_U64 right = v >> (64 - bits);
+ return left | right;
+ }
+
+ template <int kRounds>
+ HH_INLINE void Compress() {
+ for (int i = 0; i < kRounds; ++i) {
+ // ARX network: add, rotate, exclusive-or.
+ v0 += v1;
+ v2 += v3;
+ v1 = RotateLeft<13>(v1);
+ v3 = RotateLeft<16>(v3);
+ v1 ^= v0;
+ v3 ^= v2;
+
+ v0 = RotateLeft<32>(v0);
+
+ v2 += v1;
+ v0 += v3;
+ v1 = RotateLeft<17>(v1);
+ v3 = RotateLeft<21>(v3);
+ v1 ^= v2;
+ v3 ^= v0;
+
+ v2 = RotateLeft<32>(v2);
+ }
+ }
+
+ HH_U64 v0;
+ HH_U64 v1;
+ HH_U64 v2;
+ HH_U64 v3;
+};
+
+} // namespace
+
+template <size_t kUpdateRounds, size_t kFinalizeRounds>
+HH_U64 ScalarSipTreeHashT(const Lanes& key, const char* bytes,
+ const HH_U64 size) {
+ // "j-lanes" tree hashing interleaves 8-byte input packets.
+ using State = ScalarSipTreeHashState<kUpdateRounds, kFinalizeRounds>;
+ State state[kNumLanes] = {State(key, 0), State(key, 1), State(key, 2),
+ State(key, 3)};
+
+ // Hash entire 32-byte packets.
+ const size_t remainder = size & (kPacketSize - 1);
+ const size_t truncated_size = size - remainder;
+ const HH_U64* packets = reinterpret_cast<const HH_U64*>(bytes);
+ for (size_t i = 0; i < truncated_size / kPacketSize; ++i) {
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ const HH_U64 packet = *packets++;
+ state[lane].Update(packet);
+ }
+ }
+
+ // Update with final 32-byte packet.
+ const size_t remainder_mod4 = remainder & 3;
+ uint32_t packet4 = static_cast<uint32_t>(remainder << 24);
+ const char* final_bytes = bytes + size - remainder_mod4;
+ for (size_t i = 0; i < remainder_mod4; ++i) {
+ const uint32_t byte = static_cast<unsigned char>(final_bytes[i]);
+ packet4 += byte << (i * 8);
+ }
+
+ char final_packet[kPacketSize] = {0};
+ memcpy(final_packet, bytes + truncated_size, remainder - remainder_mod4);
+ memcpy(final_packet + kPacketSize - 4, &packet4, sizeof(packet4));
+ packets = reinterpret_cast<const HH_U64*>(final_packet);
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ state[lane].Update(packets[lane]);
+ }
+
+ // Store the resulting hashes.
+ uint64_t hashes[4];
+ for (int lane = 0; lane < kNumLanes; ++lane) {
+ hashes[lane] = state[lane].Finalize();
+ }
+
+ typename SipHashStateT<kUpdateRounds, kFinalizeRounds>::Key reduce_key;
+ memcpy(&reduce_key, &key, sizeof(reduce_key));
+ return ReduceSipTreeHash<kNumLanes, kUpdateRounds, kFinalizeRounds>(
+ reduce_key, hashes);
+}
+
+HH_U64 ScalarSipTreeHash(const Lanes& key, const char* bytes,
+ const HH_U64 size) {
+ return ScalarSipTreeHashT<2, 4>(key, bytes, size);
+}
+
+HH_U64 ScalarSipTreeHash13(const Lanes& key, const char* bytes,
+ const HH_U64 size) {
+ return ScalarSipTreeHashT<1, 3>(key, bytes, size);
+}
+} // namespace highwayhash
+
+using highwayhash::HH_U64;
+using highwayhash::ScalarSipTreeHash;
+using highwayhash::ScalarSipTreeHash13;
+using Key = HH_U64[4];
+
+extern "C" {
+
+HH_U64 ScalarSipTreeHashC(const HH_U64* key, const char* bytes,
+ const HH_U64 size) {
+ return ScalarSipTreeHash(*reinterpret_cast<const Key*>(key), bytes, size);
+}
+
+HH_U64 ScalarSipTreeHash13C(const HH_U64* key, const char* bytes,
+ const HH_U64 size) {
+ return ScalarSipTreeHash13(*reinterpret_cast<const Key*>(key), bytes, size);
+}
+
+} // extern "C"
diff --git a/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.h b/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.h
index f882be89d2..2f79f3a010 100644
--- a/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.h
+++ b/contrib/libs/highwayhash/highwayhash/scalar_sip_tree_hash.h
@@ -1,37 +1,37 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_SCALAR_SIP_TREE_HASH_H_
-#define HIGHWAYHASH_SCALAR_SIP_TREE_HASH_H_
-
-// Scalar (non-vector/SIMD) version for comparison purposes.
-
-#include "highwayhash/state_helpers.h"
-
-#ifdef __cplusplus
-namespace highwayhash {
-extern "C" {
-#endif
-
-HH_U64 ScalarSipTreeHash(const HH_U64 (&key)[4], const char* bytes,
- const HH_U64 size);
-HH_U64 ScalarSipTreeHash13(const HH_U64 (&key)[4], const char* bytes,
- const HH_U64 size);
-
-#ifdef __cplusplus
-} // extern "C"
-} // namespace highwayhash
-#endif
-
-#endif // HIGHWAYHASH_SCALAR_SIP_TREE_HASH_H_
+// Copyright 2015 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_SCALAR_SIP_TREE_HASH_H_
+#define HIGHWAYHASH_SCALAR_SIP_TREE_HASH_H_
+
+// Scalar (non-vector/SIMD) version for comparison purposes.
+
+#include "highwayhash/state_helpers.h"
+
+#ifdef __cplusplus
+namespace highwayhash {
+extern "C" {
+#endif
+
+HH_U64 ScalarSipTreeHash(const HH_U64 (&key)[4], const char* bytes,
+ const HH_U64 size);
+HH_U64 ScalarSipTreeHash13(const HH_U64 (&key)[4], const char* bytes,
+ const HH_U64 size);
+
+#ifdef __cplusplus
+} // extern "C"
+} // namespace highwayhash
+#endif
+
+#endif // HIGHWAYHASH_SCALAR_SIP_TREE_HASH_H_
diff --git a/contrib/libs/highwayhash/highwayhash/sip_hash.cc b/contrib/libs/highwayhash/highwayhash/sip_hash.cc
index 3d73a0bcdd..1c08533544 100644
--- a/contrib/libs/highwayhash/highwayhash/sip_hash.cc
+++ b/contrib/libs/highwayhash/highwayhash/sip_hash.cc
@@ -1,33 +1,33 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/sip_hash.h"
-
-using highwayhash::HH_U64;
-using highwayhash::SipHash;
-using highwayhash::SipHash13;
-using Key = highwayhash::SipHashState::Key;
-using Key13 = highwayhash::SipHash13State::Key;
-
-extern "C" {
-
-HH_U64 SipHashC(const HH_U64* key, const char* bytes, const HH_U64 size) {
- return SipHash(*reinterpret_cast<const Key*>(key), bytes, size);
-}
-
-HH_U64 SipHash13C(const HH_U64* key, const char* bytes, const HH_U64 size) {
- return SipHash13(*reinterpret_cast<const Key13*>(key), bytes, size);
-}
-
-} // extern "C"
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/sip_hash.h"
+
+using highwayhash::HH_U64;
+using highwayhash::SipHash;
+using highwayhash::SipHash13;
+using Key = highwayhash::SipHashState::Key;
+using Key13 = highwayhash::SipHash13State::Key;
+
+extern "C" {
+
+HH_U64 SipHashC(const HH_U64* key, const char* bytes, const HH_U64 size) {
+ return SipHash(*reinterpret_cast<const Key*>(key), bytes, size);
+}
+
+HH_U64 SipHash13C(const HH_U64* key, const char* bytes, const HH_U64 size) {
+ return SipHash13(*reinterpret_cast<const Key13*>(key), bytes, size);
+}
+
+} // extern "C"
diff --git a/contrib/libs/highwayhash/highwayhash/sip_hash.h b/contrib/libs/highwayhash/highwayhash/sip_hash.h
index 24a5cf4f22..eebe3dc944 100644
--- a/contrib/libs/highwayhash/highwayhash/sip_hash.h
+++ b/contrib/libs/highwayhash/highwayhash/sip_hash.h
@@ -1,171 +1,171 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_SIP_HASH_H_
-#define HIGHWAYHASH_SIP_HASH_H_
-
-// Portable but fast SipHash implementation.
-
-#include <cstddef>
-#include <cstring> // memcpy
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/endianess.h"
-#include "highwayhash/state_helpers.h"
-
-namespace highwayhash {
-
-// Paper: https://www.131002.net/siphash/siphash.pdf
-template <int kUpdateIters, int kFinalizeIters>
-class SipHashStateT {
- public:
- using Key = HH_U64[2];
- static const size_t kPacketSize = sizeof(HH_U64);
-
- explicit HH_INLINE SipHashStateT(const Key& key) {
- v0 = 0x736f6d6570736575ull ^ key[0];
- v1 = 0x646f72616e646f6dull ^ key[1];
- v2 = 0x6c7967656e657261ull ^ key[0];
- v3 = 0x7465646279746573ull ^ key[1];
- }
-
- HH_INLINE void Update(const char* bytes) {
- HH_U64 packet;
- memcpy(&packet, bytes, sizeof(packet));
- packet = host_from_le64(packet);
-
- v3 ^= packet;
-
- Compress<kUpdateIters>();
-
- v0 ^= packet;
- }
-
- HH_INLINE HH_U64 Finalize() {
- // Mix in bits to avoid leaking the key if all packets were zero.
- v2 ^= 0xFF;
-
- Compress<kFinalizeIters>();
-
- return (v0 ^ v1) ^ (v2 ^ v3);
- }
- private:
- // Rotate a 64-bit value "v" left by N bits.
- template <HH_U64 bits>
- static HH_INLINE HH_U64 RotateLeft(const HH_U64 v) {
- const HH_U64 left = v << bits;
- const HH_U64 right = v >> (64 - bits);
- return left | right;
- }
-
- template <size_t rounds>
- HH_INLINE void Compress() {
- for (size_t i = 0; i < rounds; ++i) {
- // ARX network: add, rotate, exclusive-or.
- v0 += v1;
- v2 += v3;
- v1 = RotateLeft<13>(v1);
- v3 = RotateLeft<16>(v3);
- v1 ^= v0;
- v3 ^= v2;
-
- v0 = RotateLeft<32>(v0);
-
- v2 += v1;
- v0 += v3;
- v1 = RotateLeft<17>(v1);
- v3 = RotateLeft<21>(v3);
- v1 ^= v2;
- v3 ^= v0;
-
- v2 = RotateLeft<32>(v2);
- }
- }
-
- HH_U64 v0;
- HH_U64 v1;
- HH_U64 v2;
- HH_U64 v3;
-};
-
-using SipHashState = SipHashStateT<2, 4>;
-using SipHash13State = SipHashStateT<1, 3>;
-
-// Override the HighwayTreeHash padding scheme with that of SipHash so that
-// the hash output matches the known-good values in sip_hash_test.
-template <>
-HH_INLINE void PaddedUpdate<SipHashState>(const HH_U64 size,
- const char* remaining_bytes,
- const HH_U64 remaining_size,
- SipHashState* state) {
- // Copy to avoid overrunning the input buffer.
- char final_packet[SipHashState::kPacketSize] = {0};
- memcpy(final_packet, remaining_bytes, remaining_size);
- final_packet[SipHashState::kPacketSize - 1] = static_cast<char>(size & 0xFF);
- state->Update(final_packet);
-}
-
-template <>
-HH_INLINE void PaddedUpdate<SipHash13State>(const HH_U64 size,
- const char* remaining_bytes,
- const HH_U64 remaining_size,
- SipHash13State* state) {
- // Copy to avoid overrunning the input buffer.
- char final_packet[SipHash13State::kPacketSize] = {0};
- memcpy(final_packet, remaining_bytes, remaining_size);
- final_packet[SipHash13State::kPacketSize - 1] =
- static_cast<char>(size & 0xFF);
- state->Update(final_packet);
-}
-
-// Fast, cryptographically strong pseudo-random function, e.g. for
-// deterministic/idempotent 'random' number generation. See also
-// README.md for information on resisting hash flooding attacks.
-//
-// Robust versus timing attacks because memory accesses are sequential
-// and the algorithm is branch-free. Compute time is proportional to the
-// number of 8-byte packets and about twice as fast as an sse41 implementation.
-//
-// "key" is a secret 128-bit key unknown to attackers.
-// "bytes" is the data to hash; ceil(size / 8) * 8 bytes are read.
-// Returns a 64-bit hash of the given data bytes, which are swapped on
-// big-endian CPUs so the return value is the same as on little-endian CPUs.
-static HH_INLINE HH_U64 SipHash(const SipHashState::Key& key, const char* bytes,
- const HH_U64 size) {
- return ComputeHash<SipHashState>(key, bytes, size);
-}
-
-// Round-reduced SipHash version (1 update and 3 finalization rounds).
-static HH_INLINE HH_U64 SipHash13(const SipHash13State::Key& key,
- const char* bytes, const HH_U64 size) {
- return ComputeHash<SipHash13State>(key, bytes, size);
-}
-
-template <int kNumLanes, int kUpdateIters, int kFinalizeIters>
-static HH_INLINE HH_U64 ReduceSipTreeHash(
- const typename SipHashStateT<kUpdateIters, kFinalizeIters>::Key& key,
- const uint64_t (&hashes)[kNumLanes]) {
- SipHashStateT<kUpdateIters, kFinalizeIters> state(key);
-
- for (int i = 0; i < kNumLanes; ++i) {
- state.Update(reinterpret_cast<const char*>(&hashes[i]));
- }
-
- return state.Finalize();
-}
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_SIP_HASH_H_
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_SIP_HASH_H_
+#define HIGHWAYHASH_SIP_HASH_H_
+
+// Portable but fast SipHash implementation.
+
+#include <cstddef>
+#include <cstring> // memcpy
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/endianess.h"
+#include "highwayhash/state_helpers.h"
+
+namespace highwayhash {
+
+// Paper: https://www.131002.net/siphash/siphash.pdf
+template <int kUpdateIters, int kFinalizeIters>
+class SipHashStateT {
+ public:
+ using Key = HH_U64[2];
+ static const size_t kPacketSize = sizeof(HH_U64);
+
+ explicit HH_INLINE SipHashStateT(const Key& key) {
+ v0 = 0x736f6d6570736575ull ^ key[0];
+ v1 = 0x646f72616e646f6dull ^ key[1];
+ v2 = 0x6c7967656e657261ull ^ key[0];
+ v3 = 0x7465646279746573ull ^ key[1];
+ }
+
+ HH_INLINE void Update(const char* bytes) {
+ HH_U64 packet;
+ memcpy(&packet, bytes, sizeof(packet));
+ packet = host_from_le64(packet);
+
+ v3 ^= packet;
+
+ Compress<kUpdateIters>();
+
+ v0 ^= packet;
+ }
+
+ HH_INLINE HH_U64 Finalize() {
+ // Mix in bits to avoid leaking the key if all packets were zero.
+ v2 ^= 0xFF;
+
+ Compress<kFinalizeIters>();
+
+ return (v0 ^ v1) ^ (v2 ^ v3);
+ }
+ private:
+ // Rotate a 64-bit value "v" left by N bits.
+ template <HH_U64 bits>
+ static HH_INLINE HH_U64 RotateLeft(const HH_U64 v) {
+ const HH_U64 left = v << bits;
+ const HH_U64 right = v >> (64 - bits);
+ return left | right;
+ }
+
+ template <size_t rounds>
+ HH_INLINE void Compress() {
+ for (size_t i = 0; i < rounds; ++i) {
+ // ARX network: add, rotate, exclusive-or.
+ v0 += v1;
+ v2 += v3;
+ v1 = RotateLeft<13>(v1);
+ v3 = RotateLeft<16>(v3);
+ v1 ^= v0;
+ v3 ^= v2;
+
+ v0 = RotateLeft<32>(v0);
+
+ v2 += v1;
+ v0 += v3;
+ v1 = RotateLeft<17>(v1);
+ v3 = RotateLeft<21>(v3);
+ v1 ^= v2;
+ v3 ^= v0;
+
+ v2 = RotateLeft<32>(v2);
+ }
+ }
+
+ HH_U64 v0;
+ HH_U64 v1;
+ HH_U64 v2;
+ HH_U64 v3;
+};
+
+using SipHashState = SipHashStateT<2, 4>;
+using SipHash13State = SipHashStateT<1, 3>;
+
+// Override the HighwayTreeHash padding scheme with that of SipHash so that
+// the hash output matches the known-good values in sip_hash_test.
+template <>
+HH_INLINE void PaddedUpdate<SipHashState>(const HH_U64 size,
+ const char* remaining_bytes,
+ const HH_U64 remaining_size,
+ SipHashState* state) {
+ // Copy to avoid overrunning the input buffer.
+ char final_packet[SipHashState::kPacketSize] = {0};
+ memcpy(final_packet, remaining_bytes, remaining_size);
+ final_packet[SipHashState::kPacketSize - 1] = static_cast<char>(size & 0xFF);
+ state->Update(final_packet);
+}
+
+template <>
+HH_INLINE void PaddedUpdate<SipHash13State>(const HH_U64 size,
+ const char* remaining_bytes,
+ const HH_U64 remaining_size,
+ SipHash13State* state) {
+ // Copy to avoid overrunning the input buffer.
+ char final_packet[SipHash13State::kPacketSize] = {0};
+ memcpy(final_packet, remaining_bytes, remaining_size);
+ final_packet[SipHash13State::kPacketSize - 1] =
+ static_cast<char>(size & 0xFF);
+ state->Update(final_packet);
+}
+
+// Fast, cryptographically strong pseudo-random function, e.g. for
+// deterministic/idempotent 'random' number generation. See also
+// README.md for information on resisting hash flooding attacks.
+//
+// Robust versus timing attacks because memory accesses are sequential
+// and the algorithm is branch-free. Compute time is proportional to the
+// number of 8-byte packets and about twice as fast as an sse41 implementation.
+//
+// "key" is a secret 128-bit key unknown to attackers.
+// "bytes" is the data to hash; ceil(size / 8) * 8 bytes are read.
+// Returns a 64-bit hash of the given data bytes, which are swapped on
+// big-endian CPUs so the return value is the same as on little-endian CPUs.
+static HH_INLINE HH_U64 SipHash(const SipHashState::Key& key, const char* bytes,
+ const HH_U64 size) {
+ return ComputeHash<SipHashState>(key, bytes, size);
+}
+
+// Round-reduced SipHash version (1 update and 3 finalization rounds).
+static HH_INLINE HH_U64 SipHash13(const SipHash13State::Key& key,
+ const char* bytes, const HH_U64 size) {
+ return ComputeHash<SipHash13State>(key, bytes, size);
+}
+
+template <int kNumLanes, int kUpdateIters, int kFinalizeIters>
+static HH_INLINE HH_U64 ReduceSipTreeHash(
+ const typename SipHashStateT<kUpdateIters, kFinalizeIters>::Key& key,
+ const uint64_t (&hashes)[kNumLanes]) {
+ SipHashStateT<kUpdateIters, kFinalizeIters> state(key);
+
+ for (int i = 0; i < kNumLanes; ++i) {
+ state.Update(reinterpret_cast<const char*>(&hashes[i]));
+ }
+
+ return state.Finalize();
+}
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_SIP_HASH_H_
diff --git a/contrib/libs/highwayhash/highwayhash/sip_hash_test.cc b/contrib/libs/highwayhash/highwayhash/sip_hash_test.cc
index 8da79cf058..425dfea93c 100644
--- a/contrib/libs/highwayhash/highwayhash/sip_hash_test.cc
+++ b/contrib/libs/highwayhash/highwayhash/sip_hash_test.cc
@@ -1,150 +1,150 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/sip_hash.h"
-
-#include <cassert>
-#include <numeric>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef HH_GOOGLETEST
-#include "base/integral_types.h"
-#include "testing/base/public/benchmark.h"
-#include "testing/base/public/gunit.h"
-#endif
-#include "highwayhash/scalar_sip_tree_hash.h"
-#include "highwayhash/sip_tree_hash.h"
-
-namespace highwayhash {
-namespace {
-
-void VerifySipHash() {
- const int kMaxSize = 64;
- char in[kMaxSize]; // empty string, 00, 00 01, ...
- const HH_U64 key[2] = {0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL};
-
- // Known-good SipHash-2-4 output from D. Bernstein.
- const HH_U64 kSipHashOutput[64] = {
- 0x726FDB47DD0E0E31, 0x74F839C593DC67FD, 0x0D6C8009D9A94F5A,
- 0x85676696D7FB7E2D, 0xCF2794E0277187B7, 0x18765564CD99A68D,
- 0xCBC9466E58FEE3CE, 0xAB0200F58B01D137, 0x93F5F5799A932462,
- 0x9E0082DF0BA9E4B0, 0x7A5DBBC594DDB9F3, 0xF4B32F46226BADA7,
- 0x751E8FBC860EE5FB, 0x14EA5627C0843D90, 0xF723CA908E7AF2EE,
- 0xA129CA6149BE45E5, 0x3F2ACC7F57C29BDB, 0x699AE9F52CBE4794,
- 0x4BC1B3F0968DD39C, 0xBB6DC91DA77961BD, 0xBED65CF21AA2EE98,
- 0xD0F2CBB02E3B67C7, 0x93536795E3A33E88, 0xA80C038CCD5CCEC8,
- 0xB8AD50C6F649AF94, 0xBCE192DE8A85B8EA, 0x17D835B85BBB15F3,
- 0x2F2E6163076BCFAD, 0xDE4DAAACA71DC9A5, 0xA6A2506687956571,
- 0xAD87A3535C49EF28, 0x32D892FAD841C342, 0x7127512F72F27CCE,
- 0xA7F32346F95978E3, 0x12E0B01ABB051238, 0x15E034D40FA197AE,
- 0x314DFFBE0815A3B4, 0x027990F029623981, 0xCADCD4E59EF40C4D,
- 0x9ABFD8766A33735C, 0x0E3EA96B5304A7D0, 0xAD0C42D6FC585992,
- 0x187306C89BC215A9, 0xD4A60ABCF3792B95, 0xF935451DE4F21DF2,
- 0xA9538F0419755787, 0xDB9ACDDFF56CA510, 0xD06C98CD5C0975EB,
- 0xE612A3CB9ECBA951, 0xC766E62CFCADAF96, 0xEE64435A9752FE72,
- 0xA192D576B245165A, 0x0A8787BF8ECB74B2, 0x81B3E73D20B49B6F,
- 0x7FA8220BA3B2ECEA, 0x245731C13CA42499, 0xB78DBFAF3A8D83BD,
- 0xEA1AD565322A1A0B, 0x60E61C23A3795013, 0x6606D7E446282B93,
- 0x6CA4ECB15C5F91E1, 0x9F626DA15C9625F3, 0xE51B38608EF25F57,
- 0x958A324CEB064572};
-
- for (int size = 0; size < kMaxSize; ++size) {
- in[size] = static_cast<char>(size);
- const HH_U64 hash = highwayhash::SipHash(key, in, size);
-#ifdef HH_GOOGLETEST
- EXPECT_EQ(kSipHashOutput[size], hash) << "Mismatch at length " << size;
-#else
- if (hash != kSipHashOutput[size]) {
- printf("Mismatch at length %d\n", size);
- abort();
- }
-#endif
- }
-}
-
-#ifdef HH_GOOGLETEST
-TEST(SipHashTest, OutputMatchesExpectations) { VerifySipHash(); }
-
-namespace bm {
-/* Run with:
- blaze run -c opt --cpu=haswell third_party/highwayhash:sip_hash_test -- \
- --benchmarks=all --benchmark_min_iters=1 --benchmark_min_time=0.25
-*/
-
-// Returns a pointer to memory of at least size bytes long to be used as hashing
-// input.
-char* GetInput(size_t size) {
- static constexpr size_t kMaxSize = 100 << 20;
- assert(size <= kMaxSize);
- static auto* res = []() {
- auto* res = new char[kMaxSize];
- std::iota(res, res + kMaxSize, 0);
- return res;
- }();
- return res;
-}
-
-template <class Hasher>
-void BM(int iters, int size) {
- StopBenchmarkTiming();
- auto* input = GetInput(size);
- const HH_U64 keys[4] = {0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL,
- 0x1716151413121110ULL, 0x1F1E1D1C1B1A1918ULL};
- Hasher hasher(keys);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
- testing::DoNotOptimize(hasher(input, size));
- }
- StopBenchmarkTiming();
- SetBenchmarkBytesProcessed(static_cast<int64>(iters) * size);
-}
-
-void Args(::testing::Benchmark* bm) {
- bm->DenseRange(1, 16)->Range(32, 100 << 20);
-}
-
-#define DEFINE_HASHER(hashfn, num_keys) \
- struct hashfn##er { \
- hashfn##er(const HH_U64* k) { memcpy(keys, k, sizeof(keys)); } \
- HH_U64 operator()(const char* input, size_t size) { \
- return highwayhash::hashfn(keys, input, size); \
- } \
- HH_U64 keys[num_keys]; \
- }
-
-DEFINE_HASHER(SipHash, 2);
-BENCHMARK(BM<SipHasher>)->Apply(Args);
-
-DEFINE_HASHER(ScalarSipTreeHash, 4);
-BENCHMARK(BM<ScalarSipTreeHasher>)->Apply(Args);
-
-#ifdef __AVX2__
-DEFINE_HASHER(SipTreeHash, 4);
-BENCHMARK(BM<SipTreeHasher>)->Apply(Args);
-#endif
-
-} // namespace bm
-#endif // HH_GOOGLETEST
-
-} // namespace
-} // namespace highwayhash
-
-#ifndef HH_GOOGLETEST
-int main(int argc, char* argv[]) {
- highwayhash::VerifySipHash();
- printf("VerifySipHash succeeded.\n");
- return 0;
-}
-#endif
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/sip_hash.h"
+
+#include <cassert>
+#include <numeric>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef HH_GOOGLETEST
+#include "base/integral_types.h"
+#include "testing/base/public/benchmark.h"
+#include "testing/base/public/gunit.h"
+#endif
+#include "highwayhash/scalar_sip_tree_hash.h"
+#include "highwayhash/sip_tree_hash.h"
+
+namespace highwayhash {
+namespace {
+
+void VerifySipHash() {
+ const int kMaxSize = 64;
+ char in[kMaxSize]; // empty string, 00, 00 01, ...
+ const HH_U64 key[2] = {0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL};
+
+ // Known-good SipHash-2-4 output from D. Bernstein.
+ const HH_U64 kSipHashOutput[64] = {
+ 0x726FDB47DD0E0E31, 0x74F839C593DC67FD, 0x0D6C8009D9A94F5A,
+ 0x85676696D7FB7E2D, 0xCF2794E0277187B7, 0x18765564CD99A68D,
+ 0xCBC9466E58FEE3CE, 0xAB0200F58B01D137, 0x93F5F5799A932462,
+ 0x9E0082DF0BA9E4B0, 0x7A5DBBC594DDB9F3, 0xF4B32F46226BADA7,
+ 0x751E8FBC860EE5FB, 0x14EA5627C0843D90, 0xF723CA908E7AF2EE,
+ 0xA129CA6149BE45E5, 0x3F2ACC7F57C29BDB, 0x699AE9F52CBE4794,
+ 0x4BC1B3F0968DD39C, 0xBB6DC91DA77961BD, 0xBED65CF21AA2EE98,
+ 0xD0F2CBB02E3B67C7, 0x93536795E3A33E88, 0xA80C038CCD5CCEC8,
+ 0xB8AD50C6F649AF94, 0xBCE192DE8A85B8EA, 0x17D835B85BBB15F3,
+ 0x2F2E6163076BCFAD, 0xDE4DAAACA71DC9A5, 0xA6A2506687956571,
+ 0xAD87A3535C49EF28, 0x32D892FAD841C342, 0x7127512F72F27CCE,
+ 0xA7F32346F95978E3, 0x12E0B01ABB051238, 0x15E034D40FA197AE,
+ 0x314DFFBE0815A3B4, 0x027990F029623981, 0xCADCD4E59EF40C4D,
+ 0x9ABFD8766A33735C, 0x0E3EA96B5304A7D0, 0xAD0C42D6FC585992,
+ 0x187306C89BC215A9, 0xD4A60ABCF3792B95, 0xF935451DE4F21DF2,
+ 0xA9538F0419755787, 0xDB9ACDDFF56CA510, 0xD06C98CD5C0975EB,
+ 0xE612A3CB9ECBA951, 0xC766E62CFCADAF96, 0xEE64435A9752FE72,
+ 0xA192D576B245165A, 0x0A8787BF8ECB74B2, 0x81B3E73D20B49B6F,
+ 0x7FA8220BA3B2ECEA, 0x245731C13CA42499, 0xB78DBFAF3A8D83BD,
+ 0xEA1AD565322A1A0B, 0x60E61C23A3795013, 0x6606D7E446282B93,
+ 0x6CA4ECB15C5F91E1, 0x9F626DA15C9625F3, 0xE51B38608EF25F57,
+ 0x958A324CEB064572};
+
+ for (int size = 0; size < kMaxSize; ++size) {
+ in[size] = static_cast<char>(size);
+ const HH_U64 hash = highwayhash::SipHash(key, in, size);
+#ifdef HH_GOOGLETEST
+ EXPECT_EQ(kSipHashOutput[size], hash) << "Mismatch at length " << size;
+#else
+ if (hash != kSipHashOutput[size]) {
+ printf("Mismatch at length %d\n", size);
+ abort();
+ }
+#endif
+ }
+}
+
+#ifdef HH_GOOGLETEST
+TEST(SipHashTest, OutputMatchesExpectations) { VerifySipHash(); }
+
+namespace bm {
+/* Run with:
+ blaze run -c opt --cpu=haswell third_party/highwayhash:sip_hash_test -- \
+ --benchmarks=all --benchmark_min_iters=1 --benchmark_min_time=0.25
+*/
+
+// Returns a pointer to memory of at least size bytes long to be used as hashing
+// input.
+char* GetInput(size_t size) {
+ static constexpr size_t kMaxSize = 100 << 20;
+ assert(size <= kMaxSize);
+ static auto* res = []() {
+ auto* res = new char[kMaxSize];
+ std::iota(res, res + kMaxSize, 0);
+ return res;
+ }();
+ return res;
+}
+
+template <class Hasher>
+void BM(int iters, int size) {
+ StopBenchmarkTiming();
+ auto* input = GetInput(size);
+ const HH_U64 keys[4] = {0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL,
+ 0x1716151413121110ULL, 0x1F1E1D1C1B1A1918ULL};
+ Hasher hasher(keys);
+ StartBenchmarkTiming();
+ for (int i = 0; i < iters; ++i) {
+ testing::DoNotOptimize(hasher(input, size));
+ }
+ StopBenchmarkTiming();
+ SetBenchmarkBytesProcessed(static_cast<int64>(iters) * size);
+}
+
+void Args(::testing::Benchmark* bm) {
+ bm->DenseRange(1, 16)->Range(32, 100 << 20);
+}
+
+#define DEFINE_HASHER(hashfn, num_keys) \
+ struct hashfn##er { \
+ hashfn##er(const HH_U64* k) { memcpy(keys, k, sizeof(keys)); } \
+ HH_U64 operator()(const char* input, size_t size) { \
+ return highwayhash::hashfn(keys, input, size); \
+ } \
+ HH_U64 keys[num_keys]; \
+ }
+
+DEFINE_HASHER(SipHash, 2);
+BENCHMARK(BM<SipHasher>)->Apply(Args);
+
+DEFINE_HASHER(ScalarSipTreeHash, 4);
+BENCHMARK(BM<ScalarSipTreeHasher>)->Apply(Args);
+
+#ifdef __AVX2__
+DEFINE_HASHER(SipTreeHash, 4);
+BENCHMARK(BM<SipTreeHasher>)->Apply(Args);
+#endif
+
+} // namespace bm
+#endif // HH_GOOGLETEST
+
+} // namespace
+} // namespace highwayhash
+
+#ifndef HH_GOOGLETEST
+int main(int argc, char* argv[]) {
+ highwayhash::VerifySipHash();
+ printf("VerifySipHash succeeded.\n");
+ return 0;
+}
+#endif
diff --git a/contrib/libs/highwayhash/highwayhash/sip_tree_hash.cc b/contrib/libs/highwayhash/highwayhash/sip_tree_hash.cc
index 2dc4ce78e4..18c56d7907 100644
--- a/contrib/libs/highwayhash/highwayhash/sip_tree_hash.cc
+++ b/contrib/libs/highwayhash/highwayhash/sip_tree_hash.cc
@@ -1,227 +1,227 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "highwayhash/sip_tree_hash.h"
-
-#include <cstring> // memcpy
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-#include "highwayhash/sip_hash.h"
-
-#if HH_TARGET == HH_TARGET_AVX2
-#include "highwayhash/vector256.h"
-namespace highwayhash {
-namespace HH_TARGET_NAME {
-namespace {
-
-// Paper: https://www.131002.net/siphash/siphash.pdf
-// SSE41 implementation: https://goo.gl/80GBSD
-// Tree hash extension: http://dx.doi.org/10.4236/jis.2014.53010
-
-// The hash state is updated by injecting 4x8-byte packets;
-// XORing together all state vectors yields 32 bytes that are
-// reduced to 64 bits via 8-byte SipHash.
-
-const int kPacketSize = 32;
-const int kNumLanes = kPacketSize / sizeof(HH_U64);
-
-// 32 bytes key. Parameters are hardwired to c=2, d=4 [rounds].
-template <int kUpdateRounds, int kFinalizeRounds>
-class SipTreeHashStateT {
- public:
- explicit HH_INLINE SipTreeHashStateT(const HH_U64 (&keys)[kNumLanes]) {
- const V4x64U init(0x7465646279746573ull, 0x6c7967656e657261ull,
- 0x646f72616e646f6dull, 0x736f6d6570736575ull);
- const V4x64U lanes(kNumLanes | 3, kNumLanes | 2, kNumLanes | 1,
- kNumLanes | 0);
- const V4x64U key =
- LoadUnaligned<V4x64U>(reinterpret_cast<const uint64_t*>(keys)) ^ lanes;
- v0 = V4x64U(_mm256_permute4x64_epi64(init, 0x00)) ^ key;
- v1 = V4x64U(_mm256_permute4x64_epi64(init, 0x55)) ^ key;
- v2 = V4x64U(_mm256_permute4x64_epi64(init, 0xAA)) ^ key;
- v3 = V4x64U(_mm256_permute4x64_epi64(init, 0xFF)) ^ key;
- }
-
- HH_INLINE void Update(const V4x64U& packet) {
- v3 ^= packet;
-
- Compress<kUpdateRounds>();
-
- v0 ^= packet;
- }
-
- HH_INLINE V4x64U Finalize() {
- // Mix in bits to avoid leaking the key if all packets were zero.
- v2 ^= V4x64U(0xFF);
-
- Compress<kFinalizeRounds>();
-
- return (v0 ^ v1) ^ (v2 ^ v3);
- }
-
- private:
- static HH_INLINE V4x64U RotateLeft16(const V4x64U& v) {
- const V4x64U control(0x0D0C0B0A09080F0EULL, 0x0504030201000706ULL,
- 0x0D0C0B0A09080F0EULL, 0x0504030201000706ULL);
- return V4x64U(_mm256_shuffle_epi8(v, control));
- }
-
- // Rotates each 64-bit element of "v" left by N bits.
- template <HH_U64 bits>
- static HH_INLINE V4x64U RotateLeft(const V4x64U& v) {
- const V4x64U left = v << bits;
- const V4x64U right = v >> (64 - bits);
- return left | right;
- }
-
- static HH_INLINE V4x64U Rotate32(const V4x64U& v) {
- return V4x64U(_mm256_shuffle_epi32(v, _MM_SHUFFLE(2, 3, 0, 1)));
- }
-
- template <int kRounds>
- HH_INLINE void Compress() {
- // Loop is faster than unrolling!
- for (int i = 0; i < kRounds; ++i) {
- // ARX network: add, rotate, exclusive-or.
- v0 += v1;
- v2 += v3;
- v1 = RotateLeft<13>(v1);
- v3 = RotateLeft16(v3);
- v1 ^= v0;
- v3 ^= v2;
-
- v0 = Rotate32(v0);
-
- v2 += v1;
- v0 += v3;
- v1 = RotateLeft<17>(v1);
- v3 = RotateLeft<21>(v3);
- v1 ^= v2;
- v3 ^= v0;
-
- v2 = Rotate32(v2);
- }
- }
-
- V4x64U v0;
- V4x64U v1;
- V4x64U v2;
- V4x64U v3;
-};
-
-// Returns 32-byte packet by loading the remaining 0..31 bytes, storing
-// "remainder" in the upper byte, and zeroing any intervening bytes.
-// "remainder" is the number of accessible/remaining bytes (size % 32).
-// Loading past the end of the input risks page fault exceptions which even
-// LDDQU cannot prevent.
-static HH_INLINE V4x64U LoadFinalPacket32(const char* bytes, const HH_U64 size,
- const HH_U64 remainder) {
- // Copying into an aligned buffer incurs a store-to-load-forwarding stall.
- // Instead, we use masked loads to read any remaining whole uint32_t
- // without incurring page faults for the others.
- const size_t remaining_32 = remainder >> 2; // 0..7
-
- // mask[32*i+31] := uint32_t #i valid/accessible ? 1 : 0.
- // To avoid large lookup tables, we pack uint32_t lanes into bytes,
- // compute the packed mask by shifting, and then sign-extend 0xFF to
- // 0xFFFFFFFF (although only the MSB needs to be set).
- // remaining_32 = 0 => mask = 00000000; remaining_32 = 7 => mask = 01111111.
- const HH_U64 packed_mask = 0x00FFFFFFFFFFFFFFULL >> ((7 - remaining_32) * 8);
- const V4x64U mask(_mm256_cvtepi8_epi32(_mm_cvtsi64_si128(packed_mask)));
- // Load 0..7 remaining (potentially unaligned) uint32_t.
- const V4x64U packet28(
- _mm256_maskload_epi32(reinterpret_cast<const int*>(bytes), mask));
-
- // Load any remaining bytes individually and combine into a uint32_t.
- const int remainder_mod4 = remainder & 3;
- // Length padding ensures that zero-valued buffers of different lengths
- // result in different hashes.
- uint32_t packet4 = static_cast<uint32_t>(remainder << 24);
- const char* final_bytes = bytes + (remaining_32 * 4);
- for (int i = 0; i < remainder_mod4; ++i) {
- const uint32_t byte = static_cast<unsigned char>(final_bytes[i]);
- packet4 += byte << (i * 8);
- }
-
- // The upper 4 bytes of packet28 are zero; replace with packet4 to
- // obtain the (length-padded) 32-byte packet.
- const __m256i v4 = _mm256_broadcastd_epi32(_mm_cvtsi32_si128(packet4));
- const V4x64U packet(_mm256_blend_epi32(packet28, v4, 0x80));
- return packet;
-}
-
-} // namespace
-} // namespace HH_TARGET_NAME
-
-template <size_t kUpdateRounds, size_t kFinalizeRounds>
-HH_U64 SipTreeHashT(const HH_U64 (&key)[4], const char* bytes,
- const HH_U64 size) {
- using namespace HH_TARGET_NAME;
- SipTreeHashStateT<kUpdateRounds, kFinalizeRounds> state(key);
-
- const size_t remainder = size & (kPacketSize - 1);
- const size_t truncated_size = size - remainder;
- const HH_U64* packets = reinterpret_cast<const HH_U64*>(bytes);
- for (size_t i = 0; i < truncated_size / sizeof(HH_U64); i += kNumLanes) {
- const V4x64U packet =
- LoadUnaligned<V4x64U>(reinterpret_cast<const uint64_t*>(packets) + i);
- state.Update(packet);
- }
-
- const V4x64U final_packet =
- LoadFinalPacket32(bytes + truncated_size, size, remainder);
-
- state.Update(final_packet);
-
- // Faster than passing __m256i and extracting.
- HH_ALIGNAS(32) uint64_t hashes[kNumLanes];
- Store(state.Finalize(), hashes);
-
- typename SipHashStateT<kUpdateRounds, kFinalizeRounds>::Key reduce_key;
- memcpy(&reduce_key, &key, sizeof(reduce_key));
- return ReduceSipTreeHash<kNumLanes, kUpdateRounds, kFinalizeRounds>(
- reduce_key, hashes);
-}
-
-HH_U64 SipTreeHash(const HH_U64 (&key)[4], const char* bytes,
- const HH_U64 size) {
- return SipTreeHashT<2, 4>(key, bytes, size);
-}
-
-HH_U64 SipTreeHash13(const HH_U64 (&key)[4], const char* bytes,
- const HH_U64 size) {
- return SipTreeHashT<1, 3>(key, bytes, size);
-}
-
-} // namespace highwayhash
-
-using highwayhash::HH_U64;
-using highwayhash::SipTreeHash;
-using highwayhash::SipTreeHash13;
-using Key = HH_U64[4];
-
-extern "C" {
-
-HH_U64 SipTreeHashC(const HH_U64* key, const char* bytes, const HH_U64 size) {
- return SipTreeHash(*reinterpret_cast<const Key*>(key), bytes, size);
-}
-
-HH_U64 SipTreeHash13C(const HH_U64* key, const char* bytes, const HH_U64 size) {
- return SipTreeHash13(*reinterpret_cast<const Key*>(key), bytes, size);
-}
-
-} // extern "C"
-
-#endif // HH_TARGET == HH_TARGET_AVX2
+// Copyright 2015 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highwayhash/sip_tree_hash.h"
+
+#include <cstring> // memcpy
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+#include "highwayhash/sip_hash.h"
+
+#if HH_TARGET == HH_TARGET_AVX2
+#include "highwayhash/vector256.h"
+namespace highwayhash {
+namespace HH_TARGET_NAME {
+namespace {
+
+// Paper: https://www.131002.net/siphash/siphash.pdf
+// SSE41 implementation: https://goo.gl/80GBSD
+// Tree hash extension: http://dx.doi.org/10.4236/jis.2014.53010
+
+// The hash state is updated by injecting 4x8-byte packets;
+// XORing together all state vectors yields 32 bytes that are
+// reduced to 64 bits via 8-byte SipHash.
+
+const int kPacketSize = 32;
+const int kNumLanes = kPacketSize / sizeof(HH_U64);
+
+// 32 bytes key. Parameters are hardwired to c=2, d=4 [rounds].
+template <int kUpdateRounds, int kFinalizeRounds>
+class SipTreeHashStateT {
+ public:
+ explicit HH_INLINE SipTreeHashStateT(const HH_U64 (&keys)[kNumLanes]) {
+ const V4x64U init(0x7465646279746573ull, 0x6c7967656e657261ull,
+ 0x646f72616e646f6dull, 0x736f6d6570736575ull);
+ const V4x64U lanes(kNumLanes | 3, kNumLanes | 2, kNumLanes | 1,
+ kNumLanes | 0);
+ const V4x64U key =
+ LoadUnaligned<V4x64U>(reinterpret_cast<const uint64_t*>(keys)) ^ lanes;
+ v0 = V4x64U(_mm256_permute4x64_epi64(init, 0x00)) ^ key;
+ v1 = V4x64U(_mm256_permute4x64_epi64(init, 0x55)) ^ key;
+ v2 = V4x64U(_mm256_permute4x64_epi64(init, 0xAA)) ^ key;
+ v3 = V4x64U(_mm256_permute4x64_epi64(init, 0xFF)) ^ key;
+ }
+
+ HH_INLINE void Update(const V4x64U& packet) {
+ v3 ^= packet;
+
+ Compress<kUpdateRounds>();
+
+ v0 ^= packet;
+ }
+
+ HH_INLINE V4x64U Finalize() {
+ // Mix in bits to avoid leaking the key if all packets were zero.
+ v2 ^= V4x64U(0xFF);
+
+ Compress<kFinalizeRounds>();
+
+ return (v0 ^ v1) ^ (v2 ^ v3);
+ }
+
+ private:
+ static HH_INLINE V4x64U RotateLeft16(const V4x64U& v) {
+ const V4x64U control(0x0D0C0B0A09080F0EULL, 0x0504030201000706ULL,
+ 0x0D0C0B0A09080F0EULL, 0x0504030201000706ULL);
+ return V4x64U(_mm256_shuffle_epi8(v, control));
+ }
+
+ // Rotates each 64-bit element of "v" left by N bits.
+ template <HH_U64 bits>
+ static HH_INLINE V4x64U RotateLeft(const V4x64U& v) {
+ const V4x64U left = v << bits;
+ const V4x64U right = v >> (64 - bits);
+ return left | right;
+ }
+
+ static HH_INLINE V4x64U Rotate32(const V4x64U& v) {
+ return V4x64U(_mm256_shuffle_epi32(v, _MM_SHUFFLE(2, 3, 0, 1)));
+ }
+
+ template <int kRounds>
+ HH_INLINE void Compress() {
+ // Loop is faster than unrolling!
+ for (int i = 0; i < kRounds; ++i) {
+ // ARX network: add, rotate, exclusive-or.
+ v0 += v1;
+ v2 += v3;
+ v1 = RotateLeft<13>(v1);
+ v3 = RotateLeft16(v3);
+ v1 ^= v0;
+ v3 ^= v2;
+
+ v0 = Rotate32(v0);
+
+ v2 += v1;
+ v0 += v3;
+ v1 = RotateLeft<17>(v1);
+ v3 = RotateLeft<21>(v3);
+ v1 ^= v2;
+ v3 ^= v0;
+
+ v2 = Rotate32(v2);
+ }
+ }
+
+ V4x64U v0;
+ V4x64U v1;
+ V4x64U v2;
+ V4x64U v3;
+};
+
+// Returns 32-byte packet by loading the remaining 0..31 bytes, storing
+// "remainder" in the upper byte, and zeroing any intervening bytes.
+// "remainder" is the number of accessible/remaining bytes (size % 32).
+// Loading past the end of the input risks page fault exceptions which even
+// LDDQU cannot prevent.
+static HH_INLINE V4x64U LoadFinalPacket32(const char* bytes, const HH_U64 size,
+ const HH_U64 remainder) {
+ // Copying into an aligned buffer incurs a store-to-load-forwarding stall.
+ // Instead, we use masked loads to read any remaining whole uint32_t
+ // without incurring page faults for the others.
+ const size_t remaining_32 = remainder >> 2; // 0..7
+
+ // mask[32*i+31] := uint32_t #i valid/accessible ? 1 : 0.
+ // To avoid large lookup tables, we pack uint32_t lanes into bytes,
+ // compute the packed mask by shifting, and then sign-extend 0xFF to
+ // 0xFFFFFFFF (although only the MSB needs to be set).
+ // remaining_32 = 0 => mask = 00000000; remaining_32 = 7 => mask = 01111111.
+ const HH_U64 packed_mask = 0x00FFFFFFFFFFFFFFULL >> ((7 - remaining_32) * 8);
+ const V4x64U mask(_mm256_cvtepi8_epi32(_mm_cvtsi64_si128(packed_mask)));
+ // Load 0..7 remaining (potentially unaligned) uint32_t.
+ const V4x64U packet28(
+ _mm256_maskload_epi32(reinterpret_cast<const int*>(bytes), mask));
+
+ // Load any remaining bytes individually and combine into a uint32_t.
+ const int remainder_mod4 = remainder & 3;
+ // Length padding ensures that zero-valued buffers of different lengths
+ // result in different hashes.
+ uint32_t packet4 = static_cast<uint32_t>(remainder << 24);
+ const char* final_bytes = bytes + (remaining_32 * 4);
+ for (int i = 0; i < remainder_mod4; ++i) {
+ const uint32_t byte = static_cast<unsigned char>(final_bytes[i]);
+ packet4 += byte << (i * 8);
+ }
+
+ // The upper 4 bytes of packet28 are zero; replace with packet4 to
+ // obtain the (length-padded) 32-byte packet.
+ const __m256i v4 = _mm256_broadcastd_epi32(_mm_cvtsi32_si128(packet4));
+ const V4x64U packet(_mm256_blend_epi32(packet28, v4, 0x80));
+ return packet;
+}
+
+} // namespace
+} // namespace HH_TARGET_NAME
+
+template <size_t kUpdateRounds, size_t kFinalizeRounds>
+HH_U64 SipTreeHashT(const HH_U64 (&key)[4], const char* bytes,
+ const HH_U64 size) {
+ using namespace HH_TARGET_NAME;
+ SipTreeHashStateT<kUpdateRounds, kFinalizeRounds> state(key);
+
+ const size_t remainder = size & (kPacketSize - 1);
+ const size_t truncated_size = size - remainder;
+ const HH_U64* packets = reinterpret_cast<const HH_U64*>(bytes);
+ for (size_t i = 0; i < truncated_size / sizeof(HH_U64); i += kNumLanes) {
+ const V4x64U packet =
+ LoadUnaligned<V4x64U>(reinterpret_cast<const uint64_t*>(packets) + i);
+ state.Update(packet);
+ }
+
+ const V4x64U final_packet =
+ LoadFinalPacket32(bytes + truncated_size, size, remainder);
+
+ state.Update(final_packet);
+
+ // Faster than passing __m256i and extracting.
+ HH_ALIGNAS(32) uint64_t hashes[kNumLanes];
+ Store(state.Finalize(), hashes);
+
+ typename SipHashStateT<kUpdateRounds, kFinalizeRounds>::Key reduce_key;
+ memcpy(&reduce_key, &key, sizeof(reduce_key));
+ return ReduceSipTreeHash<kNumLanes, kUpdateRounds, kFinalizeRounds>(
+ reduce_key, hashes);
+}
+
+HH_U64 SipTreeHash(const HH_U64 (&key)[4], const char* bytes,
+ const HH_U64 size) {
+ return SipTreeHashT<2, 4>(key, bytes, size);
+}
+
+HH_U64 SipTreeHash13(const HH_U64 (&key)[4], const char* bytes,
+ const HH_U64 size) {
+ return SipTreeHashT<1, 3>(key, bytes, size);
+}
+
+} // namespace highwayhash
+
+using highwayhash::HH_U64;
+using highwayhash::SipTreeHash;
+using highwayhash::SipTreeHash13;
+using Key = HH_U64[4];
+
+extern "C" {
+
+HH_U64 SipTreeHashC(const HH_U64* key, const char* bytes, const HH_U64 size) {
+ return SipTreeHash(*reinterpret_cast<const Key*>(key), bytes, size);
+}
+
+HH_U64 SipTreeHash13C(const HH_U64* key, const char* bytes, const HH_U64 size) {
+ return SipTreeHash13(*reinterpret_cast<const Key*>(key), bytes, size);
+}
+
+} // extern "C"
+
+#endif // HH_TARGET == HH_TARGET_AVX2
diff --git a/contrib/libs/highwayhash/highwayhash/sip_tree_hash.h b/contrib/libs/highwayhash/highwayhash/sip_tree_hash.h
index 788aa8025b..ee5a42340e 100644
--- a/contrib/libs/highwayhash/highwayhash/sip_tree_hash.h
+++ b/contrib/libs/highwayhash/highwayhash/sip_tree_hash.h
@@ -1,52 +1,52 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_SIP_TREE_HASH_H_
-#define HIGHWAYHASH_SIP_TREE_HASH_H_
-
-#include "highwayhash/state_helpers.h"
-
-#ifdef __cplusplus
-namespace highwayhash {
-extern "C" {
-#endif
-
-// Fast, cryptographically strong pseudo-random function. Useful for:
-// . hash tables holding attacker-controlled data. This function is
-// immune to hash flooding DOS attacks because multi-collisions are
-// infeasible to compute, provided the key remains secret.
-// . deterministic/idempotent 'random' number generation, e.g. for
-// choosing a subset of items based on their contents.
-//
-// Robust versus timing attacks because memory accesses are sequential
-// and the algorithm is branch-free. Compute time is proportional to the
-// number of 8-byte packets and 1.5x faster than an sse41 implementation.
-// Requires an AVX-2 capable CPU.
-//
-// "key" is a secret 256-bit key unknown to attackers.
-// "bytes" is the data to hash (possibly unaligned).
-// "size" is the number of bytes to hash; exactly that many bytes are read.
-// Returns a 64-bit hash of the given data bytes.
-HH_U64 SipTreeHash(const HH_U64 (&key)[4], const char* bytes,
- const HH_U64 size);
-
-HH_U64 SipTreeHash13(const HH_U64 (&key)[4], const char* bytes,
- const HH_U64 size);
-
-#ifdef __cplusplus
-} // extern "C"
-} // namespace highwayhash
-#endif
-
-#endif // HIGHWAYHASH_SIP_TREE_HASH_H_
+// Copyright 2015 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_SIP_TREE_HASH_H_
+#define HIGHWAYHASH_SIP_TREE_HASH_H_
+
+#include "highwayhash/state_helpers.h"
+
+#ifdef __cplusplus
+namespace highwayhash {
+extern "C" {
+#endif
+
+// Fast, cryptographically strong pseudo-random function. Useful for:
+// . hash tables holding attacker-controlled data. This function is
+// immune to hash flooding DOS attacks because multi-collisions are
+// infeasible to compute, provided the key remains secret.
+// . deterministic/idempotent 'random' number generation, e.g. for
+// choosing a subset of items based on their contents.
+//
+// Robust versus timing attacks because memory accesses are sequential
+// and the algorithm is branch-free. Compute time is proportional to the
+// number of 8-byte packets and 1.5x faster than an sse41 implementation.
+// Requires an AVX-2 capable CPU.
+//
+// "key" is a secret 256-bit key unknown to attackers.
+// "bytes" is the data to hash (possibly unaligned).
+// "size" is the number of bytes to hash; exactly that many bytes are read.
+// Returns a 64-bit hash of the given data bytes.
+HH_U64 SipTreeHash(const HH_U64 (&key)[4], const char* bytes,
+ const HH_U64 size);
+
+HH_U64 SipTreeHash13(const HH_U64 (&key)[4], const char* bytes,
+ const HH_U64 size);
+
+#ifdef __cplusplus
+} // extern "C"
+} // namespace highwayhash
+#endif
+
+#endif // HIGHWAYHASH_SIP_TREE_HASH_H_
diff --git a/contrib/libs/highwayhash/highwayhash/state_helpers.h b/contrib/libs/highwayhash/highwayhash/state_helpers.h
index 88e31a4509..4dd651260f 100644
--- a/contrib/libs/highwayhash/highwayhash/state_helpers.h
+++ b/contrib/libs/highwayhash/highwayhash/state_helpers.h
@@ -1,128 +1,128 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_STATE_H_
-#define HIGHWAYHASH_STATE_H_
-
-// Helper functions to split inputs into packets and call State::Update on each.
-
-#include <stdint.h>
-#include <cstddef>
-#include <cstring>
-#include <memory>
-
-#include "highwayhash/compiler_specific.h"
-
-namespace highwayhash {
-
-// uint64_t is unsigned long on Linux; we need 'unsigned long long'
-// for interoperability with TensorFlow.
-typedef unsigned long long HH_U64; // NOLINT
-
-// Copies the remaining bytes to a zero-padded buffer, sets the upper byte to
-// size % 256 (always possible because this should only be called if the
-// total size is not a multiple of the packet size) and updates hash state.
-//
-// The padding scheme is essentially from SipHash, but permuted for the
-// convenience of AVX-2 masked loads. This function must use the same layout so
-// that the vector and scalar HighwayTreeHash have the same result.
-//
-// "remaining_size" is the number of accessible/remaining bytes
-// (size % kPacketSize).
-//
-// Primary template; the specialization for AVX-2 is faster. Intended as an
-// implementation detail, do not call directly.
-template <class State>
-HH_INLINE void PaddedUpdate(const HH_U64 size, const char* remaining_bytes,
- const HH_U64 remaining_size, State* state) {
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_STATE_H_
+#define HIGHWAYHASH_STATE_H_
+
+// Helper functions to split inputs into packets and call State::Update on each.
+
+#include <stdint.h>
+#include <cstddef>
+#include <cstring>
+#include <memory>
+
+#include "highwayhash/compiler_specific.h"
+
+namespace highwayhash {
+
+// uint64_t is unsigned long on Linux; we need 'unsigned long long'
+// for interoperability with TensorFlow.
+typedef unsigned long long HH_U64; // NOLINT
+
+// Copies the remaining bytes to a zero-padded buffer, sets the upper byte to
+// size % 256 (always possible because this should only be called if the
+// total size is not a multiple of the packet size) and updates hash state.
+//
+// The padding scheme is essentially from SipHash, but permuted for the
+// convenience of AVX-2 masked loads. This function must use the same layout so
+// that the vector and scalar HighwayTreeHash have the same result.
+//
+// "remaining_size" is the number of accessible/remaining bytes
+// (size % kPacketSize).
+//
+// Primary template; the specialization for AVX-2 is faster. Intended as an
+// implementation detail, do not call directly.
+template <class State>
+HH_INLINE void PaddedUpdate(const HH_U64 size, const char* remaining_bytes,
+ const HH_U64 remaining_size, State* state) {
HH_ALIGNAS(32) char final_packet[State::kPacketSize] = {0};
-
- // This layout matches the AVX-2 specialization in highway_tree_hash.h.
- uint32_t packet4 = static_cast<uint32_t>(size) << 24;
-
- const size_t remainder_mod4 = remaining_size & 3;
- if (remainder_mod4 != 0) {
- const char* final_bytes = remaining_bytes + remaining_size - remainder_mod4;
- packet4 += static_cast<uint32_t>(final_bytes[0]);
- const int idx1 = remainder_mod4 >> 1;
- const int idx2 = remainder_mod4 - 1;
- packet4 += static_cast<uint32_t>(final_bytes[idx1]) << 8;
- packet4 += static_cast<uint32_t>(final_bytes[idx2]) << 16;
- }
-
- memcpy(final_packet, remaining_bytes, remaining_size - remainder_mod4);
- memcpy(final_packet + State::kPacketSize - 4, &packet4, sizeof(packet4));
-
- state->Update(final_packet);
-}
-
-// Updates hash state for every whole packet, and once more for the final
-// padded packet.
-template <class State>
-HH_INLINE void UpdateState(const char* bytes, const HH_U64 size, State* state) {
- // Feed entire packets.
- const int kPacketSize = State::kPacketSize;
- static_assert((kPacketSize & (kPacketSize - 1)) == 0, "Size must be 2^i.");
- const size_t remainder = size & (kPacketSize - 1);
- const size_t truncated_size = size - remainder;
- for (size_t i = 0; i < truncated_size; i += kPacketSize) {
- state->Update(bytes + i);
- }
-
- PaddedUpdate(size, bytes + truncated_size, remainder, state);
-}
-
-// Convenience function for updating with the bytes of a string.
-template <class String, class State>
-HH_INLINE void UpdateState(const String& s, State* state) {
- const char* bytes = reinterpret_cast<const char*>(s.data());
- const size_t size = s.length() * sizeof(typename String::value_type);
- UpdateState(bytes, size, state);
-}
-
-// Computes a hash of a byte array using the given hash State class.
-//
-// Example: const SipHashState::Key key = { 1, 2 }; char data[4];
-// ComputeHash<SipHashState>(key, data, sizeof(data));
-//
-// This function avoids duplicating Update/Finalize in every call site.
-// Callers wanting to combine multiple hashes should repeatedly UpdateState()
-// and only call State::Finalize once.
-template <class State>
-HH_U64 ComputeHash(const typename State::Key& key, const char* bytes,
- const HH_U64 size) {
- State state(key);
- UpdateState(bytes, size, &state);
- return state.Finalize();
-}
-
-// Computes a hash of a string's bytes using the given hash State class.
-//
-// Example: const SipHashState::Key key = { 1, 2 };
-// StringHasher<SipHashState>()(key, std::u16string(u"abc"));
-//
-// A struct with nested function template enables deduction of the String type.
-template <class State>
-struct StringHasher {
- template <class String>
- HH_U64 operator()(const typename State::Key& key, const String& s) {
- State state(key);
- UpdateState(s, &state);
- return state.Finalize();
- }
-};
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_STATE_H_
+
+ // This layout matches the AVX-2 specialization in highway_tree_hash.h.
+ uint32_t packet4 = static_cast<uint32_t>(size) << 24;
+
+ const size_t remainder_mod4 = remaining_size & 3;
+ if (remainder_mod4 != 0) {
+ const char* final_bytes = remaining_bytes + remaining_size - remainder_mod4;
+ packet4 += static_cast<uint32_t>(final_bytes[0]);
+ const int idx1 = remainder_mod4 >> 1;
+ const int idx2 = remainder_mod4 - 1;
+ packet4 += static_cast<uint32_t>(final_bytes[idx1]) << 8;
+ packet4 += static_cast<uint32_t>(final_bytes[idx2]) << 16;
+ }
+
+ memcpy(final_packet, remaining_bytes, remaining_size - remainder_mod4);
+ memcpy(final_packet + State::kPacketSize - 4, &packet4, sizeof(packet4));
+
+ state->Update(final_packet);
+}
+
+// Updates hash state for every whole packet, and once more for the final
+// padded packet.
+template <class State>
+HH_INLINE void UpdateState(const char* bytes, const HH_U64 size, State* state) {
+ // Feed entire packets.
+ const int kPacketSize = State::kPacketSize;
+ static_assert((kPacketSize & (kPacketSize - 1)) == 0, "Size must be 2^i.");
+ const size_t remainder = size & (kPacketSize - 1);
+ const size_t truncated_size = size - remainder;
+ for (size_t i = 0; i < truncated_size; i += kPacketSize) {
+ state->Update(bytes + i);
+ }
+
+ PaddedUpdate(size, bytes + truncated_size, remainder, state);
+}
+
+// Convenience function for updating with the bytes of a string.
+template <class String, class State>
+HH_INLINE void UpdateState(const String& s, State* state) {
+ const char* bytes = reinterpret_cast<const char*>(s.data());
+ const size_t size = s.length() * sizeof(typename String::value_type);
+ UpdateState(bytes, size, state);
+}
+
+// Computes a hash of a byte array using the given hash State class.
+//
+// Example: const SipHashState::Key key = { 1, 2 }; char data[4];
+// ComputeHash<SipHashState>(key, data, sizeof(data));
+//
+// This function avoids duplicating Update/Finalize in every call site.
+// Callers wanting to combine multiple hashes should repeatedly UpdateState()
+// and only call State::Finalize once.
+template <class State>
+HH_U64 ComputeHash(const typename State::Key& key, const char* bytes,
+ const HH_U64 size) {
+ State state(key);
+ UpdateState(bytes, size, &state);
+ return state.Finalize();
+}
+
+// Computes a hash of a string's bytes using the given hash State class.
+//
+// Example: const SipHashState::Key key = { 1, 2 };
+// StringHasher<SipHashState>()(key, std::u16string(u"abc"));
+//
+// A struct with nested function template enables deduction of the String type.
+template <class State>
+struct StringHasher {
+ template <class String>
+ HH_U64 operator()(const typename State::Key& key, const String& s) {
+ State state(key);
+ UpdateState(s, &state);
+ return state.Finalize();
+ }
+};
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_STATE_H_
diff --git a/contrib/libs/highwayhash/highwayhash/tsc_timer.h b/contrib/libs/highwayhash/highwayhash/tsc_timer.h
index 6a4b4a4bdb..4a88c0f8e6 100644
--- a/contrib/libs/highwayhash/highwayhash/tsc_timer.h
+++ b/contrib/libs/highwayhash/highwayhash/tsc_timer.h
@@ -1,204 +1,204 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_TSC_TIMER_H_
-#define HIGHWAYHASH_TSC_TIMER_H_
-
-// High-resolution (~10 ns) timestamps, using fences to prevent reordering and
-// ensure exactly the desired regions are measured.
-
-#include <stdint.h>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-
-#if HH_ARCH_X64 && HH_MSC_VERSION
-#include <emmintrin.h> // _mm_lfence
-#include <intrin.h>
-#endif
-
-namespace highwayhash {
-
-// Start/Stop return absolute timestamps and must be placed immediately before
-// and after the region to measure. We provide separate Start/Stop functions
-// because they use different fences.
-//
-// Background: RDTSC is not 'serializing'; earlier instructions may complete
-// after it, and/or later instructions may complete before it. 'Fences' ensure
-// regions' elapsed times are independent of such reordering. The only
-// documented unprivileged serializing instruction is CPUID, which acts as a
-// full fence (no reordering across it in either direction). Unfortunately
-// the latency of CPUID varies wildly (perhaps made worse by not initializing
-// its EAX input). Because it cannot reliably be deducted from the region's
-// elapsed time, it must not be included in the region to measure (i.e.
-// between the two RDTSC).
-//
-// The newer RDTSCP is sometimes described as serializing, but it actually
-// only serves as a half-fence with release semantics. Although all
-// instructions in the region will complete before the final timestamp is
-// captured, subsequent instructions may leak into the region and increase the
-// elapsed time. Inserting another fence after the final RDTSCP would prevent
-// such reordering without affecting the measured region.
-//
-// Fortunately, such a fence exists. The LFENCE instruction is only documented
-// to delay later loads until earlier loads are visible. However, Intel's
-// reference manual says it acts as a full fence (waiting until all earlier
-// instructions have completed, and delaying later instructions until it
-// completes). AMD assigns the same behavior to MFENCE.
-//
-// We need a fence before the initial RDTSC to prevent earlier instructions
-// from leaking into the region, and arguably another after RDTSC to avoid
-// region instructions from completing before the timestamp is recorded.
-// When surrounded by fences, the additional RDTSCP half-fence provides no
-// benefit, so the initial timestamp can be recorded via RDTSC, which has
-// lower overhead than RDTSCP because it does not read TSC_AUX. In summary,
-// we define Start = LFENCE/RDTSC/LFENCE; Stop = RDTSCP/LFENCE.
-//
-// Using Start+Start leads to higher variance and overhead than Stop+Stop.
-// However, Stop+Stop includes an LFENCE in the region measurements, which
-// adds a delay dependent on earlier loads. The combination of Start+Stop
-// is faster than Start+Start and more consistent than Stop+Stop because
-// the first LFENCE already delayed subsequent loads before the measured
-// region. This combination seems not to have been considered in prior work:
-// http://akaros.cs.berkeley.edu/lxr/akaros/kern/arch/x86/rdtsc_test.c
-//
-// Note: performance counters can measure 'exact' instructions-retired or
-// (unhalted) cycle counts. The RDPMC instruction is not serializing and also
-// requires fences. Unfortunately, it is not accessible on all OSes and we
-// prefer to avoid kernel-mode drivers. Performance counters are also affected
-// by several under/over-count errata, so we use the TSC instead.
-
-// Primary templates; must use one of the specializations.
-template <typename T>
-inline T Start();
-
-template <typename T>
-inline T Stop();
-
-template <>
-inline uint64_t Start<uint64_t>() {
- uint64_t t;
-#if HH_ARCH_PPC
- asm volatile("mfspr %0, %1" : "=r"(t) : "i"(268));
-#elif HH_ARCH_AARCH64
- asm volatile("mrs %0, cntvct_el0" : "=r"(t));
-#elif HH_ARCH_X64 && HH_MSC_VERSION
- _mm_lfence();
- HH_COMPILER_FENCE;
- t = __rdtsc();
- _mm_lfence();
- HH_COMPILER_FENCE;
-#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
- asm volatile(
- "lfence\n\t"
- "rdtsc\n\t"
- "shl $32, %%rdx\n\t"
- "or %%rdx, %0\n\t"
- "lfence"
- : "=a"(t)
- :
- // "memory" avoids reordering. rdx = TSC >> 32.
- // "cc" = flags modified by SHL.
- : "rdx", "memory", "cc");
-#else
-#error "Port"
-#endif
- return t;
-}
-
-template <>
-inline uint64_t Stop<uint64_t>() {
- uint64_t t;
-#if HH_ARCH_PPC
- asm volatile("mfspr %0, %1" : "=r"(t) : "i"(268));
-#elif HH_ARCH_AARCH64
- asm volatile("mrs %0, cntvct_el0" : "=r"(t));
-#elif HH_ARCH_X64 && HH_MSC_VERSION
- HH_COMPILER_FENCE;
- unsigned aux;
- t = __rdtscp(&aux);
- _mm_lfence();
- HH_COMPILER_FENCE;
-#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
- // Use inline asm because __rdtscp generates code to store TSC_AUX (ecx).
- asm volatile(
- "rdtscp\n\t"
- "shl $32, %%rdx\n\t"
- "or %%rdx, %0\n\t"
- "lfence"
- : "=a"(t)
- :
- // "memory" avoids reordering. rcx = TSC_AUX. rdx = TSC >> 32.
- // "cc" = flags modified by SHL.
- : "rcx", "rdx", "memory", "cc");
-#else
-#error "Port"
-#endif
- return t;
-}
-
-// Returns a 32-bit timestamp with about 4 cycles less overhead than
-// Start<uint64_t>. Only suitable for measuring very short regions because the
-// timestamp overflows about once a second.
-template <>
-inline uint32_t Start<uint32_t>() {
- uint32_t t;
-#if HH_ARCH_X64 && HH_MSC_VERSION
- _mm_lfence();
- HH_COMPILER_FENCE;
- t = static_cast<uint32_t>(__rdtsc());
- _mm_lfence();
- HH_COMPILER_FENCE;
-#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
- asm volatile(
- "lfence\n\t"
- "rdtsc\n\t"
- "lfence"
- : "=a"(t)
- :
- // "memory" avoids reordering. rdx = TSC >> 32.
- : "rdx", "memory");
-#else
- t = static_cast<uint32_t>(Start<uint64_t>());
-#endif
- return t;
-}
-
-template <>
-inline uint32_t Stop<uint32_t>() {
- uint32_t t;
-#if HH_ARCH_X64 && HH_MSC_VERSION
- HH_COMPILER_FENCE;
- unsigned aux;
- t = static_cast<uint32_t>(__rdtscp(&aux));
- _mm_lfence();
- HH_COMPILER_FENCE;
-#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
- // Use inline asm because __rdtscp generates code to store TSC_AUX (ecx).
- asm volatile(
- "rdtscp\n\t"
- "lfence"
- : "=a"(t)
- :
- // "memory" avoids reordering. rcx = TSC_AUX. rdx = TSC >> 32.
- : "rcx", "rdx", "memory");
-#else
- t = static_cast<uint32_t>(Stop<uint64_t>());
-#endif
- return t;
-}
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_TSC_TIMER_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_TSC_TIMER_H_
+#define HIGHWAYHASH_TSC_TIMER_H_
+
+// High-resolution (~10 ns) timestamps, using fences to prevent reordering and
+// ensure exactly the desired regions are measured.
+
+#include <stdint.h>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+
+#if HH_ARCH_X64 && HH_MSC_VERSION
+#include <emmintrin.h> // _mm_lfence
+#include <intrin.h>
+#endif
+
+namespace highwayhash {
+
+// Start/Stop return absolute timestamps and must be placed immediately before
+// and after the region to measure. We provide separate Start/Stop functions
+// because they use different fences.
+//
+// Background: RDTSC is not 'serializing'; earlier instructions may complete
+// after it, and/or later instructions may complete before it. 'Fences' ensure
+// regions' elapsed times are independent of such reordering. The only
+// documented unprivileged serializing instruction is CPUID, which acts as a
+// full fence (no reordering across it in either direction). Unfortunately
+// the latency of CPUID varies wildly (perhaps made worse by not initializing
+// its EAX input). Because it cannot reliably be deducted from the region's
+// elapsed time, it must not be included in the region to measure (i.e.
+// between the two RDTSC).
+//
+// The newer RDTSCP is sometimes described as serializing, but it actually
+// only serves as a half-fence with release semantics. Although all
+// instructions in the region will complete before the final timestamp is
+// captured, subsequent instructions may leak into the region and increase the
+// elapsed time. Inserting another fence after the final RDTSCP would prevent
+// such reordering without affecting the measured region.
+//
+// Fortunately, such a fence exists. The LFENCE instruction is only documented
+// to delay later loads until earlier loads are visible. However, Intel's
+// reference manual says it acts as a full fence (waiting until all earlier
+// instructions have completed, and delaying later instructions until it
+// completes). AMD assigns the same behavior to MFENCE.
+//
+// We need a fence before the initial RDTSC to prevent earlier instructions
+// from leaking into the region, and arguably another after RDTSC to avoid
+// region instructions from completing before the timestamp is recorded.
+// When surrounded by fences, the additional RDTSCP half-fence provides no
+// benefit, so the initial timestamp can be recorded via RDTSC, which has
+// lower overhead than RDTSCP because it does not read TSC_AUX. In summary,
+// we define Start = LFENCE/RDTSC/LFENCE; Stop = RDTSCP/LFENCE.
+//
+// Using Start+Start leads to higher variance and overhead than Stop+Stop.
+// However, Stop+Stop includes an LFENCE in the region measurements, which
+// adds a delay dependent on earlier loads. The combination of Start+Stop
+// is faster than Start+Start and more consistent than Stop+Stop because
+// the first LFENCE already delayed subsequent loads before the measured
+// region. This combination seems not to have been considered in prior work:
+// http://akaros.cs.berkeley.edu/lxr/akaros/kern/arch/x86/rdtsc_test.c
+//
+// Note: performance counters can measure 'exact' instructions-retired or
+// (unhalted) cycle counts. The RDPMC instruction is not serializing and also
+// requires fences. Unfortunately, it is not accessible on all OSes and we
+// prefer to avoid kernel-mode drivers. Performance counters are also affected
+// by several under/over-count errata, so we use the TSC instead.
+
+// Primary templates; must use one of the specializations.
+template <typename T>
+inline T Start();
+
+template <typename T>
+inline T Stop();
+
+template <>
+inline uint64_t Start<uint64_t>() {
+ uint64_t t;
+#if HH_ARCH_PPC
+ asm volatile("mfspr %0, %1" : "=r"(t) : "i"(268));
+#elif HH_ARCH_AARCH64
+ asm volatile("mrs %0, cntvct_el0" : "=r"(t));
+#elif HH_ARCH_X64 && HH_MSC_VERSION
+ _mm_lfence();
+ HH_COMPILER_FENCE;
+ t = __rdtsc();
+ _mm_lfence();
+ HH_COMPILER_FENCE;
+#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
+ asm volatile(
+ "lfence\n\t"
+ "rdtsc\n\t"
+ "shl $32, %%rdx\n\t"
+ "or %%rdx, %0\n\t"
+ "lfence"
+ : "=a"(t)
+ :
+ // "memory" avoids reordering. rdx = TSC >> 32.
+ // "cc" = flags modified by SHL.
+ : "rdx", "memory", "cc");
+#else
+#error "Port"
+#endif
+ return t;
+}
+
+template <>
+inline uint64_t Stop<uint64_t>() {
+ uint64_t t;
+#if HH_ARCH_PPC
+ asm volatile("mfspr %0, %1" : "=r"(t) : "i"(268));
+#elif HH_ARCH_AARCH64
+ asm volatile("mrs %0, cntvct_el0" : "=r"(t));
+#elif HH_ARCH_X64 && HH_MSC_VERSION
+ HH_COMPILER_FENCE;
+ unsigned aux;
+ t = __rdtscp(&aux);
+ _mm_lfence();
+ HH_COMPILER_FENCE;
+#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
+ // Use inline asm because __rdtscp generates code to store TSC_AUX (ecx).
+ asm volatile(
+ "rdtscp\n\t"
+ "shl $32, %%rdx\n\t"
+ "or %%rdx, %0\n\t"
+ "lfence"
+ : "=a"(t)
+ :
+ // "memory" avoids reordering. rcx = TSC_AUX. rdx = TSC >> 32.
+ // "cc" = flags modified by SHL.
+ : "rcx", "rdx", "memory", "cc");
+#else
+#error "Port"
+#endif
+ return t;
+}
+
+// Returns a 32-bit timestamp with about 4 cycles less overhead than
+// Start<uint64_t>. Only suitable for measuring very short regions because the
+// timestamp overflows about once a second.
+template <>
+inline uint32_t Start<uint32_t>() {
+ uint32_t t;
+#if HH_ARCH_X64 && HH_MSC_VERSION
+ _mm_lfence();
+ HH_COMPILER_FENCE;
+ t = static_cast<uint32_t>(__rdtsc());
+ _mm_lfence();
+ HH_COMPILER_FENCE;
+#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
+ asm volatile(
+ "lfence\n\t"
+ "rdtsc\n\t"
+ "lfence"
+ : "=a"(t)
+ :
+ // "memory" avoids reordering. rdx = TSC >> 32.
+ : "rdx", "memory");
+#else
+ t = static_cast<uint32_t>(Start<uint64_t>());
+#endif
+ return t;
+}
+
+template <>
+inline uint32_t Stop<uint32_t>() {
+ uint32_t t;
+#if HH_ARCH_X64 && HH_MSC_VERSION
+ HH_COMPILER_FENCE;
+ unsigned aux;
+ t = static_cast<uint32_t>(__rdtscp(&aux));
+ _mm_lfence();
+ HH_COMPILER_FENCE;
+#elif HH_ARCH_X64 && (HH_CLANG_VERSION || HH_GCC_VERSION)
+ // Use inline asm because __rdtscp generates code to store TSC_AUX (ecx).
+ asm volatile(
+ "rdtscp\n\t"
+ "lfence"
+ : "=a"(t)
+ :
+ // "memory" avoids reordering. rcx = TSC_AUX. rdx = TSC >> 32.
+ : "rcx", "rdx", "memory");
+#else
+ t = static_cast<uint32_t>(Stop<uint64_t>());
+#endif
+ return t;
+}
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_TSC_TIMER_H_
diff --git a/contrib/libs/highwayhash/highwayhash/vector128.h b/contrib/libs/highwayhash/highwayhash/vector128.h
index 24c30859cd..53eb9f164c 100644
--- a/contrib/libs/highwayhash/highwayhash/vector128.h
+++ b/contrib/libs/highwayhash/highwayhash/vector128.h
@@ -1,796 +1,796 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_VECTOR128_H_
-#define HIGHWAYHASH_VECTOR128_H_
-
-// Defines SIMD vector classes ("V2x64U") with overloaded arithmetic operators:
-// const V2x64U masked_sum = (a + b) & m;
-// This is shorter and more readable than compiler intrinsics:
-// const __m128i masked_sum = _mm_and_si128(_mm_add_epi64(a, b), m);
-// There is typically no runtime cost for these abstractions.
-//
-// The naming convention is VNxBBT where N is the number of lanes, BB the
-// number of bits per lane and T is the lane type: unsigned integer (U),
-// signed integer (I), or floating-point (F).
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-
-// For auto-dependency generation, we need to include all headers but not their
-// contents (otherwise compilation fails because -msse4.1 is not specified).
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-
-// WARNING: smmintrin.h will also be included through immintrin.h in the AVX2
-// translation unit, which is compiled with different flags. This risks ODR
-// violations, and can cause crashes when functions are not inlined and the
-// linker selects the AVX2 version. Unfortunately this include cannot reside
-// within a namespace due to conflicts with other system headers. We need to
-// assume all the intrinsic functions (defined as static inline by Clang's
-// library and as extern inline by GCC) are in fact inlined. targets.bzl
-// generates a test that verifies this by detecting duplicate symbols.
-#include <smmintrin.h> // SSE4.1
-
-namespace highwayhash {
-// To prevent ODR violations when including this from multiple translation
-// units (TU) that are compiled with different flags, the contents must reside
-// in a namespace whose name is unique to the TU. NOTE: this behavior is
-// incompatible with precompiled modules and requires textual inclusion instead.
-namespace HH_TARGET_NAME {
-
-// Primary template for 128-bit SSE4.1 vectors; only specializations are used.
-template <typename T>
-class V128 {};
-
-template <>
-class V128<uint8_t> {
- public:
- using Intrinsic = __m128i;
- using T = uint8_t;
- static constexpr size_t N = 16;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V128() {}
-
- // Broadcasts i to all lanes (usually by loading from memory).
- HH_INLINE explicit V128(T i) : v_(_mm_set1_epi8(i)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
- HH_INLINE V128& operator=(const V128& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V128(const Intrinsic& v) : v_(v) {}
- HH_INLINE V128& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V128 operator==(const V128& other) const {
- return V128(_mm_cmpeq_epi8(v_, other.v_));
- }
-
- HH_INLINE V128& operator+=(const V128& other) {
- v_ = _mm_add_epi8(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator-=(const V128& other) {
- v_ = _mm_sub_epi8(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator&=(const V128& other) {
- v_ = _mm_and_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator|=(const V128& other) {
- v_ = _mm_or_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator^=(const V128& other) {
- v_ = _mm_xor_si128(v_, other.v_);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V128<uint16_t> {
- public:
- using Intrinsic = __m128i;
- using T = uint16_t;
- static constexpr size_t N = 8;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V128() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V128(T p_7, T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
- : v_(_mm_set_epi16(p_7, p_6, p_5, p_4, p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts i to all lanes (usually by loading from memory).
- HH_INLINE explicit V128(T i) : v_(_mm_set1_epi16(i)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
- HH_INLINE V128& operator=(const V128& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V128(const Intrinsic& v) : v_(v) {}
- HH_INLINE V128& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V128 operator==(const V128& other) const {
- return V128(_mm_cmpeq_epi16(v_, other.v_));
- }
-
- HH_INLINE V128& operator+=(const V128& other) {
- v_ = _mm_add_epi16(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator-=(const V128& other) {
- v_ = _mm_sub_epi16(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator&=(const V128& other) {
- v_ = _mm_and_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator|=(const V128& other) {
- v_ = _mm_or_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator^=(const V128& other) {
- v_ = _mm_xor_si128(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator<<=(const int count) {
- v_ = _mm_slli_epi16(v_, count);
- return *this;
- }
- HH_INLINE V128& operator<<=(const Intrinsic& count) {
- v_ = _mm_sll_epi16(v_, count);
- return *this;
- }
-
- HH_INLINE V128& operator>>=(const int count) {
- v_ = _mm_srli_epi16(v_, count);
- return *this;
- }
- HH_INLINE V128& operator>>=(const Intrinsic& count) {
- v_ = _mm_srl_epi16(v_, count);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V128<uint32_t> {
- public:
- using Intrinsic = __m128i;
- using T = uint32_t;
- static constexpr size_t N = 4;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V128() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V128(T p_3, T p_2, T p_1, T p_0)
- : v_(_mm_set_epi32(p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts i to all lanes (usually by loading from memory).
- HH_INLINE explicit V128(T i) : v_(_mm_set1_epi32(i)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
- HH_INLINE V128& operator=(const V128& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V128(const Intrinsic& v) : v_(v) {}
- HH_INLINE V128& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V128 operator==(const V128& other) const {
- return V128(_mm_cmpeq_epi32(v_, other.v_));
- }
-
- HH_INLINE V128& operator+=(const V128& other) {
- v_ = _mm_add_epi32(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator-=(const V128& other) {
- v_ = _mm_sub_epi32(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator&=(const V128& other) {
- v_ = _mm_and_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator|=(const V128& other) {
- v_ = _mm_or_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator^=(const V128& other) {
- v_ = _mm_xor_si128(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator<<=(const int count) {
- v_ = _mm_slli_epi32(v_, count);
- return *this;
- }
- HH_INLINE V128& operator<<=(const Intrinsic& count) {
- v_ = _mm_sll_epi32(v_, count);
- return *this;
- }
-
- HH_INLINE V128& operator>>=(const int count) {
- v_ = _mm_srli_epi32(v_, count);
- return *this;
- }
- HH_INLINE V128& operator>>=(const Intrinsic& count) {
- v_ = _mm_srl_epi32(v_, count);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V128<uint64_t> {
- public:
- using Intrinsic = __m128i;
- using T = uint64_t;
- static constexpr size_t N = 2;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V128() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V128(T p_1, T p_0) : v_(_mm_set_epi64x(p_1, p_0)) {}
-
- // Broadcasts i to all lanes (usually by loading from memory).
- HH_INLINE explicit V128(T i) : v_(_mm_set_epi64x(i, i)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
- HH_INLINE V128& operator=(const V128& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V128(const Intrinsic& v) : v_(v) {}
- HH_INLINE V128& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V128 operator==(const V128& other) const {
- return V128(_mm_cmpeq_epi64(v_, other.v_));
- }
-
- HH_INLINE V128& operator+=(const V128& other) {
- v_ = _mm_add_epi64(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator-=(const V128& other) {
- v_ = _mm_sub_epi64(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator&=(const V128& other) {
- v_ = _mm_and_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator|=(const V128& other) {
- v_ = _mm_or_si128(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator^=(const V128& other) {
- v_ = _mm_xor_si128(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator<<=(const int count) {
- v_ = _mm_slli_epi64(v_, count);
- return *this;
- }
- HH_INLINE V128& operator<<=(const Intrinsic& count) {
- v_ = _mm_sll_epi64(v_, count);
- return *this;
- }
-
- HH_INLINE V128& operator>>=(const int count) {
- v_ = _mm_srli_epi64(v_, count);
- return *this;
- }
- HH_INLINE V128& operator>>=(const Intrinsic& count) {
- v_ = _mm_srl_epi64(v_, count);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V128<float> {
- public:
- using Intrinsic = __m128;
- using T = float;
- static constexpr size_t N = 4;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V128() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V128(T p_3, T p_2, T p_1, T p_0)
- : v_(_mm_set_ps(p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts to all lanes.
- HH_INLINE explicit V128(T f) : v_(_mm_set1_ps(f)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
- HH_INLINE V128& operator=(const V128& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V128(const Intrinsic& v) : v_(v) {}
- HH_INLINE V128& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- HH_INLINE V128 operator==(const V128& other) const {
- return V128(_mm_cmpeq_ps(v_, other.v_));
- }
- HH_INLINE V128 operator<(const V128& other) const {
- return V128(_mm_cmplt_ps(v_, other.v_));
- }
- HH_INLINE V128 operator>(const V128& other) const {
- return V128(_mm_cmplt_ps(other.v_, v_));
- }
-
- HH_INLINE V128& operator*=(const V128& other) {
- v_ = _mm_mul_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator/=(const V128& other) {
- v_ = _mm_div_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator+=(const V128& other) {
- v_ = _mm_add_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator-=(const V128& other) {
- v_ = _mm_sub_ps(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator&=(const V128& other) {
- v_ = _mm_and_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator|=(const V128& other) {
- v_ = _mm_or_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator^=(const V128& other) {
- v_ = _mm_xor_ps(v_, other.v_);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V128<double> {
- public:
- using Intrinsic = __m128d;
- using T = double;
- static constexpr size_t N = 2;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V128() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V128(T p_1, T p_0) : v_(_mm_set_pd(p_1, p_0)) {}
-
- // Broadcasts to all lanes.
- HH_INLINE explicit V128(T f) : v_(_mm_set1_pd(f)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
- HH_INLINE V128& operator=(const V128& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V128(const Intrinsic& v) : v_(v) {}
- HH_INLINE V128& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- HH_INLINE V128 operator==(const V128& other) const {
- return V128(_mm_cmpeq_pd(v_, other.v_));
- }
- HH_INLINE V128 operator<(const V128& other) const {
- return V128(_mm_cmplt_pd(v_, other.v_));
- }
- HH_INLINE V128 operator>(const V128& other) const {
- return V128(_mm_cmplt_pd(other.v_, v_));
- }
-
- HH_INLINE V128& operator*=(const V128& other) {
- v_ = _mm_mul_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator/=(const V128& other) {
- v_ = _mm_div_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator+=(const V128& other) {
- v_ = _mm_add_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator-=(const V128& other) {
- v_ = _mm_sub_pd(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V128& operator&=(const V128& other) {
- v_ = _mm_and_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator|=(const V128& other) {
- v_ = _mm_or_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V128& operator^=(const V128& other) {
- v_ = _mm_xor_pd(v_, other.v_);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-// Nonmember functions for any V128 via member functions.
-
-template <typename T>
-HH_INLINE V128<T> operator*(const V128<T>& left, const V128<T>& right) {
- V128<T> t(left);
- return t *= right;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator/(const V128<T>& left, const V128<T>& right) {
- V128<T> t(left);
- return t /= right;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator+(const V128<T>& left, const V128<T>& right) {
- V128<T> t(left);
- return t += right;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator-(const V128<T>& left, const V128<T>& right) {
- V128<T> t(left);
- return t -= right;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator&(const V128<T>& left, const V128<T>& right) {
- V128<T> t(left);
- return t &= right;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator|(const V128<T>& left, const V128<T>& right) {
- V128<T> t(left);
- return t |= right;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator^(const V128<T>& left, const V128<T>& right) {
- V128<T> t(left);
- return t ^= right;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator<<(const V128<T>& v, const int count) {
- V128<T> t(v);
- return t <<= count;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator>>(const V128<T>& v, const int count) {
- V128<T> t(v);
- return t >>= count;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator<<(const V128<T>& v, const __m128i& count) {
- V128<T> t(v);
- return t <<= count;
-}
-
-template <typename T>
-HH_INLINE V128<T> operator>>(const V128<T>& v, const __m128i& count) {
- V128<T> t(v);
- return t >>= count;
-}
-
-using V16x8U = V128<uint8_t>;
-using V8x16U = V128<uint16_t>;
-using V4x32U = V128<uint32_t>;
-using V2x64U = V128<uint64_t>;
-using V4x32F = V128<float>;
-using V2x64F = V128<double>;
-
-// Load/Store for any V128.
-
-// We differentiate between targets' vector types via template specialization.
-// Calling Load<V>(floats) is more natural than Load(V8x32F(), floats) and may
-// generate better code in unoptimized builds. Only declare the primary
-// templates to avoid needing mutual exclusion with vector256.
-
-template <class V>
-HH_INLINE V Load(const typename V::T* const HH_RESTRICT from);
-
-template <class V>
-HH_INLINE V LoadUnaligned(const typename V::T* const HH_RESTRICT from);
-
-// "from" must be vector-aligned.
-template <>
-HH_INLINE V16x8U Load<V16x8U>(const V16x8U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V16x8U(_mm_load_si128(p));
-}
-template <>
-HH_INLINE V8x16U Load<V8x16U>(const V8x16U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V8x16U(_mm_load_si128(p));
-}
-template <>
-HH_INLINE V4x32U Load<V4x32U>(const V4x32U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V4x32U(_mm_load_si128(p));
-}
-template <>
-HH_INLINE V2x64U Load<V2x64U>(const V2x64U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V2x64U(_mm_load_si128(p));
-}
-template <>
-HH_INLINE V4x32F Load<V4x32F>(const V4x32F::T* const HH_RESTRICT from) {
- return V4x32F(_mm_load_ps(from));
-}
-template <>
-HH_INLINE V2x64F Load<V2x64F>(const V2x64F::T* const HH_RESTRICT from) {
- return V2x64F(_mm_load_pd(from));
-}
-
-template <>
-HH_INLINE V16x8U
-LoadUnaligned<V16x8U>(const V16x8U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V16x8U(_mm_loadu_si128(p));
-}
-template <>
-HH_INLINE V8x16U
-LoadUnaligned<V8x16U>(const V8x16U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V8x16U(_mm_loadu_si128(p));
-}
-template <>
-HH_INLINE V4x32U
-LoadUnaligned<V4x32U>(const V4x32U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V4x32U(_mm_loadu_si128(p));
-}
-template <>
-HH_INLINE V2x64U
-LoadUnaligned<V2x64U>(const V2x64U::T* const HH_RESTRICT from) {
- const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
- return V2x64U(_mm_loadu_si128(p));
-}
-template <>
-HH_INLINE V4x32F
-LoadUnaligned<V4x32F>(const V4x32F::T* const HH_RESTRICT from) {
- return V4x32F(_mm_loadu_ps(from));
-}
-template <>
-HH_INLINE V2x64F
-LoadUnaligned<V2x64F>(const V2x64F::T* const HH_RESTRICT from) {
- return V2x64F(_mm_loadu_pd(from));
-}
-
-// "to" must be vector-aligned.
-template <typename T>
-HH_INLINE void Store(const V128<T>& v, T* const HH_RESTRICT to) {
- _mm_store_si128(reinterpret_cast<__m128i * HH_RESTRICT>(to), v);
-}
-HH_INLINE void Store(const V128<float>& v, float* const HH_RESTRICT to) {
- _mm_store_ps(to, v);
-}
-HH_INLINE void Store(const V128<double>& v, double* const HH_RESTRICT to) {
- _mm_store_pd(to, v);
-}
-
-template <typename T>
-HH_INLINE void StoreUnaligned(const V128<T>& v, T* const HH_RESTRICT to) {
- _mm_storeu_si128(reinterpret_cast<__m128i * HH_RESTRICT>(to), v);
-}
-HH_INLINE void StoreUnaligned(const V128<float>& v,
- float* const HH_RESTRICT to) {
- _mm_storeu_ps(to, v);
-}
-HH_INLINE void StoreUnaligned(const V128<double>& v,
- double* const HH_RESTRICT to) {
- _mm_storeu_pd(to, v);
-}
-
-// Writes directly to (aligned) memory, bypassing the cache. This is useful for
-// data that will not be read again in the near future.
-template <typename T>
-HH_INLINE void Stream(const V128<T>& v, T* const HH_RESTRICT to) {
- _mm_stream_si128(reinterpret_cast<__m128i * HH_RESTRICT>(to), v);
-}
-HH_INLINE void Stream(const V128<float>& v, float* const HH_RESTRICT to) {
- _mm_stream_ps(to, v);
-}
-HH_INLINE void Stream(const V128<double>& v, double* const HH_RESTRICT to) {
- _mm_stream_pd(to, v);
-}
-
-// Miscellaneous functions.
-
-template <typename T>
-HH_INLINE V128<T> RotateLeft(const V128<T>& v, const int count) {
- constexpr size_t num_bits = sizeof(T) * 8;
- return (v << count) | (v >> (num_bits - count));
-}
-
-template <typename T>
-HH_INLINE V128<T> AndNot(const V128<T>& neg_mask, const V128<T>& values) {
- return V128<T>(_mm_andnot_si128(neg_mask, values));
-}
-template <>
-HH_INLINE V128<float> AndNot(const V128<float>& neg_mask,
- const V128<float>& values) {
- return V128<float>(_mm_andnot_ps(neg_mask, values));
-}
-template <>
-HH_INLINE V128<double> AndNot(const V128<double>& neg_mask,
- const V128<double>& values) {
- return V128<double>(_mm_andnot_pd(neg_mask, values));
-}
-
-HH_INLINE V4x32F Select(const V4x32F& a, const V4x32F& b, const V4x32F& mask) {
- return V4x32F(_mm_blendv_ps(a, b, mask));
-}
-
-HH_INLINE V2x64F Select(const V2x64F& a, const V2x64F& b, const V2x64F& mask) {
- return V2x64F(_mm_blendv_pd(a, b, mask));
-}
-
-// Min/Max
-
-HH_INLINE V16x8U Min(const V16x8U& v0, const V16x8U& v1) {
- return V16x8U(_mm_min_epu8(v0, v1));
-}
-
-HH_INLINE V16x8U Max(const V16x8U& v0, const V16x8U& v1) {
- return V16x8U(_mm_max_epu8(v0, v1));
-}
-
-HH_INLINE V8x16U Min(const V8x16U& v0, const V8x16U& v1) {
- return V8x16U(_mm_min_epu16(v0, v1));
-}
-
-HH_INLINE V8x16U Max(const V8x16U& v0, const V8x16U& v1) {
- return V8x16U(_mm_max_epu16(v0, v1));
-}
-
-HH_INLINE V4x32U Min(const V4x32U& v0, const V4x32U& v1) {
- return V4x32U(_mm_min_epu32(v0, v1));
-}
-
-HH_INLINE V4x32U Max(const V4x32U& v0, const V4x32U& v1) {
- return V4x32U(_mm_max_epu32(v0, v1));
-}
-
-HH_INLINE V4x32F Min(const V4x32F& v0, const V4x32F& v1) {
- return V4x32F(_mm_min_ps(v0, v1));
-}
-
-HH_INLINE V4x32F Max(const V4x32F& v0, const V4x32F& v1) {
- return V4x32F(_mm_max_ps(v0, v1));
-}
-
-HH_INLINE V2x64F Min(const V2x64F& v0, const V2x64F& v1) {
- return V2x64F(_mm_min_pd(v0, v1));
-}
-
-HH_INLINE V2x64F Max(const V2x64F& v0, const V2x64F& v1) {
- return V2x64F(_mm_max_pd(v0, v1));
-}
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HH_DISABLE_TARGET_SPECIFIC
-#endif // HIGHWAYHASH_VECTOR128_H_
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_VECTOR128_H_
+#define HIGHWAYHASH_VECTOR128_H_
+
+// Defines SIMD vector classes ("V2x64U") with overloaded arithmetic operators:
+// const V2x64U masked_sum = (a + b) & m;
+// This is shorter and more readable than compiler intrinsics:
+// const __m128i masked_sum = _mm_and_si128(_mm_add_epi64(a, b), m);
+// There is typically no runtime cost for these abstractions.
+//
+// The naming convention is VNxBBT where N is the number of lanes, BB the
+// number of bits per lane and T is the lane type: unsigned integer (U),
+// signed integer (I), or floating-point (F).
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+
+// For auto-dependency generation, we need to include all headers but not their
+// contents (otherwise compilation fails because -msse4.1 is not specified).
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+
+// WARNING: smmintrin.h will also be included through immintrin.h in the AVX2
+// translation unit, which is compiled with different flags. This risks ODR
+// violations, and can cause crashes when functions are not inlined and the
+// linker selects the AVX2 version. Unfortunately this include cannot reside
+// within a namespace due to conflicts with other system headers. We need to
+// assume all the intrinsic functions (defined as static inline by Clang's
+// library and as extern inline by GCC) are in fact inlined. targets.bzl
+// generates a test that verifies this by detecting duplicate symbols.
+#include <smmintrin.h> // SSE4.1
+
+namespace highwayhash {
+// To prevent ODR violations when including this from multiple translation
+// units (TU) that are compiled with different flags, the contents must reside
+// in a namespace whose name is unique to the TU. NOTE: this behavior is
+// incompatible with precompiled modules and requires textual inclusion instead.
+namespace HH_TARGET_NAME {
+
+// Primary template for 128-bit SSE4.1 vectors; only specializations are used.
+template <typename T>
+class V128 {};
+
+template <>
+class V128<uint8_t> {
+ public:
+ using Intrinsic = __m128i;
+ using T = uint8_t;
+ static constexpr size_t N = 16;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V128() {}
+
+ // Broadcasts i to all lanes (usually by loading from memory).
+ HH_INLINE explicit V128(T i) : v_(_mm_set1_epi8(i)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
+ HH_INLINE V128& operator=(const V128& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V128(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V128& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V128 operator==(const V128& other) const {
+ return V128(_mm_cmpeq_epi8(v_, other.v_));
+ }
+
+ HH_INLINE V128& operator+=(const V128& other) {
+ v_ = _mm_add_epi8(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator-=(const V128& other) {
+ v_ = _mm_sub_epi8(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator&=(const V128& other) {
+ v_ = _mm_and_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator|=(const V128& other) {
+ v_ = _mm_or_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator^=(const V128& other) {
+ v_ = _mm_xor_si128(v_, other.v_);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V128<uint16_t> {
+ public:
+ using Intrinsic = __m128i;
+ using T = uint16_t;
+ static constexpr size_t N = 8;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V128() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V128(T p_7, T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm_set_epi16(p_7, p_6, p_5, p_4, p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts i to all lanes (usually by loading from memory).
+ HH_INLINE explicit V128(T i) : v_(_mm_set1_epi16(i)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
+ HH_INLINE V128& operator=(const V128& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V128(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V128& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V128 operator==(const V128& other) const {
+ return V128(_mm_cmpeq_epi16(v_, other.v_));
+ }
+
+ HH_INLINE V128& operator+=(const V128& other) {
+ v_ = _mm_add_epi16(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator-=(const V128& other) {
+ v_ = _mm_sub_epi16(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator&=(const V128& other) {
+ v_ = _mm_and_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator|=(const V128& other) {
+ v_ = _mm_or_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator^=(const V128& other) {
+ v_ = _mm_xor_si128(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator<<=(const int count) {
+ v_ = _mm_slli_epi16(v_, count);
+ return *this;
+ }
+ HH_INLINE V128& operator<<=(const Intrinsic& count) {
+ v_ = _mm_sll_epi16(v_, count);
+ return *this;
+ }
+
+ HH_INLINE V128& operator>>=(const int count) {
+ v_ = _mm_srli_epi16(v_, count);
+ return *this;
+ }
+ HH_INLINE V128& operator>>=(const Intrinsic& count) {
+ v_ = _mm_srl_epi16(v_, count);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V128<uint32_t> {
+ public:
+ using Intrinsic = __m128i;
+ using T = uint32_t;
+ static constexpr size_t N = 4;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V128() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V128(T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm_set_epi32(p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts i to all lanes (usually by loading from memory).
+ HH_INLINE explicit V128(T i) : v_(_mm_set1_epi32(i)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
+ HH_INLINE V128& operator=(const V128& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V128(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V128& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V128 operator==(const V128& other) const {
+ return V128(_mm_cmpeq_epi32(v_, other.v_));
+ }
+
+ HH_INLINE V128& operator+=(const V128& other) {
+ v_ = _mm_add_epi32(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator-=(const V128& other) {
+ v_ = _mm_sub_epi32(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator&=(const V128& other) {
+ v_ = _mm_and_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator|=(const V128& other) {
+ v_ = _mm_or_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator^=(const V128& other) {
+ v_ = _mm_xor_si128(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator<<=(const int count) {
+ v_ = _mm_slli_epi32(v_, count);
+ return *this;
+ }
+ HH_INLINE V128& operator<<=(const Intrinsic& count) {
+ v_ = _mm_sll_epi32(v_, count);
+ return *this;
+ }
+
+ HH_INLINE V128& operator>>=(const int count) {
+ v_ = _mm_srli_epi32(v_, count);
+ return *this;
+ }
+ HH_INLINE V128& operator>>=(const Intrinsic& count) {
+ v_ = _mm_srl_epi32(v_, count);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V128<uint64_t> {
+ public:
+ using Intrinsic = __m128i;
+ using T = uint64_t;
+ static constexpr size_t N = 2;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V128() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V128(T p_1, T p_0) : v_(_mm_set_epi64x(p_1, p_0)) {}
+
+ // Broadcasts i to all lanes (usually by loading from memory).
+ HH_INLINE explicit V128(T i) : v_(_mm_set_epi64x(i, i)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
+ HH_INLINE V128& operator=(const V128& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V128(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V128& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V128 operator==(const V128& other) const {
+ return V128(_mm_cmpeq_epi64(v_, other.v_));
+ }
+
+ HH_INLINE V128& operator+=(const V128& other) {
+ v_ = _mm_add_epi64(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator-=(const V128& other) {
+ v_ = _mm_sub_epi64(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator&=(const V128& other) {
+ v_ = _mm_and_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator|=(const V128& other) {
+ v_ = _mm_or_si128(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator^=(const V128& other) {
+ v_ = _mm_xor_si128(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator<<=(const int count) {
+ v_ = _mm_slli_epi64(v_, count);
+ return *this;
+ }
+ HH_INLINE V128& operator<<=(const Intrinsic& count) {
+ v_ = _mm_sll_epi64(v_, count);
+ return *this;
+ }
+
+ HH_INLINE V128& operator>>=(const int count) {
+ v_ = _mm_srli_epi64(v_, count);
+ return *this;
+ }
+ HH_INLINE V128& operator>>=(const Intrinsic& count) {
+ v_ = _mm_srl_epi64(v_, count);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V128<float> {
+ public:
+ using Intrinsic = __m128;
+ using T = float;
+ static constexpr size_t N = 4;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V128() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V128(T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm_set_ps(p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts to all lanes.
+ HH_INLINE explicit V128(T f) : v_(_mm_set1_ps(f)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
+ HH_INLINE V128& operator=(const V128& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V128(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V128& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ HH_INLINE V128 operator==(const V128& other) const {
+ return V128(_mm_cmpeq_ps(v_, other.v_));
+ }
+ HH_INLINE V128 operator<(const V128& other) const {
+ return V128(_mm_cmplt_ps(v_, other.v_));
+ }
+ HH_INLINE V128 operator>(const V128& other) const {
+ return V128(_mm_cmplt_ps(other.v_, v_));
+ }
+
+ HH_INLINE V128& operator*=(const V128& other) {
+ v_ = _mm_mul_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator/=(const V128& other) {
+ v_ = _mm_div_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator+=(const V128& other) {
+ v_ = _mm_add_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator-=(const V128& other) {
+ v_ = _mm_sub_ps(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator&=(const V128& other) {
+ v_ = _mm_and_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator|=(const V128& other) {
+ v_ = _mm_or_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator^=(const V128& other) {
+ v_ = _mm_xor_ps(v_, other.v_);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V128<double> {
+ public:
+ using Intrinsic = __m128d;
+ using T = double;
+ static constexpr size_t N = 2;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V128() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V128(T p_1, T p_0) : v_(_mm_set_pd(p_1, p_0)) {}
+
+ // Broadcasts to all lanes.
+ HH_INLINE explicit V128(T f) : v_(_mm_set1_pd(f)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V128(const V128& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V128(const V128<U>& other) : v_(other) {}
+ HH_INLINE V128& operator=(const V128& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V128(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V128& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ HH_INLINE V128 operator==(const V128& other) const {
+ return V128(_mm_cmpeq_pd(v_, other.v_));
+ }
+ HH_INLINE V128 operator<(const V128& other) const {
+ return V128(_mm_cmplt_pd(v_, other.v_));
+ }
+ HH_INLINE V128 operator>(const V128& other) const {
+ return V128(_mm_cmplt_pd(other.v_, v_));
+ }
+
+ HH_INLINE V128& operator*=(const V128& other) {
+ v_ = _mm_mul_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator/=(const V128& other) {
+ v_ = _mm_div_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator+=(const V128& other) {
+ v_ = _mm_add_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator-=(const V128& other) {
+ v_ = _mm_sub_pd(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V128& operator&=(const V128& other) {
+ v_ = _mm_and_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator|=(const V128& other) {
+ v_ = _mm_or_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V128& operator^=(const V128& other) {
+ v_ = _mm_xor_pd(v_, other.v_);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+// Nonmember functions for any V128 via member functions.
+
+template <typename T>
+HH_INLINE V128<T> operator*(const V128<T>& left, const V128<T>& right) {
+ V128<T> t(left);
+ return t *= right;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator/(const V128<T>& left, const V128<T>& right) {
+ V128<T> t(left);
+ return t /= right;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator+(const V128<T>& left, const V128<T>& right) {
+ V128<T> t(left);
+ return t += right;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator-(const V128<T>& left, const V128<T>& right) {
+ V128<T> t(left);
+ return t -= right;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator&(const V128<T>& left, const V128<T>& right) {
+ V128<T> t(left);
+ return t &= right;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator|(const V128<T>& left, const V128<T>& right) {
+ V128<T> t(left);
+ return t |= right;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator^(const V128<T>& left, const V128<T>& right) {
+ V128<T> t(left);
+ return t ^= right;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator<<(const V128<T>& v, const int count) {
+ V128<T> t(v);
+ return t <<= count;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator>>(const V128<T>& v, const int count) {
+ V128<T> t(v);
+ return t >>= count;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator<<(const V128<T>& v, const __m128i& count) {
+ V128<T> t(v);
+ return t <<= count;
+}
+
+template <typename T>
+HH_INLINE V128<T> operator>>(const V128<T>& v, const __m128i& count) {
+ V128<T> t(v);
+ return t >>= count;
+}
+
+using V16x8U = V128<uint8_t>;
+using V8x16U = V128<uint16_t>;
+using V4x32U = V128<uint32_t>;
+using V2x64U = V128<uint64_t>;
+using V4x32F = V128<float>;
+using V2x64F = V128<double>;
+
+// Load/Store for any V128.
+
+// We differentiate between targets' vector types via template specialization.
+// Calling Load<V>(floats) is more natural than Load(V8x32F(), floats) and may
+// generate better code in unoptimized builds. Only declare the primary
+// templates to avoid needing mutual exclusion with vector256.
+
+template <class V>
+HH_INLINE V Load(const typename V::T* const HH_RESTRICT from);
+
+template <class V>
+HH_INLINE V LoadUnaligned(const typename V::T* const HH_RESTRICT from);
+
+// "from" must be vector-aligned.
+template <>
+HH_INLINE V16x8U Load<V16x8U>(const V16x8U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V16x8U(_mm_load_si128(p));
+}
+template <>
+HH_INLINE V8x16U Load<V8x16U>(const V8x16U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V8x16U(_mm_load_si128(p));
+}
+template <>
+HH_INLINE V4x32U Load<V4x32U>(const V4x32U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V4x32U(_mm_load_si128(p));
+}
+template <>
+HH_INLINE V2x64U Load<V2x64U>(const V2x64U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V2x64U(_mm_load_si128(p));
+}
+template <>
+HH_INLINE V4x32F Load<V4x32F>(const V4x32F::T* const HH_RESTRICT from) {
+ return V4x32F(_mm_load_ps(from));
+}
+template <>
+HH_INLINE V2x64F Load<V2x64F>(const V2x64F::T* const HH_RESTRICT from) {
+ return V2x64F(_mm_load_pd(from));
+}
+
+template <>
+HH_INLINE V16x8U
+LoadUnaligned<V16x8U>(const V16x8U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V16x8U(_mm_loadu_si128(p));
+}
+template <>
+HH_INLINE V8x16U
+LoadUnaligned<V8x16U>(const V8x16U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V8x16U(_mm_loadu_si128(p));
+}
+template <>
+HH_INLINE V4x32U
+LoadUnaligned<V4x32U>(const V4x32U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V4x32U(_mm_loadu_si128(p));
+}
+template <>
+HH_INLINE V2x64U
+LoadUnaligned<V2x64U>(const V2x64U::T* const HH_RESTRICT from) {
+ const __m128i* const HH_RESTRICT p = reinterpret_cast<const __m128i*>(from);
+ return V2x64U(_mm_loadu_si128(p));
+}
+template <>
+HH_INLINE V4x32F
+LoadUnaligned<V4x32F>(const V4x32F::T* const HH_RESTRICT from) {
+ return V4x32F(_mm_loadu_ps(from));
+}
+template <>
+HH_INLINE V2x64F
+LoadUnaligned<V2x64F>(const V2x64F::T* const HH_RESTRICT from) {
+ return V2x64F(_mm_loadu_pd(from));
+}
+
+// "to" must be vector-aligned.
+template <typename T>
+HH_INLINE void Store(const V128<T>& v, T* const HH_RESTRICT to) {
+ _mm_store_si128(reinterpret_cast<__m128i * HH_RESTRICT>(to), v);
+}
+HH_INLINE void Store(const V128<float>& v, float* const HH_RESTRICT to) {
+ _mm_store_ps(to, v);
+}
+HH_INLINE void Store(const V128<double>& v, double* const HH_RESTRICT to) {
+ _mm_store_pd(to, v);
+}
+
+template <typename T>
+HH_INLINE void StoreUnaligned(const V128<T>& v, T* const HH_RESTRICT to) {
+ _mm_storeu_si128(reinterpret_cast<__m128i * HH_RESTRICT>(to), v);
+}
+HH_INLINE void StoreUnaligned(const V128<float>& v,
+ float* const HH_RESTRICT to) {
+ _mm_storeu_ps(to, v);
+}
+HH_INLINE void StoreUnaligned(const V128<double>& v,
+ double* const HH_RESTRICT to) {
+ _mm_storeu_pd(to, v);
+}
+
+// Writes directly to (aligned) memory, bypassing the cache. This is useful for
+// data that will not be read again in the near future.
+template <typename T>
+HH_INLINE void Stream(const V128<T>& v, T* const HH_RESTRICT to) {
+ _mm_stream_si128(reinterpret_cast<__m128i * HH_RESTRICT>(to), v);
+}
+HH_INLINE void Stream(const V128<float>& v, float* const HH_RESTRICT to) {
+ _mm_stream_ps(to, v);
+}
+HH_INLINE void Stream(const V128<double>& v, double* const HH_RESTRICT to) {
+ _mm_stream_pd(to, v);
+}
+
+// Miscellaneous functions.
+
+template <typename T>
+HH_INLINE V128<T> RotateLeft(const V128<T>& v, const int count) {
+ constexpr size_t num_bits = sizeof(T) * 8;
+ return (v << count) | (v >> (num_bits - count));
+}
+
+template <typename T>
+HH_INLINE V128<T> AndNot(const V128<T>& neg_mask, const V128<T>& values) {
+ return V128<T>(_mm_andnot_si128(neg_mask, values));
+}
+template <>
+HH_INLINE V128<float> AndNot(const V128<float>& neg_mask,
+ const V128<float>& values) {
+ return V128<float>(_mm_andnot_ps(neg_mask, values));
+}
+template <>
+HH_INLINE V128<double> AndNot(const V128<double>& neg_mask,
+ const V128<double>& values) {
+ return V128<double>(_mm_andnot_pd(neg_mask, values));
+}
+
+HH_INLINE V4x32F Select(const V4x32F& a, const V4x32F& b, const V4x32F& mask) {
+ return V4x32F(_mm_blendv_ps(a, b, mask));
+}
+
+HH_INLINE V2x64F Select(const V2x64F& a, const V2x64F& b, const V2x64F& mask) {
+ return V2x64F(_mm_blendv_pd(a, b, mask));
+}
+
+// Min/Max
+
+HH_INLINE V16x8U Min(const V16x8U& v0, const V16x8U& v1) {
+ return V16x8U(_mm_min_epu8(v0, v1));
+}
+
+HH_INLINE V16x8U Max(const V16x8U& v0, const V16x8U& v1) {
+ return V16x8U(_mm_max_epu8(v0, v1));
+}
+
+HH_INLINE V8x16U Min(const V8x16U& v0, const V8x16U& v1) {
+ return V8x16U(_mm_min_epu16(v0, v1));
+}
+
+HH_INLINE V8x16U Max(const V8x16U& v0, const V8x16U& v1) {
+ return V8x16U(_mm_max_epu16(v0, v1));
+}
+
+HH_INLINE V4x32U Min(const V4x32U& v0, const V4x32U& v1) {
+ return V4x32U(_mm_min_epu32(v0, v1));
+}
+
+HH_INLINE V4x32U Max(const V4x32U& v0, const V4x32U& v1) {
+ return V4x32U(_mm_max_epu32(v0, v1));
+}
+
+HH_INLINE V4x32F Min(const V4x32F& v0, const V4x32F& v1) {
+ return V4x32F(_mm_min_ps(v0, v1));
+}
+
+HH_INLINE V4x32F Max(const V4x32F& v0, const V4x32F& v1) {
+ return V4x32F(_mm_max_ps(v0, v1));
+}
+
+HH_INLINE V2x64F Min(const V2x64F& v0, const V2x64F& v1) {
+ return V2x64F(_mm_min_pd(v0, v1));
+}
+
+HH_INLINE V2x64F Max(const V2x64F& v0, const V2x64F& v1) {
+ return V2x64F(_mm_max_pd(v0, v1));
+}
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HH_DISABLE_TARGET_SPECIFIC
+#endif // HIGHWAYHASH_VECTOR128_H_
diff --git a/contrib/libs/highwayhash/highwayhash/vector256.h b/contrib/libs/highwayhash/highwayhash/vector256.h
index 29199ddf00..d1ccec49ef 100644
--- a/contrib/libs/highwayhash/highwayhash/vector256.h
+++ b/contrib/libs/highwayhash/highwayhash/vector256.h
@@ -1,758 +1,758 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_VECTOR256_H_
-#define HIGHWAYHASH_VECTOR256_H_
-
-// Defines SIMD vector classes ("V4x64U") with overloaded arithmetic operators:
-// const V4x64U masked_sum = (a + b) & m;
-// This is shorter and more readable than compiler intrinsics:
-// const __m256i masked_sum = _mm256_and_si256(_mm256_add_epi64(a, b), m);
-// There is typically no runtime cost for these abstractions.
-//
-// The naming convention is VNxBBT where N is the number of lanes, BB the
-// number of bits per lane and T is the lane type: unsigned integer (U),
-// signed integer (I), or floating-point (F).
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/compiler_specific.h"
-
-// For auto-dependency generation, we need to include all headers but not their
-// contents (otherwise compilation fails because -mavx2 is not specified).
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-
-// (This include cannot be moved within a namespace due to conflicts with
-// other system headers; see the comment in hh_sse41.h.)
-#include <immintrin.h>
-
-namespace highwayhash {
-// To prevent ODR violations when including this from multiple translation
-// units (TU) that are compiled with different flags, the contents must reside
-// in a namespace whose name is unique to the TU. NOTE: this behavior is
-// incompatible with precompiled modules and requires textual inclusion instead.
-namespace HH_TARGET_NAME {
-
-// Primary template for 256-bit AVX2 vectors; only specializations are used.
-template <typename T>
-class V256 {};
-
-template <>
-class V256<uint8_t> {
- public:
- using Intrinsic = __m256i;
- using T = uint8_t;
- static constexpr size_t N = 32;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V256() {}
-
- // Broadcasts i to all lanes.
- HH_INLINE explicit V256(T i)
- : v_(_mm256_broadcastb_epi8(_mm_cvtsi32_si128(i))) {}
-
- // Copy from other vector.
- HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
- HH_INLINE V256& operator=(const V256& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V256(const Intrinsic& v) : v_(v) {}
- HH_INLINE V256& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V256 operator==(const V256& other) const {
- return V256(_mm256_cmpeq_epi8(v_, other.v_));
- }
-
- HH_INLINE V256& operator+=(const V256& other) {
- v_ = _mm256_add_epi8(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator-=(const V256& other) {
- v_ = _mm256_sub_epi8(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator&=(const V256& other) {
- v_ = _mm256_and_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator|=(const V256& other) {
- v_ = _mm256_or_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator^=(const V256& other) {
- v_ = _mm256_xor_si256(v_, other.v_);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V256<uint16_t> {
- public:
- using Intrinsic = __m256i;
- using T = uint16_t;
- static constexpr size_t N = 16;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V256() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V256(T p_F, T p_E, T p_D, T p_C, T p_B, T p_A, T p_9, T p_8, T p_7,
- T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
- : v_(_mm256_set_epi16(p_F, p_E, p_D, p_C, p_B, p_A, p_9, p_8, p_7, p_6,
- p_5, p_4, p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts i to all lanes.
- HH_INLINE explicit V256(T i)
- : v_(_mm256_broadcastw_epi16(_mm_cvtsi32_si128(i))) {}
-
- // Copy from other vector.
- HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
- HH_INLINE V256& operator=(const V256& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V256(const Intrinsic& v) : v_(v) {}
- HH_INLINE V256& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V256 operator==(const V256& other) const {
- return V256(_mm256_cmpeq_epi16(v_, other.v_));
- }
-
- HH_INLINE V256& operator+=(const V256& other) {
- v_ = _mm256_add_epi16(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator-=(const V256& other) {
- v_ = _mm256_sub_epi16(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator&=(const V256& other) {
- v_ = _mm256_and_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator|=(const V256& other) {
- v_ = _mm256_or_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator^=(const V256& other) {
- v_ = _mm256_xor_si256(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator<<=(const int count) {
- v_ = _mm256_slli_epi16(v_, count);
- return *this;
- }
-
- HH_INLINE V256& operator>>=(const int count) {
- v_ = _mm256_srli_epi16(v_, count);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V256<uint32_t> {
- public:
- using Intrinsic = __m256i;
- using T = uint32_t;
- static constexpr size_t N = 8;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V256() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V256(T p_7, T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
- : v_(_mm256_set_epi32(p_7, p_6, p_5, p_4, p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts i to all lanes.
- HH_INLINE explicit V256(T i)
- : v_(_mm256_broadcastd_epi32(_mm_cvtsi32_si128(i))) {}
-
- // Copy from other vector.
- HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
- HH_INLINE V256& operator=(const V256& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V256(const Intrinsic& v) : v_(v) {}
- HH_INLINE V256& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V256 operator==(const V256& other) const {
- return V256(_mm256_cmpeq_epi32(v_, other.v_));
- }
-
- HH_INLINE V256& operator+=(const V256& other) {
- v_ = _mm256_add_epi32(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator-=(const V256& other) {
- v_ = _mm256_sub_epi32(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator&=(const V256& other) {
- v_ = _mm256_and_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator|=(const V256& other) {
- v_ = _mm256_or_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator^=(const V256& other) {
- v_ = _mm256_xor_si256(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator<<=(const int count) {
- v_ = _mm256_slli_epi32(v_, count);
- return *this;
- }
-
- HH_INLINE V256& operator>>=(const int count) {
- v_ = _mm256_srli_epi32(v_, count);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V256<uint64_t> {
- public:
- using Intrinsic = __m256i;
- using T = uint64_t;
- static constexpr size_t N = 4;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V256() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V256(T p_3, T p_2, T p_1, T p_0)
- : v_(_mm256_set_epi64x(p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts i to all lanes.
- HH_INLINE explicit V256(T i)
- : v_(_mm256_broadcastq_epi64(_mm_cvtsi64_si128(i))) {}
-
- // Copy from other vector.
- HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
- HH_INLINE V256& operator=(const V256& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V256(const Intrinsic& v) : v_(v) {}
- HH_INLINE V256& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- // There are no greater-than comparison instructions for unsigned T.
- HH_INLINE V256 operator==(const V256& other) const {
- return V256(_mm256_cmpeq_epi64(v_, other.v_));
- }
-
- HH_INLINE V256& operator+=(const V256& other) {
- v_ = _mm256_add_epi64(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator-=(const V256& other) {
- v_ = _mm256_sub_epi64(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator&=(const V256& other) {
- v_ = _mm256_and_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator|=(const V256& other) {
- v_ = _mm256_or_si256(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator^=(const V256& other) {
- v_ = _mm256_xor_si256(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator<<=(const int count) {
- v_ = _mm256_slli_epi64(v_, count);
- return *this;
- }
-
- HH_INLINE V256& operator>>=(const int count) {
- v_ = _mm256_srli_epi64(v_, count);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V256<float> {
- public:
- using Intrinsic = __m256;
- using T = float;
- static constexpr size_t N = 8;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V256() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V256(T p_7, T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
- : v_(_mm256_set_ps(p_7, p_6, p_5, p_4, p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts to all lanes.
- HH_INLINE explicit V256(T f) : v_(_mm256_set1_ps(f)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
- HH_INLINE V256& operator=(const V256& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V256(const Intrinsic& v) : v_(v) {}
- HH_INLINE V256& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- HH_INLINE V256 operator==(const V256& other) const {
- return V256(_mm256_cmp_ps(v_, other.v_, 0));
- }
- HH_INLINE V256 operator<(const V256& other) const {
- return V256(_mm256_cmp_ps(v_, other.v_, 1));
- }
- HH_INLINE V256 operator>(const V256& other) const {
- return V256(_mm256_cmp_ps(other.v_, v_, 1));
- }
-
- HH_INLINE V256& operator*=(const V256& other) {
- v_ = _mm256_mul_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator/=(const V256& other) {
- v_ = _mm256_div_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator+=(const V256& other) {
- v_ = _mm256_add_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator-=(const V256& other) {
- v_ = _mm256_sub_ps(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator&=(const V256& other) {
- v_ = _mm256_and_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator|=(const V256& other) {
- v_ = _mm256_or_ps(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator^=(const V256& other) {
- v_ = _mm256_xor_ps(v_, other.v_);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-template <>
-class V256<double> {
- public:
- using Intrinsic = __m256d;
- using T = double;
- static constexpr size_t N = 4;
-
- // Leaves v_ uninitialized - typically used for output parameters.
- HH_INLINE V256() {}
-
- // Lane 0 (p_0) is the lowest.
- HH_INLINE V256(T p_3, T p_2, T p_1, T p_0)
- : v_(_mm256_set_pd(p_3, p_2, p_1, p_0)) {}
-
- // Broadcasts to all lanes.
- HH_INLINE explicit V256(T f) : v_(_mm256_set1_pd(f)) {}
-
- // Copy from other vector.
- HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
- template <typename U>
- HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
- HH_INLINE V256& operator=(const V256& other) {
- v_ = other.v_;
- return *this;
- }
-
- // Convert from/to intrinsics.
- HH_INLINE V256(const Intrinsic& v) : v_(v) {}
- HH_INLINE V256& operator=(const Intrinsic& v) {
- v_ = v;
- return *this;
- }
- HH_INLINE operator Intrinsic() const { return v_; }
-
- HH_INLINE V256 operator==(const V256& other) const {
- return V256(_mm256_cmp_pd(v_, other.v_, 0));
- }
- HH_INLINE V256 operator<(const V256& other) const {
- return V256(_mm256_cmp_pd(v_, other.v_, 1));
- }
- HH_INLINE V256 operator>(const V256& other) const {
- return V256(_mm256_cmp_pd(other.v_, v_, 1));
- }
-
- HH_INLINE V256& operator*=(const V256& other) {
- v_ = _mm256_mul_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator/=(const V256& other) {
- v_ = _mm256_div_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator+=(const V256& other) {
- v_ = _mm256_add_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator-=(const V256& other) {
- v_ = _mm256_sub_pd(v_, other.v_);
- return *this;
- }
-
- HH_INLINE V256& operator&=(const V256& other) {
- v_ = _mm256_and_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator|=(const V256& other) {
- v_ = _mm256_or_pd(v_, other.v_);
- return *this;
- }
- HH_INLINE V256& operator^=(const V256& other) {
- v_ = _mm256_xor_pd(v_, other.v_);
- return *this;
- }
-
- private:
- Intrinsic v_;
-};
-
-// Nonmember functions for any V256 via member functions.
-
-template <typename T>
-HH_INLINE V256<T> operator*(const V256<T>& left, const V256<T>& right) {
- V256<T> t(left);
- return t *= right;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator/(const V256<T>& left, const V256<T>& right) {
- V256<T> t(left);
- return t /= right;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator+(const V256<T>& left, const V256<T>& right) {
- V256<T> t(left);
- return t += right;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator-(const V256<T>& left, const V256<T>& right) {
- V256<T> t(left);
- return t -= right;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator&(const V256<T>& left, const V256<T>& right) {
- V256<T> t(left);
- return t &= right;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator|(const V256<T> left, const V256<T>& right) {
- V256<T> t(left);
- return t |= right;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator^(const V256<T>& left, const V256<T>& right) {
- V256<T> t(left);
- return t ^= right;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator<<(const V256<T>& v, const int count) {
- V256<T> t(v);
- return t <<= count;
-}
-
-template <typename T>
-HH_INLINE V256<T> operator>>(const V256<T>& v, const int count) {
- V256<T> t(v);
- return t >>= count;
-}
-
-// We do not provide operator<<(V, __m128i) because it has 4 cycle latency
-// (to broadcast the shift count). It is faster to use sllv_epi64 etc. instead.
-
-using V32x8U = V256<uint8_t>;
-using V16x16U = V256<uint16_t>;
-using V8x32U = V256<uint32_t>;
-using V4x64U = V256<uint64_t>;
-using V8x32F = V256<float>;
-using V4x64F = V256<double>;
-
-// Load/Store for any V256.
-
-// We differentiate between targets' vector types via template specialization.
-// Calling Load<V>(floats) is more natural than Load(V8x32F(), floats) and may
-// generate better code in unoptimized builds. Only declare the primary
-// templates to avoid needing mutual exclusion with vector128.
-
-template <class V>
-HH_INLINE V Load(const typename V::T* const HH_RESTRICT from);
-
-template <class V>
-HH_INLINE V LoadUnaligned(const typename V::T* const HH_RESTRICT from);
-
-template <>
-HH_INLINE V32x8U Load(const V32x8U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V32x8U(_mm256_load_si256(p));
-}
-template <>
-HH_INLINE V16x16U Load(const V16x16U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V16x16U(_mm256_load_si256(p));
-}
-template <>
-HH_INLINE V8x32U Load(const V8x32U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V8x32U(_mm256_load_si256(p));
-}
-template <>
-HH_INLINE V4x64U Load(const V4x64U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V4x64U(_mm256_load_si256(p));
-}
-template <>
-HH_INLINE V8x32F Load(const V8x32F::T* const HH_RESTRICT from) {
- return V8x32F(_mm256_load_ps(from));
-}
-template <>
-HH_INLINE V4x64F Load(const V4x64F::T* const HH_RESTRICT from) {
- return V4x64F(_mm256_load_pd(from));
-}
-
-template <>
-HH_INLINE V32x8U LoadUnaligned(const V32x8U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V32x8U(_mm256_loadu_si256(p));
-}
-template <>
-HH_INLINE V16x16U LoadUnaligned(const V16x16U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V16x16U(_mm256_loadu_si256(p));
-}
-template <>
-HH_INLINE V8x32U LoadUnaligned(const V8x32U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V8x32U(_mm256_loadu_si256(p));
-}
-template <>
-HH_INLINE V4x64U LoadUnaligned(const V4x64U::T* const HH_RESTRICT from) {
- const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
- return V4x64U(_mm256_loadu_si256(p));
-}
-template <>
-HH_INLINE V8x32F LoadUnaligned(const V8x32F::T* const HH_RESTRICT from) {
- return V8x32F(_mm256_loadu_ps(from));
-}
-template <>
-HH_INLINE V4x64F LoadUnaligned(const V4x64F::T* const HH_RESTRICT from) {
- return V4x64F(_mm256_loadu_pd(from));
-}
-
-// "to" must be vector-aligned.
-template <typename T>
-HH_INLINE void Store(const V256<T>& v, T* const HH_RESTRICT to) {
- _mm256_store_si256(reinterpret_cast<__m256i * HH_RESTRICT>(to), v);
-}
-HH_INLINE void Store(const V256<float>& v, float* const HH_RESTRICT to) {
- _mm256_store_ps(to, v);
-}
-HH_INLINE void Store(const V256<double>& v, double* const HH_RESTRICT to) {
- _mm256_store_pd(to, v);
-}
-
-template <typename T>
-HH_INLINE void StoreUnaligned(const V256<T>& v, T* const HH_RESTRICT to) {
- _mm256_storeu_si256(reinterpret_cast<__m256i * HH_RESTRICT>(to), v);
-}
-HH_INLINE void StoreUnaligned(const V256<float>& v,
- float* const HH_RESTRICT to) {
- _mm256_storeu_ps(to, v);
-}
-HH_INLINE void StoreUnaligned(const V256<double>& v,
- double* const HH_RESTRICT to) {
- _mm256_storeu_pd(to, v);
-}
-
-// Writes directly to (aligned) memory, bypassing the cache. This is useful for
-// data that will not be read again in the near future.
-template <typename T>
-HH_INLINE void Stream(const V256<T>& v, T* const HH_RESTRICT to) {
- _mm256_stream_si256(reinterpret_cast<__m256i * HH_RESTRICT>(to), v);
-}
-HH_INLINE void Stream(const V256<float>& v, float* const HH_RESTRICT to) {
- _mm256_stream_ps(to, v);
-}
-HH_INLINE void Stream(const V256<double>& v, double* const HH_RESTRICT to) {
- _mm256_stream_pd(to, v);
-}
-
-// Miscellaneous functions.
-
-template <typename T>
-HH_INLINE V256<T> RotateLeft(const V256<T>& v, const int count) {
- constexpr size_t num_bits = sizeof(T) * 8;
- return (v << count) | (v >> (num_bits - count));
-}
-
-template <typename T>
-HH_INLINE V256<T> AndNot(const V256<T>& neg_mask, const V256<T>& values) {
- return V256<T>(_mm256_andnot_si256(neg_mask, values));
-}
-template <>
-HH_INLINE V256<float> AndNot(const V256<float>& neg_mask,
- const V256<float>& values) {
- return V256<float>(_mm256_andnot_ps(neg_mask, values));
-}
-template <>
-HH_INLINE V256<double> AndNot(const V256<double>& neg_mask,
- const V256<double>& values) {
- return V256<double>(_mm256_andnot_pd(neg_mask, values));
-}
-
-HH_INLINE V8x32F Select(const V8x32F& a, const V8x32F& b, const V8x32F& mask) {
- return V8x32F(_mm256_blendv_ps(a, b, mask));
-}
-
-HH_INLINE V4x64F Select(const V4x64F& a, const V4x64F& b, const V4x64F& mask) {
- return V4x64F(_mm256_blendv_pd(a, b, mask));
-}
-
-// Min/Max
-
-HH_INLINE V32x8U Min(const V32x8U& v0, const V32x8U& v1) {
- return V32x8U(_mm256_min_epu8(v0, v1));
-}
-
-HH_INLINE V32x8U Max(const V32x8U& v0, const V32x8U& v1) {
- return V32x8U(_mm256_max_epu8(v0, v1));
-}
-
-HH_INLINE V16x16U Min(const V16x16U& v0, const V16x16U& v1) {
- return V16x16U(_mm256_min_epu16(v0, v1));
-}
-
-HH_INLINE V16x16U Max(const V16x16U& v0, const V16x16U& v1) {
- return V16x16U(_mm256_max_epu16(v0, v1));
-}
-
-HH_INLINE V8x32U Min(const V8x32U& v0, const V8x32U& v1) {
- return V8x32U(_mm256_min_epu32(v0, v1));
-}
-
-HH_INLINE V8x32U Max(const V8x32U& v0, const V8x32U& v1) {
- return V8x32U(_mm256_max_epu32(v0, v1));
-}
-
-HH_INLINE V8x32F Min(const V8x32F& v0, const V8x32F& v1) {
- return V8x32F(_mm256_min_ps(v0, v1));
-}
-
-HH_INLINE V8x32F Max(const V8x32F& v0, const V8x32F& v1) {
- return V8x32F(_mm256_max_ps(v0, v1));
-}
-
-HH_INLINE V4x64F Min(const V4x64F& v0, const V4x64F& v1) {
- return V4x64F(_mm256_min_pd(v0, v1));
-}
-
-HH_INLINE V4x64F Max(const V4x64F& v0, const V4x64F& v1) {
- return V4x64F(_mm256_max_pd(v0, v1));
-}
-
-} // namespace HH_TARGET_NAME
-} // namespace highwayhash
-
-#endif // HH_DISABLE_TARGET_SPECIFIC
-#endif // HIGHWAYHASH_VECTOR256_H_
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_VECTOR256_H_
+#define HIGHWAYHASH_VECTOR256_H_
+
+// Defines SIMD vector classes ("V4x64U") with overloaded arithmetic operators:
+// const V4x64U masked_sum = (a + b) & m;
+// This is shorter and more readable than compiler intrinsics:
+// const __m256i masked_sum = _mm256_and_si256(_mm256_add_epi64(a, b), m);
+// There is typically no runtime cost for these abstractions.
+//
+// The naming convention is VNxBBT where N is the number of lanes, BB the
+// number of bits per lane and T is the lane type: unsigned integer (U),
+// signed integer (I), or floating-point (F).
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/compiler_specific.h"
+
+// For auto-dependency generation, we need to include all headers but not their
+// contents (otherwise compilation fails because -mavx2 is not specified).
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+
+// (This include cannot be moved within a namespace due to conflicts with
+// other system headers; see the comment in hh_sse41.h.)
+#include <immintrin.h>
+
+namespace highwayhash {
+// To prevent ODR violations when including this from multiple translation
+// units (TU) that are compiled with different flags, the contents must reside
+// in a namespace whose name is unique to the TU. NOTE: this behavior is
+// incompatible with precompiled modules and requires textual inclusion instead.
+namespace HH_TARGET_NAME {
+
+// Primary template for 256-bit AVX2 vectors; only specializations are used.
+template <typename T>
+class V256 {};
+
+template <>
+class V256<uint8_t> {
+ public:
+ using Intrinsic = __m256i;
+ using T = uint8_t;
+ static constexpr size_t N = 32;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V256() {}
+
+ // Broadcasts i to all lanes.
+ HH_INLINE explicit V256(T i)
+ : v_(_mm256_broadcastb_epi8(_mm_cvtsi32_si128(i))) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
+ HH_INLINE V256& operator=(const V256& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V256(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V256& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V256 operator==(const V256& other) const {
+ return V256(_mm256_cmpeq_epi8(v_, other.v_));
+ }
+
+ HH_INLINE V256& operator+=(const V256& other) {
+ v_ = _mm256_add_epi8(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator-=(const V256& other) {
+ v_ = _mm256_sub_epi8(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator&=(const V256& other) {
+ v_ = _mm256_and_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator|=(const V256& other) {
+ v_ = _mm256_or_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator^=(const V256& other) {
+ v_ = _mm256_xor_si256(v_, other.v_);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V256<uint16_t> {
+ public:
+ using Intrinsic = __m256i;
+ using T = uint16_t;
+ static constexpr size_t N = 16;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V256() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V256(T p_F, T p_E, T p_D, T p_C, T p_B, T p_A, T p_9, T p_8, T p_7,
+ T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm256_set_epi16(p_F, p_E, p_D, p_C, p_B, p_A, p_9, p_8, p_7, p_6,
+ p_5, p_4, p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts i to all lanes.
+ HH_INLINE explicit V256(T i)
+ : v_(_mm256_broadcastw_epi16(_mm_cvtsi32_si128(i))) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
+ HH_INLINE V256& operator=(const V256& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V256(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V256& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V256 operator==(const V256& other) const {
+ return V256(_mm256_cmpeq_epi16(v_, other.v_));
+ }
+
+ HH_INLINE V256& operator+=(const V256& other) {
+ v_ = _mm256_add_epi16(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator-=(const V256& other) {
+ v_ = _mm256_sub_epi16(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator&=(const V256& other) {
+ v_ = _mm256_and_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator|=(const V256& other) {
+ v_ = _mm256_or_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator^=(const V256& other) {
+ v_ = _mm256_xor_si256(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator<<=(const int count) {
+ v_ = _mm256_slli_epi16(v_, count);
+ return *this;
+ }
+
+ HH_INLINE V256& operator>>=(const int count) {
+ v_ = _mm256_srli_epi16(v_, count);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V256<uint32_t> {
+ public:
+ using Intrinsic = __m256i;
+ using T = uint32_t;
+ static constexpr size_t N = 8;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V256() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V256(T p_7, T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm256_set_epi32(p_7, p_6, p_5, p_4, p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts i to all lanes.
+ HH_INLINE explicit V256(T i)
+ : v_(_mm256_broadcastd_epi32(_mm_cvtsi32_si128(i))) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
+ HH_INLINE V256& operator=(const V256& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V256(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V256& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V256 operator==(const V256& other) const {
+ return V256(_mm256_cmpeq_epi32(v_, other.v_));
+ }
+
+ HH_INLINE V256& operator+=(const V256& other) {
+ v_ = _mm256_add_epi32(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator-=(const V256& other) {
+ v_ = _mm256_sub_epi32(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator&=(const V256& other) {
+ v_ = _mm256_and_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator|=(const V256& other) {
+ v_ = _mm256_or_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator^=(const V256& other) {
+ v_ = _mm256_xor_si256(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator<<=(const int count) {
+ v_ = _mm256_slli_epi32(v_, count);
+ return *this;
+ }
+
+ HH_INLINE V256& operator>>=(const int count) {
+ v_ = _mm256_srli_epi32(v_, count);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V256<uint64_t> {
+ public:
+ using Intrinsic = __m256i;
+ using T = uint64_t;
+ static constexpr size_t N = 4;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V256() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V256(T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm256_set_epi64x(p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts i to all lanes.
+ HH_INLINE explicit V256(T i)
+ : v_(_mm256_broadcastq_epi64(_mm_cvtsi64_si128(i))) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
+ HH_INLINE V256& operator=(const V256& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V256(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V256& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ // There are no greater-than comparison instructions for unsigned T.
+ HH_INLINE V256 operator==(const V256& other) const {
+ return V256(_mm256_cmpeq_epi64(v_, other.v_));
+ }
+
+ HH_INLINE V256& operator+=(const V256& other) {
+ v_ = _mm256_add_epi64(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator-=(const V256& other) {
+ v_ = _mm256_sub_epi64(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator&=(const V256& other) {
+ v_ = _mm256_and_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator|=(const V256& other) {
+ v_ = _mm256_or_si256(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator^=(const V256& other) {
+ v_ = _mm256_xor_si256(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator<<=(const int count) {
+ v_ = _mm256_slli_epi64(v_, count);
+ return *this;
+ }
+
+ HH_INLINE V256& operator>>=(const int count) {
+ v_ = _mm256_srli_epi64(v_, count);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V256<float> {
+ public:
+ using Intrinsic = __m256;
+ using T = float;
+ static constexpr size_t N = 8;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V256() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V256(T p_7, T p_6, T p_5, T p_4, T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm256_set_ps(p_7, p_6, p_5, p_4, p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts to all lanes.
+ HH_INLINE explicit V256(T f) : v_(_mm256_set1_ps(f)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
+ HH_INLINE V256& operator=(const V256& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V256(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V256& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ HH_INLINE V256 operator==(const V256& other) const {
+ return V256(_mm256_cmp_ps(v_, other.v_, 0));
+ }
+ HH_INLINE V256 operator<(const V256& other) const {
+ return V256(_mm256_cmp_ps(v_, other.v_, 1));
+ }
+ HH_INLINE V256 operator>(const V256& other) const {
+ return V256(_mm256_cmp_ps(other.v_, v_, 1));
+ }
+
+ HH_INLINE V256& operator*=(const V256& other) {
+ v_ = _mm256_mul_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator/=(const V256& other) {
+ v_ = _mm256_div_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator+=(const V256& other) {
+ v_ = _mm256_add_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator-=(const V256& other) {
+ v_ = _mm256_sub_ps(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator&=(const V256& other) {
+ v_ = _mm256_and_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator|=(const V256& other) {
+ v_ = _mm256_or_ps(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator^=(const V256& other) {
+ v_ = _mm256_xor_ps(v_, other.v_);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+template <>
+class V256<double> {
+ public:
+ using Intrinsic = __m256d;
+ using T = double;
+ static constexpr size_t N = 4;
+
+ // Leaves v_ uninitialized - typically used for output parameters.
+ HH_INLINE V256() {}
+
+ // Lane 0 (p_0) is the lowest.
+ HH_INLINE V256(T p_3, T p_2, T p_1, T p_0)
+ : v_(_mm256_set_pd(p_3, p_2, p_1, p_0)) {}
+
+ // Broadcasts to all lanes.
+ HH_INLINE explicit V256(T f) : v_(_mm256_set1_pd(f)) {}
+
+ // Copy from other vector.
+ HH_INLINE explicit V256(const V256& other) : v_(other.v_) {}
+ template <typename U>
+ HH_INLINE explicit V256(const V256<U>& other) : v_(other) {}
+ HH_INLINE V256& operator=(const V256& other) {
+ v_ = other.v_;
+ return *this;
+ }
+
+ // Convert from/to intrinsics.
+ HH_INLINE V256(const Intrinsic& v) : v_(v) {}
+ HH_INLINE V256& operator=(const Intrinsic& v) {
+ v_ = v;
+ return *this;
+ }
+ HH_INLINE operator Intrinsic() const { return v_; }
+
+ HH_INLINE V256 operator==(const V256& other) const {
+ return V256(_mm256_cmp_pd(v_, other.v_, 0));
+ }
+ HH_INLINE V256 operator<(const V256& other) const {
+ return V256(_mm256_cmp_pd(v_, other.v_, 1));
+ }
+ HH_INLINE V256 operator>(const V256& other) const {
+ return V256(_mm256_cmp_pd(other.v_, v_, 1));
+ }
+
+ HH_INLINE V256& operator*=(const V256& other) {
+ v_ = _mm256_mul_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator/=(const V256& other) {
+ v_ = _mm256_div_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator+=(const V256& other) {
+ v_ = _mm256_add_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator-=(const V256& other) {
+ v_ = _mm256_sub_pd(v_, other.v_);
+ return *this;
+ }
+
+ HH_INLINE V256& operator&=(const V256& other) {
+ v_ = _mm256_and_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator|=(const V256& other) {
+ v_ = _mm256_or_pd(v_, other.v_);
+ return *this;
+ }
+ HH_INLINE V256& operator^=(const V256& other) {
+ v_ = _mm256_xor_pd(v_, other.v_);
+ return *this;
+ }
+
+ private:
+ Intrinsic v_;
+};
+
+// Nonmember functions for any V256 via member functions.
+
+template <typename T>
+HH_INLINE V256<T> operator*(const V256<T>& left, const V256<T>& right) {
+ V256<T> t(left);
+ return t *= right;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator/(const V256<T>& left, const V256<T>& right) {
+ V256<T> t(left);
+ return t /= right;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator+(const V256<T>& left, const V256<T>& right) {
+ V256<T> t(left);
+ return t += right;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator-(const V256<T>& left, const V256<T>& right) {
+ V256<T> t(left);
+ return t -= right;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator&(const V256<T>& left, const V256<T>& right) {
+ V256<T> t(left);
+ return t &= right;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator|(const V256<T> left, const V256<T>& right) {
+ V256<T> t(left);
+ return t |= right;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator^(const V256<T>& left, const V256<T>& right) {
+ V256<T> t(left);
+ return t ^= right;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator<<(const V256<T>& v, const int count) {
+ V256<T> t(v);
+ return t <<= count;
+}
+
+template <typename T>
+HH_INLINE V256<T> operator>>(const V256<T>& v, const int count) {
+ V256<T> t(v);
+ return t >>= count;
+}
+
+// We do not provide operator<<(V, __m128i) because it has 4 cycle latency
+// (to broadcast the shift count). It is faster to use sllv_epi64 etc. instead.
+
+using V32x8U = V256<uint8_t>;
+using V16x16U = V256<uint16_t>;
+using V8x32U = V256<uint32_t>;
+using V4x64U = V256<uint64_t>;
+using V8x32F = V256<float>;
+using V4x64F = V256<double>;
+
+// Load/Store for any V256.
+
+// We differentiate between targets' vector types via template specialization.
+// Calling Load<V>(floats) is more natural than Load(V8x32F(), floats) and may
+// generate better code in unoptimized builds. Only declare the primary
+// templates to avoid needing mutual exclusion with vector128.
+
+template <class V>
+HH_INLINE V Load(const typename V::T* const HH_RESTRICT from);
+
+template <class V>
+HH_INLINE V LoadUnaligned(const typename V::T* const HH_RESTRICT from);
+
+template <>
+HH_INLINE V32x8U Load(const V32x8U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V32x8U(_mm256_load_si256(p));
+}
+template <>
+HH_INLINE V16x16U Load(const V16x16U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V16x16U(_mm256_load_si256(p));
+}
+template <>
+HH_INLINE V8x32U Load(const V8x32U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V8x32U(_mm256_load_si256(p));
+}
+template <>
+HH_INLINE V4x64U Load(const V4x64U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V4x64U(_mm256_load_si256(p));
+}
+template <>
+HH_INLINE V8x32F Load(const V8x32F::T* const HH_RESTRICT from) {
+ return V8x32F(_mm256_load_ps(from));
+}
+template <>
+HH_INLINE V4x64F Load(const V4x64F::T* const HH_RESTRICT from) {
+ return V4x64F(_mm256_load_pd(from));
+}
+
+template <>
+HH_INLINE V32x8U LoadUnaligned(const V32x8U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V32x8U(_mm256_loadu_si256(p));
+}
+template <>
+HH_INLINE V16x16U LoadUnaligned(const V16x16U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V16x16U(_mm256_loadu_si256(p));
+}
+template <>
+HH_INLINE V8x32U LoadUnaligned(const V8x32U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V8x32U(_mm256_loadu_si256(p));
+}
+template <>
+HH_INLINE V4x64U LoadUnaligned(const V4x64U::T* const HH_RESTRICT from) {
+ const __m256i* const HH_RESTRICT p = reinterpret_cast<const __m256i*>(from);
+ return V4x64U(_mm256_loadu_si256(p));
+}
+template <>
+HH_INLINE V8x32F LoadUnaligned(const V8x32F::T* const HH_RESTRICT from) {
+ return V8x32F(_mm256_loadu_ps(from));
+}
+template <>
+HH_INLINE V4x64F LoadUnaligned(const V4x64F::T* const HH_RESTRICT from) {
+ return V4x64F(_mm256_loadu_pd(from));
+}
+
+// "to" must be vector-aligned.
+template <typename T>
+HH_INLINE void Store(const V256<T>& v, T* const HH_RESTRICT to) {
+ _mm256_store_si256(reinterpret_cast<__m256i * HH_RESTRICT>(to), v);
+}
+HH_INLINE void Store(const V256<float>& v, float* const HH_RESTRICT to) {
+ _mm256_store_ps(to, v);
+}
+HH_INLINE void Store(const V256<double>& v, double* const HH_RESTRICT to) {
+ _mm256_store_pd(to, v);
+}
+
+template <typename T>
+HH_INLINE void StoreUnaligned(const V256<T>& v, T* const HH_RESTRICT to) {
+ _mm256_storeu_si256(reinterpret_cast<__m256i * HH_RESTRICT>(to), v);
+}
+HH_INLINE void StoreUnaligned(const V256<float>& v,
+ float* const HH_RESTRICT to) {
+ _mm256_storeu_ps(to, v);
+}
+HH_INLINE void StoreUnaligned(const V256<double>& v,
+ double* const HH_RESTRICT to) {
+ _mm256_storeu_pd(to, v);
+}
+
+// Writes directly to (aligned) memory, bypassing the cache. This is useful for
+// data that will not be read again in the near future.
+template <typename T>
+HH_INLINE void Stream(const V256<T>& v, T* const HH_RESTRICT to) {
+ _mm256_stream_si256(reinterpret_cast<__m256i * HH_RESTRICT>(to), v);
+}
+HH_INLINE void Stream(const V256<float>& v, float* const HH_RESTRICT to) {
+ _mm256_stream_ps(to, v);
+}
+HH_INLINE void Stream(const V256<double>& v, double* const HH_RESTRICT to) {
+ _mm256_stream_pd(to, v);
+}
+
+// Miscellaneous functions.
+
+template <typename T>
+HH_INLINE V256<T> RotateLeft(const V256<T>& v, const int count) {
+ constexpr size_t num_bits = sizeof(T) * 8;
+ return (v << count) | (v >> (num_bits - count));
+}
+
+template <typename T>
+HH_INLINE V256<T> AndNot(const V256<T>& neg_mask, const V256<T>& values) {
+ return V256<T>(_mm256_andnot_si256(neg_mask, values));
+}
+template <>
+HH_INLINE V256<float> AndNot(const V256<float>& neg_mask,
+ const V256<float>& values) {
+ return V256<float>(_mm256_andnot_ps(neg_mask, values));
+}
+template <>
+HH_INLINE V256<double> AndNot(const V256<double>& neg_mask,
+ const V256<double>& values) {
+ return V256<double>(_mm256_andnot_pd(neg_mask, values));
+}
+
+HH_INLINE V8x32F Select(const V8x32F& a, const V8x32F& b, const V8x32F& mask) {
+ return V8x32F(_mm256_blendv_ps(a, b, mask));
+}
+
+HH_INLINE V4x64F Select(const V4x64F& a, const V4x64F& b, const V4x64F& mask) {
+ return V4x64F(_mm256_blendv_pd(a, b, mask));
+}
+
+// Min/Max
+
+HH_INLINE V32x8U Min(const V32x8U& v0, const V32x8U& v1) {
+ return V32x8U(_mm256_min_epu8(v0, v1));
+}
+
+HH_INLINE V32x8U Max(const V32x8U& v0, const V32x8U& v1) {
+ return V32x8U(_mm256_max_epu8(v0, v1));
+}
+
+HH_INLINE V16x16U Min(const V16x16U& v0, const V16x16U& v1) {
+ return V16x16U(_mm256_min_epu16(v0, v1));
+}
+
+HH_INLINE V16x16U Max(const V16x16U& v0, const V16x16U& v1) {
+ return V16x16U(_mm256_max_epu16(v0, v1));
+}
+
+HH_INLINE V8x32U Min(const V8x32U& v0, const V8x32U& v1) {
+ return V8x32U(_mm256_min_epu32(v0, v1));
+}
+
+HH_INLINE V8x32U Max(const V8x32U& v0, const V8x32U& v1) {
+ return V8x32U(_mm256_max_epu32(v0, v1));
+}
+
+HH_INLINE V8x32F Min(const V8x32F& v0, const V8x32F& v1) {
+ return V8x32F(_mm256_min_ps(v0, v1));
+}
+
+HH_INLINE V8x32F Max(const V8x32F& v0, const V8x32F& v1) {
+ return V8x32F(_mm256_max_ps(v0, v1));
+}
+
+HH_INLINE V4x64F Min(const V4x64F& v0, const V4x64F& v1) {
+ return V4x64F(_mm256_min_pd(v0, v1));
+}
+
+HH_INLINE V4x64F Max(const V4x64F& v0, const V4x64F& v1) {
+ return V4x64F(_mm256_max_pd(v0, v1));
+}
+
+} // namespace HH_TARGET_NAME
+} // namespace highwayhash
+
+#endif // HH_DISABLE_TARGET_SPECIFIC
+#endif // HIGHWAYHASH_VECTOR256_H_
diff --git a/contrib/libs/highwayhash/highwayhash/vector_test.cc b/contrib/libs/highwayhash/highwayhash/vector_test.cc
index a8bdfacac2..d9f02567be 100644
--- a/contrib/libs/highwayhash/highwayhash/vector_test.cc
+++ b/contrib/libs/highwayhash/highwayhash/vector_test.cc
@@ -1,59 +1,59 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <stdio.h>
-
-#ifdef HH_GOOGLETEST
-#include "testing/base/public/gmock.h"
-#include "testing/base/public/gunit.h"
-#endif
-
-#include "highwayhash/instruction_sets.h"
-#include "highwayhash/vector_test_target.h"
-
-namespace highwayhash {
-namespace {
-
-void NotifyFailure(const char* target, const size_t size) {
- const size_t lane_bits = (size & 0xFF) * 8;
- const size_t lane_index = size >> 8;
-#ifdef HH_GOOGLETEST
- EXPECT_TRUE(false) << "VectorTest failed for " << target << " T=" << lane_bits
- << ", lane " << lane_index;
-#else
- printf("VectorTest failed for %10s T=%zu, lane=%zu\n", target, lane_bits,
- lane_index);
-#endif
-}
-
-void RunTests() {
- const TargetBits tested = InstructionSets::RunAll<VectorTest>(&NotifyFailure);
- HH_TARGET_NAME::ForeachTarget(tested, [](const TargetBits target) {
- printf("%10s: done\n", TargetName(target));
- });
-}
-
-#ifdef HH_GOOGLETEST
-TEST(VectorTest, Run) { RunTests(); }
-#endif
-
-} // namespace
-} // namespace highwayhash
-
-#ifndef HH_GOOGLETEST
-int main(int argc, char* argv[]) {
- highwayhash::RunTests();
- return 0;
-}
-#endif
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stdio.h>
+
+#ifdef HH_GOOGLETEST
+#include "testing/base/public/gmock.h"
+#include "testing/base/public/gunit.h"
+#endif
+
+#include "highwayhash/instruction_sets.h"
+#include "highwayhash/vector_test_target.h"
+
+namespace highwayhash {
+namespace {
+
+void NotifyFailure(const char* target, const size_t size) {
+ const size_t lane_bits = (size & 0xFF) * 8;
+ const size_t lane_index = size >> 8;
+#ifdef HH_GOOGLETEST
+ EXPECT_TRUE(false) << "VectorTest failed for " << target << " T=" << lane_bits
+ << ", lane " << lane_index;
+#else
+ printf("VectorTest failed for %10s T=%zu, lane=%zu\n", target, lane_bits,
+ lane_index);
+#endif
+}
+
+void RunTests() {
+ const TargetBits tested = InstructionSets::RunAll<VectorTest>(&NotifyFailure);
+ HH_TARGET_NAME::ForeachTarget(tested, [](const TargetBits target) {
+ printf("%10s: done\n", TargetName(target));
+ });
+}
+
+#ifdef HH_GOOGLETEST
+TEST(VectorTest, Run) { RunTests(); }
+#endif
+
+} // namespace
+} // namespace highwayhash
+
+#ifndef HH_GOOGLETEST
+int main(int argc, char* argv[]) {
+ highwayhash::RunTests();
+ return 0;
+}
+#endif
diff --git a/contrib/libs/highwayhash/highwayhash/vector_test_avx2.cc b/contrib/libs/highwayhash/highwayhash/vector_test_avx2.cc
index 86a017f7f5..30ce2c992c 100644
--- a/contrib/libs/highwayhash/highwayhash/vector_test_avx2.cc
+++ b/contrib/libs/highwayhash/highwayhash/vector_test_avx2.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME AVX2
-#include "highwayhash/vector_test_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME AVX2
+#include "highwayhash/vector_test_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/vector_test_portable.cc b/contrib/libs/highwayhash/highwayhash/vector_test_portable.cc
index df23c28070..a742b4be80 100644
--- a/contrib/libs/highwayhash/highwayhash/vector_test_portable.cc
+++ b/contrib/libs/highwayhash/highwayhash/vector_test_portable.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME Portable
-#include "highwayhash/vector_test_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME Portable
+#include "highwayhash/vector_test_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/vector_test_sse41.cc b/contrib/libs/highwayhash/highwayhash/vector_test_sse41.cc
index 4d6fbee2b4..80e11b5d9c 100644
--- a/contrib/libs/highwayhash/highwayhash/vector_test_sse41.cc
+++ b/contrib/libs/highwayhash/highwayhash/vector_test_sse41.cc
@@ -1,19 +1,19 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#define HH_TARGET_NAME SSE41
-#include "highwayhash/vector_test_target.cc"
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#define HH_TARGET_NAME SSE41
+#include "highwayhash/vector_test_target.cc"
diff --git a/contrib/libs/highwayhash/highwayhash/vector_test_target.cc b/contrib/libs/highwayhash/highwayhash/vector_test_target.cc
index 16d6ef1825..f9eed7f59a 100644
--- a/contrib/libs/highwayhash/highwayhash/vector_test_target.cc
+++ b/contrib/libs/highwayhash/highwayhash/vector_test_target.cc
@@ -1,220 +1,220 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// WARNING: this is a "restricted" source file; avoid including any headers
-// unless they are also restricted. See arch_specific.h for details.
-
-#include "highwayhash/vector_test_target.h"
-
-#include "highwayhash/arch_specific.h"
-
-#if HH_TARGET == HH_TARGET_AVX2
-#include "highwayhash/vector256.h"
-#elif HH_TARGET == HH_TARGET_SSE41
-#include "highwayhash/vector128.h"
-#elif HH_TARGET == HH_TARGET_Portable
-#include "highwayhash/scalar.h"
-#else
-#error "Unknown target, add its include here."
-#endif
-
-#ifndef HH_DISABLE_TARGET_SPECIFIC
-namespace highwayhash {
-namespace HH_TARGET_NAME {
-namespace {
-
-#if HH_TARGET == HH_TARGET_AVX2
-template <typename T>
-using V = V256<T>;
-#elif HH_TARGET == HH_TARGET_SSE41
-template <typename T>
-using V = V128<T>;
-#elif HH_TARGET == HH_TARGET_Portable
-template <typename T>
-using V = Scalar<T>;
-#else
-#error "Unknown target, add its vector typedef here."
-#endif
-
-template <class T>
-void NotifyIfUnequal(const V<T>& v, const T expected, const HHNotify notify) {
- T lanes[V<T>::N] HH_ALIGNAS(32);
- Store(v, lanes);
- for (size_t i = 0; i < V<T>::N; ++i) {
- if (lanes[i] != expected) {
- notify(TargetName(HH_TARGET), (i << 8) | sizeof(T));
- }
- }
-}
-
-template <class T>
-void NotifyIfUnequal(const T& t, const T expected, const HHNotify notify) {
- if (t != expected) {
- notify(TargetName(HH_TARGET), sizeof(T));
- }
-}
-
-// MaxValue<T>()() replaces std::numeric_limits<T>::max().
-template <typename T>
-struct MaxValue;
-template <>
-struct MaxValue<uint8_t> {
- constexpr uint8_t operator()() const { return 0xFFu; }
-};
-template <>
-struct MaxValue<uint16_t> {
- constexpr uint16_t operator()() const { return 0xFFFFu; }
-};
-template <>
-struct MaxValue<uint32_t> {
- constexpr uint32_t operator()() const { return 0xFFFFFFFFu; }
-};
-template <>
-struct MaxValue<uint64_t> {
- constexpr uint64_t operator()() const { return 0xFFFFFFFFFFFFFFFFull; }
-};
-
-template <typename T>
-void TestMembersAndBinaryOperatorsExceptShifts(const HHNotify notify) {
- // uninitialized
- V<T> v;
-
- // broadcast
- const V<T> v2(2);
- NotifyIfUnequal(v2, T(2), notify);
-
- // assign from V
- const V<T> v3(3);
- V<T> v3b;
- v3b = v3;
- NotifyIfUnequal(v3b, T(3), notify);
-
- // equal
- const V<T> veq(v3 == v3b);
- NotifyIfUnequal(veq, MaxValue<T>()(), notify);
-
- // Copying to, and constructing from intrinsic yields same result.
- typename V<T>::Intrinsic nv2 = v2;
- V<T> v2b(nv2);
- NotifyIfUnequal(v2b, T(2), notify);
-
- // .. assignment also works.
- V<T> v2c;
- v2c = nv2;
- NotifyIfUnequal(v2c, T(2), notify);
-
- const V<T> add = v2 + v3;
- NotifyIfUnequal(add, T(5), notify);
-
- const V<T> sub = v3 - v2;
- NotifyIfUnequal(sub, T(1), notify);
-
- const V<T> vand = v3 & v2;
- NotifyIfUnequal(vand, T(2), notify);
-
- const V<T> vor = add | v2;
- NotifyIfUnequal(vor, T(7), notify);
-
- const V<T> vxor = v3 ^ v2;
- NotifyIfUnequal(vxor, T(1), notify);
-}
-
-// SSE does not allow shifting uint8_t, so instantiate for all other types.
-template <class T>
-void TestShifts(const HHNotify notify) {
- const V<T> v1(1);
- // Shifting out of right side => zero
- NotifyIfUnequal(v1 >> 1, T(0), notify);
-
- // Simple left shift
- NotifyIfUnequal(v1 << 1, T(2), notify);
-
- // Sign bit
- constexpr int kSign = (sizeof(T) * 8) - 1;
- constexpr T max = MaxValue<T>()();
- constexpr T sign = ~(max >> 1);
- NotifyIfUnequal(v1 << kSign, sign, notify);
-
- // Shifting out of left side => zero
- NotifyIfUnequal(v1 << (kSign + 1), T(0), notify);
-}
-
-template <class T>
-void TestLoadStore(const HHNotify notify) {
- const size_t n = V<T>::N;
- T lanes[2 * n] HH_ALIGNAS(32);
- for (size_t i = 0; i < n; ++i) {
- lanes[i] = 4;
- }
- for (size_t i = n; i < 2 * n; ++i) {
- lanes[i] = 5;
- }
- // Aligned load
- const V<T> v4 = Load<V<T>>(lanes);
- NotifyIfUnequal(v4, T(4), notify);
-
- // Aligned store
- T lanes4[n] HH_ALIGNAS(32);
- Store(v4, lanes4);
- NotifyIfUnequal(Load<V<T>>(lanes4), T(4), notify);
-
- // Unaligned load
- const V<T> vu = LoadUnaligned<V<T>>(lanes + 1);
- Store(vu, lanes4);
- NotifyIfUnequal(lanes4[n - 1], T(5), notify);
- for (size_t i = 1; i < n - 1; ++i) {
- NotifyIfUnequal(lanes4[i], T(4), notify);
- }
-
- // Unaligned store
- StoreUnaligned(v4, lanes + n / 2);
- size_t i;
- for (i = 0; i < 3 * n / 2; ++i) {
- NotifyIfUnequal(lanes[i], T(4), notify);
- }
- // Subsequent values remain unchanged.
- for (; i < 2 * n; ++i) {
- NotifyIfUnequal(lanes[i], T(5), notify);
- }
-}
-
-void TestAll(const HHNotify notify) {
- TestMembersAndBinaryOperatorsExceptShifts<uint8_t>(notify);
- TestMembersAndBinaryOperatorsExceptShifts<uint16_t>(notify);
- TestMembersAndBinaryOperatorsExceptShifts<uint32_t>(notify);
- TestMembersAndBinaryOperatorsExceptShifts<uint64_t>(notify);
-
- TestShifts<uint16_t>(notify);
- TestShifts<uint32_t>(notify);
- TestShifts<uint64_t>(notify);
-
- TestLoadStore<uint8_t>(notify);
- TestLoadStore<uint16_t>(notify);
- TestLoadStore<uint32_t>(notify);
- TestLoadStore<uint64_t>(notify);
-}
-
-} // namespace
-} // namespace HH_TARGET_NAME
-
-template <TargetBits Target>
-void VectorTest<Target>::operator()(const HHNotify notify) const {
- HH_TARGET_NAME::TestAll(notify);
-}
-
-// Instantiate for the current target.
-template struct VectorTest<HH_TARGET>;
-
-} // namespace highwayhash
-#endif // HH_DISABLE_TARGET_SPECIFIC
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// WARNING: this is a "restricted" source file; avoid including any headers
+// unless they are also restricted. See arch_specific.h for details.
+
+#include "highwayhash/vector_test_target.h"
+
+#include "highwayhash/arch_specific.h"
+
+#if HH_TARGET == HH_TARGET_AVX2
+#include "highwayhash/vector256.h"
+#elif HH_TARGET == HH_TARGET_SSE41
+#include "highwayhash/vector128.h"
+#elif HH_TARGET == HH_TARGET_Portable
+#include "highwayhash/scalar.h"
+#else
+#error "Unknown target, add its include here."
+#endif
+
+#ifndef HH_DISABLE_TARGET_SPECIFIC
+namespace highwayhash {
+namespace HH_TARGET_NAME {
+namespace {
+
+#if HH_TARGET == HH_TARGET_AVX2
+template <typename T>
+using V = V256<T>;
+#elif HH_TARGET == HH_TARGET_SSE41
+template <typename T>
+using V = V128<T>;
+#elif HH_TARGET == HH_TARGET_Portable
+template <typename T>
+using V = Scalar<T>;
+#else
+#error "Unknown target, add its vector typedef here."
+#endif
+
+template <class T>
+void NotifyIfUnequal(const V<T>& v, const T expected, const HHNotify notify) {
+ T lanes[V<T>::N] HH_ALIGNAS(32);
+ Store(v, lanes);
+ for (size_t i = 0; i < V<T>::N; ++i) {
+ if (lanes[i] != expected) {
+ notify(TargetName(HH_TARGET), (i << 8) | sizeof(T));
+ }
+ }
+}
+
+template <class T>
+void NotifyIfUnequal(const T& t, const T expected, const HHNotify notify) {
+ if (t != expected) {
+ notify(TargetName(HH_TARGET), sizeof(T));
+ }
+}
+
+// MaxValue<T>()() replaces std::numeric_limits<T>::max().
+template <typename T>
+struct MaxValue;
+template <>
+struct MaxValue<uint8_t> {
+ constexpr uint8_t operator()() const { return 0xFFu; }
+};
+template <>
+struct MaxValue<uint16_t> {
+ constexpr uint16_t operator()() const { return 0xFFFFu; }
+};
+template <>
+struct MaxValue<uint32_t> {
+ constexpr uint32_t operator()() const { return 0xFFFFFFFFu; }
+};
+template <>
+struct MaxValue<uint64_t> {
+ constexpr uint64_t operator()() const { return 0xFFFFFFFFFFFFFFFFull; }
+};
+
+template <typename T>
+void TestMembersAndBinaryOperatorsExceptShifts(const HHNotify notify) {
+ // uninitialized
+ V<T> v;
+
+ // broadcast
+ const V<T> v2(2);
+ NotifyIfUnequal(v2, T(2), notify);
+
+ // assign from V
+ const V<T> v3(3);
+ V<T> v3b;
+ v3b = v3;
+ NotifyIfUnequal(v3b, T(3), notify);
+
+ // equal
+ const V<T> veq(v3 == v3b);
+ NotifyIfUnequal(veq, MaxValue<T>()(), notify);
+
+ // Copying to, and constructing from intrinsic yields same result.
+ typename V<T>::Intrinsic nv2 = v2;
+ V<T> v2b(nv2);
+ NotifyIfUnequal(v2b, T(2), notify);
+
+ // .. assignment also works.
+ V<T> v2c;
+ v2c = nv2;
+ NotifyIfUnequal(v2c, T(2), notify);
+
+ const V<T> add = v2 + v3;
+ NotifyIfUnequal(add, T(5), notify);
+
+ const V<T> sub = v3 - v2;
+ NotifyIfUnequal(sub, T(1), notify);
+
+ const V<T> vand = v3 & v2;
+ NotifyIfUnequal(vand, T(2), notify);
+
+ const V<T> vor = add | v2;
+ NotifyIfUnequal(vor, T(7), notify);
+
+ const V<T> vxor = v3 ^ v2;
+ NotifyIfUnequal(vxor, T(1), notify);
+}
+
+// SSE does not allow shifting uint8_t, so instantiate for all other types.
+template <class T>
+void TestShifts(const HHNotify notify) {
+ const V<T> v1(1);
+ // Shifting out of right side => zero
+ NotifyIfUnequal(v1 >> 1, T(0), notify);
+
+ // Simple left shift
+ NotifyIfUnequal(v1 << 1, T(2), notify);
+
+ // Sign bit
+ constexpr int kSign = (sizeof(T) * 8) - 1;
+ constexpr T max = MaxValue<T>()();
+ constexpr T sign = ~(max >> 1);
+ NotifyIfUnequal(v1 << kSign, sign, notify);
+
+ // Shifting out of left side => zero
+ NotifyIfUnequal(v1 << (kSign + 1), T(0), notify);
+}
+
+template <class T>
+void TestLoadStore(const HHNotify notify) {
+ const size_t n = V<T>::N;
+ T lanes[2 * n] HH_ALIGNAS(32);
+ for (size_t i = 0; i < n; ++i) {
+ lanes[i] = 4;
+ }
+ for (size_t i = n; i < 2 * n; ++i) {
+ lanes[i] = 5;
+ }
+ // Aligned load
+ const V<T> v4 = Load<V<T>>(lanes);
+ NotifyIfUnequal(v4, T(4), notify);
+
+ // Aligned store
+ T lanes4[n] HH_ALIGNAS(32);
+ Store(v4, lanes4);
+ NotifyIfUnequal(Load<V<T>>(lanes4), T(4), notify);
+
+ // Unaligned load
+ const V<T> vu = LoadUnaligned<V<T>>(lanes + 1);
+ Store(vu, lanes4);
+ NotifyIfUnequal(lanes4[n - 1], T(5), notify);
+ for (size_t i = 1; i < n - 1; ++i) {
+ NotifyIfUnequal(lanes4[i], T(4), notify);
+ }
+
+ // Unaligned store
+ StoreUnaligned(v4, lanes + n / 2);
+ size_t i;
+ for (i = 0; i < 3 * n / 2; ++i) {
+ NotifyIfUnequal(lanes[i], T(4), notify);
+ }
+ // Subsequent values remain unchanged.
+ for (; i < 2 * n; ++i) {
+ NotifyIfUnequal(lanes[i], T(5), notify);
+ }
+}
+
+void TestAll(const HHNotify notify) {
+ TestMembersAndBinaryOperatorsExceptShifts<uint8_t>(notify);
+ TestMembersAndBinaryOperatorsExceptShifts<uint16_t>(notify);
+ TestMembersAndBinaryOperatorsExceptShifts<uint32_t>(notify);
+ TestMembersAndBinaryOperatorsExceptShifts<uint64_t>(notify);
+
+ TestShifts<uint16_t>(notify);
+ TestShifts<uint32_t>(notify);
+ TestShifts<uint64_t>(notify);
+
+ TestLoadStore<uint8_t>(notify);
+ TestLoadStore<uint16_t>(notify);
+ TestLoadStore<uint32_t>(notify);
+ TestLoadStore<uint64_t>(notify);
+}
+
+} // namespace
+} // namespace HH_TARGET_NAME
+
+template <TargetBits Target>
+void VectorTest<Target>::operator()(const HHNotify notify) const {
+ HH_TARGET_NAME::TestAll(notify);
+}
+
+// Instantiate for the current target.
+template struct VectorTest<HH_TARGET>;
+
+} // namespace highwayhash
+#endif // HH_DISABLE_TARGET_SPECIFIC
diff --git a/contrib/libs/highwayhash/highwayhash/vector_test_target.h b/contrib/libs/highwayhash/highwayhash/vector_test_target.h
index c26f876912..f1ff6382dc 100644
--- a/contrib/libs/highwayhash/highwayhash/vector_test_target.h
+++ b/contrib/libs/highwayhash/highwayhash/vector_test_target.h
@@ -1,37 +1,37 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef HIGHWAYHASH_VECTOR_TEST_TARGET_H_
-#define HIGHWAYHASH_VECTOR_TEST_TARGET_H_
-
-// WARNING: this is a "restricted" header because it is included from
-// translation units compiled with different flags. This header and its
-// dependencies must not define any function unless it is static inline and/or
-// within namespace HH_TARGET_NAME. See arch_specific.h for details.
-
-#include "highwayhash/arch_specific.h"
-#include "highwayhash/hh_types.h"
-
-namespace highwayhash {
-
-// Usage: InstructionSets::RunAll<VectorTest>(). Calls "notify" for each test
-// failure.
-template <TargetBits Target>
-struct VectorTest {
- void operator()(const HHNotify notify) const;
-};
-
-} // namespace highwayhash
-
-#endif // HIGHWAYHASH_VECTOR_TEST_TARGET_H_
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef HIGHWAYHASH_VECTOR_TEST_TARGET_H_
+#define HIGHWAYHASH_VECTOR_TEST_TARGET_H_
+
+// WARNING: this is a "restricted" header because it is included from
+// translation units compiled with different flags. This header and its
+// dependencies must not define any function unless it is static inline and/or
+// within namespace HH_TARGET_NAME. See arch_specific.h for details.
+
+#include "highwayhash/arch_specific.h"
+#include "highwayhash/hh_types.h"
+
+namespace highwayhash {
+
+// Usage: InstructionSets::RunAll<VectorTest>(). Calls "notify" for each test
+// failure.
+template <TargetBits Target>
+struct VectorTest {
+ void operator()(const HHNotify notify) const;
+};
+
+} // namespace highwayhash
+
+#endif // HIGHWAYHASH_VECTOR_TEST_TARGET_H_
diff --git a/contrib/libs/highwayhash/ya.make b/contrib/libs/highwayhash/ya.make
index aec086bdcb..4f6dad6193 100644
--- a/contrib/libs/highwayhash/ya.make
+++ b/contrib/libs/highwayhash/ya.make
@@ -1,46 +1,46 @@
-LIBRARY()
-
-LICENSE(Apache-2.0)
-
+LIBRARY()
+
+LICENSE(Apache-2.0)
+
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
VERSION(2017-05-08-2b666ae078292b01024453d01480f3b362a2a012)
OWNER(somov)
-
-NO_COMPILER_WARNINGS()
-
+
+NO_COMPILER_WARNINGS()
+
ADDINCL(GLOBAL contrib/libs/highwayhash)
-
-SRCDIR(contrib/libs/highwayhash/highwayhash)
-
-SRCS(
- # Dispatcher
- arch_specific.cc
- instruction_sets.cc
- nanobenchmark.cc
- os_specific.cc
- # SipHash
- sip_hash.cc
- scalar_sip_tree_hash.cc
- # sip_tree_hash.cc with AVX2 if available
- # HighwayHash
- hh_portable.cc
- # hh_avx2.cc with AVX2
- # hh_sse41.cc with SSE4.1
- # Library
- c_bindings.cc
-)
-
-IF (ARCH_X86_64)
- PEERDIR(
- contrib/libs/highwayhash/arch/avx2
- contrib/libs/highwayhash/arch/sse41
- )
-ELSE()
- SRCS(
- sip_tree_hash.cc
- )
-ENDIF()
-
-END()
+
+SRCDIR(contrib/libs/highwayhash/highwayhash)
+
+SRCS(
+ # Dispatcher
+ arch_specific.cc
+ instruction_sets.cc
+ nanobenchmark.cc
+ os_specific.cc
+ # SipHash
+ sip_hash.cc
+ scalar_sip_tree_hash.cc
+ # sip_tree_hash.cc with AVX2 if available
+ # HighwayHash
+ hh_portable.cc
+ # hh_avx2.cc with AVX2
+ # hh_sse41.cc with SSE4.1
+ # Library
+ c_bindings.cc
+)
+
+IF (ARCH_X86_64)
+ PEERDIR(
+ contrib/libs/highwayhash/arch/avx2
+ contrib/libs/highwayhash/arch/sse41
+ )
+ELSE()
+ SRCS(
+ sip_tree_hash.cc
+ )
+ENDIF()
+
+END()
diff --git a/contrib/libs/jemalloc/reg_zone.cpp b/contrib/libs/jemalloc/reg_zone.cpp
index 8503cd48f7..6a7b9d69e1 100644
--- a/contrib/libs/jemalloc/reg_zone.cpp
+++ b/contrib/libs/jemalloc/reg_zone.cpp
@@ -1,33 +1,33 @@
-#include <util/system/compiler.h>
-
+#include <util/system/compiler.h>
+
extern "C" void je_zone_register();
-static volatile bool initialized = false;
-
+static volatile bool initialized = false;
+
namespace {
- struct TInit {
+ struct TInit {
inline TInit() {
- if (!initialized) {
+ if (!initialized) {
je_zone_register();
- initialized = true;
- }
+ initialized = true;
+ }
}
- };
-
+ };
+
void zone_register() {
- static TInit init;
- }
+ static TInit init;
+ }
}
-
-extern "C" {
+
+extern "C" {
void je_assure_zone_register() {
- if (Y_LIKELY(initialized)) {
- return;
- }
-
- // Even if we have read false "initialized", real init will be syncronized once by
- // Meyers singleton in <anonymous>::register_zone(). We could do a few
- // redundant "initialized" and singleton creation checks, but no more than that.
+ if (Y_LIKELY(initialized)) {
+ return;
+ }
+
+ // Even if we have read false "initialized", real init will be syncronized once by
+ // Meyers singleton in <anonymous>::register_zone(). We could do a few
+ // redundant "initialized" and singleton creation checks, but no more than that.
zone_register();
- }
-}
+ }
+}
diff --git a/contrib/libs/jemalloc/src/jemalloc.c b/contrib/libs/jemalloc/src/jemalloc.c
index 5dd1f3ac46..63ff26b656 100644
--- a/contrib/libs/jemalloc/src/jemalloc.c
+++ b/contrib/libs/jemalloc/src/jemalloc.c
@@ -1894,7 +1894,7 @@ struct dynamic_opts_s {
unsigned tcache_ind;
unsigned arena_ind;
};
-
+
JEMALLOC_ALWAYS_INLINE void
dynamic_opts_init(dynamic_opts_t *dynamic_opts) {
dynamic_opts->result = NULL;
@@ -1906,7 +1906,7 @@ dynamic_opts_init(dynamic_opts_t *dynamic_opts) {
dynamic_opts->tcache_ind = TCACHE_IND_AUTOMATIC;
dynamic_opts->arena_ind = ARENA_IND_AUTOMATIC;
}
-
+
/* ind is ignored if dopts->alignment > 0. */
JEMALLOC_ALWAYS_INLINE void *
imalloc_no_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
diff --git a/contrib/libs/jwt-cpp/picojson.h b/contrib/libs/jwt-cpp/picojson.h
index f462e67531..c2321e9728 100644
--- a/contrib/libs/jwt-cpp/picojson.h
+++ b/contrib/libs/jwt-cpp/picojson.h
@@ -241,7 +241,7 @@ inline value::value(int64_t i) : type_(int64_type), u_() {
inline value::value(double n) : type_(number_type), u_() {
if (
-#if defined(_MSC_VER) && !defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
!_finite(n)
#elif __cplusplus >= 201103L
std::isnan(n) || std::isinf(n)
diff --git a/contrib/libs/libaio/COPYING b/contrib/libs/libaio/COPYING
index 3c3a852d96..c4792dd27a 100644
--- a/contrib/libs/libaio/COPYING
+++ b/contrib/libs/libaio/COPYING
@@ -1,515 +1,515 @@
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-^L
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-^L
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-^L
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-^L
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-^L
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-^L
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-^L
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-^L
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
- To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
- <one line to give the library's name and a brief idea of what it
-does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper
-mail.
-
-You should also get your employer (if you work as a programmer) or
-your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James
-Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+^L
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+^L
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+^L
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+^L
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+^L
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+^L
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+^L
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+^L
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+ <one line to give the library's name and a brief idea of what it
+does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper
+mail.
+
+You should also get your employer (if you work as a programmer) or
+your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James
+Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/contrib/libs/libaio/ya.make b/contrib/libs/libaio/ya.make
index 95b6fdf3bd..3eb09b549b 100644
--- a/contrib/libs/libaio/ya.make
+++ b/contrib/libs/libaio/ya.make
@@ -1,8 +1,8 @@
LIBRARY()
-# git repository: https://pagure.io/libaio.git
-# revision: 5a546a834c36070648158d19dd564762d59f8eb8
-
+# git repository: https://pagure.io/libaio.git
+# revision: 5a546a834c36070648158d19dd564762d59f8eb8
+
LICENSE(Service-Dll-Harness)
WITHOUT_LICENSE_TEXTS()
diff --git a/contrib/libs/libc_compat/ubuntu_14/README.md b/contrib/libs/libc_compat/ubuntu_14/README.md
index 63dd8a22d9..f7b17a40cc 100644
--- a/contrib/libs/libc_compat/ubuntu_14/README.md
+++ b/contrib/libs/libc_compat/ubuntu_14/README.md
@@ -1,91 +1,91 @@
-## Общие соображения
-
-В библиотеку добавлены реализации символов, появившихся в `libc.so.6` Ubuntu
-14.04 с момента Ubuntu 12.04.
-
-Если какой-либо объектный файл ссылается на один из таких символов, то при
-компоновке этот символ будет взят из нашей библиотеки. В противном случае,
-компоновщик сослался бы на такой символ из `libc.so.6`, добавив к исполняемому
-файлу зависимость от новой версии динамической библиотеки (`GLIBC_2.16`,
-`GLIBC_2.17` или `GLIBC_2.18`). Такой исполняемый файл не может быть запущен на
-Ubuntu 12.04, даже если ни один из новых символов не используется в runtime.
-
-На Ubuntu 14.04 или более новых, в случае если процесс загружает `libc.so.6`, мы
-будем в runtime иметь две реализации символов, нашу и libc. Но все добавленные
-функции не имеют какого-либо состояния и никакими деталями внутренней реализации
-не связаны с другими. Нет разницы, какую из реализаций использовать, и даже
-попеременное использование различных реализаций в одном и том же контексте не
-должно приводить к некорректной работе.
-
-В какой-то момент этот слой совместимости будет отключен: https://st.yandex-team.ru/DEVTOOLS-7436
-
-### Разделяемая реализация
-
-Была идея оформить новые реализации так, чтобы в случае их наличия и в
-загруженной libc динамический компоновщик выбирал для всех ссылок одну
-реализацию.
-
-По всей видимости, для этого требуется собирать исполняемый файл как PIE. Только
-в этом случае для наших реализаций будут сгенерированы дополнительные PLT
-прослойки и вызовы наших реализаций будут проходить через них.
-
-Но в этом случае вообще все вызовы будут происходить таким образом и это
-повлияет на производительность. Ухудшения производительности, наверное, можно
-избежать, явно указав, какие символы в исполняемом файле должны быть публичными,
-но сейчас нет способа сделать это в одном месте, учитывая, что в некоторых
-случаях этот список должен дополняться.
-
-## `getauxval` и `secure_getenv`
-
-Функция `getauxval` требует загрузки и хранения «Auxiliary Vector» (см.
-[здесь](https://refspecs.linuxfoundation.org/LSB_1.3.0/IA64/spec/auxiliaryvector.html)).
-
-Эти данные доступны в момент запуска процесса. libc из новых Ubuntu сохраняет
-эти данные и предоставляет реализацию `getauxval`. В этом случае наша реализация
-перенаправляет вызовы `getauxval` в libc, получив при старте исполняемого файла
-соответствующий указатель.
-
-Если реализация libc недоступна (на старых Ubuntu или если libc не загружена),
-то эти данные можно получить, прочитав `/proc/self/auxv`. Это также делается
-один раз при старте.
-
-В обоих случаях, статически инициализируется синглтон `NUbuntuCompat::TGlibc`,
-который производит эти действия в конструкторе.
-
-`secure_getenv` использует одно из значений `getauxval`, поэтому к нему всё это
-также относится.
-
-Каждый метод новой libc реализован в отдельном объектом файле. `TGlibc` также
-находится в отдельном файле, и ссылки на неё стоят только в местах использования.
-Если при компоновке не понадобились ни `getauxval`, ни `secure_getenv`, то
-объектный файл с `TGlibc` тоже не будет выбран компоновщиком, и в этом случае
-никакой лишней статической инициализации выполняться не будет.
-
-## Патч libc.so
-
-Чтобы иметь возможность использовать `getauxval` (точнее его реализацию
-`__getauxval`) из новой libc, если таковая уже используется процессом,
-библиотека совместимости объявляет этот символ у себя как внешний и слабый. При
-загрузке динамический компоновщик устанавливает значение этого символа из libc
-или `nullptr`, если его там нет. Наша реализация `getauxval` проверяет
-доступность реализации libc, просто сравнивая указатель с `nullptr`.
-
-В Аркадии также есть код, который подобным образом работает с символом
-`__cxa_thread_atexit_impl`.
-
-Однако, если компоновать такую программу с использованием новой libc, то к таким
-символам и самой программе будет приписано требование соответствующей (новой)
-версии libc. Чтобы этого не произошло, при сборке с этой библиотекой
-совместимости используется патченный вариант `libc.so.6`, где у таких символов
-удалена версия.
-
-Также, файлы, проверяющие, что доступна реализация из libc, должны быть собраны
-как PIC. В противном случае вместо значения, заполненного динамическим
-компоновщиком, компилятор ещё на стадии компиляции использует `nullptr` и
-проверка никогда не срабатывает.
-
-## Упоминания
-
-Идея о возможности добавить слой совместимости была взята из ClickHouse.
-* [https://clickhouse.tech/](https://clickhouse.tech/)
-* [https://wiki.yandex-team.ru/clickhouse/](https://wiki.yandex-team.ru/clickhouse/)
+## Общие соображения
+
+В библиотеку добавлены реализации символов, появившихся в `libc.so.6` Ubuntu
+14.04 с момента Ubuntu 12.04.
+
+Если какой-либо объектный файл ссылается на один из таких символов, то при
+компоновке этот символ будет взят из нашей библиотеки. В противном случае,
+компоновщик сослался бы на такой символ из `libc.so.6`, добавив к исполняемому
+файлу зависимость от новой версии динамической библиотеки (`GLIBC_2.16`,
+`GLIBC_2.17` или `GLIBC_2.18`). Такой исполняемый файл не может быть запущен на
+Ubuntu 12.04, даже если ни один из новых символов не используется в runtime.
+
+На Ubuntu 14.04 или более новых, в случае если процесс загружает `libc.so.6`, мы
+будем в runtime иметь две реализации символов, нашу и libc. Но все добавленные
+функции не имеют какого-либо состояния и никакими деталями внутренней реализации
+не связаны с другими. Нет разницы, какую из реализаций использовать, и даже
+попеременное использование различных реализаций в одном и том же контексте не
+должно приводить к некорректной работе.
+
+В какой-то момент этот слой совместимости будет отключен: https://st.yandex-team.ru/DEVTOOLS-7436
+
+### Разделяемая реализация
+
+Была идея оформить новые реализации так, чтобы в случае их наличия и в
+загруженной libc динамический компоновщик выбирал для всех ссылок одну
+реализацию.
+
+По всей видимости, для этого требуется собирать исполняемый файл как PIE. Только
+в этом случае для наших реализаций будут сгенерированы дополнительные PLT
+прослойки и вызовы наших реализаций будут проходить через них.
+
+Но в этом случае вообще все вызовы будут происходить таким образом и это
+повлияет на производительность. Ухудшения производительности, наверное, можно
+избежать, явно указав, какие символы в исполняемом файле должны быть публичными,
+но сейчас нет способа сделать это в одном месте, учитывая, что в некоторых
+случаях этот список должен дополняться.
+
+## `getauxval` и `secure_getenv`
+
+Функция `getauxval` требует загрузки и хранения «Auxiliary Vector» (см.
+[здесь](https://refspecs.linuxfoundation.org/LSB_1.3.0/IA64/spec/auxiliaryvector.html)).
+
+Эти данные доступны в момент запуска процесса. libc из новых Ubuntu сохраняет
+эти данные и предоставляет реализацию `getauxval`. В этом случае наша реализация
+перенаправляет вызовы `getauxval` в libc, получив при старте исполняемого файла
+соответствующий указатель.
+
+Если реализация libc недоступна (на старых Ubuntu или если libc не загружена),
+то эти данные можно получить, прочитав `/proc/self/auxv`. Это также делается
+один раз при старте.
+
+В обоих случаях, статически инициализируется синглтон `NUbuntuCompat::TGlibc`,
+который производит эти действия в конструкторе.
+
+`secure_getenv` использует одно из значений `getauxval`, поэтому к нему всё это
+также относится.
+
+Каждый метод новой libc реализован в отдельном объектом файле. `TGlibc` также
+находится в отдельном файле, и ссылки на неё стоят только в местах использования.
+Если при компоновке не понадобились ни `getauxval`, ни `secure_getenv`, то
+объектный файл с `TGlibc` тоже не будет выбран компоновщиком, и в этом случае
+никакой лишней статической инициализации выполняться не будет.
+
+## Патч libc.so
+
+Чтобы иметь возможность использовать `getauxval` (точнее его реализацию
+`__getauxval`) из новой libc, если таковая уже используется процессом,
+библиотека совместимости объявляет этот символ у себя как внешний и слабый. При
+загрузке динамический компоновщик устанавливает значение этого символа из libc
+или `nullptr`, если его там нет. Наша реализация `getauxval` проверяет
+доступность реализации libc, просто сравнивая указатель с `nullptr`.
+
+В Аркадии также есть код, который подобным образом работает с символом
+`__cxa_thread_atexit_impl`.
+
+Однако, если компоновать такую программу с использованием новой libc, то к таким
+символам и самой программе будет приписано требование соответствующей (новой)
+версии libc. Чтобы этого не произошло, при сборке с этой библиотекой
+совместимости используется патченный вариант `libc.so.6`, где у таких символов
+удалена версия.
+
+Также, файлы, проверяющие, что доступна реализация из libc, должны быть собраны
+как PIC. В противном случае вместо значения, заполненного динамическим
+компоновщиком, компилятор ещё на стадии компиляции использует `nullptr` и
+проверка никогда не срабатывает.
+
+## Упоминания
+
+Идея о возможности добавить слой совместимости была взята из ClickHouse.
+* [https://clickhouse.tech/](https://clickhouse.tech/)
+* [https://wiki.yandex-team.ru/clickhouse/](https://wiki.yandex-team.ru/clickhouse/)
diff --git a/contrib/libs/libc_compat/ubuntu_14/aligned_alloc.c b/contrib/libs/libc_compat/ubuntu_14/aligned_alloc.c
index 880babd32a..c4a1378624 100644
--- a/contrib/libs/libc_compat/ubuntu_14/aligned_alloc.c
+++ b/contrib/libs/libc_compat/ubuntu_14/aligned_alloc.c
@@ -1,6 +1,6 @@
-#include <malloc.h>
-#include <stdlib.h>
-
-__attribute__((weak)) void* aligned_alloc(size_t alignment, size_t size) {
- return memalign(alignment, size);
-}
+#include <malloc.h>
+#include <stdlib.h>
+
+__attribute__((weak)) void* aligned_alloc(size_t alignment, size_t size) {
+ return memalign(alignment, size);
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/c16rtomb.c b/contrib/libs/libc_compat/ubuntu_14/c16rtomb.c
index 18bc92c36c..39ca3758fa 100644
--- a/contrib/libs/libc_compat/ubuntu_14/c16rtomb.c
+++ b/contrib/libs/libc_compat/ubuntu_14/c16rtomb.c
@@ -1,35 +1,35 @@
-#include <uchar.h>
-#include <errno.h>
-#include <wchar.h>
-
-size_t c16rtomb(char *restrict s, char16_t c16, mbstate_t *restrict ps)
-{
- static unsigned internal_state;
- if (!ps) ps = (void *)&internal_state;
- unsigned *x = (unsigned *)ps;
- wchar_t wc;
-
- if (!s) {
- if (*x) goto ilseq;
- return 1;
- }
-
- if (!*x && c16 - 0xd800u < 0x400) {
- *x = c16 - 0xd7c0 << 10;
- return 0;
- }
-
- if (*x) {
- if (c16 - 0xdc00u >= 0x400) goto ilseq;
- else wc = *x + c16 - 0xdc00;
- *x = 0;
- } else {
- wc = c16;
- }
- return wcrtomb(s, wc, 0);
-
-ilseq:
- *x = 0;
- errno = EILSEQ;
- return -1;
-}
+#include <uchar.h>
+#include <errno.h>
+#include <wchar.h>
+
+size_t c16rtomb(char *restrict s, char16_t c16, mbstate_t *restrict ps)
+{
+ static unsigned internal_state;
+ if (!ps) ps = (void *)&internal_state;
+ unsigned *x = (unsigned *)ps;
+ wchar_t wc;
+
+ if (!s) {
+ if (*x) goto ilseq;
+ return 1;
+ }
+
+ if (!*x && c16 - 0xd800u < 0x400) {
+ *x = c16 - 0xd7c0 << 10;
+ return 0;
+ }
+
+ if (*x) {
+ if (c16 - 0xdc00u >= 0x400) goto ilseq;
+ else wc = *x + c16 - 0xdc00;
+ *x = 0;
+ } else {
+ wc = c16;
+ }
+ return wcrtomb(s, wc, 0);
+
+ilseq:
+ *x = 0;
+ errno = EILSEQ;
+ return -1;
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/c32rtomb.c b/contrib/libs/libc_compat/ubuntu_14/c32rtomb.c
index 9fccc0fafd..67851328e8 100644
--- a/contrib/libs/libc_compat/ubuntu_14/c32rtomb.c
+++ b/contrib/libs/libc_compat/ubuntu_14/c32rtomb.c
@@ -1,7 +1,7 @@
-#include <uchar.h>
-#include <wchar.h>
-
-size_t c32rtomb(char *restrict s, char32_t c32, mbstate_t *restrict ps)
-{
- return wcrtomb(s, c32, ps);
-}
+#include <uchar.h>
+#include <wchar.h>
+
+size_t c32rtomb(char *restrict s, char32_t c32, mbstate_t *restrict ps)
+{
+ return wcrtomb(s, c32, ps);
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/features.h b/contrib/libs/libc_compat/ubuntu_14/features.h
index 2930bdf967..9fbab45ab5 100644
--- a/contrib/libs/libc_compat/ubuntu_14/features.h
+++ b/contrib/libs/libc_compat/ubuntu_14/features.h
@@ -1,5 +1,5 @@
-#pragma once
-
-#define weak __attribute__((__weak__))
-#define weak_alias(old, new) \
- extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
+#pragma once
+
+#define weak __attribute__((__weak__))
+#define weak_alias(old, new) \
+ extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
diff --git a/contrib/libs/libc_compat/ubuntu_14/getauxval.cpp b/contrib/libs/libc_compat/ubuntu_14/getauxval.cpp
index 702abf3bbb..9f20dd0195 100644
--- a/contrib/libs/libc_compat/ubuntu_14/getauxval.cpp
+++ b/contrib/libs/libc_compat/ubuntu_14/getauxval.cpp
@@ -1,10 +1,10 @@
-#include <sys/auxv.h>
-
-#include "glibc.h"
-#include "features.h"
-
-extern "C" {
- unsigned long getauxval(unsigned long item) noexcept {
- return NUbuntuCompat::GetGlibc().GetAuxVal(item);
- }
-}
+#include <sys/auxv.h>
+
+#include "glibc.h"
+#include "features.h"
+
+extern "C" {
+ unsigned long getauxval(unsigned long item) noexcept {
+ return NUbuntuCompat::GetGlibc().GetAuxVal(item);
+ }
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/glibc.cpp b/contrib/libs/libc_compat/ubuntu_14/glibc.cpp
index b2c6098dd8..1cc444bce1 100644
--- a/contrib/libs/libc_compat/ubuntu_14/glibc.cpp
+++ b/contrib/libs/libc_compat/ubuntu_14/glibc.cpp
@@ -1,111 +1,111 @@
-#include <elf.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "glibc.h"
-#include "features.h"
-
-namespace {
- void ReadAuxVector(Elf64_auxv_t** begin, Elf64_auxv_t** end) noexcept {
- int fd = open("/proc/self/auxv", O_RDONLY | O_CLOEXEC);
- if (fd == -1) {
- return;
- }
-
- constexpr size_t item_size = sizeof(Elf64_auxv_t);
- constexpr size_t block_size = item_size * 32;
-
- size_t bytes_read = 0;
- size_t size = 0;
-
- struct TBuffer {
- ~TBuffer() {
- free(Pointer);
- }
- char* Pointer = nullptr;
- } buffer;
-
- while (true) {
- size_t bytes_left = size - bytes_read;
-
- if (!bytes_left) {
- size += block_size;
- char* new_buffer = (char*)realloc(buffer.Pointer, size);
- if (!new_buffer) {
- return;
- }
- buffer.Pointer = new_buffer;
- continue;
- }
-
- ssize_t r = read(fd, buffer.Pointer + bytes_read, bytes_left);
- if (!r) {
- break;
- } else if (r < 0) {
- if (errno == EINTR) {
- continue;
- } else {
- return;
- }
- }
-
- bytes_read += r;
- }
-
- size_t item_count = bytes_read / item_size;
- *begin = (Elf64_auxv_t*)buffer.Pointer;
- *end = (Elf64_auxv_t*)(buffer.Pointer + item_count * item_size);
- buffer.Pointer = nullptr;
- }
-}
-
-extern "C" {
- weak unsigned long __getauxval(unsigned long item);
-}
-
-namespace NUbuntuCompat {
-
- TGlibc::TGlibc() noexcept
- : AuxVectorBegin(nullptr)
- , AuxVectorEnd(nullptr)
- {
- if (!__getauxval) {
- ReadAuxVector((Elf64_auxv_t**)&AuxVectorBegin, (Elf64_auxv_t**)&AuxVectorEnd);
- }
-
- Secure = (bool)GetAuxVal(AT_SECURE);
- }
-
- TGlibc::~TGlibc() noexcept {
- free(AuxVectorBegin);
- }
-
- unsigned long TGlibc::GetAuxVal(unsigned long item) noexcept {
- if (__getauxval) {
- return __getauxval(item);
- }
-
- for (Elf64_auxv_t* p = (Elf64_auxv_t*)AuxVectorBegin; p < (Elf64_auxv_t*)AuxVectorEnd; ++p) {
- if (p->a_type == item) {
- return p->a_un.a_val;
- }
- }
-
- errno = ENOENT;
- return 0;
- }
-
- bool TGlibc::IsSecure() noexcept {
- return Secure;
- }
-
- static TGlibc __attribute__((__init_priority__(101))) GlibcInstance;
-
- TGlibc& GetGlibc() noexcept {
- return GlibcInstance;
- }
-}
+#include <elf.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "glibc.h"
+#include "features.h"
+
+namespace {
+ void ReadAuxVector(Elf64_auxv_t** begin, Elf64_auxv_t** end) noexcept {
+ int fd = open("/proc/self/auxv", O_RDONLY | O_CLOEXEC);
+ if (fd == -1) {
+ return;
+ }
+
+ constexpr size_t item_size = sizeof(Elf64_auxv_t);
+ constexpr size_t block_size = item_size * 32;
+
+ size_t bytes_read = 0;
+ size_t size = 0;
+
+ struct TBuffer {
+ ~TBuffer() {
+ free(Pointer);
+ }
+ char* Pointer = nullptr;
+ } buffer;
+
+ while (true) {
+ size_t bytes_left = size - bytes_read;
+
+ if (!bytes_left) {
+ size += block_size;
+ char* new_buffer = (char*)realloc(buffer.Pointer, size);
+ if (!new_buffer) {
+ return;
+ }
+ buffer.Pointer = new_buffer;
+ continue;
+ }
+
+ ssize_t r = read(fd, buffer.Pointer + bytes_read, bytes_left);
+ if (!r) {
+ break;
+ } else if (r < 0) {
+ if (errno == EINTR) {
+ continue;
+ } else {
+ return;
+ }
+ }
+
+ bytes_read += r;
+ }
+
+ size_t item_count = bytes_read / item_size;
+ *begin = (Elf64_auxv_t*)buffer.Pointer;
+ *end = (Elf64_auxv_t*)(buffer.Pointer + item_count * item_size);
+ buffer.Pointer = nullptr;
+ }
+}
+
+extern "C" {
+ weak unsigned long __getauxval(unsigned long item);
+}
+
+namespace NUbuntuCompat {
+
+ TGlibc::TGlibc() noexcept
+ : AuxVectorBegin(nullptr)
+ , AuxVectorEnd(nullptr)
+ {
+ if (!__getauxval) {
+ ReadAuxVector((Elf64_auxv_t**)&AuxVectorBegin, (Elf64_auxv_t**)&AuxVectorEnd);
+ }
+
+ Secure = (bool)GetAuxVal(AT_SECURE);
+ }
+
+ TGlibc::~TGlibc() noexcept {
+ free(AuxVectorBegin);
+ }
+
+ unsigned long TGlibc::GetAuxVal(unsigned long item) noexcept {
+ if (__getauxval) {
+ return __getauxval(item);
+ }
+
+ for (Elf64_auxv_t* p = (Elf64_auxv_t*)AuxVectorBegin; p < (Elf64_auxv_t*)AuxVectorEnd; ++p) {
+ if (p->a_type == item) {
+ return p->a_un.a_val;
+ }
+ }
+
+ errno = ENOENT;
+ return 0;
+ }
+
+ bool TGlibc::IsSecure() noexcept {
+ return Secure;
+ }
+
+ static TGlibc __attribute__((__init_priority__(101))) GlibcInstance;
+
+ TGlibc& GetGlibc() noexcept {
+ return GlibcInstance;
+ }
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/glibc.h b/contrib/libs/libc_compat/ubuntu_14/glibc.h
index e651371878..fa8f7dd013 100644
--- a/contrib/libs/libc_compat/ubuntu_14/glibc.h
+++ b/contrib/libs/libc_compat/ubuntu_14/glibc.h
@@ -1,20 +1,20 @@
-#pragma once
-
-typedef unsigned long (*TGetAuxVal)(unsigned long);
-
-namespace NUbuntuCompat {
- class TGlibc {
- public:
- TGlibc() noexcept;
- ~TGlibc() noexcept;
- unsigned long GetAuxVal(unsigned long item) noexcept;
- bool IsSecure() noexcept;
-
- private:
- void* AuxVectorBegin;
- void* AuxVectorEnd;
- bool Secure;
- };
-
- TGlibc& GetGlibc() noexcept;
-};
+#pragma once
+
+typedef unsigned long (*TGetAuxVal)(unsigned long);
+
+namespace NUbuntuCompat {
+ class TGlibc {
+ public:
+ TGlibc() noexcept;
+ ~TGlibc() noexcept;
+ unsigned long GetAuxVal(unsigned long item) noexcept;
+ bool IsSecure() noexcept;
+
+ private:
+ void* AuxVectorBegin;
+ void* AuxVectorEnd;
+ bool Secure;
+ };
+
+ TGlibc& GetGlibc() noexcept;
+};
diff --git a/contrib/libs/libc_compat/ubuntu_14/mbrtoc16.c b/contrib/libs/libc_compat/ubuntu_14/mbrtoc16.c
index 160b8686c9..765ff9037c 100644
--- a/contrib/libs/libc_compat/ubuntu_14/mbrtoc16.c
+++ b/contrib/libs/libc_compat/ubuntu_14/mbrtoc16.c
@@ -1,30 +1,30 @@
-#include <uchar.h>
-#include <wchar.h>
-
-size_t mbrtoc16(char16_t *restrict pc16, const char *restrict s, size_t n, mbstate_t *restrict ps)
-{
- static unsigned internal_state;
- if (!ps) ps = (void *)&internal_state;
- unsigned *pending = (unsigned *)ps;
-
- if (!s) return mbrtoc16(0, "", 1, ps);
-
- /* mbrtowc states for partial UTF-8 characters have the high bit set;
- * we use nonzero states without high bit for pending surrogates. */
- if ((int)*pending > 0) {
- if (pc16) *pc16 = *pending;
- *pending = 0;
- return -3;
- }
-
- wchar_t wc;
- size_t ret = mbrtowc(&wc, s, n, ps);
- if (ret <= 4) {
- if (wc >= 0x10000) {
- *pending = (wc & 0x3ff) + 0xdc00;
- wc = 0xd7c0 + (wc >> 10);
- }
- if (pc16) *pc16 = wc;
- }
- return ret;
-}
+#include <uchar.h>
+#include <wchar.h>
+
+size_t mbrtoc16(char16_t *restrict pc16, const char *restrict s, size_t n, mbstate_t *restrict ps)
+{
+ static unsigned internal_state;
+ if (!ps) ps = (void *)&internal_state;
+ unsigned *pending = (unsigned *)ps;
+
+ if (!s) return mbrtoc16(0, "", 1, ps);
+
+ /* mbrtowc states for partial UTF-8 characters have the high bit set;
+ * we use nonzero states without high bit for pending surrogates. */
+ if ((int)*pending > 0) {
+ if (pc16) *pc16 = *pending;
+ *pending = 0;
+ return -3;
+ }
+
+ wchar_t wc;
+ size_t ret = mbrtowc(&wc, s, n, ps);
+ if (ret <= 4) {
+ if (wc >= 0x10000) {
+ *pending = (wc & 0x3ff) + 0xdc00;
+ wc = 0xd7c0 + (wc >> 10);
+ }
+ if (pc16) *pc16 = wc;
+ }
+ return ret;
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/mbrtoc32.c b/contrib/libs/libc_compat/ubuntu_14/mbrtoc32.c
index e7189170c4..9b6b236739 100644
--- a/contrib/libs/libc_compat/ubuntu_14/mbrtoc32.c
+++ b/contrib/libs/libc_compat/ubuntu_14/mbrtoc32.c
@@ -1,13 +1,13 @@
-#include <uchar.h>
-#include <wchar.h>
-
-size_t mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps)
-{
- static unsigned internal_state;
- if (!ps) ps = (void *)&internal_state;
- if (!s) return mbrtoc32(0, "", 1, ps);
- wchar_t wc;
- size_t ret = mbrtowc(&wc, s, n, ps);
- if (ret <= 4 && pc32) *pc32 = wc;
- return ret;
-}
+#include <uchar.h>
+#include <wchar.h>
+
+size_t mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps)
+{
+ static unsigned internal_state;
+ if (!ps) ps = (void *)&internal_state;
+ if (!s) return mbrtoc32(0, "", 1, ps);
+ wchar_t wc;
+ size_t ret = mbrtowc(&wc, s, n, ps);
+ if (ret <= 4 && pc32) *pc32 = wc;
+ return ret;
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/secure_getenv.cpp b/contrib/libs/libc_compat/ubuntu_14/secure_getenv.cpp
index 947fc3eb5a..14e3e90906 100644
--- a/contrib/libs/libc_compat/ubuntu_14/secure_getenv.cpp
+++ b/contrib/libs/libc_compat/ubuntu_14/secure_getenv.cpp
@@ -1,12 +1,12 @@
-#include <stdlib.h>
-
-#include "glibc.h"
-
-extern "C" {
- char *secure_getenv(const char *name) noexcept {
- if (NUbuntuCompat::GetGlibc().IsSecure()) {
- return nullptr;
- }
- return getenv(name);
- }
-}
+#include <stdlib.h>
+
+#include "glibc.h"
+
+extern "C" {
+ char *secure_getenv(const char *name) noexcept {
+ if (NUbuntuCompat::GetGlibc().IsSecure()) {
+ return nullptr;
+ }
+ return getenv(name);
+ }
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/timespec_get.c b/contrib/libs/libc_compat/ubuntu_14/timespec_get.c
index 806d87f3d8..742b62ec84 100644
--- a/contrib/libs/libc_compat/ubuntu_14/timespec_get.c
+++ b/contrib/libs/libc_compat/ubuntu_14/timespec_get.c
@@ -1,10 +1,10 @@
-#include <time.h>
-
-/* There is no other implemented value than TIME_UTC; all other values
- * are considered erroneous. */
-int timespec_get(struct timespec * ts, int base)
-{
- if (base != TIME_UTC) return 0;
- int ret = clock_gettime(CLOCK_REALTIME, ts);
- return ret < 0 ? 0 : base;
-}
+#include <time.h>
+
+/* There is no other implemented value than TIME_UTC; all other values
+ * are considered erroneous. */
+int timespec_get(struct timespec * ts, int base)
+{
+ if (base != TIME_UTC) return 0;
+ int ret = clock_gettime(CLOCK_REALTIME, ts);
+ return ret < 0 ? 0 : base;
+}
diff --git a/contrib/libs/libc_compat/ubuntu_14/ya.make b/contrib/libs/libc_compat/ubuntu_14/ya.make
index fc770dd4b4..7355c4ad9d 100644
--- a/contrib/libs/libc_compat/ubuntu_14/ya.make
+++ b/contrib/libs/libc_compat/ubuntu_14/ya.make
@@ -1,5 +1,5 @@
-LIBRARY()
-
+LIBRARY()
+
WITHOUT_LICENSE_TEXTS()
LICENSE(BSD-3-Clause)
@@ -9,34 +9,34 @@ OWNER(
g:contrib
g:cpp-contrib
)
-
-NO_PLATFORM()
-NO_RUNTIME()
+NO_PLATFORM()
+
+NO_RUNTIME()
+
+NO_UTIL()
-NO_UTIL()
-
-DISABLE(NEED_PLATFORM_PEERDIRS)
+DISABLE(NEED_PLATFORM_PEERDIRS)
DISABLE(OPENSOURCE_EXPORT)
-
+
IF (OS_SDK == "ubuntu-14")
PEERDIR(
build/platform/linux_sdk
)
- SRCS(
- aligned_alloc.c
- c16rtomb.c
- c32rtomb.c
- getauxval.cpp
- mbrtoc16.c
- mbrtoc32.c
- secure_getenv.cpp
- timespec_get.c
- )
+ SRCS(
+ aligned_alloc.c
+ c16rtomb.c
+ c32rtomb.c
+ getauxval.cpp
+ mbrtoc16.c
+ mbrtoc32.c
+ secure_getenv.cpp
+ timespec_get.c
+ )
SRC_CPP_PIC(
glibc.cpp
-fno-lto
)
-ENDIF()
-
-END()
+ENDIF()
+
+END()
diff --git a/contrib/libs/libidn/COPYING.LIB b/contrib/libs/libidn/COPYING.LIB
index 8f7d8cdfef..8add30ad59 100644
--- a/contrib/libs/libidn/COPYING.LIB
+++ b/contrib/libs/libidn/COPYING.LIB
@@ -1,504 +1,504 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/contrib/libs/libidn/stringprep.h b/contrib/libs/libidn/stringprep.h
index 687adc5ca1..9b977d3142 100644
--- a/contrib/libs/libidn/stringprep.h
+++ b/contrib/libs/libidn/stringprep.h
@@ -46,7 +46,7 @@ extern "C"
#endif
#define STRINGPREP_VERSION "1.9"
-#define LIBIDN_STATIC
+#define LIBIDN_STATIC
/* Libidn Windows DLL */
#ifndef LIBIDN_API
diff --git a/contrib/libs/libunwind/src/Unwind-EHABI.cpp b/contrib/libs/libunwind/src/Unwind-EHABI.cpp
index ded98ac4eb..21c8b2777b 100644
--- a/contrib/libs/libunwind/src/Unwind-EHABI.cpp
+++ b/contrib/libs/libunwind/src/Unwind-EHABI.cpp
@@ -884,7 +884,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
return result;
}
-[[maybe_unused]] static uint64_t ValueAsBitPattern(_Unwind_VRS_DataRepresentation representation,
+[[maybe_unused]] static uint64_t ValueAsBitPattern(_Unwind_VRS_DataRepresentation representation,
void* valuep) {
uint64_t value = 0;
switch (representation) {
diff --git a/contrib/libs/libunwind/ut/libunwind_ut.cpp b/contrib/libs/libunwind/ut/libunwind_ut.cpp
index 711e0f115a..93767c50c8 100644
--- a/contrib/libs/libunwind/ut/libunwind_ut.cpp
+++ b/contrib/libs/libunwind/ut/libunwind_ut.cpp
@@ -1,29 +1,29 @@
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/system/compiler.h>
-
-#include <exception>
-#include <vector>
-
-Y_NO_INLINE void Except(int arg, ...) {
- (void)arg;
- throw std::exception();
-}
-
+
+#include <util/system/compiler.h>
+
+#include <exception>
+#include <vector>
+
+Y_NO_INLINE void Except(int arg, ...) {
+ (void)arg;
+ throw std::exception();
+}
+
Y_UNIT_TEST_SUITE(LibunwindSuite) {
- static void Y_NO_INLINE DoTestVarargs() {
- std::vector<int> v;
- v.push_back(0);
- Except(0x11, 0x22, 0x33, 0x44, 0xAA, 0xBB, 0xCC, 0xDD);
- }
-
+ static void Y_NO_INLINE DoTestVarargs() {
+ std::vector<int> v;
+ v.push_back(0);
+ Except(0x11, 0x22, 0x33, 0x44, 0xAA, 0xBB, 0xCC, 0xDD);
+ }
+
Y_UNIT_TEST(TestVarargs) {
- try {
- DoTestVarargs();
- } catch (const std::exception& e) {
- return;
- }
-
- UNIT_FAIL("Should not be here");
- }
-}
+ try {
+ DoTestVarargs();
+ } catch (const std::exception& e) {
+ return;
+ }
+
+ UNIT_FAIL("Should not be here");
+ }
+}
diff --git a/contrib/libs/libunwind/ut/ya.make b/contrib/libs/libunwind/ut/ya.make
index f0026a0c42..a608aee8a4 100644
--- a/contrib/libs/libunwind/ut/ya.make
+++ b/contrib/libs/libunwind/ut/ya.make
@@ -1,11 +1,11 @@
-UNITTEST()
-
+UNITTEST()
+
WITHOUT_LICENSE_TEXTS()
-
+
OWNER(somov)
-SRCS(
- libunwind_ut.cpp
-)
-
-END()
+SRCS(
+ libunwind_ut.cpp
+)
+
+END()
diff --git a/contrib/libs/libxml/COPYING b/contrib/libs/libxml/COPYING
index 61034c5d19..d61318502c 100644
--- a/contrib/libs/libxml/COPYING
+++ b/contrib/libs/libxml/COPYING
@@ -1,23 +1,23 @@
-Except where otherwise noted in the source code (e.g. the files hash.c,
-list.c and the trio files, which are covered by a similar licence but
-with different Copyright notices) all the files are:
-
- Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is fur-
-nished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
-NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+Except where otherwise noted in the source code (e.g. the files hash.c,
+list.c and the trio files, which are covered by a similar licence but
+with different Copyright notices) all the files are:
+
+ Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/contrib/libs/libxml/ya.make b/contrib/libs/libxml/ya.make
index b64b9e9973..b7ee2eb058 100644
--- a/contrib/libs/libxml/ya.make
+++ b/contrib/libs/libxml/ya.make
@@ -6,7 +6,7 @@ OWNER(
g:cpp-contrib
g:yandex_io
)
-
+
VERSION(2.9.10)
ORIGINAL_SOURCE(http://xmlsoft.org/sources/libxml2-2.9.10.tar.gz)
@@ -22,7 +22,7 @@ PEERDIR(
contrib/libs/libiconv
contrib/libs/zlib
)
-
+
ADDINCL(
GLOBAL contrib/libs/libxml/include
contrib/libs/libiconv/include
diff --git a/contrib/libs/llvm12/include/llvm/Demangle/ItaniumDemangle.h b/contrib/libs/llvm12/include/llvm/Demangle/ItaniumDemangle.h
index e0a8cfcf13..09d4e42b85 100644
--- a/contrib/libs/llvm12/include/llvm/Demangle/ItaniumDemangle.h
+++ b/contrib/libs/llvm12/include/llvm/Demangle/ItaniumDemangle.h
@@ -217,13 +217,13 @@ public:
#endif
};
-class IASTProcessor {
-public:
- virtual void Process(const Node*) = 0;
-};
-
-void demangleAST(const char *MangledName, IASTProcessor *Processor);
-
+class IASTProcessor {
+public:
+ virtual void Process(const Node*) = 0;
+};
+
+void demangleAST(const char *MangledName, IASTProcessor *Processor);
+
class NodeArray {
Node **Elements;
size_t NumElements;
@@ -5596,7 +5596,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateArg() {
return nullptr;
return Arg;
}
- case 'I': // 'I' here is an old GCC mangling ABI. It is common in outside binaries.
+ case 'I': // 'I' here is an old GCC mangling ABI. It is common in outside binaries.
case 'J': {
++First;
size_t ArgsBegin = Names.size();
diff --git a/contrib/libs/llvm12/lib/Demangle/ItaniumDemangle.cpp b/contrib/libs/llvm12/lib/Demangle/ItaniumDemangle.cpp
index 60cab24031..6dfd931e83 100644
--- a/contrib/libs/llvm12/lib/Demangle/ItaniumDemangle.cpp
+++ b/contrib/libs/llvm12/lib/Demangle/ItaniumDemangle.cpp
@@ -323,12 +323,12 @@ public:
using Demangler = itanium_demangle::ManglingParser<DefaultAllocator>;
-void llvm::itanium_demangle::demangleAST(const char *MangledName, IASTProcessor *Processor) {
- Demangler Parser(MangledName, MangledName + std::strlen(MangledName));
- Node* node = Parser.parse();
- Processor->Process(node);
-}
-
+void llvm::itanium_demangle::demangleAST(const char *MangledName, IASTProcessor *Processor) {
+ Demangler Parser(MangledName, MangledName + std::strlen(MangledName));
+ Node* node = Parser.parse();
+ Processor->Process(node);
+}
+
char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
size_t *N, int *Status) {
if (MangledName == nullptr || (Buf != nullptr && N == nullptr)) {
diff --git a/contrib/libs/lzmasdk/AesOpt.c b/contrib/libs/lzmasdk/AesOpt.c
index db59d7d152..00291288ba 100644
--- a/contrib/libs/lzmasdk/AesOpt.c
+++ b/contrib/libs/lzmasdk/AesOpt.c
@@ -13,15 +13,15 @@
#ifdef USE_INTEL_AES
-#if defined(__clang__)
-#define TARGET_AES __attribute__((__target__("aes")))
-#else
-#define TARGET_AES
-#endif
-
+#if defined(__clang__)
+#define TARGET_AES __attribute__((__target__("aes")))
+#else
+#define TARGET_AES
+#endif
+
#include <wmmintrin.h>
-void TARGET_AES MY_FAST_CALL AesCbc_Encode_Intel(__m128i *p, __m128i *data, size_t numBlocks)
+void TARGET_AES MY_FAST_CALL AesCbc_Encode_Intel(__m128i *p, __m128i *data, size_t numBlocks)
{
__m128i m = *p;
for (; numBlocks != 0; numBlocks--, data++)
@@ -58,7 +58,7 @@ void TARGET_AES MY_FAST_CALL AesCbc_Encode_Intel(__m128i *p, __m128i *data, size
#define AES_ENC(n) AES_OP_W(_mm_aesenc_si128, n)
#define AES_ENC_LAST(n) AES_OP_W(_mm_aesenclast_si128, n)
-void TARGET_AES MY_FAST_CALL AesCbc_Decode_Intel(__m128i *p, __m128i *data, size_t numBlocks)
+void TARGET_AES MY_FAST_CALL AesCbc_Decode_Intel(__m128i *p, __m128i *data, size_t numBlocks)
{
__m128i iv = *p;
for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS)
@@ -113,10 +113,10 @@ void TARGET_AES MY_FAST_CALL AesCbc_Decode_Intel(__m128i *p, __m128i *data, size
*p = iv;
}
-void TARGET_AES MY_FAST_CALL AesCtr_Code_Intel(__m128i *p, __m128i *data, size_t numBlocks)
+void TARGET_AES MY_FAST_CALL AesCtr_Code_Intel(__m128i *p, __m128i *data, size_t numBlocks)
{
__m128i ctr = *p;
- __m128i one = _mm_set_epi64x(1, 0);
+ __m128i one = _mm_set_epi64x(1, 0);
for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS)
{
UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1;
diff --git a/contrib/libs/openssl/dynamic/ya.make b/contrib/libs/openssl/dynamic/ya.make
index 906559980c..d68bbe8c4c 100644
--- a/contrib/libs/openssl/dynamic/ya.make
+++ b/contrib/libs/openssl/dynamic/ya.make
@@ -1,8 +1,8 @@
DLL_FOR(contrib/libs/openssl)
-
-OWNER(
- somov
- elantsev
+
+OWNER(
+ somov
+ elantsev
g:contrib
g:cpp-contrib
-)
+)
diff --git a/contrib/libs/openssl/include/openssl/opensslconf-linux.h b/contrib/libs/openssl/include/openssl/opensslconf-linux.h
index ab11275318..e5e3a76622 100644
--- a/contrib/libs/openssl/include/openssl/opensslconf-linux.h
+++ b/contrib/libs/openssl/include/openssl/opensslconf-linux.h
@@ -72,19 +72,19 @@ extern "C" {
#ifndef OPENSSL_NO_SSL_TRACE
# define OPENSSL_NO_SSL_TRACE
#endif
-
-// https://st.yandex-team.ru/DEVTOOLS-5331
-#define Y_OPENSSL_ENABLE_DEPRECATED
-
-#if !defined(Y_OPENSSL_ENABLE_DEPRECATED)
-# ifndef OPENSSL_NO_SSL3
-# define OPENSSL_NO_SSL3
-# endif
-# ifndef OPENSSL_NO_SSL3_METHOD
-# define OPENSSL_NO_SSL3_METHOD
-# endif
-#endif
-
+
+// https://st.yandex-team.ru/DEVTOOLS-5331
+#define Y_OPENSSL_ENABLE_DEPRECATED
+
+#if !defined(Y_OPENSSL_ENABLE_DEPRECATED)
+# ifndef OPENSSL_NO_SSL3
+# define OPENSSL_NO_SSL3
+# endif
+# ifndef OPENSSL_NO_SSL3_METHOD
+# define OPENSSL_NO_SSL3_METHOD
+# endif
+#endif
+
#ifndef OPENSSL_NO_TESTS
# define OPENSSL_NO_TESTS
#endif
@@ -94,14 +94,14 @@ extern "C" {
#ifndef OPENSSL_NO_UNIT_TEST
# define OPENSSL_NO_UNIT_TEST
#endif
-
-// https://st.yandex-team.ru/DEVTOOLS-5331
-#if !defined(Y_OPENSSL_ENABLE_DEPRECATED)
-# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
-# define OPENSSL_NO_WEAK_SSL_CIPHERS
-# endif
+
+// https://st.yandex-team.ru/DEVTOOLS-5331
+#if !defined(Y_OPENSSL_ENABLE_DEPRECATED)
+# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
+# define OPENSSL_NO_WEAK_SSL_CIPHERS
+# endif
#endif
-
+
#ifndef OPENSSL_NO_DYNAMIC_ENGINE
# define OPENSSL_NO_DYNAMIC_ENGINE
#endif
diff --git a/contrib/libs/openssl/ssl/ssl_cert.c b/contrib/libs/openssl/ssl/ssl_cert.c
index d657e668c3..a592e3382f 100644
--- a/contrib/libs/openssl/ssl/ssl_cert.c
+++ b/contrib/libs/openssl/ssl/ssl_cert.c
@@ -926,14 +926,14 @@ static int ssl_security_default_callback(const SSL *s, const SSL_CTX *ctx,
/* No unauthenticated ciphersuites */
if (c->algorithm_auth & SSL_aNULL)
return 0;
-
- // https://st.yandex-team.ru/DEVTOOLS-5331
-#if !defined(Y_OPENSSL_ENABLE_DEPRECATED)
+
+ // https://st.yandex-team.ru/DEVTOOLS-5331
+#if !defined(Y_OPENSSL_ENABLE_DEPRECATED)
/* No MD5 mac ciphersuites */
if (c->algorithm_mac & SSL_MD5)
return 0;
-#endif
-
+#endif
+
/* SHA1 HMAC is 160 bits of security */
if (minbits > 160 && c->algorithm_mac & SSL_SHA1)
return 0;
diff --git a/contrib/libs/protoc/LICENSE b/contrib/libs/protoc/LICENSE
index 81c8e50b73..19b305b000 100644
--- a/contrib/libs/protoc/LICENSE
+++ b/contrib/libs/protoc/LICENSE
@@ -1,32 +1,32 @@
Copyright 2008 Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Code generated by the Protocol Buffer compiler is owned by the owner
-of the input file used when generating it. This code is not
-standalone and requires a support library to be linked with it. This
-support library is itself covered by the above license.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Code generated by the Protocol Buffer compiler is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
diff --git a/contrib/libs/re2/re2/re2.cc b/contrib/libs/re2/re2/re2.cc
index 4637322b08..47fb385e4e 100644
--- a/contrib/libs/re2/re2/re2.cc
+++ b/contrib/libs/re2/re2/re2.cc
@@ -1050,14 +1050,14 @@ bool Parse(const char* str, size_t n, std::string* dest) {
return true;
}
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
template <>
bool Parse(const char* str, size_t n, TString* dest) {
if (dest == NULL) return true;
dest->assign(str, n);
return true;
}
-#endif
+#endif
template <>
bool Parse(const char* str, size_t n, StringPiece* dest) {
diff --git a/contrib/libs/re2/re2/re2.h b/contrib/libs/re2/re2/re2.h
index 28c3fc708f..f8f8043daf 100644
--- a/contrib/libs/re2/re2/re2.h
+++ b/contrib/libs/re2/re2/re2.h
@@ -210,9 +210,9 @@
#include <string>
#include <type_traits>
#include <vector>
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
#include <util/generic/string.h>
-#endif
+#endif
#if defined(__APPLE__)
#include <TargetConditionals.h>
@@ -283,10 +283,10 @@ class RE2 {
#endif
RE2(const StringPiece& pattern);
RE2(const StringPiece& pattern, const Options& options);
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
// ambiguity resolution.
RE2(const TString& pattern) : RE2(StringPiece(pattern)) {}
-#endif
+#endif
~RE2();
// Returns whether RE2 was created properly.
@@ -464,7 +464,7 @@ class RE2 {
static bool Replace(std::string* str,
const RE2& re,
const StringPiece& rewrite);
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
static bool Replace(TString *str,
const RE2& pattern,
const StringPiece& rewrite) {
@@ -473,7 +473,7 @@ class RE2 {
*str = tmp;
return res;
}
-#endif
+#endif
// Like Replace(), except replaces successive non-overlapping occurrences
// of the pattern in the string with the rewrite. E.g.
@@ -492,7 +492,7 @@ class RE2 {
const RE2& re,
const StringPiece& rewrite);
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
static int GlobalReplace(TString* str,
const RE2& pattern,
const StringPiece& rewrite) {
@@ -501,7 +501,7 @@ class RE2 {
*str = tmp;
return res;
}
-#endif
+#endif
// Like Replace, except that if the pattern matches, "rewrite"
// is copied into "out" with substitutions. The non-matching
@@ -516,7 +516,7 @@ class RE2 {
const StringPiece& rewrite,
std::string* out);
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
static bool Extract(const StringPiece& text,
const RE2& pattern,
const StringPiece& rewrite,
@@ -526,7 +526,7 @@ class RE2 {
*out = tmp;
return res;
}
-#endif
+#endif
// Escapes all potentially meaningful regexp characters in
// 'unquoted'. The returned string, used as a regular expression,
@@ -621,7 +621,7 @@ class RE2 {
return CheckRewriteString(rewrite, static_cast<std::string*>(error));
}
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
bool CheckRewriteString(const StringPiece& rewrite, TString* error) const {
if (error) {
std::string tmp;
@@ -632,7 +632,7 @@ class RE2 {
return CheckRewriteString(rewrite, nullptr);
}
}
-#endif
+#endif
// Returns the maximum submatch needed for the rewrite to be done by
// Replace(). E.g. if rewrite == "foo \\2,\\1", returns 2.
@@ -847,9 +847,9 @@ template <typename T> struct Parse3ary : public std::false_type {};
template <> struct Parse3ary<void> : public std::true_type {};
template <> struct Parse3ary<std::string> : public std::true_type {};
template <> struct Parse3ary<StringPiece> : public std::true_type {};
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
template <> struct Parse3ary<TString> : public std::true_type {};
-#endif
+#endif
template <> struct Parse3ary<char> : public std::true_type {};
template <> struct Parse3ary<signed char> : public std::true_type {};
template <> struct Parse3ary<unsigned char> : public std::true_type {};
diff --git a/contrib/libs/re2/re2/stringpiece.h b/contrib/libs/re2/re2/stringpiece.h
index aeec0490d4..ef73683401 100644
--- a/contrib/libs/re2/re2/stringpiece.h
+++ b/contrib/libs/re2/re2/stringpiece.h
@@ -33,9 +33,9 @@
#if __has_include(<string_view>) && __cplusplus >= 201703L
#include <string_view>
#endif
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
#include <util/generic/string.h>
-#endif
+#endif
namespace re2 {
@@ -70,10 +70,10 @@ class StringPiece {
: data_(str), size_(str == NULL ? 0 : strlen(str)) {}
StringPiece(const char* str, size_type len)
: data_(str), size_(len) {}
-#if defined(ARCADIA_ROOT)
+#if defined(ARCADIA_ROOT)
StringPiece(const TString& str)
: StringPiece(str.data(), str.size()) {}
-#endif
+#endif
const_iterator begin() const { return data_; }
const_iterator end() const { return data_ + size_; }
diff --git a/contrib/libs/sparsehash/ya.make b/contrib/libs/sparsehash/ya.make
index cd32cf679c..d12785158a 100644
--- a/contrib/libs/sparsehash/ya.make
+++ b/contrib/libs/sparsehash/ya.make
@@ -2,8 +2,8 @@
LIBRARY()
-LICENSE(BSD-3-Clause)
-
+LICENSE(BSD-3-Clause)
+
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
OWNER(g:cpp-contrib)
diff --git a/contrib/libs/sqlite3/sqlite3.c b/contrib/libs/sqlite3/sqlite3.c
index e4c477615e..3b763874be 100644
--- a/contrib/libs/sqlite3/sqlite3.c
+++ b/contrib/libs/sqlite3/sqlite3.c
@@ -27181,7 +27181,7 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){
** is used regardless of the run-time threadsafety setting.
*/
#ifdef SQLITE_MUTEX_NOOP
-#error Are you sure you want this?
+#error Are you sure you want this?
SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
return sqlite3NoopMutex();
}
diff --git a/contrib/libs/sqlite3/ya.make b/contrib/libs/sqlite3/ya.make
index 6b950529ad..e6b26dccc3 100644
--- a/contrib/libs/sqlite3/ya.make
+++ b/contrib/libs/sqlite3/ya.make
@@ -55,12 +55,12 @@ IF (OS_WINDOWS)
CFLAGS(
-DSQLITE_OS_WIN
)
-ELSE()
+ELSE()
CFLAGS(
-DSQLITE_OS_UNIX
)
-ENDIF()
-
+ENDIF()
+
SRCS(
sqlite3.c
test_multiplex.c
diff --git a/contrib/libs/t1ha/src/t1ha0.c b/contrib/libs/t1ha/src/t1ha0.c
index c07cc10576..bde71299cb 100644
--- a/contrib/libs/t1ha/src/t1ha0.c
+++ b/contrib/libs/t1ha/src/t1ha0.c
@@ -361,7 +361,7 @@ uint64_t t1ha0_32be(const void *data, size_t len, uint64_t seed) {
__cold uint64_t t1ha_ia32cpu_features(void) {
uint32_t features = 0;
uint32_t extended = 0;
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__GNUC__) || defined(__clang__)
uint32_t eax, ebx, ecx, edx;
const unsigned cpuid_max = __get_cpuid_max(0, NULL);
if (cpuid_max >= 1) {
diff --git a/contrib/libs/ya.make b/contrib/libs/ya.make
index 21e14a9788..9c4640fdcf 100644
--- a/contrib/libs/ya.make
+++ b/contrib/libs/ya.make
@@ -60,15 +60,15 @@ RECURSE(
eigen
expat
falconn
- farmhash
- farmhash/ut
+ farmhash
+ farmhash/ut
faster-rnnlm
fastlz
fastops
fcgi
- ffmpeg-3
- ffmpeg-3.4.1
- fft
+ ffmpeg-3
+ ffmpeg-3.4.1
+ fft
flatbuffers
flatbuffers64
flatbuffers64/flatc
@@ -76,7 +76,7 @@ RECURSE(
fmath
fmt
fontconfig
- fp16
+ fp16
freetype
fuse
fxdiv
@@ -101,7 +101,7 @@ RECURSE(
harfbuzz
hdf5
hdr_histogram
- highwayhash
+ highwayhash
hiredis
httpd24
hwloc
@@ -147,7 +147,7 @@ RECURSE(
libev
libevent
libexslt
- libfdk-aac
+ libfdk-aac
libfuzzer12
libgeotiff
libgit2
@@ -191,12 +191,12 @@ RECURSE(
libunwind
liburing
libuv
- libvorbis
- libvorbis/libvorbisenc
- libvpx
+ libvorbis
+ libvorbis/libvorbisenc
+ libvpx
libwebp
- libx264
- libx265
+ libx264
+ libx265
libxml
libxml/dynamic
libxslt
@@ -242,7 +242,7 @@ RECURSE(
node_nan
nsync
numa
- nvidia
+ nvidia
odpi
onnx
opencl-headers
@@ -254,7 +254,7 @@ RECURSE(
openjpeg
openldap
openldap/libraries
- openmp
+ openmp
openssl
opentracing-cpp
opus
@@ -289,7 +289,7 @@ RECURSE(
python/ut
qhull
quicklz
- r-lang
+ r-lang
re2
regional-units/library
regional-units/library/ut
@@ -328,11 +328,11 @@ RECURSE(
tcmalloc/dynamic
tensorboard
termbox
- tf
- tf/samples
- tf/tensorflow
- tf/tensorflow/compiler
- tf/tests
+ tf
+ tf/samples
+ tf/tensorflow
+ tf/tensorflow/compiler
+ tf/tests
tf-2.4
tf-2.4/sample_python
tf-2.4/tensorflow/python
diff --git a/contrib/libs/zlib/gzguts.h b/contrib/libs/zlib/gzguts.h
index 2715c956e1..2b7382f654 100644
--- a/contrib/libs/zlib/gzguts.h
+++ b/contrib/libs/zlib/gzguts.h
@@ -33,8 +33,8 @@
#ifdef _WIN32
# include <stddef.h>
-#else
-# include <unistd.h>
+#else
+# include <unistd.h>
#endif
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)