From: hniksic Date: Sat, 19 Nov 2005 19:35:02 +0000 (-0800) Subject: [svn] Use uintptr_t instead of unsigned long for integer representation of pointers. X-Git-Tag: v1.13~701 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=3e145c601836a25495d6656491f69eafd7212dd4 [svn] Use uintptr_t instead of unsigned long for integer representation of pointers. --- diff --git a/ChangeLog b/ChangeLog index e88d6742..56ee8ac4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-11-19 Hrvoje Niksic + + * configure.in: Check for uintptr_t. + 2005-11-02 Mauro Tortonesi * Makefile.in: Improved support for unit testing. diff --git a/configure.in b/configure.in index e012e52d..413309e1 100644 --- a/configure.in +++ b/configure.in @@ -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 #include diff --git a/src/ChangeLog b/src/ChangeLog index 848ef66d..2d40ced9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-11-19 Hrvoje Niksic + + * 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 * Makefile.in: Removed support for unit testing (now it is in diff --git a/src/hash.c b/src/hash.c index 23bdbbe4..c1feb667 100644 --- a/src/hash.c +++ b/src/hash.c @@ -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 diff --git a/src/sysdep.h b/src/sysdep.h index 90d2a7c3..50c0d14d 100644 --- a/src/sysdep.h +++ b/src/sysdep.h @@ -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 */