aboutsummaryrefslogtreecommitdiff
path: root/util/bufferiszero.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2016-08-29 11:46:16 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2016-09-13 19:13:32 +0200
commitefad6682452ec85a898609c885c2721ea12585db (patch)
treeb599172e3a086abf695d24bee825faab80d29926 /util/bufferiszero.c
parent43ff5e01ecba41628f68eb3c62fd49e0405fcca9 (diff)
downloadqemu-efad6682452ec85a898609c885c2721ea12585db.zip
qemu-efad6682452ec85a898609c885c2721ea12585db.tar.gz
qemu-efad6682452ec85a898609c885c2721ea12585db.tar.bz2
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>
Diffstat (limited to 'util/bufferiszero.c')
-rw-r--r--util/bufferiszero.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/util/bufferiszero.c b/util/bufferiszero.c
index a3a842f..4af3caa 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
*/