* 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
|
@ -1,3 +1,16 @@
|
|||
Sat Mar 23 17:24:28 1996 Fred Fish <fnf@cygnus.com>
|
||||
|
||||
* 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.
|
||||
|
||||
Sat Mar 23 17:10:56 1996 Fred Fish <fnf@cygnus.com>
|
||||
|
||||
* configure, testsuite/configure, testsuite/gdb.base/configure,
|
||||
|
|
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);
|
||||
|
|
21
gdb/bcache.h
21
gdb/bcache.h
|
@ -25,11 +25,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|||
#define BCACHE_HASHSIZE (1 << BCACHE_HASHLENGTH)
|
||||
#define BCACHE_MAXLENGTH 128
|
||||
|
||||
/* Note that the user data is stored in data[]. Since it can be any type,
|
||||
it needs to have the same alignment as the most strict alignment of
|
||||
any type on the host machine. So do it the same way obstack does. */
|
||||
|
||||
struct hashlink {
|
||||
struct hashlink *next;
|
||||
char data[1];
|
||||
union {
|
||||
char data[1];
|
||||
double dummy;
|
||||
} d;
|
||||
};
|
||||
|
||||
/* BCACHE_DATA is used to get the address of the cached data. */
|
||||
|
||||
#define BCACHE_DATA(p) ((p)->d.data)
|
||||
|
||||
/* BCACHE_DATA_ALIGNMENT is used to get the offset of the start of
|
||||
cached data within the hashlink struct. This value, plus the
|
||||
size of the cached data, is the amount of space to allocate for
|
||||
a hashlink struct to hold the next pointer and the data. */
|
||||
|
||||
#define BCACHE_DATA_ALIGNMENT \
|
||||
(((char *) &BCACHE_DATA((struct hashlink*) 0) - (char *) 0))
|
||||
|
||||
struct bcache {
|
||||
struct obstack cache;
|
||||
struct hashlink **indextable[BCACHE_MAXLENGTH];
|
||||
|
|
|
@ -1528,9 +1528,10 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
|
|||
case N_SYM_SLINE:
|
||||
/* This type of "symbol" really just records
|
||||
one line-number -- core-address correspondence.
|
||||
Enter it in the line list for this symbol table. */
|
||||
Enter it in the line list for this symbol table. */
|
||||
/* Relocate for dynamic loading and for ELF acc fn-relative syms. */
|
||||
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
|
||||
/* FIXME: loses if sizeof (char *) > sizeof (int) */
|
||||
record_line (current_subfile, (int)name, valu);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue