Recent changes (master)

Jens Axboe
2016-09-24T12:00:05Z

The following changes since commit 1d272416412b0c867224a2b667e6b6124cbc26e8:

stat: check if ctime_r() ends in a newline before stripping (2016-09-20 21:58:34 -0600)

are available in the git repository at:

git://git.kernel.dk/fio.git master

for you to fetch changes up to 0a301e93062df3735f9bb87c445e18d98a4b6efb:

bloom: add string version (2016-09-23 11:57:00 -0600)

----------------------------------------------------------------
Jens Axboe (3):
bloom: use bool
bloom: hashes take byte lengths, not nwords
bloom: add string version

lib/bloom.c | 15 ++++++++++-----
lib/bloom.h | 4 +++-
2 files changed, 13 insertions(+), 6 deletions(-)

---

Diff of recent changes:

diff --git a/lib/bloom.c b/lib/bloom.c
index f4eff57..c2e6c11 100644
--- a/lib/bloom.c
+++ b/lib/bloom.c
@@ -88,14 +88,14 @@ void bloom_free(struct bloom *b)
free(b);
}

-static int __bloom_check(struct bloom *b, uint32_t *data, unsigned int nwords,
- int set)
+static bool __bloom_check(struct bloom *b, const void *data, unsigned int len,
+ bool set)
{
uint32_t hash[N_HASHES];
int i, was_set;

for (i = 0; i < N_HASHES; i++) {
- hash[i] = hashes[i].fn(data, nwords, hashes[i].seed);
+ hash[i] = hashes[i].fn(data, len, hashes[i].seed);
hash[i] = hash[i] % b->nentries;
}

@@ -113,7 +113,12 @@ static int __bloom_check(struct bloom *b, uint32_t *data, unsigned int nwords,
return was_set == N_HASHES;
}

-int bloom_set(struct bloom *b, uint32_t *data, unsigned int nwords)
+bool bloom_set(struct bloom *b, uint32_t *data, unsigned int nwords)
{
- return __bloom_check(b, data, nwords, 1);
+ return __bloom_check(b, data, nwords * sizeof(uint32_t), true);
+}
+
+bool bloom_set_string(struct bloom *b, const char *data, unsigned int len)
+{
+ return __bloom_check(b, data, len, true);
}
diff --git a/lib/bloom.h b/lib/bloom.h
index 127ed9b..d40d9f6 100644
--- a/lib/bloom.h
+++ b/lib/bloom.h
@@ -2,11 +2,13 @@
#define FIO_BLOOM_H

#include <inttypes.h>
+#include "../lib/types.h"

struct bloom;

struct bloom *bloom_new(uint64_t entries);
void bloom_free(struct bloom *b);
-int bloom_set(struct bloom *b, uint32_t *data, unsigned int nwords);
+bool bloom_set(struct bloom *b, uint32_t *data, unsigned int nwords);
+bool bloom_set_string(struct bloom *b, const char *data, unsigned int len);

#endif