From 9d7a9cbe6a1f50602433ee50261f8f03a231243c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 15 May 2015 20:47:27 +0200 Subject: [PATCH] add missing new header --- src/util/strings.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/util/strings.h diff --git a/src/util/strings.h b/src/util/strings.h new file mode 100644 index 000000000..4157fc853 --- /dev/null +++ b/src/util/strings.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 1998-2015, Enno Rehling +Katja Zedel + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +**/ + +#ifndef STRINGS_H +#define STRINGS_H +#ifdef __cplusplus +extern "C" { +#endif + + extern unsigned int hashstring(const char *s); + extern const char *escape_string(const char *str, char *buffer, + size_t len); + extern unsigned int jenkins_hash(unsigned int a); + extern unsigned int wang_hash(unsigned int a); + + /* benchmark for units: + * JENKINS_HASH: 5.25 misses/hit (with good cache behavior) + * WANG_HASH: 5.33 misses/hit (with good cache behavior) + * KNUTH_HASH: 1.93 misses/hit (with bad cache behavior) + * CF_HASH: fucking awful! + */ +#define KNUTH_HASH1(a, m) ((a) % m) +#define KNUTH_HASH2(a, m) (m - 2 - a % (m-2)) +#define CF_HASH1(a, m) ((a) % m) +#define CF_HASH2(a, m) (8 - ((a) & 7)) +#define JENKINS_HASH1(a, m) (jenkins_hash(a) % m) +#define JENKINS_HASH2(a, m) 1 +#define WANG_HASH1(a, m) (wang_hash(a) % m) +#define WANG_HASH2(a, m) 1 + +#define HASH1 JENKINS_HASH1 +#define HASH2 JENKINS_HASH2 + +#ifdef __cplusplus +} +#endif +#endif /* STRINGS_H */