Gate LZ4Frame behind version check
authorNick Terrell <terrelln@fb.com>
Mon, 27 Mar 2017 23:14:38 +0000 (16:14 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 27 Mar 2017 23:20:47 +0000 (16:20 -0700)
Summary:
D4715918 broke open source builds on Ubuntu 14.04, since it has lz4-r114, but the lz4 frame API was introduced in [r123](https://github.com/lz4/lz4/blob/r123/lz4frame.h).
Put the `LZ4FrameCodec` behind a lz4 version check.
Fixes https://github.com/facebook/fbthrift/issues/209.

Reviewed By: yfeldblum

Differential Revision: D4780830

fbshipit-source-id: 19492a7e6bdd128e610c36b5778274e19eff9548

folly/io/Compression.cpp

index 0774912579411ae0d16a085fba1b5431ef41b417..ae6adf7e8c78e949a8e521bd0d44076db0b5f639 100644 (file)
 
 #if FOLLY_HAVE_LIBLZ4
 #include <lz4.h>
 
 #if FOLLY_HAVE_LIBLZ4
 #include <lz4.h>
-#include <lz4frame.h>
 #include <lz4hc.h>
 #include <lz4hc.h>
+#if LZ4_VERSION_NUMBER >= 10301
+#include <lz4frame.h>
+#endif
 #endif
 
 #include <glog/logging.h>
 #endif
 
 #include <glog/logging.h>
@@ -384,6 +386,8 @@ std::unique_ptr<IOBuf> LZ4Codec::doUncompress(
   return out;
 }
 
   return out;
 }
 
+#if LZ4_VERSION_NUMBER >= 10301
+
 class LZ4FrameCodec final : public Codec {
  public:
   static std::unique_ptr<Codec> create(int level, CodecType type);
 class LZ4FrameCodec final : public Codec {
  public:
   static std::unique_ptr<Codec> create(int level, CodecType type);
@@ -400,7 +404,7 @@ class LZ4FrameCodec final : public Codec {
   void resetDCtx();
 
   int level_;
   void resetDCtx();
 
   int level_;
-  LZ4F_dctx* dctx_{nullptr};
+  LZ4F_decompressionContext_t dctx_{nullptr};
   bool dirty_{false};
 };
 
   bool dirty_{false};
 };
 
@@ -537,6 +541,7 @@ std::unique_ptr<IOBuf> LZ4FrameCodec::doUncompress(
   return queue.move();
 }
 
   return queue.move();
 }
 
+#endif // LZ4_VERSION_NUMBER >= 10301
 #endif // FOLLY_HAVE_LIBLZ4
 
 #if FOLLY_HAVE_LIBSNAPPY
 #endif // FOLLY_HAVE_LIBLZ4
 
 #if FOLLY_HAVE_LIBSNAPPY
@@ -1430,7 +1435,7 @@ static constexpr CodecFactory
         nullptr,
 #endif
 
         nullptr,
 #endif
 
-#if FOLLY_HAVE_LIBLZ4
+#if (FOLLY_HAVE_LIBLZ4 && LZ4_VERSION_NUMBER >= 10301)
         LZ4FrameCodec::create,
 #else
         nullptr,
         LZ4FrameCodec::create,
 #else
         nullptr,