* [PATCH] Move hash collision warnings undef ! be_quiet
@ 2002-08-27 23:41 Jakub Jelinek
2002-08-27 23:59 ` Jakub Jelinek
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2002-08-27 23:41 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
Hi!
2002-08-28 Jakub Jelinek <jakub@redhat.com>
* locale/programs/locarchive.c (insert_name): Suppress warnings about
hash collisions if be_quiet.
--- libc/locale/programs/locarchive.c.jj Thu Aug 22 06:22:05 2002
+++ libc/locale/programs/locarchive.c Wed Aug 28 02:37:27 2002
@@ -547,13 +547,12 @@ insert_name (struct locarhandle *ah,
break;
}
- if (namehashtab[idx].hashval == hval)
+ if (namehashtab[idx].hashval == hval && ! be_quiet)
{
error (0, 0, "hash collision (%u) %s, %s",
hval, name, (char *) ah->addr + namehashtab[idx].name_offset);
}
-
/* Remember the first place we can insert the new entry. */
if (namehashtab[idx].locrec_offset == 0 && insert_idx == -1)
insert_idx = idx;
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Move hash collision warnings undef ! be_quiet
2002-08-27 23:41 [PATCH] Move hash collision warnings undef ! be_quiet Jakub Jelinek
@ 2002-08-27 23:59 ` Jakub Jelinek
2002-08-28 0:01 ` Roland McGrath
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2002-08-27 23:59 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Roland McGrath, Glibc hackers
On Wed, Aug 28, 2002 at 08:41:40AM +0200, Jakub Jelinek wrote:
> Hi!
>
> 2002-08-28 Jakub Jelinek <jakub@redhat.com>
>
> * locale/programs/locarchive.c (insert_name): Suppress warnings about
> hash collisions if be_quiet.
Well, there is another problem. locale-archive uses uint32_t
to store hashval, yet compute_hashval calculates it as unsigned long int.
Which means that a) the hash is incompatible between 32-bit and 64-bit
b) it creates tons of collisions
Working on a fix...
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Move hash collision warnings undef ! be_quiet
2002-08-27 23:59 ` Jakub Jelinek
@ 2002-08-28 0:01 ` Roland McGrath
2002-08-28 0:14 ` Jakub Jelinek
0 siblings, 1 reply; 5+ messages in thread
From: Roland McGrath @ 2002-08-28 0:01 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers
The fix is trivial (uint32_t in hashval.h). I'll do it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Move hash collision warnings undef ! be_quiet
2002-08-28 0:01 ` Roland McGrath
@ 2002-08-28 0:14 ` Jakub Jelinek
2002-08-28 0:31 ` Roland McGrath
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2002-08-28 0:14 UTC (permalink / raw)
To: Roland McGrath; +Cc: Jakub Jelinek, Ulrich Drepper, Glibc hackers
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Move hash collision warnings undef ! be_quiet
2002-08-28 0:14 ` Jakub Jelinek
@ 2002-08-28 0:31 ` Roland McGrath
0 siblings, 0 replies; 5+ messages in thread
From: Roland McGrath @ 2002-08-28 0:31 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers
That's about identical to what I was in the middle of doing.
I've cleaned it up and put it in.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-08-28 7:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-27 23:41 [PATCH] Move hash collision warnings undef ! be_quiet Jakub Jelinek
2002-08-27 23:59 ` Jakub Jelinek
2002-08-28 0:01 ` Roland McGrath
2002-08-28 0:14 ` Jakub Jelinek
2002-08-28 0:31 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).