snappy 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +34 -0
  3. data/.github/workflows/publish.yml +34 -0
  4. data/Gemfile +3 -4
  5. data/Rakefile +32 -30
  6. data/ext/api.c +6 -1
  7. data/lib/snappy.rb +5 -5
  8. data/lib/snappy/hadoop/reader.rb +6 -2
  9. data/lib/snappy/reader.rb +11 -7
  10. data/lib/snappy/shim.rb +1 -1
  11. data/lib/snappy/version.rb +1 -1
  12. data/snappy.gemspec +13 -9
  13. data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
  14. data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
  15. data/test/snappy_hadoop_test.rb +26 -0
  16. data/test/snappy_reader_test.rb +148 -0
  17. data/test/snappy_test.rb +95 -0
  18. data/test/snappy_writer_test.rb +55 -0
  19. data/test/test_helper.rb +7 -0
  20. data/vendor/snappy/CMakeLists.txt +177 -54
  21. data/vendor/snappy/NEWS +8 -0
  22. data/vendor/snappy/README.md +19 -20
  23. data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
  24. data/vendor/snappy/cmake/config.h.in +6 -6
  25. data/vendor/snappy/docs/README.md +72 -0
  26. data/vendor/snappy/snappy-internal.h +12 -5
  27. data/vendor/snappy/snappy-stubs-internal.cc +1 -1
  28. data/vendor/snappy/snappy-stubs-internal.h +60 -15
  29. data/vendor/snappy/snappy-stubs-public.h.in +16 -36
  30. data/vendor/snappy/snappy-test.cc +16 -15
  31. data/vendor/snappy/snappy-test.h +12 -60
  32. data/vendor/snappy/snappy.cc +333 -187
  33. data/vendor/snappy/snappy.h +14 -10
  34. data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
  35. data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
  36. data/vendor/snappy/snappy_unittest.cc +220 -124
  37. metadata +26 -20
  38. data/.travis.yml +0 -31
  39. data/smoke.sh +0 -8
  40. data/test/hadoop/test-snappy-hadoop-reader.rb +0 -103
  41. data/test/hadoop/test-snappy-hadoop-writer.rb +0 -48
  42. data/test/test-snappy-hadoop.rb +0 -22
  43. data/test/test-snappy-reader.rb +0 -129
  44. data/test/test-snappy-writer.rb +0 -55
  45. data/test/test-snappy.rb +0 -58
  46. data/vendor/snappy/cmake/SnappyConfig.cmake +0 -1
@@ -1,3 +1,11 @@
1
+ Snappy v1.1.8, January 15th 2020:
2
+
3
+ * Small performance improvements.
4
+
5
+ * Removed snappy::string alias for std::string.
6
+
7
+ * Improved CMake configuration.
8
+
1
9
  Snappy v1.1.7, August 24th 2017:
2
10
 
3
11
  * Improved CMake build support for 64-bit Linux distributions.
@@ -51,7 +51,7 @@ In particular:
51
51
 
52
52
  - Snappy uses 64-bit operations in several places to process more data at
53
53
  once than would otherwise be possible.
54
- - Snappy assumes unaligned 32- and 64-bit loads and stores are cheap.
54
+ - Snappy assumes unaligned 32 and 64-bit loads and stores are cheap.
55
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
@@ -65,32 +65,37 @@ are of course most welcome; see "Contact", below.
65
65
  Building
66
66
  ========
67
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
68
+ You need the CMake version specified in [CMakeLists.txt](./CMakeLists.txt)
69
+ or later to build:
73
70
 
71
+ ```bash
72
+ mkdir build
73
+ cd build && cmake ../ && make
74
+ ```
74
75
 
75
76
  Usage
76
77
  =====
77
78
 
78
79
  Note that Snappy, both the implementation and the main interface,
79
80
  is written in C++. However, several third-party bindings to other languages
80
- are available; see the home page at http://google.github.io/snappy/
81
- for more information. Also, if you want to use Snappy from C code, you can
82
- use the included C bindings in snappy-c.h.
81
+ are available; see the [home page](docs/README.md) for more information.
82
+ Also, if you want to use Snappy from C code, you can use the included C
83
+ bindings in snappy-c.h.
83
84
 
84
85
  To use Snappy from your own C++ program, include the file "snappy.h" from
85
86
  your calling file, and link against the compiled library.
86
87
 
87
88
  There are many ways to call Snappy, but the simplest possible is
88
89
 
89
- snappy::Compress(input.data(), input.size(), &output);
90
+ ```c++
91
+ snappy::Compress(input.data(), input.size(), &output);
92
+ ```
90
93
 
91
94
  and similarly
92
95
 
93
- snappy::Uncompress(input.data(), input.size(), &output);
96
+ ```c++
97
+ snappy::Uncompress(input.data(), input.size(), &output);
98
+ ```
94
99
 
95
100
  where "input" and "output" are both instances of std::string.
96
101
 
@@ -112,12 +117,12 @@ tests to verify you have not broken anything. Note that if you have the
112
117
  Google Test library installed, unit test behavior (especially failures) will be
113
118
  significantly more user-friendly. You can find Google Test at
114
119
 
115
- http://github.com/google/googletest
120
+ https://github.com/google/googletest
116
121
 
117
122
  You probably also want the gflags library for handling of command-line flags;
118
123
  you can find it at
119
124
 
120
- http://gflags.github.io/gflags/
125
+ https://gflags.github.io/gflags/
121
126
 
122
127
  In addition to the unit tests, snappy contains microbenchmarks used to
123
128
  tune compression and decompression performance. These are automatically run
@@ -140,10 +145,4 @@ Contact
140
145
  =======
141
146
 
142
147
  Snappy is distributed through GitHub. For the latest version, a bug tracker,
143
- and other information, see
144
-
145
- http://google.github.io/snappy/
146
-
147
- or the repository at
148
-
149
- https://github.com/google/snappy
148
+ and other information, see https://github.com/google/snappy.
@@ -0,0 +1,33 @@
1
+ # Copyright 2019 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_INIT@
30
+
31
+ include("${CMAKE_CURRENT_LIST_DIR}/SnappyTargets.cmake")
32
+
33
+ check_required_components(Snappy)
@@ -28,12 +28,6 @@
28
28
  /* Define to 1 if you have the `z' library (-lz). */
29
29
  #cmakedefine HAVE_LIBZ 1
30
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
31
  /* Define to 1 if you have the <sys/endian.h> header file. */
38
32
  #cmakedefine HAVE_SYS_ENDIAN_H 1
39
33
 
@@ -55,6 +49,12 @@
55
49
  /* Define to 1 if you have the <windows.h> header file. */
56
50
  #cmakedefine HAVE_WINDOWS_H 1
57
51
 
52
+ /* Define to 1 if you target processors with SSSE3+ and have <tmmintrin.h>. */
53
+ #cmakedefine01 SNAPPY_HAVE_SSSE3
54
+
55
+ /* Define to 1 if you target processors with BMI2+ and have <bmi2intrin.h>. */
56
+ #cmakedefine01 SNAPPY_HAVE_BMI2
57
+
58
58
  /* Define to 1 if your processor stores words with the most significant byte
59
59
  first (like Motorola and SPARC, unlike Intel and VAX). */
60
60
  #cmakedefine SNAPPY_IS_BIG_ENDIAN 1
@@ -0,0 +1,72 @@
1
+ Snappy is a compression/decompression library. It does not aim for maximum
2
+ compression, or compatibility with any other compression library; instead, it
3
+ aims for very high speeds and reasonable compression. For instance, compared
4
+ to the fastest mode of zlib, Snappy is an order of magnitude faster for most
5
+ inputs, but the resulting compressed files are anywhere from 20% to 100%
6
+ bigger. On a single core of a Core i7 processor in 64-bit mode, Snappy
7
+ compresses at about 250 MB/sec or more and decompresses at about 500 MB/sec
8
+ or more.
9
+
10
+ Snappy is widely used inside Google, in everything from BigTable and MapReduce
11
+ to our internal RPC systems. (Snappy has previously been referred to as "Zippy"
12
+ in some presentations and the likes.)
13
+
14
+ For more information, please see the [README](../README.md). Benchmarks against
15
+ a few other compression libraries (zlib, LZO, LZF, FastLZ, and QuickLZ) are
16
+ included in the source code distribution. The source code also contains a
17
+ [formal format specification](../format_description.txt), as well
18
+ as a specification for a [framing format](../framing_format.txt) useful for
19
+ higher-level framing and encapsulation of Snappy data, e.g. for transporting
20
+ Snappy-compressed data across HTTP in a streaming fashion. Note that the Snappy
21
+ distribution currently has no code implementing the latter, but some of the
22
+ ports do (see below).
23
+
24
+ Snappy is written in C++, but C bindings are included, and several bindings to
25
+ other languages are maintained by third parties:
26
+
27
+ * C#: [Snappy for .NET](http://snappy4net.codeplex.com/) (P/Invoke wrapper),
28
+ [Snappy.NET](http://snappy.angeloflogic.com/) (P/Invoke wrapper),
29
+ [Snappy.Sharp](https://github.com/jeffesp/Snappy.Sharp) (native
30
+ reimplementation)
31
+ * [C port](http://github.com/andikleen/snappy-c)
32
+ * [C++ MSVC packaging](http://snappy.angeloflogic.com/) (plus Windows binaries,
33
+ NuGet packages and command-line tool)
34
+ * Common Lisp: [Library bindings](http://flambard.github.com/thnappy/),
35
+ [native reimplementation](https://github.com/brown/snappy)
36
+ * Erlang: [esnappy](https://github.com/thekvs/esnappy),
37
+ [snappy-erlang-nif](https://github.com/fdmanana/snappy-erlang-nif)
38
+ * [Go](https://github.com/golang/snappy/)
39
+ * [Haskell](http://hackage.haskell.org/package/snappy)
40
+ * [Haxe](https://github.com/MaddinXx/hxsnappy) (C++/Neko)
41
+ * [iOS packaging](https://github.com/ideawu/snappy-ios)
42
+ * Java: [JNI wrapper](https://github.com/xerial/snappy-java) (including the
43
+ framing format), [native reimplementation](http://code.google.com/p/jsnappy/),
44
+ [other native reimplementation](https://github.com/dain/snappy) (including
45
+ the framing format)
46
+ * [Lua](https://github.com/forhappy/lua-snappy)
47
+ * [Node.js](https://github.com/kesla/node-snappy) (including the [framing
48
+ format](https://github.com/kesla/node-snappy-stream))
49
+ * [Perl](http://search.cpan.org/dist/Compress-Snappy/)
50
+ * [PHP](https://github.com/kjdev/php-ext-snappy)
51
+ * [Python](http://pypi.python.org/pypi/python-snappy) (including a command-line
52
+ tool for the framing format)
53
+ * [R](https://github.com/lulyon/R-snappy)
54
+ * [Ruby](https://github.com/miyucy/snappy)
55
+ * [Rust](https://github.com/BurntSushi/rust-snappy)
56
+ * [Smalltalk](https://github.com/mumez/sqnappy) (including the framing format)
57
+
58
+ Snappy is used or is available as an alternative in software such as
59
+
60
+ * [MongoDB](https://www.mongodb.com/)
61
+ * [Cassandra](http://cassandra.apache.org/)
62
+ * [Couchbase](http://www.couchbase.com/)
63
+ * [Hadoop](http://hadoop.apache.org/)
64
+ * [LessFS](http://www.lessfs.com/wordpress/)
65
+ * [LevelDB](https://github.com/google/leveldb) (which is in turn used by
66
+ [Google Chrome](http://chrome.google.com/))
67
+ * [Lucene](http://lucene.apache.org/)
68
+ * [VoltDB](http://voltdb.com/)
69
+
70
+ If you know of more, do not hesitate to let us know. The easiest way to get in
71
+ touch is via the
72
+ [Snappy discussion mailing list](http://groups.google.com/group/snappy-compression).
@@ -36,19 +36,26 @@
36
36
  namespace snappy {
37
37
  namespace internal {
38
38
 
39
+ // Working memory performs a single allocation to hold all scratch space
40
+ // required for compression.
39
41
  class WorkingMemory {
40
42
  public:
41
- WorkingMemory() : large_table_(NULL) { }
42
- ~WorkingMemory() { delete[] large_table_; }
43
+ explicit WorkingMemory(size_t input_size);
44
+ ~WorkingMemory();
43
45
 
44
46
  // Allocates and clears a hash table using memory in "*this",
45
47
  // stores the number of buckets in "*table_size" and returns a pointer to
46
48
  // the base of the hash table.
47
- uint16* GetHashTable(size_t input_size, int* table_size);
49
+ uint16* GetHashTable(size_t fragment_size, int* table_size) const;
50
+ char* GetScratchInput() const { return input_; }
51
+ char* GetScratchOutput() const { return output_; }
48
52
 
49
53
  private:
50
- uint16 small_table_[1<<10]; // 2KB
51
- uint16* large_table_; // Allocated only when needed
54
+ char* mem_; // the allocated memory, never nullptr
55
+ size_t size_; // the size of the allocated memory, never 0
56
+ uint16* table_; // the pointer to the hashtable
57
+ char* input_; // the pointer to the input scratch buffer
58
+ char* output_; // the pointer to the output scratch buffer
52
59
 
53
60
  // No copying
54
61
  WorkingMemory(const WorkingMemory&);
@@ -33,7 +33,7 @@
33
33
 
34
34
  namespace snappy {
35
35
 
36
- void Varint::Append32(string* s, uint32 value) {
36
+ void Varint::Append32(std::string* s, uint32 value) {
37
37
  char buf[Varint::kMax32];
38
38
  const char* p = Varint::Encode32(buf, value);
39
39
  s->append(buf, p - buf);
@@ -53,6 +53,18 @@
53
53
  #include <intrin.h>
54
54
  #endif // defined(_MSC_VER)
55
55
 
56
+ #ifndef __has_feature
57
+ #define __has_feature(x) 0
58
+ #endif
59
+
60
+ #if __has_feature(memory_sanitizer)
61
+ #include <sanitizer/msan_interface.h>
62
+ #define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \
63
+ __msan_unpoison((address), (size))
64
+ #else
65
+ #define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) /* empty */
66
+ #endif // __has_feature(memory_sanitizer)
67
+
56
68
  #include "snappy-stubs-public.h"
57
69
 
58
70
  #if defined(__x86_64__)
@@ -187,7 +199,7 @@ struct Unaligned32Struct {
187
199
  ((reinterpret_cast< ::snappy::base::internal::Unaligned32Struct *>(_p))->value = \
188
200
  (_val))
189
201
 
190
- // TODO(user): NEON supports unaligned 64-bit loads and stores.
202
+ // TODO: NEON supports unaligned 64-bit loads and stores.
191
203
  // See if that would be more efficient on platforms supporting it,
192
204
  // at least for copies.
193
205
 
@@ -353,6 +365,9 @@ class LittleEndian {
353
365
  // Some bit-manipulation functions.
354
366
  class Bits {
355
367
  public:
368
+ // Return floor(log2(n)) for positive integer n.
369
+ static int Log2FloorNonZero(uint32 n);
370
+
356
371
  // Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0.
357
372
  static int Log2Floor(uint32 n);
358
373
 
@@ -373,50 +388,72 @@ class Bits {
373
388
 
374
389
  #ifdef HAVE_BUILTIN_CTZ
375
390
 
391
+ inline int Bits::Log2FloorNonZero(uint32 n) {
392
+ assert(n != 0);
393
+ // (31 ^ x) is equivalent to (31 - x) for x in [0, 31]. An easy proof
394
+ // represents subtraction in base 2 and observes that there's no carry.
395
+ //
396
+ // GCC and Clang represent __builtin_clz on x86 as 31 ^ _bit_scan_reverse(x).
397
+ // Using "31 ^" here instead of "31 -" allows the optimizer to strip the
398
+ // function body down to _bit_scan_reverse(x).
399
+ return 31 ^ __builtin_clz(n);
400
+ }
401
+
376
402
  inline int Bits::Log2Floor(uint32 n) {
377
- return n == 0 ? -1 : 31 ^ __builtin_clz(n);
403
+ return (n == 0) ? -1 : Bits::Log2FloorNonZero(n);
378
404
  }
379
405
 
380
406
  inline int Bits::FindLSBSetNonZero(uint32 n) {
407
+ assert(n != 0);
381
408
  return __builtin_ctz(n);
382
409
  }
383
410
 
384
411
  #if defined(ARCH_K8) || defined(ARCH_PPC) || defined(ARCH_ARM)
385
412
  inline int Bits::FindLSBSetNonZero64(uint64 n) {
413
+ assert(n != 0);
386
414
  return __builtin_ctzll(n);
387
415
  }
388
416
  #endif // defined(ARCH_K8) || defined(ARCH_PPC) || defined(ARCH_ARM)
389
417
 
390
418
  #elif defined(_MSC_VER)
391
419
 
420
+ inline int Bits::Log2FloorNonZero(uint32 n) {
421
+ assert(n != 0);
422
+ unsigned long where;
423
+ _BitScanReverse(&where, n);
424
+ return static_cast<int>(where);
425
+ }
426
+
392
427
  inline int Bits::Log2Floor(uint32 n) {
393
428
  unsigned long where;
394
- if (_BitScanReverse(&where, n)) {
395
- return where;
396
- } else {
397
- return -1;
398
- }
429
+ if (_BitScanReverse(&where, n))
430
+ return static_cast<int>(where);
431
+ return -1;
399
432
  }
400
433
 
401
434
  inline int Bits::FindLSBSetNonZero(uint32 n) {
435
+ assert(n != 0);
402
436
  unsigned long where;
403
- if (_BitScanForward(&where, n)) return static_cast<int>(where);
437
+ if (_BitScanForward(&where, n))
438
+ return static_cast<int>(where);
404
439
  return 32;
405
440
  }
406
441
 
407
442
  #if defined(ARCH_K8) || defined(ARCH_PPC) || defined(ARCH_ARM)
408
443
  inline int Bits::FindLSBSetNonZero64(uint64 n) {
444
+ assert(n != 0);
409
445
  unsigned long where;
410
- if (_BitScanForward64(&where, n)) return static_cast<int>(where);
446
+ if (_BitScanForward64(&where, n))
447
+ return static_cast<int>(where);
411
448
  return 64;
412
449
  }
413
450
  #endif // defined(ARCH_K8) || defined(ARCH_PPC) || defined(ARCH_ARM)
414
451
 
415
452
  #else // Portable versions.
416
453
 
417
- inline int Bits::Log2Floor(uint32 n) {
418
- if (n == 0)
419
- return -1;
454
+ inline int Bits::Log2FloorNonZero(uint32 n) {
455
+ assert(n != 0);
456
+
420
457
  int log = 0;
421
458
  uint32 value = n;
422
459
  for (int i = 4; i >= 0; --i) {
@@ -431,7 +468,13 @@ inline int Bits::Log2Floor(uint32 n) {
431
468
  return log;
432
469
  }
433
470
 
471
+ inline int Bits::Log2Floor(uint32 n) {
472
+ return (n == 0) ? -1 : Bits::Log2FloorNonZero(n);
473
+ }
474
+
434
475
  inline int Bits::FindLSBSetNonZero(uint32 n) {
476
+ assert(n != 0);
477
+
435
478
  int rc = 31;
436
479
  for (int i = 4, shift = 1 << 4; i >= 0; --i) {
437
480
  const uint32 x = n << shift;
@@ -447,6 +490,8 @@ inline int Bits::FindLSBSetNonZero(uint32 n) {
447
490
  #if defined(ARCH_K8) || defined(ARCH_PPC) || defined(ARCH_ARM)
448
491
  // FindLSBSetNonZero64() is defined in terms of FindLSBSetNonZero().
449
492
  inline int Bits::FindLSBSetNonZero64(uint64 n) {
493
+ assert(n != 0);
494
+
450
495
  const uint32 bottombits = static_cast<uint32>(n);
451
496
  if (bottombits == 0) {
452
497
  // Bottom bits are zero, so scan in top bits
@@ -479,7 +524,7 @@ class Varint {
479
524
  static char* Encode32(char* ptr, uint32 v);
480
525
 
481
526
  // EFFECTS Appends the varint representation of "value" to "*s".
482
- static void Append32(string* s, uint32 value);
527
+ static void Append32(std::string* s, uint32 value);
483
528
  };
484
529
 
485
530
  inline const char* Varint::Parse32WithLimit(const char* p,
@@ -536,7 +581,7 @@ inline char* Varint::Encode32(char* sptr, uint32 v) {
536
581
  // replace this function with one that resizes the string without
537
582
  // filling the new space with zeros (if applicable) --
538
583
  // it will be non-portable but faster.
539
- inline void STLStringResizeUninitialized(string* s, size_t new_size) {
584
+ inline void STLStringResizeUninitialized(std::string* s, size_t new_size) {
540
585
  s->resize(new_size);
541
586
  }
542
587
 
@@ -552,7 +597,7 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) {
552
597
  // (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-defects.html#530)
553
598
  // proposes this as the method. It will officially be part of the standard
554
599
  // for C++0x. This should already work on all current implementations.
555
- inline char* string_as_array(string* str) {
600
+ inline char* string_as_array(std::string* str) {
556
601
  return str->empty() ? NULL : &*str->begin();
557
602
  }
558
603
 
@@ -1,5 +1,4 @@
1
1
  // Copyright 2011 Google Inc. All Rights Reserved.
2
- // Author: sesse@google.com (Steinar H. Gunderson)
3
2
  //
4
3
  // Redistribution and use in source and binary forms, with or without
5
4
  // modification, are permitted provided that the following conditions are
@@ -36,56 +35,37 @@
36
35
  #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
37
36
  #define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
38
37
 
39
- #if ${HAVE_STDINT_H_01} // HAVE_STDINT_H
40
- #include <stdint.h>
41
- #endif // HAVE_STDDEF_H
42
-
43
- #if ${HAVE_STDDEF_H_01} // HAVE_STDDEF_H
44
- #include <stddef.h>
45
- #endif // HAVE_STDDEF_H
38
+ #include <cstddef>
39
+ #include <cstdint>
40
+ #include <string>
46
41
 
47
42
  #if ${HAVE_SYS_UIO_H_01} // HAVE_SYS_UIO_H
48
43
  #include <sys/uio.h>
49
44
  #endif // HAVE_SYS_UIO_H
50
45
 
51
- #define SNAPPY_MAJOR ${SNAPPY_MAJOR}
52
- #define SNAPPY_MINOR ${SNAPPY_MINOR}
53
- #define SNAPPY_PATCHLEVEL ${SNAPPY_PATCHLEVEL}
46
+ #define SNAPPY_MAJOR ${PROJECT_VERSION_MAJOR}
47
+ #define SNAPPY_MINOR ${PROJECT_VERSION_MINOR}
48
+ #define SNAPPY_PATCHLEVEL ${PROJECT_VERSION_PATCH}
54
49
  #define SNAPPY_VERSION \
55
50
  ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
56
51
 
57
- #include <string>
58
-
59
52
  namespace snappy {
60
53
 
61
- #if ${HAVE_STDINT_H_01} // HAVE_STDINT_H
62
- typedef int8_t int8;
63
- typedef uint8_t uint8;
64
- typedef int16_t int16;
65
- typedef uint16_t uint16;
66
- typedef int32_t int32;
67
- typedef uint32_t uint32;
68
- typedef int64_t int64;
69
- typedef uint64_t uint64;
70
- #else
71
- typedef signed char int8;
72
- typedef unsigned char uint8;
73
- typedef short int16;
74
- typedef unsigned short uint16;
75
- typedef int int32;
76
- typedef unsigned int uint32;
77
- typedef long long int64;
78
- typedef unsigned long long uint64;
79
- #endif // HAVE_STDINT_H
80
-
81
- typedef std::string string;
54
+ using int8 = std::int8_t;
55
+ using uint8 = std::uint8_t;
56
+ using int16 = std::int16_t;
57
+ using uint16 = std::uint16_t;
58
+ using int32 = std::int32_t;
59
+ using uint32 = std::uint32_t;
60
+ using int64 = std::int64_t;
61
+ using uint64 = std::uint64_t;
82
62
 
83
63
  #if !${HAVE_SYS_UIO_H_01} // !HAVE_SYS_UIO_H
84
64
  // Windows does not have an iovec type, yet the concept is universally useful.
85
65
  // It is simple to define it ourselves, so we put it inside our own namespace.
86
66
  struct iovec {
87
- void* iov_base;
88
- size_t iov_len;
67
+ void* iov_base;
68
+ size_t iov_len;
89
69
  };
90
70
  #endif // !HAVE_SYS_UIO_H
91
71