]> sjero.net Git - wget/blobdiff - src/hash.c
[svn] Don't define countof if it's already defined.
[wget] / src / hash.c
index 23bdbbe4e66bacc69b5f6187acebe0c368541937..64451712bb9cefd88c09e3c79a7834b5e45bd6ea 100644 (file)
@@ -50,7 +50,9 @@ so, delete this exception statement from your version.  */
 # define xnew_array(type, x) xmalloc (sizeof (type) * (x))
 # define xmalloc malloc
 # define xfree free
-# define countof(x) (sizeof (x) / sizeof ((x)[0]))
+# ifndef countof
+#  define countof(x) (sizeof (x) / sizeof ((x)[0]))
+# endif
 # define TOLOWER(x) ('A' <= (x) && (x) <= 'Z' ? (x) - 32 : (x))
 #endif
 
@@ -170,7 +172,7 @@ struct hash_table {
    -1.  This is acceptable because it still allows the use of
    nonnegative integer keys.  */
 
-#define INVALID_PTR ((void *) ~0UL)
+#define INVALID_PTR ((void *) ~(uintptr_t) 0)
 #ifndef UCHAR_MAX
 # define UCHAR_MAX 0xff
 #endif
@@ -709,7 +711,7 @@ make_nocase_string_hash_table (int items)
 unsigned long
 hash_pointer (const void *ptr)
 {
-  unsigned long key = (unsigned long) ptr;
+  uintptr_t key = (uintptr_t) ptr;
   key += (key << 12);
   key ^= (key >> 22);
   key += (key << 4);
@@ -718,7 +720,7 @@ hash_pointer (const void *ptr)
   key ^= (key >> 2);
   key += (key << 7);
   key ^= (key >> 12);
-#if SIZEOF_LONG > 4
+#if SIZEOF_VOID_P > 4
   key += (key << 44);
   key ^= (key >> 54);
   key += (key << 36);
@@ -728,7 +730,7 @@ hash_pointer (const void *ptr)
   key += (key << 39);
   key ^= (key >> 44);
 #endif
-  return key;
+  return (unsigned long) key;
 }
 
 static int