]> www.ginac.de Git - cln.git/commitdiff
64-bit mingw port: In hash table routines, use 'intptr_t' instead of 'long'.
authorRobert Szalai <robicjedi@gmail.com>
Sun, 27 Oct 2019 18:47:00 +0000 (19:47 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 27 Oct 2019 18:47:00 +0000 (19:47 +0100)
16 files changed:
include/cln/string.h
include/cln/symbol.h
src/base/hash/cl_hash.h
src/base/hash/cl_hash1.h
src/base/hash/cl_hash1weak.h
src/base/hash/cl_hash2.h
src/base/hash/cl_hash2weak.h
src/base/hash/cl_hashset.h
src/base/hash/cl_hashuniq.h
src/base/hash/cl_hashuniqweak.h
src/base/hash/cl_rcpointer2_hashweak_rcpointer.h
src/base/hash/cl_rcpointer_hashweak_rcpointer.h
src/base/string/cl_st_hashcode.cc
src/base/symbol/cl_sy_hashcode.cc
src/integer/cl_I.h
src/integer/hash/cl_I_hashcode.cc

index 03f61f54fa4190152d65122ef3a2b4c76b57d050..683e0bc83ab75efca19306cf48c721f7bed00d00 100644 (file)
@@ -129,7 +129,7 @@ inline cl_string::cl_string ()
 }
 
 // Hash code.
-extern unsigned long hashcode (const cl_string& str);
+extern uintptr_t hashcode (const cl_string& str);
 
 // Output.
 extern void fprint (std::ostream& stream, const cl_string& str);
index 646918758ff44b8faa978104104959a5d836a5fc..30e4a5e6fedf3dc9b1eb1af69bd959a9d9e77199 100644 (file)
@@ -41,7 +41,7 @@ inline bool equal (const cl_symbol& s1, const cl_symbol& s2)
 }
 
 // Hash code.
-extern unsigned long hashcode (const cl_symbol& s);
+extern uintptr_t hashcode (const cl_symbol& s);
 
 }  // namespace cln
 
index 1ab1c2b7d543469561394a60564d5b60dd261a70..46803c16637e74f0ebbcac141fdcdec5e5301495 100644 (file)
@@ -10,7 +10,7 @@
 
 namespace cln {
 
-const long htentry_last = 0; // means that there is no next entry
+const intptr_t htentry_last = 0; // means that there is no next entry
 
 // These forward declarations are needed for Sun CC 3.0.1 and 4.0.1.
 template <class htentry> struct _cl_hashtable_iterator;
@@ -20,17 +20,17 @@ struct cl_heap_hashtable : public cl_heap {
     friend struct _cl_hashtable_iterator<htentry>;
 protected:
     typedef struct htxentry {
-        long next;     // > 0: pseudo-list continues at next-1
+        intptr_t next; // > 0: pseudo-list continues at next-1
                        // == 0: end of pseudo-list
                        // == -1: end of pseudo-free-list
                        // < -1: part of pseudo-free-list, continues at -next-2
         htentry entry; // if next >= 0
     } htxentry;
-    long _modulus; // size of the primary entry table, > 0
-    long _size;  // maximum number of entries
-    long _count; // current number of entries
-    long _freelist; // start of pseudo-free-list
-    long * _slots;  // vector of length _modulus
+    intptr_t _modulus; // size of the primary entry table, > 0
+    intptr_t _size;  // maximum number of entries
+    intptr_t _count; // current number of entries
+    intptr_t _freelist; // start of pseudo-free-list
+    intptr_t * _slots;  // vector of length _modulus
     htxentry * _entries; // vector of length _size
     void* _total_vector;
     bool (*_garcol_fun) (cl_heap*); // Function to make room in the table.
@@ -42,17 +42,17 @@ public:
     // Deallocation.
     void operator delete (void* ptr) { free_hook(ptr); }
     // Constructor: build a new, empty table.
-    cl_heap_hashtable (long initial_size = 5) : cl_heap (),
+    cl_heap_hashtable (intptr_t initial_size = 5) : cl_heap (),
         _size (initial_size), _count (0), _garcol_fun (no_garcol)
     {
         _modulus = compute_modulus(_size);
-        _total_vector = malloc_hook(_modulus*sizeof(long) + _size*sizeof(htxentry));
-        _slots = (long*) ((char*)_total_vector + 0);
-        _entries = (htxentry *) ((char*)_total_vector + _modulus*sizeof(long));
-        for (var long hi = _modulus-1; hi >= 0; hi--)
+        _total_vector = malloc_hook(_modulus*sizeof(intptr_t) + _size*sizeof(htxentry));
+        _slots = (intptr_t*) ((char*)_total_vector + 0);
+        _entries = (htxentry *) ((char*)_total_vector + _modulus*sizeof(intptr_t));
+        for (var intptr_t hi = _modulus-1; hi >= 0; hi--)
             _slots[hi] = 0;
-        var long free_list_head = -1;
-        for (var long i = _size-1; i >= 0; i--) {
+        var intptr_t free_list_head = -1;
+        for (var intptr_t i = _size-1; i >= 0; i--) {
             _entries[i].next = free_list_head;
             free_list_head = -2-i;
         }
@@ -61,17 +61,17 @@ public:
     // Destructor.
     ~cl_heap_hashtable ()
     {
-        for (long i = 0; i < _size; i++)
+        for (intptr_t i = 0; i < _size; i++)
             if (_entries[i].next >= 0)
                 _entries[i].~htxentry();
         free_hook(_total_vector);
     }
     // Count number of entries.
-    long num_entries ()
+    intptr_t num_entries ()
     {
         #if 0
-        var long n = 0;
-        for (long i = 0; i < _size; i++)
+        var intptr_t n = 0;
+        for (intptr_t i = 0; i < _size; i++)
             if (_entries[i].next >= 0)
                 n++;
         return n;
@@ -84,7 +84,7 @@ public:
     _cl_hashtable_iterator<htentry> iterator ();
 protected:
     // Compute the modulus, given the maximum number of entries.
-    static long compute_modulus (long size)
+    static intptr_t compute_modulus (intptr_t size)
     {
         // It should be somewhat greater than size, since we want to
         // avoid collisions.
@@ -107,7 +107,7 @@ protected:
         // by 2 or 3, and if the modulus were divisible by this number,
         // only every second or every third primary slot would be filled,
         // resulting in many collisions.
-        var long m = 1*size;
+        var intptr_t m = 1*size;
         // Make sure m is not divisible by 2.
         if ((m % 2) == 0)
             m++;
@@ -123,11 +123,11 @@ protected:
         return m;
     }
     // Return the index of a free entry. Assumes the free list is non-empty.
-    long get_free_index ()
+    intptr_t get_free_index ()
     {
         // Check whether there is some in the free list.
         if (_freelist < -1) {
-            var long index = -2-_freelist;
+            var intptr_t index = -2-_freelist;
             _freelist = _entries[index].next;
             return index;
         }
@@ -135,7 +135,7 @@ protected:
         return -1; // dummy
     }
     // Put a free index into the free list.
-    void put_free_index (long index)
+    void put_free_index (intptr_t index)
     {
         _entries[index].next = _freelist;
         _freelist = -2-index;
@@ -151,11 +151,11 @@ struct _cl_hashtable_iterator
 {
 private:
     typename cl_heap_hashtable<htentry>::htxentry * _entries;
-    long _index;
+    intptr_t _index;
 public:
     _cl_hashtable_iterator () : _entries (0), _index (-1) {}
 public: /* ugh */
-    _cl_hashtable_iterator (typename cl_heap_hashtable<htentry>::htxentry * e, long i)
+    _cl_hashtable_iterator (typename cl_heap_hashtable<htentry>::htxentry * e, intptr_t i)
         : _entries (e), _index (i)
     {
         do { _index--; }
@@ -167,7 +167,7 @@ public:
     {
         if (_index < 0)
             throw runtime_exception();
-        var long old_index = _index;
+        var intptr_t old_index = _index;
         do { _index--; }
            while (_index >= 0 && _entries[_index].next < 0);
         return _entries[old_index].entry;
index 397bcbaead7799394b1f62a889f877ebae57d3b9..201f9512498e5e8e80388a0ad704386fad943a29 100644 (file)
@@ -10,7 +10,7 @@ namespace cln {
 
 // Requirements:
 // - function  bool equal (key1_type,key1_type);
-// - function  unsigned long hashcode (key1_type);
+// - function  uintptr_t hashcode (key1_type);
 
 template <class key1_type, class value_type>
 struct cl_htentry1 {
@@ -39,7 +39,7 @@ public:
     // if it is not NULL.
     value_type* get (const key1_type& key)
     {
-        var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
+        var intptr_t index = this->_slots[hashcode(key) % this->_modulus] - 1;
         while (index >= 0) {
             if (!(index < this->_size))
                 throw runtime_exception();
@@ -52,10 +52,10 @@ public:
     // Store (htset alias puthash).
     void put (const key1_type& key, const value_type& val)
     {
-        var unsigned long hcode = hashcode(key);
+        var uintptr_t hcode = hashcode(key);
         // Search whether it is already there.
         {
-            var long index = this->_slots[hcode % this->_modulus] - 1;
+            var intptr_t index = this->_slots[hcode % this->_modulus] - 1;
             while (index >= 0) {
                 if (!(index < this->_size))
                     throw runtime_exception();
@@ -68,8 +68,8 @@ public:
         }
         // Put it into the table.
         prepare_store();
-        var long hindex = hcode % this->_modulus; // _modulus may have changed!
-        var long index = this->get_free_index();
+        var intptr_t hindex = hcode % this->_modulus; // _modulus may have changed!
+        var intptr_t index = this->get_free_index();
         new (&this->_entries[index].entry) cl_htentry1<key1_type,value_type> (key,val);
         this->_entries[index].next = this->_slots[hindex];
         this->_slots[hindex] = 1+index;
@@ -78,9 +78,9 @@ public:
     // Remove (htrem alias remhash).
     void remove (const key1_type& key)
     {
-        var long* _index = &this->_slots[hashcode(key) % this->_modulus];
+        var intptr_t* _index = &this->_slots[hashcode(key) % this->_modulus];
         while (*_index > 0) {
-            var long index = *_index - 1;
+            var intptr_t index = *_index - 1;
             if (!(index < this->_size))
                 throw runtime_exception();
             if (equal(key,this->_entries[index].entry.key)) {
@@ -117,25 +117,25 @@ private:
     }
     void grow ()
     {
-        var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
-        var long new_modulus = inherited::compute_modulus(new_size);
-        var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
-        var long* new_slots = (long*) ((char*)new_total_vector + 0);
-        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(long));
-        for (var long hi = new_modulus-1; hi >= 0; hi--)
+        var intptr_t new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
+        var intptr_t new_modulus = inherited::compute_modulus(new_size);
+        var void* new_total_vector = malloc_hook(new_modulus*sizeof(intptr_t) + new_size*sizeof(htxentry));
+        var intptr_t* new_slots = (intptr_t*) ((char*)new_total_vector + 0);
+        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(intptr_t));
+        for (var intptr_t hi = new_modulus-1; hi >= 0; hi--)
             new_slots[hi] = 0;
-        var long free_list_head = -1;
-        for (var long i = new_size-1; i >= 0; i--) {
+        var intptr_t free_list_head = -1;
+        for (var intptr_t i = new_size-1; i >= 0; i--) {
             new_entries[i].next = free_list_head;
             free_list_head = -2-i;
         }
         var htxentry* old_entries = this->_entries;
-        for (var long old_index = 0; old_index < this->_size; old_index++)
+        for (var intptr_t old_index = 0; old_index < this->_size; old_index++)
             if (old_entries[old_index].next >= 0) {
                 var key1_type& key = old_entries[old_index].entry.key;
                 var value_type& val = old_entries[old_index].entry.val;
-                var long hindex = hashcode(key) % new_modulus;
-                var long index = -2-free_list_head;
+                var intptr_t hindex = hashcode(key) % new_modulus;
+                var intptr_t index = -2-free_list_head;
                 free_list_head = new_entries[index].next;
                 new (&new_entries[index].entry) cl_htentry1<key1_type,value_type> (key,val);
                 new_entries[index].next = new_slots[hindex];
index a8b835a3b87be4c4b365349c0ae6fdc028e5a5ea..b7799f07bf29ea40bcabe991977c42eed1e6f2f3 100644 (file)
@@ -48,8 +48,8 @@ private:
                if (ht->_count < 100)
                        return false;
                // Do a garbage collection.
-               var long removed = 0;
-               for (long i = 0; i < ht->_size; i++)
+               var intptr_t removed = 0;
+               for (intptr_t i = 0; i < ht->_size; i++)
                    if (ht->_entries[i].next >= 0) {
                        var cl_htentry1<key1_type,value_type>& entry = ht->_entries[i].entry;
                        if (ht->_maygc_htentry(entry)) {
index bdf9f00bd114ec4fe9d204bef55d95d74cb5c5e8..513a52f173e3c5772a0567a3dc35b532189f4b30 100644 (file)
@@ -11,7 +11,7 @@ namespace cln {
 // Requirements:
 // - function  bool equal (key1_type,key1_type);
 // - function  bool equal (key2_type,key2_type);
-// - function  unsigned long hashcode (key1_type,key2_type);
+// - function  uintptr_t hashcode (key1_type,key2_type);
 
 template <class key1_type, class key2_type, class value_type>
 struct cl_htentry2 {
@@ -41,7 +41,7 @@ public:
     // if it is not NULL.
     value_type* get (const key1_type& key1, const key2_type& key2)
     {
-        var long index = this->_slots[hashcode(key1,key2) % this->_modulus] - 1;
+        var intptr_t index = this->_slots[hashcode(key1,key2) % this->_modulus] - 1;
         while (index >= 0) {
             if (!(index < this->_size))
                 throw runtime_exception();
@@ -55,10 +55,10 @@ public:
     // Store (htset alias puthash).
     void put (const key1_type& key1, const key2_type& key2, const value_type& val)
     {
-        var unsigned long hcode = hashcode(key1,key2);
+        var uintptr_t hcode = hashcode(key1,key2);
         // Search whether it is already there.
         {
-            var long index = this->_slots[hcode % this->_modulus] - 1;
+            var intptr_t index = this->_slots[hcode % this->_modulus] - 1;
             while (index >= 0) {
                 if (!(index < this->_size))
                     throw runtime_exception();
@@ -72,8 +72,8 @@ public:
         }
         // Put it into the table.
         prepare_store();
-        var long hindex = hcode % this->_modulus; // _modulus may have changed!
-        var long index = this->get_free_index();
+        var intptr_t hindex = hcode % this->_modulus; // _modulus may have changed!
+        var intptr_t index = this->get_free_index();
         new (&this->_entries[index].entry) cl_htentry2<key1_type,key2_type,value_type> (key1,key2,val);
         this->_entries[index].next = this->_slots[hindex];
         this->_slots[hindex] = 1+index;
@@ -82,9 +82,9 @@ public:
     // Remove (htrem alias remhash).
     void remove (const key1_type& key1, const key2_type& key2)
     {
-        var long* _index = &this->_slots[hashcode(key1,key2) % this->_modulus];
+        var intptr_t* _index = &this->_slots[hashcode(key1,key2) % this->_modulus];
         while (*_index > 0) {
-            var long index = *_index - 1;
+            var intptr_t index = *_index - 1;
             if (!(index < this->_size))
                 throw runtime_exception();
             if (equal(key1,this->_entries[index].entry.key1)
@@ -122,26 +122,26 @@ private:
     }
     void grow ()
     {
-        var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
-        var long new_modulus = inherited::compute_modulus(new_size);
-        var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
-        var long* new_slots = (long*) ((char*)new_total_vector + 0);
-        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(long));
-        for (var long hi = new_modulus-1; hi >= 0; hi--)
+        var intptr_t new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
+        var intptr_t new_modulus = inherited::compute_modulus(new_size);
+        var void* new_total_vector = malloc_hook(new_modulus*sizeof(intptr_t) + new_size*sizeof(htxentry));
+        var intptr_t* new_slots = (intptr_t*) ((char*)new_total_vector + 0);
+        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(intptr_t));
+        for (var intptr_t hi = new_modulus-1; hi >= 0; hi--)
             new_slots[hi] = 0;
-        var long free_list_head = -1;
-        for (var long i = new_size-1; i >= 0; i--) {
+        var intptr_t free_list_head = -1;
+        for (var intptr_t i = new_size-1; i >= 0; i--) {
             new_entries[i].next = free_list_head;
             free_list_head = -2-i;
         }
         var htxentry* old_entries = this->_entries;
-        for (var long old_index = 0; old_index < this->_size; old_index++)
+        for (var intptr_t old_index = 0; old_index < this->_size; old_index++)
             if (old_entries[old_index].next >= 0) {
                 var key1_type& key1 = old_entries[old_index].entry.key1;
                 var key2_type& key2 = old_entries[old_index].entry.key2;
                 var value_type& val = old_entries[old_index].entry.val;
-                var long hindex = hashcode(key1,key2) % new_modulus;
-                var long index = -2-free_list_head;
+                var intptr_t hindex = hashcode(key1,key2) % new_modulus;
+                var intptr_t index = -2-free_list_head;
                 free_list_head = new_entries[index].next;
                 new (&new_entries[index].entry) cl_htentry2<key1_type,key2_type,value_type> (key1,key2,val);
                 new_entries[index].next = new_slots[hindex];
index 58e517f764dea9fc846eab7220e7c243a917de2e..c8e245ec742c4d5aa4e78f63738adf6dc9c5621e 100644 (file)
@@ -48,8 +48,8 @@ private:
                if (ht->_count < 100)
                        return false;
                // Do a garbage collection.
-               var long removed = 0;
-               for (long i = 0; i < ht->_size; i++)
+               var intptr_t removed = 0;
+               for (intptr_t i = 0; i < ht->_size; i++)
                    if (ht->_entries[i].next >= 0) {
                        var cl_htentry2<key1_type,key2_type,value_type>& entry = ht->_entries[i].entry;
                        if (ht->_maygc_htentry(entry)) {
index b2a60ee5517c5655ff509e10572d7e65fc651387..c8457e63676dc598f89e82a0ec639e7d8f040ce0 100644 (file)
@@ -10,7 +10,7 @@ namespace cln {
 
 // Requirements:
 // - function  bool equal (key1_type,key1_type);
-// - function  unsigned long hashcode (key1_type);
+// - function  uintptr_t hashcode (key1_type);
 
 template <class key1_type>
 struct cl_htsetentry {
@@ -35,7 +35,7 @@ public:
     // Lookup (htref alias gethash).
     bool get (const key1_type& key)
     {
-        var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
+        var intptr_t index = this->_slots[hashcode(key) % this->_modulus] - 1;
         while (index >= 0) {
             if (!(index < this->_size))
                 throw runtime_exception();
@@ -48,10 +48,10 @@ public:
     // Store (htset alias puthash).
     void put (const key1_type& key)
     {
-        var unsigned long hcode = hashcode(key);
+        var uintptr_t hcode = hashcode(key);
         // Search whether it is already there.
         {
-            var long index = this->_slots[hcode % this->_modulus] - 1;
+            var intptr_t index = this->_slots[hcode % this->_modulus] - 1;
             while (index >= 0) {
                 if (!(index < this->_size))
                     throw runtime_exception();
@@ -62,8 +62,8 @@ public:
         }
         // Put it into the table.
         prepare_store();
-        var long hindex = hcode % this->_modulus; // _modulus may have changed!
-        var long index = this->get_free_index();
+        var intptr_t hindex = hcode % this->_modulus; // _modulus may have changed!
+        var intptr_t index = this->get_free_index();
         new (&this->_entries[index].entry) cl_htsetentry<key1_type> (key);
         this->_entries[index].next = this->_slots[hindex];
         this->_slots[hindex] = 1+index;
@@ -72,9 +72,9 @@ public:
     // Remove (htrem alias remhash).
     void remove (const key1_type& key)
     {
-        var long* _index = &this->_slots[hashcode(key) % this->_modulus];
+        var intptr_t* _index = &this->_slots[hashcode(key) % this->_modulus];
         while (*_index > 0) {
-            var long index = *_index - 1;
+            var intptr_t index = *_index - 1;
             if (!(index < this->_size))
                 throw runtime_exception();
             if (equal(key,this->_entries[index].entry.key)) {
@@ -111,24 +111,24 @@ private:
     }
     void grow ()
     {
-        var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
-        var long new_modulus = inherited::compute_modulus(new_size);
-        var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
-        var long* new_slots = (long*) ((char*)new_total_vector + 0);
-        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(long));
-        for (var long hi = new_modulus-1; hi >= 0; hi--)
+        var intptr_t new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
+        var intptr_t new_modulus = inherited::compute_modulus(new_size);
+        var void* new_total_vector = malloc_hook(new_modulus*sizeof(intptr_t) + new_size*sizeof(htxentry));
+        var intptr_t* new_slots = (intptr_t*) ((char*)new_total_vector + 0);
+        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(intptr_t));
+        for (var intptr_t hi = new_modulus-1; hi >= 0; hi--)
             new_slots[hi] = 0;
-        var long free_list_head = -1;
-        for (var long i = new_size-1; i >= 0; i--) {
+        var intptr_t free_list_head = -1;
+        for (var intptr_t i = new_size-1; i >= 0; i--) {
             new_entries[i].next = free_list_head;
             free_list_head = -2-i;
         }
         var htxentry* old_entries = this->_entries;
-        for (var long old_index = 0; old_index < this->_size; old_index++)
+        for (var intptr_t old_index = 0; old_index < this->_size; old_index++)
             if (old_entries[old_index].next >= 0) {
                 var key1_type& key = old_entries[old_index].entry.key;
-                var long hindex = hashcode(key) % new_modulus;
-                var long index = -2-free_list_head;
+                var intptr_t hindex = hashcode(key) % new_modulus;
+                var intptr_t index = -2-free_list_head;
                 free_list_head = new_entries[index].next;
                 new (&new_entries[index].entry) cl_htsetentry<key1_type> (key);
                 new_entries[index].next = new_slots[hindex];
index c2b4bab4e632e48f62c8277633be7d792e16700a..03a9a5f42086d5c7c01fc92e03e1c3ce6e44b272 100644 (file)
@@ -13,7 +13,7 @@ namespace cln {
 
 // Requirements:
 // - function  bool equal (key1_type,key1_type);
-// - function  unsigned long hashcode (key1_type);
+// - function  uintptr_t hashcode (key1_type);
 // - function  key1_type hashkey (value_type);
 // - constructor  value_type::value_type (struct hashuniq *, key1_type);
 
@@ -43,7 +43,7 @@ public:
     // if it is not NULL.
     value_type * get (const key1_type& key)
     {
-        var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
+        var intptr_t index = this->_slots[hashcode(key) % this->_modulus] - 1;
         while (index >= 0) {
             if (!(index < this->_size))
                 throw runtime_exception();
@@ -56,10 +56,10 @@ public:
     // Store (htset alias puthash).
     void put (const key1_type& key)
     {
-        var unsigned long hcode = hashcode(key);
+        var uintptr_t hcode = hashcode(key);
         // Search whether it is already there.
         {
-            var long index = this->_slots[hcode % this->_modulus] - 1;
+            var intptr_t index = this->_slots[hcode % this->_modulus] - 1;
             while (index >= 0) {
                 if (!(index < this->_size))
                     throw runtime_exception();
@@ -70,8 +70,8 @@ public:
         }
         // Put it into the table.
         prepare_store();
-        var long hindex = hcode % this->_modulus; // _modulus may have changed!
-        var long index = this->get_free_index();
+        var intptr_t hindex = hcode % this->_modulus; // _modulus may have changed!
+        var intptr_t index = this->get_free_index();
         new (&this->_entries[index].entry) cl_htuniqentry<key1_type,value_type> (value_type((struct hashuniq *)0, key));
         this->_entries[index].next = this->_slots[hindex];
         this->_slots[hindex] = 1+index;
@@ -80,9 +80,9 @@ public:
     // Remove (htrem alias remhash).
     void remove (const key1_type& key)
     {
-        var long* _index = &this->_slots[hashcode(key) % this->_modulus];
+        var intptr_t* _index = &this->_slots[hashcode(key) % this->_modulus];
         while (*_index > 0) {
-            var long index = *_index - 1;
+            var intptr_t index = *_index - 1;
             if (!(index < this->_size))
                 throw runtime_exception();
             if (equal(key,hashkey(this->_entries[index].entry.val))) {
@@ -119,24 +119,24 @@ private:
     }
     void grow ()
     {
-        var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
-        var long new_modulus = inherited::compute_modulus(new_size);
-        var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
-        var long* new_slots = (long*) ((char*)new_total_vector + 0);
-        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(long));
-        for (var long hi = new_modulus-1; hi >= 0; hi--)
+        var intptr_t new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
+        var intptr_t new_modulus = inherited::compute_modulus(new_size);
+        var void* new_total_vector = malloc_hook(new_modulus*sizeof(intptr_t) + new_size*sizeof(htxentry));
+        var intptr_t* new_slots = (intptr_t*) ((char*)new_total_vector + 0);
+        var htxentry* new_entries = (htxentry *) ((char*)new_total_vector + new_modulus*sizeof(intptr_t));
+        for (var intptr_t hi = new_modulus-1; hi >= 0; hi--)
             new_slots[hi] = 0;
-        var long free_list_head = -1;
-        for (var long i = new_size-1; i >= 0; i--) {
+        var intptr_t free_list_head = -1;
+        for (var intptr_t i = new_size-1; i >= 0; i--) {
             new_entries[i].next = free_list_head;
             free_list_head = -2-i;
         }
         var htxentry* old_entries = this->_entries;
-        for (var long old_index = 0; old_index < this->_size; old_index++)
+        for (var intptr_t old_index = 0; old_index < this->_size; old_index++)
             if (old_entries[old_index].next >= 0) {
                 var value_type& val = old_entries[old_index].entry.val;
-                var long hindex = hashcode(hashkey(val)) % new_modulus;
-                var long index = -2-free_list_head;
+                var intptr_t hindex = hashcode(hashkey(val)) % new_modulus;
+                var intptr_t index = -2-free_list_head;
                 free_list_head = new_entries[index].next;
                 new (&new_entries[index].entry) cl_htuniqentry<key1_type,value_type> (val);
                 new_entries[index].next = new_slots[hindex];
index 9b0a8a793a56404ce65d21110498ce83d6db48ae..977912092a75a593e24c39db29348d3b282f5bcd 100644 (file)
@@ -47,8 +47,8 @@ private:
                if (ht->_count < 100)
                        return false;
                // Do a garbage collection.
-               var long removed = 0;
-               for (long i = 0; i < ht->_size; i++)
+               var intptr_t removed = 0;
+               for (intptr_t i = 0; i < ht->_size; i++)
                    if (ht->_entries[i].next >= 0) {
                        var value_type& v = ht->_entries[i].entry.val;
                        if (!v.pointer_p() || (v.heappointer->refcount == 1)) {
index 49eb6b3d42fcab8fbc4443557538233f6cdad721..b51f4668ac13dfdb00289fb6da9d812aa549ba91 100644 (file)
@@ -14,10 +14,10 @@ static inline bool equal (const cl_rcpointer& x, const cl_rcpointer& y)
 { return (x.pointer == y.pointer); }
 
 // Hash code. Luckily objects don't move around in memory.
-inline unsigned long hashcode (const cl_rcpointer& x1, const cl_rcpointer& x2)
+inline uintptr_t hashcode (const cl_rcpointer& x1, const cl_rcpointer& x2)
 {
-       var unsigned long hashcode1 = (unsigned long)x1.pointer;
-       var unsigned long hashcode2 = (unsigned long)x2.pointer;
+       var uintptr_t hashcode1 = (uintptr_t)x1.pointer;
+       var uintptr_t hashcode2 = (uintptr_t)x2.pointer;
        hashcode2 = (hashcode2 << 5) | (hashcode2 >> (long_bitsize-5)); // rotate
        return hashcode1 ^ hashcode2;
 }
index 2026692e2181f08d49c3af385d806d7d4b7e2901..be81c0997822f29fff84ccf44625ad9ffa98109a 100644 (file)
@@ -14,8 +14,8 @@ static inline bool equal (const cl_rcpointer& x, const cl_rcpointer& y)
 { return (x.pointer == y.pointer); }
 
 // Hash code. Luckily objects don't move around in memory.
-inline unsigned long hashcode (const cl_rcpointer& x)
-{ return (unsigned long)x.pointer; }
+inline uintptr_t hashcode (const cl_rcpointer& x)
+{ return (uintptr_t)x.pointer; }
 
 typedef cl_htentry1<cl_rcpointer,cl_rcpointer> cl_htentry_from_rcpointer_to_rcpointer;
 
index 5091a3c2d4e0a56ca789f8224cd0d7f42dc5908a..61b9bb2adb667dfb119d5033b3ff0e5541595cab 100644 (file)
 
 namespace cln {
 
-unsigned long hashcode (const cl_string& str)
+uintptr_t hashcode (const cl_string& str)
 {
-    var unsigned long code = 0x61284AF3;
+    var uintptr_t code = 0x61284AF3;
     // We walk through all characters. It may take some time for very
     // long strings, but it's better than completely ignoring some characters.
-    var long len = str.size();
+    var intptr_t len = str.size();
     var const char * ptr = str.asciz();
     for (; len > 0; len--) {
         var unsigned char c = *ptr++;
         code = (code << 5) | (code >> 27); // rotate left 5 bits
-        code += (long)c << 16;
-        code ^= (long)c;
+        code += (intptr_t)c << 16;
+        code ^= (intptr_t)c;
         code &= 0xFFFFFFFF;
     }
     return code;
index 8dcb79bcf730892a8ec06274d82b266bed36dff7..f79875981be23db2cfe564e23c5202783023c233 100644 (file)
@@ -15,13 +15,13 @@ namespace cln {
 
 #define declare_alignof(where,type)  \
   struct CONCAT(aligndummy,__LINE__) { char slot1; type slot2; }; \
-  const unsigned long where = offsetof(CONCAT(aligndummy,__LINE__), slot2);
+  const uintptr_t where = offsetof(CONCAT(aligndummy,__LINE__), slot2);
 
-unsigned long hashcode (const cl_symbol& s)
+uintptr_t hashcode (const cl_symbol& s)
 {
        // Strings don't move in memory, so we can just take the address.
        declare_alignof(string_alignment,cl_heap_string);
-       return (unsigned long)(s.pointer)
+       return (uintptr_t)(s.pointer)
               / (string_alignment & -string_alignment); // divide by power of 2
 }
 
index 8c1c3d5e3f64f6872cebc365e35313c0b3107cc8..f5545047af270ff7616cbca4cfceaea22f85e437 100644 (file)
@@ -712,7 +712,7 @@ inline sintD FN_MSD (cl_uint word)
 
 
 // Hash code.
-  extern unsigned long hashcode (const cl_I& x);
+  extern uintptr_t hashcode (const cl_I& x);
 
 
 // A fixnum (cl_FN) is an immediate integer.
index 080f2f2908d54c6731e5360e73c22f36f4a33cad..b766ba12b980ce841bca7dbf7c505a43b1ef22f4 100644 (file)
@@ -11,9 +11,9 @@
 
 namespace cln {
 
-unsigned long hashcode (const cl_I& x)
+uintptr_t hashcode (const cl_I& x)
 {
-       var unsigned long code = 0x814BE3A5;
+       var uintptr_t code = 0x814BE3A5;
        // We walk through all limbs. It may take some time for very large
        // integers, but it's better than completely ignoring some limbs.
        if (fixnump(x)) {
@@ -31,8 +31,8 @@ unsigned long hashcode (const cl_I& x)
                for (; len > 0; len--) {
                        var uintD c = msprefnext(MSDptr);
                        code = (code << 5) | (code >> 27); // rotate left 5 bits
-                       code += (long)c << 16;
-                       code ^= (long)c;
+                       code += (intptr_t)c << 16;
+                       code ^= (intptr_t)c;
                        code &= 0xFFFFFFFF;
                }
        }