Skip to content

Commit cfc573e

Browse files
committed
Define missing SNAPPY_PREFETCH macros.
PiperOrigin-RevId: 523287305
1 parent 92f18e6 commit cfc573e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ int main() {
153153
return __builtin_ctzll(0);
154154
}" HAVE_BUILTIN_CTZ)
155155

156+
check_cxx_source_compiles("
157+
int main() {
158+
__builtin_prefetch(0, 0, 3);
159+
return 0;
160+
}" HAVE_BUILTIN_PREFETCH)
161+
156162
check_cxx_source_compiles("
157163
__attribute__((always_inline)) int zero() { return 0; }
158164

cmake/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
/* Define to 1 if the compiler supports __builtin_expect. */
1111
#cmakedefine01 HAVE_BUILTIN_EXPECT
1212

13+
/* Define to 1 if the compiler supports __builtin_prefetch. */
14+
#cmakedefine01 HAVE_BUILTIN_PREFETCH
15+
1316
/* Define to 1 if you have a definition for mmap() in <sys/mman.h>. */
1417
#cmakedefine01 HAVE_FUNC_MMAP
1518

snappy-stubs-internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105
#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE
106106
#endif // HAVE_ATTRIBUTE_ALWAYS_INLINE
107107

108+
#if HAVE_BUILTIN_PREFETCH
109+
#define SNAPPY_PREFETCH(ptr) __builtin_prefetch(ptr, 0, 3)
110+
#else
111+
#define SNAPPY_PREFETCH(ptr) (void)(ptr)
112+
#endif
113+
108114
// Stubbed version of ABSL_FLAG.
109115
//
110116
// In the open source version, flags can only be changed at compile time.

0 commit comments

Comments
 (0)