From: Yann Collet Date: Wed, 12 Sep 2018 23:15:37 +0000 (-0700) Subject: fixed PREFETCH() macro X-Git-Tag: v0.0.29~13^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2618253da213a08ab571d8ec38fc963d78882ba4;p=thirdparty%2Fzstd.git fixed PREFETCH() macro for corner cases and platforms without this instruction --- diff --git a/lib/common/compiler.h b/lib/common/compiler.h index e68b81bf6..31eb1ccdf 100644 --- a/lib/common/compiler.h +++ b/lib/common/compiler.h @@ -91,25 +91,27 @@ /* prefetch * can be disabled, by declaring NO_PREFETCH macro */ #if defined(NO_PREFETCH) -# define PREFETCH(ptr) /* disabled */ +# define PREFETCH(ptr) (void)(ptr) /* disabled */ #else # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */ # include /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ -# define PREFETCH(ptr) _mm_prefetch((const char*)ptr, _MM_HINT_T1) +# define PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1) # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) -# define PREFETCH(ptr) __builtin_prefetch(ptr, 0 /* rw==read */, 2 /* locality */) +# define PREFETCH(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */) # else -# define PREFETCH(ptr) /* disabled */ +# define PREFETCH(ptr) (void)(ptr) /* disabled */ # endif #endif /* NO_PREFETCH */ #define CACHELINE_SIZE 64 -#define PREFETCH_AREA(ptr, size) { \ - size_t pos; \ - for (pos=0; pos