From: Carl Woffenden Date: Wed, 21 Aug 2019 15:49:17 +0000 (+0200) Subject: Tweaks to create a single-file decoder X-Git-Tag: v1.4.4~1^2~71^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=901ea61f83333c88e749c6fb3d8d35f01378bde4;p=thirdparty%2Fzstd.git Tweaks to create a single-file decoder The CHECK_F macros differ slightly (but eventually do the same thing). Older GCC needs to fallback on the old-style pragma optimisation flags. --- diff --git a/lib/common/compiler.h b/lib/common/compiler.h index 6686b837d..36584aa69 100644 --- a/lib/common/compiler.h +++ b/lib/common/compiler.h @@ -127,9 +127,14 @@ } \ } -/* vectorization */ +/* vectorization + * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */ #if !defined(__clang__) && defined(__GNUC__) -# define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize"))) +# if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5) +# define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize"))) +# else +# define DONT_VECTORIZE _Pragma("GCC optimize(\"no-tree-vectorize\")") +# endif #else # define DONT_VECTORIZE #endif diff --git a/lib/common/fse_decompress.c b/lib/common/fse_decompress.c index 72bbead5b..4f0737898 100644 --- a/lib/common/fse_decompress.c +++ b/lib/common/fse_decompress.c @@ -52,7 +52,9 @@ #define FSE_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) /* use only *after* variable declarations */ /* check and forward error code */ +#ifndef CHECK_F #define CHECK_F(f) { size_t const e = f; if (FSE_isError(e)) return e; } +#endif /* ************************************************************** diff --git a/lib/decompress/huf_decompress.c b/lib/decompress/huf_decompress.c index 3f8bd2973..bb2d0a96b 100644 --- a/lib/decompress/huf_decompress.c +++ b/lib/decompress/huf_decompress.c @@ -61,7 +61,9 @@ * Error Management ****************************************************************/ #define HUF_isError ERR_isError +#ifndef CHECK_F #define CHECK_F(f) { size_t const err_ = (f); if (HUF_isError(err_)) return err_; } +#endif /* **************************************************************