aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-12-28 21:43:14 +0100
committerClifford Wolf <clifford@clifford.at>2014-12-28 21:43:14 +0100
commit2ad131764fc9b9b3f913650d206a540c2d57dc45 (patch)
tree1e92a71f1a11620670ab200d77dda5a437929178
parent8773fd5897d1057dc8f87d4ffd13c96a708080e8 (diff)
downloadyosys-2ad131764fc9b9b3f913650d206a540c2d57dc45.tar.gz
yosys-2ad131764fc9b9b3f913650d206a540c2d57dc45.tar.bz2
yosys-2ad131764fc9b9b3f913650d206a540c2d57dc45.zip
Some cleanups
-rw-r--r--kernel/hashlib.h18
-rw-r--r--kernel/yosys.cc4
-rw-r--r--kernel/yosys.h9
3 files changed, 20 insertions, 11 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h
index d363d68b5..e5e76a1e1 100644
--- a/kernel/hashlib.h
+++ b/kernel/hashlib.h
@@ -17,7 +17,7 @@
namespace hashlib {
-#define HASHLIB_SIZE_FACTOR 3
+const int config_size_factor = 3;
// The XOR version of DJB2
// (traditionally 5381 is used as starting value for the djb2 hash)
@@ -161,9 +161,9 @@ class dict
entries.clear();
counter = other.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * counter);
+ int new_size = hashtable_size(config_size_factor * counter);
hashtable.resize(new_size);
- new_size = new_size / HASHLIB_SIZE_FACTOR + 1;
+ new_size = new_size / config_size_factor + 1;
entries.reserve(new_size);
for (auto &it : other)
@@ -243,9 +243,9 @@ class dict
if (free_list < 0)
{
int i = entries.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * entries.size());
+ int new_size = hashtable_size(config_size_factor * entries.size());
hashtable.resize(new_size);
- entries.resize(new_size / HASHLIB_SIZE_FACTOR + 1);
+ entries.resize(new_size / config_size_factor + 1);
entries[i].udata = value;
entries[i].set_next_used(0);
counter++;
@@ -499,9 +499,9 @@ class pool
entries.clear();
counter = other.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * counter);
+ int new_size = hashtable_size(config_size_factor * counter);
hashtable.resize(new_size);
- new_size = new_size / HASHLIB_SIZE_FACTOR + 1;
+ new_size = new_size / config_size_factor + 1;
entries.reserve(new_size);
for (auto &it : other)
@@ -581,9 +581,9 @@ class pool
if (free_list < 0)
{
int i = entries.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * entries.size());
+ int new_size = hashtable_size(config_size_factor * entries.size());
hashtable.resize(new_size);
- entries.resize(new_size / HASHLIB_SIZE_FACTOR + 1);
+ entries.resize(new_size / config_size_factor + 1);
entries[i].key = key;
entries[i].set_next_used(0);
counter++;
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index 52bd066b7..0faca8d51 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -56,12 +56,14 @@ Tcl_Interp *yosys_tcl_interp = NULL;
#endif
bool memhasher_active = false;
-uint32_t memhasher_rng;
+uint32_t memhasher_rng = 123456;
std::vector<void*> memhasher_store;
void memhasher_on()
{
+#ifdef __linux__
memhasher_rng += time(NULL) << 16 ^ getpid();
+#endif
memhasher_store.resize(0x10000);
memhasher_active = true;
}
diff --git a/kernel/yosys.h b/kernel/yosys.h
index 50a159939..bbcbd5fed 100644
--- a/kernel/yosys.h
+++ b/kernel/yosys.h
@@ -124,7 +124,14 @@
YOSYS_NAMESPACE_BEGIN
-#include "kernel/hashlib.h"
+#ifdef HASHLIB_H
+# undef HASHLIB_H
+# include "kernel/hashlib.h"
+#else
+# include "kernel/hashlib.h"
+# undef HASHLIB_H
+#endif
+
using std::vector;
using std::string;
using hashlib::mkhash;