cutils: Add test for buffer_is_zero

Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-Id: <1472496380-19706-6-git-send-email-rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Richard Henderson 2016-08-29 11:46:16 -07:00 committed by Paolo Bonzini
parent 43ff5e01ec
commit efad668245
4 changed files with 102 additions and 0 deletions

View file

@ -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
*/