]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use autoconf to check for optional zstd functionality.
authorNick Mathewson <nickm@torproject.org>
Sun, 18 Feb 2018 21:19:43 +0000 (16:19 -0500)
committerNick Mathewson <nickm@torproject.org>
Sun, 18 Feb 2018 21:19:43 +0000 (16:19 -0500)
Fixes a bug in our zstd-static code.  Bug not in any released
version of Tor.

configure.ac
src/common/compress_zstd.c

index 1f43650b088ee6a400bf7248085817d45b2789d8..22c8a561372cd25eb8c211da0910e28459318748 100644 (file)
@@ -977,6 +977,16 @@ if test "x$have_zstd" = "xyes"; then
     AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
     TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
     TOR_ZSTD_LIBS="${ZSTD_LIBS}"
+
+    dnl now check for zstd functions
+    save_LIBS="$LIBS"
+    save_CFLAGS="$CFLAGS"
+    LIBS="$LIBS $ZSTD_LIBS"
+    CFLAGS="$CFLAGS $ZSTD_CFLAGS"
+    AC_CHECK_FUNCS(ZSTD_estimateCStreamSize \
+                   ZSTD_estimateDCtxSize)
+    LIBS="$save_LIBS"
+    CFLAGS="$save_CFLAGS"
 fi
 AC_SUBST(TOR_ZSTD_CFLAGS)
 AC_SUBST(TOR_ZSTD_LIBS)
index 4e26c724e8a0bef12acbb3d69cdd7a22aa346414..4024f5594dfed402bbbd9c8ce5a3f26b40826c55 100644 (file)
@@ -219,10 +219,14 @@ tor_zstd_state_size_precalc(int compress, int preset)
 #ifdef ZSTD_STATIC_LINKING_ONLY
   if (tor_zstd_can_use_static_apis()) {
     if (compress) {
+#ifdef HAVE_ZSTD_ESTIMATECSTREAMSIZE
       return ZSTD_estimateCStreamSize(preset);
+#endif
     } else {
+#ifdef HAVE_ZSTD_ESTIMATEDCTXSIZE
       /* Could use DStream, but that takes a windowSize. */
       return ZSTD_estimateDCtxSize();
+#endif
     }
   }
 #endif