This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Wed, Aug 28, 2002 at 12:00:21AM -0700, Roland McGrath wrote: > The fix is trivial (uint32_t in hashval.h). I'll do it. This is what I wrote (not tested yet though): 2002-08-28 Jakub Jelinek <jakub@redhat.com> * locale/hashval.h: Allow using hash types other than unsigned long. * locale/loadarchive.c (hashval_t): Define. * locale/programs/locarchive.c: Include hashval.h directly instead of simple-hash.h. (compute_hashval, hashval_t): Define. --- libc/locale/programs/locarchive.c.jj Wed Aug 28 02:37:27 2002 +++ libc/locale/programs/locarchive.c Wed Aug 28 03:09:24 2002 @@ -43,9 +43,14 @@ #include "../../crypt/md5.h" #include "../localeinfo.h" #include "../locarchive.h" -#include "simple-hash.h" #include "localedef.h" +/* Define the hash function. We define the function as static inline. */ +#define compute_hashval static inline compute_hashval +#define hashval_t uint32_t +#include "hashval.h" +#undef compute_hashval + extern const char *output_prefix; #define ARCHIVE_NAME LOCALEDIR "/locale-archive" --- libc/locale/hashval.h.jj Tue Aug 13 02:01:50 2002 +++ libc/locale/hashval.h Wed Aug 28 03:06:25 2002 @@ -18,20 +18,27 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef LONGBITS +#ifndef hashval_t +# define hashval_t unsigned long int +# ifndef LONGBITS +# include <limits.h> +# define LONGBITS (sizeof (long int) * CHAR_BIT) +# endif +# define HASHVAL_T_BITS LONGBITS +#elif !defined HASHVAL_T_BITS # include <limits.h> -# define LONGBITS (sizeof (long int) * CHAR_BIT) +# define HASHVAL_T_BITS (sizeof (hashval_t) * CHAR_BIT) #endif -unsigned long int compute_hashval (const void *key, size_t keylen); +hashval_t compute_hashval (const void *key, size_t keylen); -unsigned long int +hashval_t compute_hashval (key, keylen) const void *key; size_t keylen; { size_t cnt; - unsigned long int hval; + hashval_t hval; /* Compute the hash value for the given string. The algorithm is taken from [Aho,Sethi,Ullman], modified to reduce the number of @@ -41,8 +48,8 @@ compute_hashval (key, keylen) hval = keylen; while (cnt < keylen) { - hval = (hval << 9) | (hval >> (LONGBITS - 9)); - hval += (unsigned long int) *(((char *) key) + cnt++); + hval = (hval << 9) | (hval >> (HASHVAL_T_BITS - 9)); + hval += (hashval_t) *(((char *) key) + cnt++); } - return hval != 0 ? hval : ~((unsigned long int) 0); + return hval != 0 ? hval : ~((hashval_t) 0); } --- libc/locale/loadarchive.c.jj Sun Aug 25 16:58:57 2002 +++ libc/locale/loadarchive.c Wed Aug 28 03:07:22 2002 @@ -35,6 +35,7 @@ /* Define the hash function. We define the function as static inline. */ #define compute_hashval static inline compute_hashval +#define hashval_t uint32_t #include "hashval.h" #undef compute_hashval Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |