From efad6682452ec85a898609c885c2721ea12585db Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 29 Aug 2016 11:46:16 -0700 Subject: cutils: Add test for buffer_is_zero Signed-off-by: Richard Henderson Message-Id: <1472496380-19706-6-git-send-email-rth@twiddle.net> Signed-off-by: Paolo Bonzini --- util/bufferiszero.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'util') diff --git a/util/bufferiszero.c b/util/bufferiszero.c index a3a842f9fd..4af3caa1b6 100644 --- a/util/bufferiszero.c +++ b/util/bufferiszero.c @@ -162,6 +162,19 @@ static void __attribute__((constructor)) init_cpuid_cache(void) cpuid_cache = cache; } +#define HAVE_NEXT_ACCEL +bool test_buffer_is_zero_next_accel(void) +{ + /* If no bits set, we just tested buffer_zero_int, and there + are no more acceleration options to test. */ + if (cpuid_cache == 0) { + return false; + } + /* Disable the accelerator we used before and select a new one. */ + cpuid_cache &= cpuid_cache - 1; + return true; +} + static bool select_accel_fn(const void *buf, size_t len) { uintptr_t ibuf = (uintptr_t)buf; @@ -180,6 +193,13 @@ static bool select_accel_fn(const void *buf, size_t len) #define select_accel_fn buffer_zero_int #endif +#ifndef HAVE_NEXT_ACCEL +bool test_buffer_is_zero_next_accel(void) +{ + return false; +} +#endif + /* * Checks if a buffer is all zeroes */ -- cgit v1.2.3