snappy 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0907dc377be43ac27d5df46ef70d05ec941ce31e776bb49123532a1a4c1addbd'
4
- data.tar.gz: bb3c95ef49930abeef0c5a55c2a5be679ac694c65bcb39264380a8ef9a29ed4d
3
+ metadata.gz: b2895775124f25371d6d97fb3e0be40aba03493c5f7d9347826611c2b574f708
4
+ data.tar.gz: '0195162d3971e799cd011db55304b19a9a63a02411644d82f063f6a594f9664b'
5
5
  SHA512:
6
- metadata.gz: 99c5b7d50a94ecc9e8729fa42bc1ee57b52f82ae873e1d67f8e858fa24f8a681477b0e4ef0d32e61b337a9fd2d407fbabb5ec3ecb997b948d5ff6ea2261705f4
7
- data.tar.gz: 64b38648394f87c5e34ccc519585caee30597bcab11bf20ed110afc7db414f50a53a1c3b1bb35beb329765cae6a3763d016d0888e549f3a1650a72846e882391
6
+ metadata.gz: 5bcc0284ef578c7e0545e0fc1865351d8b1a2ef162244b9aa9bb41b0aac2a601a53d0d51badbbd1204e3b17162088a083130ab2635171a44efd0d5e3600b527b
7
+ data.tar.gz: 7a8c04e18c08ef4e981f8658c4abfdb6be004be3684d5e618a42668f305b5408dc85385e05b472250a04731b30eccaeaa2d3f3902e6b7d7a754d7c573ed3a3d8
@@ -7,7 +7,7 @@ jobs:
7
7
  strategy:
8
8
  fail-fast: false
9
9
  matrix:
10
- ruby: [2.7, 3.0, 3.1, 3.2, 3.3, jruby]
10
+ ruby: [2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 4.0, jruby]
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
13
  - uses: actions/checkout@v4
@@ -10,10 +10,14 @@ jobs:
10
10
  strategy:
11
11
  fail-fast: false
12
12
  matrix:
13
- ruby: [2.7, jruby]
13
+ ruby: [4.0, jruby]
14
+ if: github.repository == 'miyucy/snappy'
14
15
  runs-on: ubuntu-latest
16
+ permissions:
17
+ contents: write
18
+ id-token: write
15
19
  steps:
16
- - uses: actions/checkout@v2
20
+ - uses: actions/checkout@v4
17
21
  with:
18
22
  submodules: true
19
23
  - name: Set up Ruby
@@ -21,14 +25,4 @@ jobs:
21
25
  with:
22
26
  ruby-version: ${{ matrix.ruby }}
23
27
  bundler-cache: true
24
- - name: Run release task
25
- run: |
26
- mkdir -p ~/.gem
27
- cat << EOF > ~/.gem/credentials
28
- ---
29
- :github: Bearer ${{secrets.GITHUB_TOKEN}}
30
- :rubygems_api_key: ${{secrets.RUBYGEMS_API_KEY}}
31
- EOF
32
- chmod 600 ~/.gem/credentials
33
- bundle exec rake release[remote]
34
- rm -f ~/.gem/credentials
28
+ - uses: rubygems/release-gem@v1
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  # syntax = docker/dockerfile:labs
2
- ARG RUBY_VERSION=3.1
2
+ ARG RUBY_VERSION=3.4
3
3
  FROM ruby:${RUBY_VERSION}
4
4
 
5
5
  ENV BUNDLE_JOBS=4
data/Gemfile CHANGED
@@ -4,5 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem "rake", "~> 13.0"
7
+ gem "ostruct"
7
8
  gem "test-unit", "~> 3.0"
8
9
  gem "test-unit-rr"
data/README.md CHANGED
@@ -10,6 +10,9 @@ see https://github.com/google/snappy
10
10
  ```bash
11
11
  $ brew install snappy
12
12
  $ brew install autoconf automake cmake libtool
13
+
14
+ # This step may be needed if gem installation fails
15
+ bundle config build.snappy --with-snappy-dir=/opt/homebrew/opt/snappy
13
16
  ```
14
17
 
15
18
  ### Ubuntu
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ if defined?(JRUBY_VERSION)
31
31
 
32
32
  desc "Compile the extension"
33
33
  task compile: :setup do
34
- ant.javac destdir: "${build.dir}", includeantruntime: "no", target: "1.6", source: "1.6", debug: "on" do
34
+ ant.javac destdir: "${build.dir}", includeantruntime: "no", target: "1.8", source: "1.8", debug: "on" do
35
35
  classpath refid: "compile.class.path"
36
36
  src { pathelement location: "${src.dir}" }
37
37
  end
data/lib/snappy/shim.rb CHANGED
@@ -3,28 +3,8 @@
3
3
  module Snappy
4
4
  module_function
5
5
 
6
- if RUBY_VERSION[0..2] == "1.8"
7
- def set_encoding(io)
8
- io
9
- end
10
-
11
- def b(str)
12
- str
13
- end
14
- else
15
- def set_encoding(io)
16
- io.set_encoding Encoding::ASCII_8BIT
17
- io
18
- end
19
-
20
- if ::String.instance_methods.include? :b
21
- def b(str)
22
- str.b
23
- end
24
- else
25
- def b(str)
26
- str.force_encoding Encoding::ASCII_8BIT
27
- end
28
- end
6
+ def set_encoding(io)
7
+ io.set_encoding Encoding::ASCII_8BIT
8
+ io
29
9
  end
30
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snappy
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/snappy/writer.rb CHANGED
@@ -4,7 +4,7 @@ require 'snappy/shim'
4
4
 
5
5
  module Snappy
6
6
  class Writer
7
- MAGIC = Snappy.b("\x82SNAPPY\x0")
7
+ MAGIC = "\x82SNAPPY\x0".b
8
8
  DEFAULT_VERSION = 1
9
9
  MINIMUM_COMPATIBLE_VERSION = 1
10
10
  DEFAULT_BLOCK_SIZE = 32 * 1024
data/test/snappy_test.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "test_helper"
4
+ require "securerandom"
4
5
 
5
6
  class SnappyTest < Test::Unit::TestCase
6
- T = [*"a".."z", *"A".."Z", *"0".."9"].freeze
7
-
8
7
  def random_data(length = 1024)
9
- Array.new(length) { T.sample }.join
8
+ SecureRandom.alphanumeric(length)
10
9
  end
11
10
 
12
11
  test "VERSION" do
@@ -20,6 +19,11 @@ class SnappyTest < Test::Unit::TestCase
20
19
  assert_equal s, Snappy.inflate(Snappy.deflate(s))
21
20
  end
22
21
 
22
+ test "binary data" do
23
+ s = SecureRandom.random_bytes(1024)
24
+ assert_equal s, Snappy.inflate(Snappy.deflate(s))
25
+ end
26
+
23
27
  test "well done (pair)" do
24
28
  s = random_data
25
29
  [
@@ -83,13 +87,34 @@ class SnappyTest < Test::Unit::TestCase
83
87
  notify "Ractor not defined"
84
88
  omit
85
89
  end
90
+ unless RUBY_VERSION.start_with?("4")
91
+ omit
92
+ end
86
93
  s = random_data
87
94
  a = Array.new(2) do
88
95
  Ractor.new(s) do |s|
89
96
  Snappy.inflate(Snappy.deflate(s)) == s
90
97
  end
91
98
  end
92
- assert_equal [true, true], a.map(&:take)
99
+ assert_equal [true, true], a.map(&:value)
100
+ end
101
+
102
+ test "take2" do
103
+ unless defined? ::Ractor
104
+ notify "Ractor not defined"
105
+ omit
106
+ end
107
+ unless RUBY_VERSION.start_with?("4")
108
+ omit
109
+ end
110
+ s = random_data
111
+ i = Ractor.new(s) do |s|
112
+ Snappy.deflate(s)
113
+ end.value
114
+ j = Ractor.new(i) do |i|
115
+ Snappy.inflate(i)
116
+ end.value
117
+ assert_equal s, j
93
118
  end
94
119
  end
95
120
  end
@@ -0,0 +1,211 @@
1
+ # Copyright 2023 Google Inc. All Rights Reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are
5
+ # met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above
10
+ # copyright notice, this list of conditions and the following disclaimer
11
+ # in the documentation and/or other materials provided with the
12
+ # distribution.
13
+ # * Neither the name of Google Inc. nor the names of its
14
+ # contributors may be used to endorse or promote products derived from
15
+ # this software without specific prior written permission.
16
+ #
17
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ package(default_visibility = ["//visibility:public"])
30
+
31
+ licenses(["notice"])
32
+
33
+ SNAPPY_VERSION = (1, 2, 2)
34
+
35
+ config_setting(
36
+ name = "windows",
37
+ constraint_values = ["@platforms//os:windows"],
38
+ )
39
+
40
+ cc_library(
41
+ name = "config",
42
+ hdrs = ["config.h"],
43
+ defines = ["HAVE_CONFIG_H"],
44
+ )
45
+
46
+ cc_library(
47
+ name = "snappy-stubs-public",
48
+ hdrs = [":snappy-stubs-public.h"],
49
+ )
50
+
51
+ cc_library(
52
+ name = "snappy-stubs-internal",
53
+ srcs = ["snappy-stubs-internal.cc"],
54
+ hdrs = ["snappy-stubs-internal.h"],
55
+ deps = [
56
+ ":config",
57
+ ":snappy-stubs-public",
58
+ ],
59
+ )
60
+
61
+ cc_library(
62
+ name = "snappy",
63
+ srcs = [
64
+ "snappy.cc",
65
+ "snappy-internal.h",
66
+ "snappy-sinksource.cc",
67
+ ],
68
+ hdrs = [
69
+ "snappy.h",
70
+ "snappy-sinksource.h",
71
+ ],
72
+ copts = select({
73
+ ":windows": [],
74
+ "//conditions:default": [
75
+ "-Wno-sign-compare",
76
+ ],
77
+ }),
78
+ deps = [
79
+ ":config",
80
+ ":snappy-stubs-internal",
81
+ ":snappy-stubs-public",
82
+ ],
83
+ )
84
+
85
+ cc_library(
86
+ name = "snappy-c",
87
+ srcs = ["snappy-c.cc"],
88
+ hdrs = ["snappy-c.h"],
89
+ deps = [":snappy"],
90
+ )
91
+
92
+ filegroup(
93
+ name = "testdata",
94
+ srcs = glob(["testdata/*"]),
95
+ )
96
+
97
+ cc_library(
98
+ name = "snappy-test",
99
+ testonly = True,
100
+ srcs = [
101
+ "snappy-test.cc",
102
+ "snappy_test_data.cc",
103
+ ],
104
+ hdrs = [
105
+ "snappy-test.h",
106
+ "snappy_test_data.h",
107
+ ],
108
+ deps = [":snappy-stubs-internal"],
109
+ )
110
+
111
+ cc_test(
112
+ name = "snappy_benchmark",
113
+ srcs = ["snappy_benchmark.cc"],
114
+ data = [":testdata"],
115
+ deps = [
116
+ ":snappy",
117
+ ":snappy-test",
118
+ "@com_google_benchmark//:benchmark_main",
119
+ ],
120
+ )
121
+
122
+ cc_test(
123
+ name = "snappy_unittest",
124
+ srcs = [
125
+ "snappy_unittest.cc",
126
+ ],
127
+ data = [":testdata"],
128
+ deps = [
129
+ ":snappy",
130
+ ":snappy-test",
131
+ "@com_google_googletest//:gtest_main",
132
+ ],
133
+ )
134
+
135
+ # Generate a config.h similar to what cmake would produce.
136
+ genrule(
137
+ name = "config_h",
138
+ outs = ["config.h"],
139
+ cmd = """cat <<EOF >$@
140
+ #define HAVE_STDDEF_H 1
141
+ #define HAVE_STDINT_H 1
142
+ #ifdef __has_builtin
143
+ # if !defined(HAVE_BUILTIN_EXPECT) && __has_builtin(__builtin_expect)
144
+ # define HAVE_BUILTIN_EXPECT 1
145
+ # endif
146
+ # if !defined(HAVE_BUILTIN_CTZ) && __has_builtin(__builtin_ctzll)
147
+ # define HAVE_BUILTIN_CTZ 1
148
+ # endif
149
+ # if !defined(HAVE_BUILTIN_PREFETCH) && __has_builtin(__builtin_prefetech)
150
+ # define HAVE_BUILTIN_PREFETCH 1
151
+ # endif
152
+ #elif defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
153
+ # ifndef HAVE_BUILTIN_EXPECT
154
+ # define HAVE_BUILTIN_EXPECT 1
155
+ # endif
156
+ # ifndef HAVE_BUILTIN_CTZ
157
+ # define HAVE_BUILTIN_CTZ 1
158
+ # endif
159
+ # ifndef HAVE_BUILTIN_PREFETCH
160
+ # define HAVE_BUILTIN_PREFETCH 1
161
+ # endif
162
+ #endif
163
+
164
+ #if defined(_WIN32) && !defined(HAVE_WINDOWS_H)
165
+ #define HAVE_WINDOWS_H 1
166
+ #endif
167
+
168
+ #ifdef __has_include
169
+ # if !defined(HAVE_BYTESWAP_H) && __has_include(<byteswap.h>)
170
+ # define HAVE_BYTESWAP_H 1
171
+ # endif
172
+ # if !defined(HAVE_UNISTD_H) && __has_include(<unistd.h>)
173
+ # define HAVE_UNISTD_H 1
174
+ # endif
175
+ # if !defined(HAVE_SYS_ENDIAN_H) && __has_include(<sys/endian.h>)
176
+ # define HAVE_SYS_ENDIAN_H 1
177
+ # endif
178
+ # if !defined(HAVE_SYS_MMAN_H) && __has_include(<sys/mman.h>)
179
+ # define HAVE_SYS_MMAN_H 1
180
+ # endif
181
+ # if !defined(HAVE_SYS_UIO_H) && __has_include(<sys/uio.h>)
182
+ # define HAVE_SYS_UIO_H 1
183
+ # endif
184
+ # if !defined(HAVE_SYS_TIME_H) && __has_include(<sys/time.h>)
185
+ # define HAVE_SYS_TIME_H 1
186
+ # endif
187
+ #endif
188
+
189
+ #ifndef SNAPPY_IS_BIG_ENDIAN
190
+ # ifdef __s390x__
191
+ # define SNAPPY_IS_BIG_ENDIAN 1
192
+ # elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
193
+ # define SNAPPY_IS_BIG_ENDIAN 1
194
+ # endif
195
+ #endif
196
+ EOF
197
+ """,
198
+ )
199
+
200
+ genrule(
201
+ name = "snappy_stubs_public_h",
202
+ srcs = ["snappy-stubs-public.h.in"],
203
+ outs = ["snappy-stubs-public.h"],
204
+ # Assume sys/uio.h is available on non-Windows.
205
+ # Set the version numbers.
206
+ cmd = ("""sed -e 's/$${HAVE_SYS_UIO_H_01}/!_WIN32/g' \
207
+ -e 's/$${PROJECT_VERSION_MAJOR}/%d/g' \
208
+ -e 's/$${PROJECT_VERSION_MINOR}/%d/g' \
209
+ -e 's/$${PROJECT_VERSION_PATCH}/%d/g' \
210
+ $< >$@""" % SNAPPY_VERSION),
211
+ )
@@ -26,8 +26,8 @@
26
26
  # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
27
  # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
28
 
29
- cmake_minimum_required(VERSION 3.1)
30
- project(Snappy VERSION 1.1.10 LANGUAGES C CXX)
29
+ cmake_minimum_required(VERSION 3.10)
30
+ project(Snappy VERSION 1.2.2 LANGUAGES C CXX)
31
31
 
32
32
  # C++ standard can be overridden when this is used as a sub-project.
33
33
  if(NOT CMAKE_CXX_STANDARD)
@@ -38,7 +38,7 @@ if(NOT CMAKE_CXX_STANDARD)
38
38
  endif(NOT CMAKE_CXX_STANDARD)
39
39
 
40
40
  # https://github.com/izenecloud/cmake/blob/master/SetCompilerWarningAll.cmake
41
- if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
41
+ if(MSVC)
42
42
  # Use the highest warning level for Visual Studio.
43
43
  set(CMAKE_CXX_WARNING_LEVEL 4)
44
44
  if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
@@ -55,7 +55,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
55
55
  # Disable RTTI.
56
56
  string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
57
57
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
58
- else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
58
+ else(MSVC)
59
59
  # Use -Wall for clang and gcc.
60
60
  if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
61
61
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
@@ -73,6 +73,11 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
73
73
  endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
74
74
  endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
75
75
 
76
+ # Disable sign comparison warnings. Matches upcoming Bazel setup.
77
+ if(NOT CMAKE_CXX_FLAGS MATCHES "-Wno-sign-compare")
78
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
79
+ endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wno-sign-compare")
80
+
76
81
  # Disable C++ exceptions.
77
82
  string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
78
83
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
@@ -80,7 +85,7 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
80
85
  # Disable RTTI.
81
86
  string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
82
87
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
83
- endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
88
+ endif(MSVC)
84
89
 
85
90
  # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
86
91
  # it prominent in the GUI.
@@ -141,6 +146,8 @@ endif(SNAPPY_REQUIRE_AVX2)
141
146
  # Used by googletest.
142
147
  check_cxx_compiler_flag(-Wno-missing-field-initializers
143
148
  SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
149
+ check_cxx_compiler_flag(-Wno-implicit-int-float-conversion
150
+ SNAPPY_HAVE_NO_IMPLICIT_INT_FLOAT_CONVERSION)
144
151
 
145
152
  include(CheckCXXSourceCompiles)
146
153
  check_cxx_source_compiles("
@@ -153,6 +160,12 @@ int main() {
153
160
  return __builtin_ctzll(0);
154
161
  }" HAVE_BUILTIN_CTZ)
155
162
 
163
+ check_cxx_source_compiles("
164
+ int main() {
165
+ __builtin_prefetch(0, 0, 3);
166
+ return 0;
167
+ }" HAVE_BUILTIN_PREFETCH)
168
+
156
169
  check_cxx_source_compiles("
157
170
  __attribute__((always_inline)) int zero() { return 0; }
158
171
 
@@ -193,10 +206,13 @@ int main() {
193
206
 
194
207
  check_cxx_source_compiles("
195
208
  #include <arm_neon.h>
209
+ #include <stdint.h>
196
210
  int main() {
197
211
  uint8_t val = 3, dup[8];
198
- uint8x16_t v = vld1q_dup_u8(&val);
199
- vst1q_u8(dup, v);
212
+ uint8x16_t v1 = vld1q_dup_u8(&val);
213
+ uint8x16_t v2 = vqtbl1q_u8(v1, v1);
214
+ vst1q_u8(dup, v1);
215
+ vst1q_u8(dup, v2);
200
216
  return 0;
201
217
  }" SNAPPY_HAVE_NEON)
202
218
 
@@ -245,9 +261,7 @@ target_sources(snappy
245
261
  "snappy-stubs-internal.cc"
246
262
  "snappy.cc"
247
263
  "${PROJECT_BINARY_DIR}/config.h"
248
-
249
- # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
250
- $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
264
+ PUBLIC
251
265
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
252
266
  $<INSTALL_INTERFACE:include/snappy-c.h>
253
267
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
@@ -284,6 +298,9 @@ if(SNAPPY_BUILD_TESTS OR SNAPPY_BUILD_BENCHMARKS)
284
298
 
285
299
  # Test files include snappy-test.h, HAVE_CONFIG_H must be defined.
286
300
  target_compile_definitions(snappy_test_support PUBLIC -DHAVE_CONFIG_H)
301
+ if(BUILD_SHARED_LIBS)
302
+ set_target_properties(snappy_test_support PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
303
+ endif(BUILD_SHARED_LIBS)
287
304
 
288
305
  target_link_libraries(snappy_test_support snappy)
289
306
 
@@ -323,6 +340,11 @@ if(SNAPPY_BUILD_TESTS)
323
340
  APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
324
341
  endif(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
325
342
 
343
+ if(SNAPPY_HAVE_NO_IMPLICIT_INT_FLOAT_CONVERSION)
344
+ set_property(TARGET gtest
345
+ APPEND PROPERTY COMPILE_OPTIONS -Wno-implicit-int-float-conversion)
346
+ endif(SNAPPY_HAVE_NO_IMPLICIT_INT_FLOAT_CONVERSION)
347
+
326
348
  add_executable(snappy_unittest "")
327
349
  target_sources(snappy_unittest
328
350
  PRIVATE
@@ -0,0 +1,23 @@
1
+ module(
2
+ name = "snappy",
3
+ version = "1.2.2",
4
+ compatibility_level = 1,
5
+ )
6
+
7
+ bazel_dep(
8
+ name = "googletest",
9
+ version = "1.14.0.bcr.1",
10
+ dev_dependency = True,
11
+ repo_name = "com_google_googletest",
12
+ )
13
+ bazel_dep(
14
+ name = "google_benchmark",
15
+ version = "1.9.0",
16
+ dev_dependency = True,
17
+ repo_name = "com_google_benchmark",
18
+ )
19
+
20
+ bazel_dep(
21
+ name = "platforms",
22
+ version = "0.0.9",
23
+ )
data/vendor/snappy/NEWS CHANGED
@@ -1,3 +1,18 @@
1
+ Snappy v1.2.2, Mar 26th 2025:
2
+
3
+ * We added a new compression level in v1.2.1 which compresses a bit
4
+ denser but slower. Decompression speed should be even faster with it.
5
+
6
+ * We fixed a very old issue of data corruption when compressed size
7
+ exceeds 4GB. This can happen when you compress data close to 4GB
8
+ and it's incompressible, for example, random data.
9
+
10
+ * Started to use minimum CMake 3.10 because older ones are not
11
+ planned to be supported.
12
+
13
+ * Various other small fixes and performance improvements (especially
14
+ for clang).
15
+
1
16
  Snappy v1.1.10, Mar 8th 2023:
2
17
 
3
18
  * Performance improvements
@@ -140,10 +140,10 @@ explicitly supports the following:
140
140
  1. C++11
141
141
  2. Clang (gcc and MSVC are best-effort).
142
142
  3. Low level optimizations (e.g. assembly or equivalent intrinsics) for:
143
- 1. [x86](https://en.wikipedia.org/wiki/X86)
144
- 2. [x86-64](https://en.wikipedia.org/wiki/X86-64)
145
- 3. ARMv7 (32-bit)
146
- 4. ARMv8 (AArch64)
143
+ - [x86](https://en.wikipedia.org/wiki/X86)
144
+ - [x86-64](https://en.wikipedia.org/wiki/X86-64)
145
+ - ARMv7 (32-bit)
146
+ - ARMv8 (AArch64)
147
147
  4. Supports only the Snappy compression scheme as described in
148
148
  [format_description.txt](format_description.txt).
149
149
  5. CMake for building
@@ -0,0 +1,27 @@
1
+ # Copyright 2023 Google Inc. All Rights Reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are
5
+ # met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above
10
+ # copyright notice, this list of conditions and the following disclaimer
11
+ # in the documentation and/or other materials provided with the
12
+ # distribution.
13
+ # * Neither the name of Google Inc. nor the names of its
14
+ # contributors may be used to endorse or promote products derived from
15
+ # this software without specific prior written permission.
16
+ #
17
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File without changes
@@ -10,6 +10,9 @@
10
10
  /* Define to 1 if the compiler supports __builtin_expect. */
11
11
  #cmakedefine01 HAVE_BUILTIN_EXPECT
12
12
 
13
+ /* Define to 1 if the compiler supports __builtin_prefetch. */
14
+ #cmakedefine01 HAVE_BUILTIN_PREFETCH
15
+
13
16
  /* Define to 1 if you have a definition for mmap() in <sys/mman.h>. */
14
17
  #cmakedefine01 HAVE_FUNC_MMAP
15
18
 
@@ -31,6 +31,8 @@
31
31
  #ifndef THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_
32
32
  #define THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_
33
33
 
34
+ #include <utility>
35
+
34
36
  #include "snappy-stubs-internal.h"
35
37
 
36
38
  #if SNAPPY_HAVE_SSSE3
@@ -256,6 +258,8 @@ static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
256
258
  s2 += 8;
257
259
  }
258
260
  }
261
+ SNAPPY_PREFETCH(s1 + 64);
262
+ SNAPPY_PREFETCH(s2 + 64);
259
263
 
260
264
  // Find out how long the match is. We loop over the data 64 bits at a
261
265
  // time until we find a 64-bit block that doesn't match; then we find
@@ -330,6 +334,31 @@ static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
330
334
  }
331
335
  #endif
332
336
 
337
+ static inline size_t FindMatchLengthPlain(const char* s1, const char* s2,
338
+ const char* s2_limit) {
339
+ // Implementation based on the x86-64 version, above.
340
+ assert(s2_limit >= s2);
341
+ int matched = 0;
342
+
343
+ while (s2 <= s2_limit - 8 &&
344
+ UNALIGNED_LOAD64(s2) == UNALIGNED_LOAD64(s1 + matched)) {
345
+ s2 += 8;
346
+ matched += 8;
347
+ }
348
+ if (LittleEndian::IsLittleEndian() && s2 <= s2_limit - 8) {
349
+ uint64_t x = UNALIGNED_LOAD64(s2) ^ UNALIGNED_LOAD64(s1 + matched);
350
+ int matching_bits = Bits::FindLSBSetNonZero64(x);
351
+ matched += matching_bits >> 3;
352
+ s2 += matching_bits >> 3;
353
+ } else {
354
+ while ((s2 < s2_limit) && (s1[matched] == *s2)) {
355
+ ++s2;
356
+ ++matched;
357
+ }
358
+ }
359
+ return matched;
360
+ }
361
+
333
362
  // Lookup tables for decompression code. Give --snappy_dump_decompression_table
334
363
  // to the unit test to recompute char_table.
335
364