From 83ef06748df545ab477e6191c1868e41ed9e57de Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 5 May 2014 18:26:30 -0700 Subject: [PATCH] Add snappy compression integration --- Builds/VisualStudio2013/Common.props | 2 +- Builds/VisualStudio2013/RippleD.vcxproj | 2 +- .../VisualStudio2013/RippleD.vcxproj.filters | 102 +++++++++--------- SConstruct | 5 +- src/ripple/rocksdb/ripple_rocksdb.h | 1 + src/snappy/config/snappy-stubs-public.h | 82 ++++++++++++++ src/snappy/snappy.unity.cpp | 34 ++++++ 7 files changed, 177 insertions(+), 51 deletions(-) create mode 100644 src/snappy/config/snappy-stubs-public.h create mode 100644 src/snappy/snappy.unity.cpp diff --git a/Builds/VisualStudio2013/Common.props b/Builds/VisualStudio2013/Common.props index e39132ab4..853bf2adb 100644 --- a/Builds/VisualStudio2013/Common.props +++ b/Builds/VisualStudio2013/Common.props @@ -14,7 +14,7 @@ _VARIADIC_MAX=10;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) true Level3 - $(RepoDir)\src\protobuf\src;$(RepoDir)\src\protobuf\vsprojects;$(RepoDir)\src\leveldb;$(RepoDir)\src\leveldb\include;$(RepoDir)\build\proto;%(AdditionalIncludeDirectories) + $(RepoDir)\src\protobuf\src;$(RepoDir)\src\protobuf\vsprojects;$(RepoDir)\src\leveldb;$(RepoDir)\src\leveldb\include;$(RepoDir)\src\snappy\snappy;$(RepoDir)\src\snappy\config;$(RepoDir)\build\proto;%(AdditionalIncludeDirectories) /bigobj %(AdditionalOptions) Async 4018;4244 diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 2d9a28618..cf04a6d45 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -1766,6 +1766,7 @@ true + true true @@ -2463,7 +2464,6 @@ false true false - %(AdditionalIncludeDirectories) Console diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 163640f6f..c1dbd1d5c 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -28,9 +28,6 @@ {1f093002-9955-4915-a17b-398d55c9fc76} - - {6967f835-a1b0-47e3-9bd9-6fc8bd0f3df7} - {c69b07a2-44e5-4b06-99a9-81f5d137ea15} @@ -334,6 +331,12 @@ {ae6e40a1-a2ff-4a9e-b510-92192b96db44} + + {3ea8d3ab-136d-4ae1-bc76-24d8f318e539} + + + {6967f835-a1b0-47e3-9bd9-6fc8bd0f3df7} + @@ -424,43 +427,43 @@ [2] Old Ripple\ripple_websocket\autosocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket [0] Libraries\leveldb\db @@ -1734,6 +1737,9 @@ [1] Ripple\proto + + [0] Libraries\snappy + @@ -1836,97 +1842,97 @@ [2] Old Ripple\ripple_websocket\autosocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket - [0] Libraries\websocket + [1] Ripple\websocket [0] Libraries\leveldb\db @@ -2727,7 +2733,7 @@ [1] Ripple\sitefiles\api - [0] Libraries\websocket + [1] Ripple\websocket [1] Ripple\rocksdb diff --git a/SConstruct b/SConstruct index cfb1b89ff..83c6185dc 100644 --- a/SConstruct +++ b/SConstruct @@ -210,7 +210,9 @@ INCLUDE_PATHS = [ '.', 'src/leveldb', 'src/leveldb/port', - 'src/leveldb/include' + 'src/leveldb/include', + 'src/snappy/snappy', + 'src/snappy/config', ] # if BOOST_HOME: @@ -237,6 +239,7 @@ COMPILED_FILES.extend (['src/ripple/beast/ripple_beastc.c']) # New-style Ripple unity sources # COMPILED_FILES.extend([ + 'src/snappy/snappy.unity.cpp', 'src/ripple/http/ripple_http.cpp', 'src/ripple/json/ripple_json.cpp', 'src/ripple/peerfinder/ripple_peerfinder.cpp', diff --git a/src/ripple/rocksdb/ripple_rocksdb.h b/src/ripple/rocksdb/ripple_rocksdb.h index 23a39b72d..68fbd9e6a 100644 --- a/src/ripple/rocksdb/ripple_rocksdb.h +++ b/src/ripple/rocksdb/ripple_rocksdb.h @@ -35,6 +35,7 @@ #endif #if RIPPLE_ROCKSDB_AVAILABLE +#define SNAPPY #include "rocksdb/include/rocksdb/arena.h" #include "rocksdb/include/rocksdb/cache.h" #include "rocksdb/include/rocksdb/compaction_filter.h" diff --git a/src/snappy/config/snappy-stubs-public.h b/src/snappy/config/snappy-stubs-public.h new file mode 100644 index 000000000..83f5e9ff7 --- /dev/null +++ b/src/snappy/config/snappy-stubs-public.h @@ -0,0 +1,82 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// Author: sesse@google.com (Steinar H. Gunderson) +// +// 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. +// +// Various type stubs for the open-source version of Snappy. +// +// This file cannot include config.h, as it is included from snappy.h, +// which is a public header. Instead, snappy-stubs-public.h is generated by +// from snappy-stubs-public.h.in at configure time. + +#ifndef UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ +#define UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ + +#include +#include + +#ifndef _MSC_VER +#include +#endif + +#define SNAPPY_MAJOR 1 // @SNAPPY_MAJOR@ +#define SNAPPY_MINOR 0 // @SNAPPY_MINOR@ +#define SNAPPY_PATCHLEVEL 0 // @SNAPPY_PATCHLEVEL@ +#define SNAPPY_VERSION \ + ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL) + +#include + +namespace snappy { + +typedef std::int8_t int8; +typedef std::int16_t int16; +typedef std::int32_t int32; +typedef std::int64_t int64; +typedef std::uint8_t uint8; +typedef std::uint16_t uint16; +typedef std::uint32_t uint32; +typedef std::uint64_t uint64; + +typedef std::string string; + +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) + +#ifdef _MSC_VER +// Windows does not have an iovec type, yet the concept is universally useful. +// It is simple to define it ourselves, so we put it inside our own namespace. +struct iovec { + void* iov_base; + size_t iov_len; +}; +#endif + +} // namespace snappy + +#endif // UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ \ No newline at end of file diff --git a/src/snappy/snappy.unity.cpp b/src/snappy/snappy.unity.cpp new file mode 100644 index 000000000..abb426ea6 --- /dev/null +++ b/src/snappy/snappy.unity.cpp @@ -0,0 +1,34 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2014 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include "../BeastConfig.h" + +#ifdef _MSC_VER +#include +namespace snappy { +typedef std::ptrdiff_t ssize_t; +} +#endif + +#include "snappy/snappy.cc" +#include "snappy/snappy-sinksource.cc" +#include "snappy/snappy-stubs-internal.cc" + +//#include "./snappy_unittest.cc" +//#include "./snappy-test.cc"#include "./snappy-c.cc"