]> sjero.net Git - wget/commitdiff
[svn] Use uintptr_t instead of unsigned long for integer representation of pointers.
authorhniksic <devnull@localhost>
Sat, 19 Nov 2005 19:35:02 +0000 (11:35 -0800)
committerhniksic <devnull@localhost>
Sat, 19 Nov 2005 19:35:02 +0000 (11:35 -0800)
ChangeLog
configure.in
src/ChangeLog
src/hash.c
src/sysdep.h

index e88d674249568e4cfc93d2e701630494412e61b6..56ee8ac436da9715926b9dae224cf15501fdceea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-19  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * configure.in: Check for uintptr_t.
+
 2005-11-02  Mauro Tortonesi  <mauro@ferrara.linux.it>
 
        * Makefile.in: Improved support for unit testing.
index e012e52dfc181ffdffd8c9943ce0e95aa2c3abb0..413309e1624fceb0c7e59cb09c37046750e6bf96 100644 (file)
@@ -182,13 +182,14 @@ AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
+AC_CHECK_SIZEOF(void *)
 
 dnl
 dnl Checks for non-universal or system-specific types.
 dnl
 AC_TYPE_SIZE_T
 AC_TYPE_PID_T
-AC_CHECK_TYPES(uint32_t)
+AC_CHECK_TYPES([uint32_t, uintptr_t])
 AC_CHECK_TYPES(sig_atomic_t, [], [], [
 #include <stdio.h>
 #include <sys/types.h>
index 848ef66d5bae125c22afe702bf325169d0bd3d73..2d40ced963de6d1da36ef765fcf8be321446f188 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-19  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * hash.c (INVALID_PTR): Use uintptr_t instead of unsigned long.
+       (hash_pointer): Don't assume a pointer fits in `unsigned long'.
+
 2005-11-02  Mauro Tortonesi  <mauro@ferrara.linux.it>
 
        * Makefile.in: Removed support for unit testing (now it is in
index 23bdbbe4e66bacc69b5f6187acebe0c368541937..c1feb6676995e4dad7de26acf4fa1f83e65f45e7 100644 (file)
@@ -170,7 +170,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 +709,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 +718,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 +728,7 @@ hash_pointer (const void *ptr)
   key += (key << 39);
   key ^= (key >> 44);
 #endif
-  return key;
+  return (unsigned long) key;
 }
 
 static int
index 90d2a7c35ee1b07369372f48fda3da119f623b17..50c0d14dbb7467ad95bb4e2749c70ff8a041f841 100644 (file)
@@ -207,4 +207,9 @@ typedef unsigned short uint32_t;
 # endif
 #endif
 
+/* If uintptr_t isn't defined, simply typedef it to unsigned long. */
+#ifndef HAVE_UINTPTR_T
+typedef unsigned long uintptr_t;
+#endif
+
 #endif /* SYSDEP_H */