Add generic hweight helpers

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/Makefile b/Makefile
index 03e46fa..967996d 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@
 		engines/mmap.c engines/sync.c engines/null.c engines/net.c \
 		memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
 		json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
-		helpers.c lib/flist_sort.c
+		helpers.c lib/flist_sort.c lib/hweight.c
 
 ifdef CONFIG_64BIT_LLP64
   CFLAGS += -DBITS_PER_LONG=32
diff --git a/lib/hweight.c b/lib/hweight.c
new file mode 100644
index 0000000..738ed27
--- /dev/null
+++ b/lib/hweight.c
@@ -0,0 +1,19 @@
+#include "hweight.h"
+
+unsigned int hweight8(uint8_t w)
+{
+	unsigned int res = w - ((w >> 1) & 0x55);
+
+	res = (res & 0x33) + ((res >> 2) & 0x33);
+	return (res + (res >> 4)) & 0x0F;
+}
+
+unsigned int hweight32(uint32_t w)
+{
+	unsigned int res = w - ((w >> 1) & 0x55555555);
+
+	res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+	res = (res + (res >> 4)) & 0x0F0F0F0F;
+	res = res + (res >> 8);
+	return (res + (res >> 16)) & 0x000000FF;
+}
diff --git a/lib/hweight.h b/lib/hweight.h
new file mode 100644
index 0000000..1965eaa
--- /dev/null
+++ b/lib/hweight.h
@@ -0,0 +1,9 @@
+#ifndef FIO_HWEIGHT_H
+#define FIO_HWEIGHT_H
+
+#include <inttypes.h>
+
+unsigned int hweight8(uint8_t w);
+unsigned int hweight32(uint32_t w);
+
+#endif
diff --git a/options.c b/options.c
index 8d460be..2b71abd 100644
--- a/options.c
+++ b/options.c
@@ -1961,6 +1961,11 @@
 		.parent	= "verify_async",
 	},
 #endif
+	{
+		.name	= "experimental_verify",
+		.off1	= td_var_offset(experimental_verify),
+		.type	= FIO_OPT_BOOL,
+	},
 #ifdef FIO_HAVE_TRIM
 	{
 		.name	= "trim_percentage",
diff --git a/verify.c b/verify.c
index c0485d5..cb13b62 100644
--- a/verify.c
+++ b/verify.c
@@ -13,6 +13,7 @@
 #include "smalloc.h"
 #include "trim.h"
 #include "lib/rand.h"
+#include "lib/hweight.h"
 
 #include "crc/md5.h"
 #include "crc/crc64.h"
@@ -308,14 +309,6 @@
 	return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(hdr);
 }
 
-static unsigned int hweight8(unsigned int w)
-{
-	unsigned int res = w - ((w >> 1) & 0x55);
-
-	res = (res & 0x33) + ((res >> 2) & 0x33);
-	return (res + (res >> 4)) & 0x0F;
-}
-
 static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
 {
 	struct thread_data *td = vc->td;