]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
add build macro NO_PREFETCH 1226/head
authorYann Collet <cyan@fb.com>
Sat, 7 Jul 2018 00:06:04 +0000 (17:06 -0700)
committerYann Collet <cyan@fb.com>
Sat, 7 Jul 2018 00:06:04 +0000 (17:06 -0700)
prevent usage of prefetch intrinsic commands
which are not supported by c2rust
(see https://github.com/immunant/c2rust/issues/13)

lib/common/compiler.h

index 366ed2b4b4fe00595a945bad50a2f88dae9e4682..595bac2046fe1e53faea9099285644feab994d32 100644 (file)
   #endif
 #endif
 
-/* prefetch */
-#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))  /* _mm_prefetch() is not defined outside of x86/x64 */
-#  include <mmintrin.h>   /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
-#  define PREFETCH(ptr)   _mm_prefetch((const char*)ptr, _MM_HINT_T0)
-#elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
-#  define PREFETCH(ptr)   __builtin_prefetch(ptr, 0, 0)
-#else
+/* prefetch
+ * can be disabled, by declaring NO_PREFETCH macro */
+#if defined(NO_PREFETCH)
 #  define PREFETCH(ptr)   /* disabled */
-#endif
+#else
+#  if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))  /* _mm_prefetch() is not defined outside of x86/x64 */
+#    include <mmintrin.h>   /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
+#    define PREFETCH(ptr)   _mm_prefetch((const char*)ptr, _MM_HINT_T0)
+#  elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
+#    define PREFETCH(ptr)   __builtin_prefetch(ptr, 0, 0)
+#  else
+#    define PREFETCH(ptr)   /* disabled */
+#  endif
+#endif  /* NO_PREFETCH */
 
 /* disable warnings */
 #ifdef _MSC_VER    /* Visual Studio */