This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

egcs-20000501: Minor improvement to libiberty pointer hash


This bootstrapped without differences on sparc-redhat-linux.

malloc(3)ed data (and probably almost every structure in sight) is aligned
at 8 bytes, so the original hash function would clump values at multiples
of 8. Very bad if you use a hashtable whose size is a power of two, and not
nice in other cases. Casting the pointer to long should silence a warning
on alpha (where int is 32 bits and pointers are 64). Sorry, no alpha at
hand to check for this. I understand this was pre-approved by Mark
Mitchell.

2000-05-04  Horst von Brand <vonbrand@sleipnir.valparaiso.cl>

        * hashtab.c (hash_pointer): Delete low-order bits which are
	probably zero, also eliminate a warning on alpha.

*** egcs-20000501/libiberty/hashtab.c.dist	Mon May  1 20:45:06 2000
--- egcs-20000501/libiberty/hashtab.c	Thu May  4 21:46:21 2000
***************
*** 104,110 ****
  hash_pointer (p)
       const void *p;
  {
!   return (hashval_t) p;
  }
  
  /* Returns non-zero if P1 and P2 are equal.  */
--- 104,110 ----
  hash_pointer (p)
       const void *p;
  {
!   return (hashval_t) ((long)p >> 3);
  }
  
  /* Returns non-zero if P1 and P2 are equal.  */

-- 
Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Viņa del Mar, Chile                               +56 32 672616

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]