Skip to content

Commit 7d696b5

Browse files
committed
Use zstd unconditionally
1 parent 90c3a44 commit 7d696b5

File tree

5 files changed

+3
-56
lines changed

5 files changed

+3
-56
lines changed

m4/R.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,8 +3843,8 @@ if test "x${have_zstd}" = xyes; then
38433843
AC_DEFINE(HAVE_ZSTD_DECOMPRESSBOUND, 1, [Define if zstd has ZSTD_decompressBound])
38443844
fi
38453845
# so far we don't require it, but we might
3846-
#else
3847-
# AC_MSG_ERROR("libzstd library and headers are required")
3846+
else
3847+
AC_MSG_ERROR("libzstd library and headers are required")
38483848
fi
38493849
])# R_ZSTD
38503850

src/gnuwin32/fixed/h/config.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,12 +1040,6 @@
10401040
/* Define if you have the X11/Xmu headers and libraries. */
10411041
/* #undef HAVE_X11_Xmu */
10421042

1043-
/* Define if your system has zstd >= 1.3.3. */
1044-
#define HAVE_ZSTD 1
1045-
1046-
/* Define if zstd has ZSTD_decompressBound */
1047-
#define HAVE_ZSTD_DECOMPRESSBOUND 1
1048-
10491043
/* Define to 1 if you have the `__cospi' function. */
10501044
/* #undef HAVE___COSPI */
10511045

src/include/config.h.in

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -998,15 +998,6 @@
998998
/* Define if you have the X11/Xmu headers and libraries. */
999999
#undef HAVE_X11_Xmu
10001000

1001-
/* Define if your system has zstd >= 1.3.3. */
1002-
#undef HAVE_ZSTD
1003-
1004-
/* Define if zstd has ZSTD_decompressBound */
1005-
#undef HAVE_ZSTD_DECOMPRESSBOUND
1006-
1007-
/* Define to 1 if you have the <zstd.h> header file. */
1008-
#undef HAVE_ZSTD_H
1009-
10101001
/* Define to 1 if you have the '__cospi' function. */
10111002
#undef HAVE___COSPI
10121003

src/main/connections.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,19 +2399,7 @@ newxzfile(const char *description, const char *mode, int type, int compress)
23992399
return new;
24002400
}
24012401

2402-
2403-
#ifdef HAVE_ZSTD
2404-
2405-
#ifndef HAVE_ZSTD_DECOMPRESSBOUND
2406-
static unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize) {
2407-
/* FIXME: it is stupid, but we could add a full streaming decompression pass as a fall-back */
2408-
error("The used zstd library does not include support for streaming decompression bounds so we cannot decompress streams in memory.");
2409-
}
2410-
#else
2411-
/* seems silly, but this is needed to declare ZSTD_decompressBound */
24122402
#define ZSTD_STATIC_LINKING_ONLY 1
2413-
#endif
2414-
24152403
#include <zstd.h>
24162404

24172405
typedef struct zstdfileconn {
@@ -2661,15 +2649,6 @@ newzstdfile(const char *description, const char *mode, int compress)
26612649
return new;
26622650
}
26632651

2664-
#else
2665-
static Rconnection
2666-
newzstdfile(const char *description, const char *mode, int compress) {
2667-
error("Zstd compression support was not included in this R binary.");
2668-
/* unreachable */
2669-
return 0;
2670-
}
2671-
#endif
2672-
26732652
typedef enum { COMP_UNKNOWN = 0, COMP_GZ, COMP_BZ, COMP_XZ, COMP_ZSTD } comp_type;
26742653

26752654
static comp_type
@@ -6999,7 +6978,6 @@ SEXP R_decompress3(SEXP in, Rboolean *err)
69996978
lzma_end(&strm);
70006979
#if 0 /* not enabled - just ready if we ever want to allow zstd */
70016980
} else if (type == 'S') {
7002-
#ifdef HAVE_ZSTD
70036981
unsigned long long sz = ZSTD_getFrameContentSize(p + 5, inlen - 5);
70046982
if (sz == ZSTD_CONTENTSIZE_UNKNOWN) /* possible streaming so no size in the header */
70056983
sz = ZSTD_decompressBound(p + 5, inlen - 5);
@@ -7009,9 +6987,6 @@ SEXP R_decompress3(SEXP in, Rboolean *err)
70096987
*err = TRUE;
70106988
return R_NilValue;
70116989
}
7012-
#else
7013-
error("Zstd compression support was not included in this R binary.");
7014-
#endif
70156990
#endif
70166991
} else if (type == '2') {
70176992
int res;
@@ -7146,7 +7121,6 @@ do_memCompress(SEXP call, SEXP op, SEXP args, SEXP env)
71467121
break;
71477122
}
71487123
case 5: /* zstd */
7149-
#ifdef HAVE_ZSTD
71507124
{
71517125
size_t inlen = XLENGTH(from);
71527126
size_t outlen = ZSTD_compressBound(inlen);
@@ -7159,9 +7133,6 @@ do_memCompress(SEXP call, SEXP op, SEXP args, SEXP env)
71597133
memcpy(RAW(ans), buf, res);
71607134
break;
71617135
}
7162-
#else
7163-
error("Zstd compression support was not included in this R binary.");
7164-
#endif
71657136
default:
71667137
break;
71677138
}
@@ -7373,7 +7344,6 @@ do_memDecompress(SEXP call, SEXP op, SEXP args, SEXP env)
73737344
break;
73747345
}
73757346
case 6: /* zstd */
7376-
#ifdef HAVE_ZSTD
73777347
{
73787348
size_t inlen = XLENGTH(from), res;
73797349
unsigned long long outlen;
@@ -7393,9 +7363,6 @@ do_memDecompress(SEXP call, SEXP op, SEXP args, SEXP env)
73937363
memcpy(RAW(ans), buf, res);
73947364
break;
73957365
}
7396-
#else
7397-
error("Zstd compression support was not included in this R binary.");
7398-
#endif
73997366
// case 5 is "unknown', covered above
74007367
default:
74017368
break;

src/main/platform.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,6 +3601,7 @@ attribute_hidden SEXP do_mkjunction(SEXP call, SEXP op, SEXP args, SEXP rho)
36013601
#include <zlib.h>
36023602
#include <bzlib.h>
36033603
#include <lzma.h>
3604+
#include <zstd.h>
36043605

36053606
#ifdef HAVE_PCRE2
36063607
/* PCRE2_CODE_UNIT_WIDTH is defined to 8 via config.h */
@@ -3685,13 +3686,7 @@ do_eSoftVersion(SEXP call, SEXP op, SEXP args, SEXP rho)
36853686
SET_STRING_ELT(ans, i, mkChar(""));
36863687
#endif
36873688
SET_STRING_ELT(nms, i++, mkChar("libdeflate"));
3688-
3689-
#ifdef HAVE_ZSTD
3690-
#include <zstd.h>
36913689
SET_STRING_ELT(ans, i, mkChar(ZSTD_versionString()));
3692-
#else
3693-
SET_STRING_ELT(ans, i, mkChar(""));
3694-
#endif
36953690
SET_STRING_ELT(nms, i++, mkChar("zstd"));
36963691

36973692
#ifdef HAVE_PCRE2

0 commit comments

Comments
 (0)