* os9kread.c (os9k_process_one_symbol): Note nonportable
assumption that an int can hold a char *. * bcache.h (struct hashlink): Wrap data[] inside union with double to force longest alignment. (BCACHE_DATA): New macro to access data[]. (BCACHE_ALIGNMENT): New macro to get offset to data[]. * bcache.c (lookup_cache, bcache): Use BCACHE_DATA to get address of cached data. Use BCACHE_ALIGNMENT to compute amount of space to allocate for each hashlink struct.
This commit is contained in:
parent
a319972ce6
commit
4cfb23a94c
4 changed files with 43 additions and 9 deletions
15
gdb/bcache.c
15
gdb/bcache.c
|
@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|||
#include "defs.h"
|
||||
#include "obstack.h"
|
||||
#include "bcache.h"
|
||||
#include "gdb_string.h" /* For memcpy declaration */
|
||||
|
||||
/* FIXME: Incredibly simplistic hash generator. Probably way too expensive
|
||||
(consider long strings) and unlikely to have good distribution across hash
|
||||
|
@ -67,9 +68,9 @@ lookup_cache (bytes, count, hashval, bcachep)
|
|||
linkp = hashtablep[hashval];
|
||||
while (linkp != NULL)
|
||||
{
|
||||
if (memcmp (linkp -> data, bytes, count) == 0)
|
||||
if (memcmp (BCACHE_DATA (linkp), bytes, count) == 0)
|
||||
{
|
||||
location = linkp -> data;
|
||||
location = BCACHE_DATA (linkp);
|
||||
break;
|
||||
}
|
||||
linkp = linkp -> next;
|
||||
|
@ -115,17 +116,17 @@ bcache (bytes, count, bcachep)
|
|||
{
|
||||
*hashtablepp = (struct hashlink **)
|
||||
obstack_alloc (&bcachep->cache, BCACHE_HASHSIZE * sizeof (struct hashlink *));
|
||||
bcachep -> cache_bytes += sizeof (struct hashlink *);
|
||||
bcachep -> cache_bytes += BCACHE_HASHSIZE * sizeof (struct hashlink *);
|
||||
memset (*hashtablepp, 0, BCACHE_HASHSIZE * sizeof (struct hashlink *));
|
||||
}
|
||||
linkpp = &(*hashtablepp)[hashval];
|
||||
newlink = (struct hashlink *)
|
||||
obstack_alloc (&bcachep->cache, sizeof (struct hashlink *) + count);
|
||||
bcachep -> cache_bytes += sizeof (struct hashlink *) + count;
|
||||
memcpy (newlink -> data, bytes, count);
|
||||
obstack_alloc (&bcachep->cache, BCACHE_DATA_ALIGNMENT + count);
|
||||
bcachep -> cache_bytes += BCACHE_DATA_ALIGNMENT + count;
|
||||
memcpy (BCACHE_DATA (newlink), bytes, count);
|
||||
newlink -> next = *linkpp;
|
||||
*linkpp = newlink;
|
||||
location = newlink -> data;
|
||||
location = BCACHE_DATA (newlink);
|
||||
}
|
||||
}
|
||||
return (location);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue