about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/aterm-map.cc15
-rw-r--r--src/libutil/aterm-map.hh4
-rw-r--r--src/libutil/util.cc4
3 files changed, 12 insertions, 11 deletions
diff --git a/src/libutil/aterm-map.cc b/src/libutil/aterm-map.cc
index f400464378f5..33388e148a65 100644
--- a/src/libutil/aterm-map.cc
+++ b/src/libutil/aterm-map.cc
@@ -111,34 +111,35 @@ void ATermMap::copy(KeyValue * elements, unsigned int capacity)
 }
 
 
+/* !!! use a bigger shift for 64-bit platforms? */
 static const unsigned int shift = 16;
-static const unsigned int knuth = (unsigned int) (0.6180339887 * (1 << shift));
+static const unsigned long knuth = (unsigned long) (0.6180339887 * (1 << shift));
 
 
-unsigned int ATermMap::hash1(ATerm key) const
+unsigned long ATermMap::hash1(ATerm key) const
 {
     /* Don't care about the least significant bits of the ATerm
        pointer since they're always 0. */
-    unsigned int key2 = ((unsigned int) key) >> 2;
+    unsigned long key2 = ((unsigned long) key) >> 2;
 
     /* Approximately equal to:
     double d = key2 * 0.6180339887;
     unsigned int h = (int) (capacity * (d - floor(d)));
     */
  
-    unsigned int h = (capacity * ((key2 * knuth) & ((1 << shift) - 1))) >> shift;
+    unsigned long h = (capacity * ((key2 * knuth) & ((1 << shift) - 1))) >> shift;
 
     return h;
 }
 
 
-unsigned int ATermMap::hash2(ATerm key) const
+unsigned long ATermMap::hash2(ATerm key) const
 {
-    unsigned int key2 = ((unsigned int) key) >> 2;
+    unsigned long key2 = ((unsigned long) key) >> 2;
     /* Note: the result must be relatively prime to `capacity' (which
        is a power of 2), so we make sure that the result is always
        odd. */
-    unsigned int h = ((key2 * 134217689) & (capacity - 1)) | 1;
+    unsigned long h = ((key2 * 134217689) & (capacity - 1)) | 1;
     return h;
 }
 
diff --git a/src/libutil/aterm-map.hh b/src/libutil/aterm-map.hh
index 203b42934a0d..115ed36cd53a 100644
--- a/src/libutil/aterm-map.hh
+++ b/src/libutil/aterm-map.hh
@@ -113,8 +113,8 @@ private:
 
     void copy(KeyValue * elements, unsigned int capacity);
     
-    inline unsigned int hash1(ATerm key) const;
-    inline unsigned int hash2(ATerm key) const;
+    inline unsigned long hash1(ATerm key) const;
+    inline unsigned long hash2(ATerm key) const;
 };
 
 
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 0d970e69e303..4e93464865f7 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -119,7 +119,7 @@ Path canonPath(const Path & path, bool resolveSymlinks)
 
 Path dirOf(const Path & path)
 {
-    unsigned int pos = path.rfind('/');
+    Path::size_type pos = path.rfind('/');
     if (pos == string::npos)
         throw Error(format("invalid file name: %1%") % path);
     return pos == 0 ? "/" : Path(path, 0, pos);
@@ -128,7 +128,7 @@ Path dirOf(const Path & path)
 
 string baseNameOf(const Path & path)
 {
-    unsigned int pos = path.rfind('/');
+    Path::size_type pos = path.rfind('/');
     if (pos == string::npos)
         throw Error(format("invalid file name %1% ") % path);
     return string(path, pos + 1);