diff options
author | Richard O'Grady <rjogrady@google.com> | 2023-04-10 20:48:20 -0700 |
---|---|---|
committer | Richard O'Grady <rjogrady@google.com> | 2023-04-11 10:38:23 -0700 |
commit | cfc573e08faf4d4c61a2bd8ccbfba1803a0fef59 (patch) | |
tree | 1571361b64e7fd1fa37cf4f0104616ea4fcfbfa4 | |
parent | 92f18e66fdf34bdde3d5116ca3fac3910fe14fc5 (diff) | |
download | snappy-git-cfc573e08faf4d4c61a2bd8ccbfba1803a0fef59.tar.gz |
Define missing SNAPPY_PREFETCH macros.
PiperOrigin-RevId: 523287305
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | cmake/config.h.in | 3 | ||||
-rw-r--r-- | snappy-stubs-internal.h | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c3062e2..7711693 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,12 @@ int main() { }" HAVE_BUILTIN_CTZ) check_cxx_source_compiles(" +int main() { + __builtin_prefetch(0, 0, 3); + return 0; +}" HAVE_BUILTIN_PREFETCH) + +check_cxx_source_compiles(" __attribute__((always_inline)) int zero() { return 0; } int main() { diff --git a/cmake/config.h.in b/cmake/config.h.in index d1de25c..3510c27 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -10,6 +10,9 @@ /* Define to 1 if the compiler supports __builtin_expect. */ #cmakedefine01 HAVE_BUILTIN_EXPECT +/* Define to 1 if the compiler supports __builtin_prefetch. */ +#cmakedefine01 HAVE_BUILTIN_PREFETCH + /* Define to 1 if you have a definition for mmap() in <sys/mman.h>. */ #cmakedefine01 HAVE_FUNC_MMAP diff --git a/snappy-stubs-internal.h b/snappy-stubs-internal.h index 1548ed7..526c38b 100644 --- a/snappy-stubs-internal.h +++ b/snappy-stubs-internal.h @@ -105,6 +105,12 @@ #define SNAPPY_ATTRIBUTE_ALWAYS_INLINE #endif // HAVE_ATTRIBUTE_ALWAYS_INLINE +#if HAVE_BUILTIN_PREFETCH +#define SNAPPY_PREFETCH(ptr) __builtin_prefetch(ptr, 0, 3) +#else +#define SNAPPY_PREFETCH(ptr) (void)(ptr) +#endif + // Stubbed version of ABSL_FLAG. // // In the open source version, flags can only be changed at compile time. |