snappy 0.0.17 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +6 -1
  3. data/Gemfile +5 -0
  4. data/README.md +28 -4
  5. data/Rakefile +1 -0
  6. data/ext/extconf.rb +21 -16
  7. data/lib/snappy.rb +1 -0
  8. data/lib/snappy/hadoop.rb +22 -0
  9. data/lib/snappy/hadoop/reader.rb +58 -0
  10. data/lib/snappy/hadoop/writer.rb +51 -0
  11. data/lib/snappy/reader.rb +4 -4
  12. data/lib/snappy/version.rb +1 -1
  13. data/smoke.sh +1 -1
  14. data/snappy.gemspec +0 -4
  15. data/test/hadoop/test-snappy-hadoop-reader.rb +103 -0
  16. data/test/hadoop/test-snappy-hadoop-writer.rb +48 -0
  17. data/test/test-snappy-hadoop.rb +22 -0
  18. data/vendor/snappy/CMakeLists.txt +174 -0
  19. data/vendor/snappy/CONTRIBUTING.md +26 -0
  20. data/vendor/snappy/NEWS +32 -0
  21. data/vendor/snappy/{README → README.md} +13 -3
  22. data/vendor/snappy/cmake/SnappyConfig.cmake +1 -0
  23. data/vendor/snappy/cmake/config.h.in +62 -0
  24. data/vendor/snappy/snappy-internal.h +9 -12
  25. data/vendor/snappy/snappy-stubs-internal.h +63 -30
  26. data/vendor/snappy/snappy-stubs-public.h.in +13 -19
  27. data/vendor/snappy/snappy-test.cc +10 -7
  28. data/vendor/snappy/snappy-test.h +12 -38
  29. data/vendor/snappy/snappy.cc +81 -30
  30. data/vendor/snappy/snappy_unittest.cc +16 -137
  31. metadata +18 -82
  32. data/vendor/snappy/ChangeLog +0 -2468
  33. data/vendor/snappy/INSTALL +0 -370
  34. data/vendor/snappy/Makefile +0 -982
  35. data/vendor/snappy/Makefile.am +0 -26
  36. data/vendor/snappy/Makefile.in +0 -982
  37. data/vendor/snappy/aclocal.m4 +0 -9738
  38. data/vendor/snappy/autogen.sh +0 -12
  39. data/vendor/snappy/autom4te.cache/output.0 +0 -18856
  40. data/vendor/snappy/autom4te.cache/output.1 +0 -18852
  41. data/vendor/snappy/autom4te.cache/requests +0 -297
  42. data/vendor/snappy/autom4te.cache/traces.0 +0 -2689
  43. data/vendor/snappy/autom4te.cache/traces.1 +0 -714
  44. data/vendor/snappy/config.guess +0 -1530
  45. data/vendor/snappy/config.h +0 -135
  46. data/vendor/snappy/config.h.in +0 -134
  47. data/vendor/snappy/config.log +0 -1640
  48. data/vendor/snappy/config.status +0 -2318
  49. data/vendor/snappy/config.sub +0 -1773
  50. data/vendor/snappy/configure +0 -18852
  51. data/vendor/snappy/configure.ac +0 -134
  52. data/vendor/snappy/depcomp +0 -688
  53. data/vendor/snappy/install-sh +0 -527
  54. data/vendor/snappy/libtool +0 -10246
  55. data/vendor/snappy/ltmain.sh +0 -9661
  56. data/vendor/snappy/m4/gtest.m4 +0 -74
  57. data/vendor/snappy/m4/libtool.m4 +0 -8001
  58. data/vendor/snappy/m4/ltoptions.m4 +0 -384
  59. data/vendor/snappy/m4/ltsugar.m4 +0 -123
  60. data/vendor/snappy/m4/ltversion.m4 +0 -23
  61. data/vendor/snappy/m4/lt~obsolete.m4 +0 -98
  62. data/vendor/snappy/missing +0 -331
  63. data/vendor/snappy/snappy-stubs-public.h +0 -100
  64. data/vendor/snappy/snappy.pc +0 -10
  65. data/vendor/snappy/snappy.pc.in +0 -10
  66. data/vendor/snappy/stamp-h1 +0 -1
@@ -0,0 +1,48 @@
1
+ require "minitest/autorun"
2
+ require "minitest/spec"
3
+ require "snappy"
4
+ require "stringio"
5
+
6
+ describe Snappy::Hadoop::Writer do
7
+ before do
8
+ @buffer = StringIO.new
9
+ end
10
+
11
+ subject do
12
+ Snappy::Hadoop::Writer.new @buffer
13
+ end
14
+
15
+ describe :initialize do
16
+ it "should yield itself to the block" do
17
+ yielded = nil
18
+ returned = Snappy::Hadoop::Writer.new @buffer do |w|
19
+ yielded = w
20
+ end
21
+ returned.must_equal yielded
22
+ end
23
+
24
+ it "should dump on the end of yield" do
25
+ Snappy::Hadoop::Writer.new @buffer do |w|
26
+ w << "foo"
27
+ end
28
+ @buffer.string.must_equal "\u0000\u0000\u0000\u0003\u0000\u0000\u0000\u0005\u0003\bfoo"
29
+ end
30
+ end
31
+
32
+ describe :io do
33
+ it "should be a constructor argument" do
34
+ io = StringIO.new
35
+ Snappy::Hadoop::Writer.new(io).io.must_equal io
36
+ end
37
+ end
38
+
39
+ describe :block_size do
40
+ it "should default to DEFAULT_BLOCK_SIZE" do
41
+ Snappy::Hadoop::Writer.new(StringIO.new).block_size.must_equal Snappy::Hadoop::Writer::DEFAULT_BLOCK_SIZE
42
+ end
43
+
44
+ it "should be settable via the constructor" do
45
+ Snappy::Hadoop::Writer.new(StringIO.new, 42).block_size.must_equal 42
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,22 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/spec'
3
+ require 'snappy'
4
+
5
+ describe Snappy::Hadoop do
6
+ T = [*'a'..'z', *'A'..'Z', *'0'..'9']
7
+
8
+ it 'well done' do
9
+ s = Array.new(1024){T.sample}.join
10
+ Snappy::Hadoop.inflate(Snappy::Hadoop.deflate s).must_equal(s)
11
+ end
12
+
13
+ it 'well done (pair)' do
14
+ s = Array.new(1024){T.sample}.join
15
+ [
16
+ [:deflate, :inflate],
17
+ ].each do |(i, o)|
18
+ Snappy::Hadoop.__send__(o, (Snappy::Hadoop.__send__ i, s)).must_equal(s)
19
+ eval %{Snappy::Hadoop.#{o}(Snappy::Hadoop.#{i} s).must_equal(s)}
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,174 @@
1
+ cmake_minimum_required(VERSION 3.1)
2
+ project(Snappy VERSION 1.1.7 LANGUAGES C CXX)
3
+
4
+ # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
5
+ # it prominent in the GUI.
6
+ option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)
7
+
8
+ option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON)
9
+
10
+ include(TestBigEndian)
11
+ test_big_endian(SNAPPY_IS_BIG_ENDIAN)
12
+
13
+ include(CheckIncludeFile)
14
+ check_include_file("byteswap.h" HAVE_BYTESWAP_H)
15
+ check_include_file("stddef.h" HAVE_STDDEF_H)
16
+ check_include_file("stdint.h" HAVE_STDINT_H)
17
+ check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H)
18
+ check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
19
+ check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
20
+ check_include_file("sys/time.h" HAVE_SYS_TIME_H)
21
+ check_include_file("sys/uio.h" HAVE_SYS_UIO_H)
22
+ check_include_file("unistd.h" HAVE_UNISTD_H)
23
+ check_include_file("windows.h" HAVE_WINDOWS_H)
24
+
25
+ include(CheckLibraryExists)
26
+ check_library_exists(z zlibVersion "" HAVE_LIBZ)
27
+ check_library_exists(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
28
+
29
+ include(CheckCXXSourceCompiles)
30
+ check_cxx_source_compiles(
31
+ "int main(void) { return __builtin_expect(0, 1); }" HAVE_BUILTIN_EXPECT)
32
+
33
+ check_cxx_source_compiles(
34
+ "int main(void) { return __builtin_ctzll(0); }" HAVE_BUILTIN_CTZ)
35
+
36
+ include(CheckSymbolExists)
37
+ check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP)
38
+ check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF)
39
+
40
+ find_package(GTest QUIET)
41
+ if(GTEST_FOUND)
42
+ set(HAVE_GTEST 1)
43
+ endif(GTEST_FOUND)
44
+
45
+ find_package(Gflags QUIET)
46
+ if(GFLAGS_FOUND)
47
+ set(HAVE_GFLAGS 1)
48
+ endif(GFLAGS_FOUND)
49
+
50
+ configure_file(
51
+ "${PROJECT_SOURCE_DIR}/cmake/config.h.in"
52
+ "${PROJECT_BINARY_DIR}/config.h"
53
+ )
54
+
55
+ # We don't want to define HAVE_ macros in public headers. Instead, we use
56
+ # CMake's variable substitution with 0/1 variables, which will be seen by the
57
+ # preprocessor as constants.
58
+ set(HAVE_STDINT_H_01 ${HAVE_STDINT_H})
59
+ set(HAVE_STDDEF_H_01 ${HAVE_STDDEF_H})
60
+ set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H})
61
+ if(NOT HAVE_STDINT_H_01)
62
+ set(HAVE_STDINT_H_01 0)
63
+ endif(NOT HAVE_STDINT_H_01)
64
+ if(NOT HAVE_STDDEF_H_01)
65
+ set(HAVE_STDDEF_H_01 0)
66
+ endif(NOT HAVE_STDDEF_H_01)
67
+ if(NOT HAVE_SYS_UIO_H_01)
68
+ set(HAVE_SYS_UIO_H_01 0)
69
+ endif(NOT HAVE_SYS_UIO_H_01)
70
+
71
+ configure_file(
72
+ "${PROJECT_SOURCE_DIR}/snappy-stubs-public.h.in"
73
+ "${PROJECT_BINARY_DIR}/snappy-stubs-public.h")
74
+
75
+ add_library(snappy "")
76
+ target_sources(snappy
77
+ PRIVATE
78
+ "${PROJECT_SOURCE_DIR}/snappy-internal.h"
79
+ "${PROJECT_SOURCE_DIR}/snappy-stubs-internal.h"
80
+ "${PROJECT_SOURCE_DIR}/snappy-c.cc"
81
+ "${PROJECT_SOURCE_DIR}/snappy-sinksource.cc"
82
+ "${PROJECT_SOURCE_DIR}/snappy-stubs-internal.cc"
83
+ "${PROJECT_SOURCE_DIR}/snappy.cc"
84
+ "${PROJECT_BINARY_DIR}/config.h"
85
+
86
+ # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
87
+ $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
88
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
89
+ $<INSTALL_INTERFACE:include/snappy-c.h>
90
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
91
+ $<INSTALL_INTERFACE:include/snappy-sinksource.h>
92
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h>
93
+ $<INSTALL_INTERFACE:include/snappy.h>
94
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h>
95
+ $<INSTALL_INTERFACE:include/snappy-stubs-public.h>
96
+ )
97
+ target_include_directories(snappy
98
+ PUBLIC
99
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
100
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
101
+ $<INSTALL_INTERFACE:include>
102
+ )
103
+ set_target_properties(snappy
104
+ PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
105
+
106
+ target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
107
+ if(BUILD_SHARED_LIBS)
108
+ set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
109
+ endif(BUILD_SHARED_LIBS)
110
+
111
+ if(SNAPPY_BUILD_TESTS)
112
+ enable_testing()
113
+
114
+ add_executable(snappy_unittest "")
115
+ target_sources(snappy_unittest
116
+ PRIVATE
117
+ "${PROJECT_SOURCE_DIR}/snappy_unittest.cc"
118
+ "${PROJECT_SOURCE_DIR}/snappy-test.cc"
119
+ )
120
+ target_compile_definitions(snappy_unittest PRIVATE -DHAVE_CONFIG_H)
121
+ target_link_libraries(snappy_unittest snappy ${GFLAGS_LIBRARIES})
122
+
123
+ if(HAVE_LIBZ)
124
+ target_link_libraries(snappy_unittest z)
125
+ endif(HAVE_LIBZ)
126
+ if(HAVE_LIBLZO2)
127
+ target_link_libraries(snappy_unittest lzo2)
128
+ endif(HAVE_LIBLZO2)
129
+
130
+ target_include_directories(snappy_unittest
131
+ BEFORE PRIVATE
132
+ "${PROJECT_SOURCE_DIR}"
133
+ "${GTEST_INCLUDE_DIRS}"
134
+ "${GFLAGS_INCLUDE_DIRS}"
135
+ )
136
+
137
+ add_test(
138
+ NAME snappy_unittest
139
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
140
+ COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest")
141
+ endif(SNAPPY_BUILD_TESTS)
142
+
143
+ include(GNUInstallDirs)
144
+ install(TARGETS snappy
145
+ EXPORT SnappyTargets
146
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
147
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
148
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
149
+ )
150
+ install(
151
+ FILES
152
+ "${PROJECT_SOURCE_DIR}/snappy-c.h"
153
+ "${PROJECT_SOURCE_DIR}/snappy-sinksource.h"
154
+ "${PROJECT_SOURCE_DIR}/snappy.h"
155
+ "${PROJECT_BINARY_DIR}/snappy-stubs-public.h"
156
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
157
+ )
158
+
159
+ include(CMakePackageConfigHelpers)
160
+ write_basic_package_version_file(
161
+ "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake"
162
+ COMPATIBILITY SameMajorVersion
163
+ )
164
+ install(
165
+ EXPORT SnappyTargets
166
+ NAMESPACE Snappy::
167
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy"
168
+ )
169
+ install(
170
+ FILES
171
+ "${PROJECT_SOURCE_DIR}/cmake/SnappyConfig.cmake"
172
+ "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake"
173
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy"
174
+ )
@@ -0,0 +1,26 @@
1
+ # How to Contribute
2
+
3
+ We'd love to accept your patches and contributions to this project. There are
4
+ just a few small guidelines you need to follow.
5
+
6
+ ## Contributor License Agreement
7
+
8
+ Contributions to this project must be accompanied by a Contributor License
9
+ Agreement. You (or your employer) retain the copyright to your contribution,
10
+ this simply gives us permission to use and redistribute your contributions as
11
+ part of the project. Head over to <https://cla.developers.google.com/> to see
12
+ your current agreements on file or to sign a new one.
13
+
14
+ You generally only need to submit a CLA once, so if you've already submitted one
15
+ (even if it was for a different project), you probably don't need to do it
16
+ again.
17
+
18
+ ## Code reviews
19
+
20
+ All submissions, including submissions by project members, require review. We
21
+ use GitHub pull requests for this purpose. Consult
22
+ [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23
+ information on using pull requests.
24
+
25
+ Please make sure that all the automated checks (CLA, AppVeyor, Travis) pass for
26
+ your pull requests. Pull requests whose checks fail may be ignored.
@@ -1,3 +1,35 @@
1
+ Snappy v1.1.7, August 24th 2017:
2
+
3
+ * Improved CMake build support for 64-bit Linux distributions.
4
+
5
+ * MSVC builds now use MSVC-specific intrinsics that map to clzll.
6
+
7
+ * ARM64 (AArch64) builds use the code paths optimized for 64-bit processors.
8
+
9
+ Snappy v1.1.6, July 12th 2017:
10
+
11
+ This is a re-release of v1.1.5 with proper SONAME / SOVERSION values.
12
+
13
+ Snappy v1.1.5, June 28th 2017:
14
+
15
+ This release has broken SONAME / SOVERSION values. Users of snappy as a shared
16
+ library should avoid 1.1.5 and use 1.1.6 instead. SONAME / SOVERSION errors will
17
+ manifest as the dynamic library loader complaining that it cannot find snappy's
18
+ shared library file (libsnappy.so / libsnappy.dylib), or that the library it
19
+ found does not have the required version. 1.1.6 has the same code as 1.1.5, but
20
+ carries build configuration fixes for the issues above.
21
+
22
+ * Add CMake build support. The autoconf build support is now deprecated, and
23
+ will be removed in the next release.
24
+
25
+ * Add AppVeyor configuration, for Windows CI coverage.
26
+
27
+ * Small performance improvement on little-endian PowerPC.
28
+
29
+ * Small performance improvement on LLVM with position-independent executables.
30
+
31
+ * Fix a few issues with various build environments.
32
+
1
33
  Snappy v1.1.4, January 25th 2017:
2
34
 
3
35
  * Fix a 1% performance regression when snappy is used in PIE executables.
@@ -34,7 +34,7 @@ Snappy is intended to be fast. On a single core of a Core i7 processor
34
34
  in 64-bit mode, it compresses at about 250 MB/sec or more and decompresses at
35
35
  about 500 MB/sec or more. (These numbers are for the slowest inputs in our
36
36
  benchmark suite; others are much faster.) In our tests, Snappy usually
37
- is faster than algorithms in the same class (e.g. LZO, LZF, FastLZ, QuickLZ,
37
+ is faster than algorithms in the same class (e.g. LZO, LZF, QuickLZ,
38
38
  etc.) while achieving comparable compression ratios.
39
39
 
40
40
  Typical compression ratios (based on the benchmark suite) are about 1.5-1.7x
@@ -52,7 +52,7 @@ In particular:
52
52
  - Snappy uses 64-bit operations in several places to process more data at
53
53
  once than would otherwise be possible.
54
54
  - Snappy assumes unaligned 32- and 64-bit loads and stores are cheap.
55
- On some platforms, these must be emulated with single-byte loads
55
+ On some platforms, these must be emulated with single-byte loads
56
56
  and stores, which is much slower.
57
57
  - Snappy assumes little-endian throughout, and needs to byte-swap data in
58
58
  several places if running on a big-endian platform.
@@ -62,6 +62,16 @@ Performance optimizations, whether for 64-bit x86 or other platforms,
62
62
  are of course most welcome; see "Contact", below.
63
63
 
64
64
 
65
+ Building
66
+ ========
67
+
68
+ CMake is supported and autotools will soon be deprecated.
69
+ You need CMake 3.4 or above to build:
70
+
71
+ mkdir build
72
+ cd build && cmake ../ && make
73
+
74
+
65
75
  Usage
66
76
  =====
67
77
 
@@ -116,7 +126,7 @@ before the unit tests, but you can disable them using the flag
116
126
  need to edit the source).
117
127
 
118
128
  Finally, snappy can benchmark Snappy against a few other compression libraries
119
- (zlib, LZO, LZF, FastLZ and QuickLZ), if they were detected at configure time.
129
+ (zlib, LZO, LZF, and QuickLZ), if they were detected at configure time.
120
130
  To benchmark using a given file, give the compression algorithm you want to test
121
131
  Snappy against (e.g. --zlib) and then a list of one or more file names on the
122
132
  command line. The testdata/ directory contains the files used by the
@@ -0,0 +1 @@
1
+ include("${CMAKE_CURRENT_LIST_DIR}/SnappyTargets.cmake")
@@ -0,0 +1,62 @@
1
+ #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
2
+ #define THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
3
+
4
+ /* Define to 1 if the compiler supports __builtin_ctz and friends. */
5
+ #cmakedefine HAVE_BUILTIN_CTZ 1
6
+
7
+ /* Define to 1 if the compiler supports __builtin_expect. */
8
+ #cmakedefine HAVE_BUILTIN_EXPECT 1
9
+
10
+ /* Define to 1 if you have the <byteswap.h> header file. */
11
+ #cmakedefine HAVE_BYTESWAP_H 1
12
+
13
+ /* Define to 1 if you have a definition for mmap() in <sys/mman.h>. */
14
+ #cmakedefine HAVE_FUNC_MMAP 1
15
+
16
+ /* Define to 1 if you have a definition for sysconf() in <unistd.h>. */
17
+ #cmakedefine HAVE_FUNC_SYSCONF 1
18
+
19
+ /* Define to 1 to use the gflags package for command-line parsing. */
20
+ #cmakedefine HAVE_GFLAGS 1
21
+
22
+ /* Define to 1 if you have Google Test. */
23
+ #cmakedefine HAVE_GTEST 1
24
+
25
+ /* Define to 1 if you have the `lzo2' library (-llzo2). */
26
+ #cmakedefine HAVE_LIBLZO2 1
27
+
28
+ /* Define to 1 if you have the `z' library (-lz). */
29
+ #cmakedefine HAVE_LIBZ 1
30
+
31
+ /* Define to 1 if you have the <stddef.h> header file. */
32
+ #cmakedefine HAVE_STDDEF_H 1
33
+
34
+ /* Define to 1 if you have the <stdint.h> header file. */
35
+ #cmakedefine HAVE_STDINT_H 1
36
+
37
+ /* Define to 1 if you have the <sys/endian.h> header file. */
38
+ #cmakedefine HAVE_SYS_ENDIAN_H 1
39
+
40
+ /* Define to 1 if you have the <sys/mman.h> header file. */
41
+ #cmakedefine HAVE_SYS_MMAN_H 1
42
+
43
+ /* Define to 1 if you have the <sys/resource.h> header file. */
44
+ #cmakedefine HAVE_SYS_RESOURCE_H 1
45
+
46
+ /* Define to 1 if you have the <sys/time.h> header file. */
47
+ #cmakedefine HAVE_SYS_TIME_H 1
48
+
49
+ /* Define to 1 if you have the <sys/uio.h> header file. */
50
+ #cmakedefine HAVE_SYS_UIO_H 1
51
+
52
+ /* Define to 1 if you have the <unistd.h> header file. */
53
+ #cmakedefine HAVE_UNISTD_H 1
54
+
55
+ /* Define to 1 if you have the <windows.h> header file. */
56
+ #cmakedefine HAVE_WINDOWS_H 1
57
+
58
+ /* Define to 1 if your processor stores words with the most significant byte
59
+ first (like Motorola and SPARC, unlike Intel and VAX). */
60
+ #cmakedefine SNAPPY_IS_BIG_ENDIAN 1
61
+
62
+ #endif // THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
@@ -50,7 +50,9 @@ class WorkingMemory {
50
50
  uint16 small_table_[1<<10]; // 2KB
51
51
  uint16* large_table_; // Allocated only when needed
52
52
 
53
- DISALLOW_COPY_AND_ASSIGN(WorkingMemory);
53
+ // No copying
54
+ WorkingMemory(const WorkingMemory&);
55
+ void operator=(const WorkingMemory&);
54
56
  };
55
57
 
56
58
  // Flat array compression that does not emit the "uncompressed length"
@@ -80,9 +82,9 @@ char* CompressFragment(const char* input,
80
82
  // Does not read *(s1 + (s2_limit - s2)) or beyond.
81
83
  // Requires that s2_limit >= s2.
82
84
  //
83
- // Separate implementation for x86_64, for speed. Uses the fact that
84
- // x86_64 is little endian.
85
- #if defined(ARCH_K8)
85
+ // Separate implementation for 64-bit, little-endian cpus.
86
+ #if !defined(SNAPPY_IS_BIG_ENDIAN) && \
87
+ (defined(ARCH_K8) || defined(ARCH_PPC) || defined(ARCH_ARM))
86
88
  static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
87
89
  const char* s2,
88
90
  const char* s2_limit) {
@@ -94,7 +96,7 @@ static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
94
96
  // uncommon code paths that determine, without extra effort, whether the match
95
97
  // length is less than 8. In short, we are hoping to avoid a conditional
96
98
  // branch, and perhaps get better code layout from the C++ compiler.
97
- if (PREDICT_TRUE(s2 <= s2_limit - 8)) {
99
+ if (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 8)) {
98
100
  uint64 a1 = UNALIGNED_LOAD64(s1);
99
101
  uint64 a2 = UNALIGNED_LOAD64(s2);
100
102
  if (a1 != a2) {
@@ -110,7 +112,7 @@ static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
110
112
  // time until we find a 64-bit block that doesn't match; then we find
111
113
  // the first non-matching bit and use that to calculate the total
112
114
  // length of the match.
113
- while (PREDICT_TRUE(s2 <= s2_limit - 8)) {
115
+ while (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 8)) {
114
116
  if (UNALIGNED_LOAD64(s2) == UNALIGNED_LOAD64(s1 + matched)) {
115
117
  s2 += 8;
116
118
  matched += 8;
@@ -122,7 +124,7 @@ static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
122
124
  return std::pair<size_t, bool>(matched, false);
123
125
  }
124
126
  }
125
- while (PREDICT_TRUE(s2 < s2_limit)) {
127
+ while (SNAPPY_PREDICT_TRUE(s2 < s2_limit)) {
126
128
  if (s1[matched] == *s2) {
127
129
  ++s2;
128
130
  ++matched;
@@ -170,11 +172,6 @@ enum {
170
172
  };
171
173
  static const int kMaximumTagLength = 5; // COPY_4_BYTE_OFFSET plus the actual offset.
172
174
 
173
- // Mapping from i in range [0,4] to a mask to extract the bottom 8*i bits
174
- static const uint32 wordmask[] = {
175
- 0u, 0xffu, 0xffffu, 0xffffffu, 0xffffffffu
176
- };
177
-
178
175
  // Data stored per entry in lookup table:
179
176
  // Range Bits-used Description
180
177
  // ------------------------------------