From 5a66fe5de00a07af9e159efa2bfdaa6fdb925d24 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Mon, 27 Mar 2017 16:14:38 -0700 Subject: [PATCH] Gate LZ4Frame behind version check 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/folly/io/Compression.cpp b/folly/io/Compression.cpp index 07749125..ae6adf7e 100644 --- a/folly/io/Compression.cpp +++ b/folly/io/Compression.cpp @@ -18,8 +18,10 @@ #if FOLLY_HAVE_LIBLZ4 #include -#include #include +#if LZ4_VERSION_NUMBER >= 10301 +#include +#endif #endif #include @@ -384,6 +386,8 @@ std::unique_ptr LZ4Codec::doUncompress( return out; } +#if LZ4_VERSION_NUMBER >= 10301 + class LZ4FrameCodec final : public Codec { public: static std::unique_ptr create(int level, CodecType type); @@ -400,7 +404,7 @@ class LZ4FrameCodec final : public Codec { void resetDCtx(); int level_; - LZ4F_dctx* dctx_{nullptr}; + LZ4F_decompressionContext_t dctx_{nullptr}; bool dirty_{false}; }; @@ -537,6 +541,7 @@ std::unique_ptr LZ4FrameCodec::doUncompress( return queue.move(); } +#endif // LZ4_VERSION_NUMBER >= 10301 #endif // FOLLY_HAVE_LIBLZ4 #if FOLLY_HAVE_LIBSNAPPY @@ -1430,7 +1435,7 @@ static constexpr CodecFactory nullptr, #endif -#if FOLLY_HAVE_LIBLZ4 +#if (FOLLY_HAVE_LIBLZ4 && LZ4_VERSION_NUMBER >= 10301) LZ4FrameCodec::create, #else nullptr, -- 2.34.1