randomize addresses as hash keys - gcl.git - GNU Common Lisp

index : gcl.git
GNU Common Lisp
summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamm Maguire <camm@debian.org>2013年11月11日 14:55:48 +0000
committerCamm Maguire <camm@debian.org>2013年11月11日 15:37:43 +0000
commitf20a8c9e4e8c8c1791d58fb02a1b2810f0dec20d (patch)
tree46a9a414d0d8a830cd932b27d5db9702a333318e
parent1b6d17e80edbbd8d9d06cb1cad43901bb06b8c6e (diff)
downloadgcl-f20a8c9e4e8c8c1791d58fb02a1b2810f0dec20d.tar.gz
randomize addresses as hash keys
Diffstat
-rwxr-xr-xgcl/cmpnew/gcl_cmpwt.lsp 7
-rwxr-xr-xgcl/o/hash.d 9
2 files changed, 10 insertions, 6 deletions
diff --git a/gcl/cmpnew/gcl_cmpwt.lsp b/gcl/cmpnew/gcl_cmpwt.lsp
index 22f074989..b0dfe1f46 100755
--- a/gcl/cmpnew/gcl_cmpwt.lsp
+++ b/gcl/cmpnew/gcl_cmpwt.lsp
@@ -171,9 +171,10 @@
(setf (gethash x *hash-eq*)
(if (> depth 3) 0
(if (typep x 'cons)
- (logxor (setq depth (the fixnum (1+ depth)))
- (memoized-hash-equal (car x) depth)
- (memoized-hash-equal (cdr x) depth))
+ (logxor (setq depth (the fixnum (1+ depth)));FIXME?
+ (logxor
+ (memoized-hash-equal (car x) depth)
+ (memoized-hash-equal (cdr x) depth)))
(si::hash-equal x depth))))))
(defun push-data-incf (x)
diff --git a/gcl/o/hash.d b/gcl/o/hash.d
index c2e0383db..140c0d2e9 100755
--- a/gcl/o/hash.d
+++ b/gcl/o/hash.d
@@ -57,7 +57,7 @@ object sKsize;
object sKrehash_size;
object sKrehash_threshold;
-#define MHSH(a_) ((a_) & ~(((unsigned long)1)<<(sizeof(a_)*CHAR_SIZE-1)))
+#define MHSH(a_) ((a_) & ~(1UL<<(sizeof(a_)*CHAR_SIZE-1)))
typedef union {/*FIXME size checks*/
float f;
@@ -101,6 +101,9 @@ uarrhash(void *v,void *ve,uchar off,uchar bits) {
}
+#define hash_eq1(x) ufixhash((ufixnum)x/sizeof(x))
+#define hash_eq(x) MHSH(hash_eq1(x))
+
static ufixnum
hash_eql(object x) {
@@ -151,7 +154,7 @@ hash_eql(object x) {
break;
default:
- h=((unsigned long)x / sizeof(x));
+ h=hash_eq1(x);
break;
}
@@ -420,7 +423,7 @@ gethash(object key, object hashtable) {
switch (htest) {
case htt_eq:
- hash_loop(eq,MHSH((long)key>>3));
+ hash_loop(eq,hash_eq(key));
break;
case htt_eql:
hash_loop(eql,hash_eql(key));
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月04日 19:14:49 +0000

AltStyle によって変換されたページ (->オリジナル) /